feat: server refresh

This commit is contained in:
cha0s 2019-04-20 19:31:53 -05:00
parent 5416b6d0b8
commit 33cf967647

View File

@ -12,15 +12,27 @@ export class Server extends decorateServer(class {}) {
constructor(httpServer) {
super();
this.io = new SocketServer(httpServer, {
this.httpServer = httpServer;
this.onConnect = this.onConnect.bind(this);
}
close(fn) {
this.io.off('connect', this.onConnect);
this.io.close(fn);
}
onConnect(socket) {
this.emit('connect', new ServerSocket(socket));
}
open() {
this.io = new SocketServer(this.httpServer, {
parser: SocketIoParser,
path: '/avocado',
perMessageDeflate: false,
serveClient: false,
});
this.io.on('connect', (socket) => {
this.emit('connect', new ServerSocket(socket));
});
this.io.on('connect', this.onConnect);
}
}