本文整理汇总了TypeScript中socket.io.default.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript io.default.on方法的具体用法?TypeScript io.default.on怎么用?TypeScript io.default.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类socket.io.default
的用法示例。
在下文中一共展示了io.default.on方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: require
import {expect} from 'chai';
import {
DataFrame,
FailureFrame,
MutationFrame,
RequestFrame,
SocketIOClient,
SocketIOServer
} from '../src/socket';
var Server = require('socket.io');
var Socket = require('socket.io-client');
var server: SocketIO.Server = new Server(8080);
var connHandler: Function = (socket: SocketIO.Socket): void => {};
server.on('connection', (socket: SocketIO.Socket) => connHandler(socket));
var options = {transports: ['websocket'], 'force new connection': true};
var key: Object = {key: true};
var cntxt: Object = {auth: true};
describe('SocketIOClient', () => {
it("request should send a request frame to the server", (done) => {
var ioSocket: SocketIO.Socket = Socket.connect('http://localhost:8080', options);
var client: SocketIOClient = new SocketIOClient(ioSocket);
connHandler = (socket: SocketIO.Socket) => {
socket.on('request', (frame: RequestFrame) => {
expect(frame.key).to.deep.equal(key);
expect(frame.context).to.deep.equal(cntxt);
示例2: before
before(() => {
server = new Server(8080);
server.on('connection', (socket: SocketIO.Socket) => connHandler(socket));
});