本文整理匯總了TypeScript中socket.io-client函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript io-client函數的具體用法?TypeScript io-client怎麽用?TypeScript io-client使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了io-client函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: LoadEnvironment
$(() => {
LoadEnvironment();
RegisterBindingHandlers();
RegisterComponents();
InitializeSettings();
if ($("#tracker").length) {
let viewModel = new TrackerViewModel(io());
ko.applyBindings(viewModel, document.body);
viewModel.ImportEncounterIfAvailable();
viewModel.GetWhatsNewIfAvailable();
}
if ($("#playerview").length) {
let encounterId = env.EncounterId;
const playerView = new ReactPlayerView(
document.getElementById("playerview__container"),
encounterId
);
playerView.LoadEncounterFromServer();
playerView.ConnectToSocket(io());
}
if ($("#landing").length) {
let launcherViewModel = new LauncherViewModel();
ko.applyBindings(launcherViewModel, document.body);
}
$(".loading-splash").hide();
});
示例2: socketioClient
mounted: () => {
const liveButton = document.getElementById('live-button');
const socket = socketioClient(
SOCKET, {reconnectionDelay: 300, reconnectionDelayMax: 300});
socket.connect();
socket.on('connect', () => {
liveButton.style.display = 'block';
liveButton.textContent = 'Test Live';
});
socket.on('accuracyPerClass', (accPerClass: AccuracyPerClass) => {
plotAccuracyPerClass(accPerClass);
});
socket.on('disconnect', () => {
liveButton.style.display = 'block';
document.getElementById('waiting-msg').style.display = 'block';
document.getElementById('table').style.display = 'none';
});
liveButton.onclick = () => {
liveButton.textContent = 'Loading...';
socket.emit('live_data', '' + true);
};
},
示例3: _connectSocket
private async _connectSocket(socketServerUrl: string) {
// Connect to the server
const socket = io(socketServerUrl);
// Add the socket io listeners
socket.on('list:changes', (data) => {
console.log(JSON.stringify(data));
this._getListChanges(data).then((changes: any) => {
console.log(JSON.stringify(changes));
if (changes != "") {
let web = new Web(this.context.pageContext.web.absoluteUrl);
// get a specific item by id
web.lists.getById(changes[0].ListId).items.getById(changes[0].ItemId).get().then((item: any) => {
console.log(item);
this._lastQueryDate = moment();
// Create the notification panel
this._createNotification(item.Title, item.SPFxThumbnail.Url);
// After x seconds the place holder is removed from the DOM
let that = this;
setTimeout(
function () {
// Delete the notification panel
that._deleteNotification();
}, 10000);
});
}
});
});
}
開發者ID:AdrianDiaz81,項目名稱:sp-dev-fx-extensions,代碼行數:30,代碼來源:WebhooksToastNotificationsApplicationCustomizer.ts
示例4: apiSaga
export function* apiSaga() {
const { apiHost }: ApplicationState = yield select();
yield fork(getComponents);
yield fork(syncWorkspaceState);
yield fork(createSocketIOSaga(io(apiHost)));
yield fork(handlePingPong);
}
示例5: it
it('Delete socket new Point', done => {
var data = {
firstName: 'Jose', lastName: LAST_NAME_TEST, email: 'jose@fito.gmail',
contactNumber: '23234234234', address: 'jose fito address',
latitude: 28.4666304, longitude: -16.3213076, ip: '19.16.2.3'
};
let socket = io('http://localhost:3000');
socket.on(EMIT_REMOVED_POINT, (point: any) => {
assert.equal(point.firstName, 'Jose');
socket.disconnect();
done();
});
request.post(
'http://localhost:3000/api/points',
{ form: data },
(error: any, response: any, body: any) => {
if (!error && response.statusCode == 200) {
var newPoint = JSON.parse(body);
request.del(`http://localhost:3000/api/points/${newPoint._id}`,
(error: any, response: any, body: any) => {
if (!error && response.statusCode == 200) {
} else {
done(`${response.statusCode} - ${error}\n ${body}`);
}
});
} else {
done(error);
}
}
);
});
示例6: io
this.store.select(state => state.data.authentication.jwtToken).take(1).subscribe((token: string) => {
this.socket = io(BACKEND, {query: "jwttoken=" + token});
this.socket.on("UPDATE_REDUX", action => {
info("Realtime update coming in!");
this.store.dispatch(action)
});
});
示例7: beforeEach
beforeEach(done => {
appConfig = {
name : 'Test API Server',
version : '0.0.1',
database : database,
authenticator: authenticator
};
app = createApp(appConfig);
listener = new SocketListener();
listenerConfig = {
action : sinon.stub().returns(Promise.resolve(actionResult)),
adapter: sinon.stub().returns(Promise.resolve(adapterResult))
};
listener.on('test', listenerConfig);
app.register('/', listener);
app.on('error', () => undefined);
(app.webServer as any).listen(testPort);
socketClient = io(`http://localhost:${testPort}`, {
query: { authorization: `token ${authToken}` }
});
socketClient.on('connect', done);
socketClient.on('error', done);
});
示例8: done
beforeEach(done => {
app = createApp(appConfig);
app.on('error', () => undefined);
listener = new SocketListener();
listenerConfig = {
action : sinon.stub().returns(Promise.resolve(actionResult)),
adapter: sinon.stub().returns(Promise.resolve(adapterResult))
};
listener.on('test', listenerConfig);
app.register('/', listener);
(app.webServer as any).listen(testPort);
socketClient = io(`http://localhost:${testPort}`, {
query: { authorization: `token ${authToken}` }
});
socketClient.on('error', done);
socketClient.on('connect', () => {
socketClient.emit('unknown', payload, err => {
if (!err) {
return done('Should return error');
}
socketError = err;
done();
});
});
});