本文整理汇总了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();
});
});
});