feat: server refresh
This commit is contained in:
parent
5416b6d0b8
commit
33cf967647
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user