mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
disconnect socket on system disconnect event.
This commit is contained in:
parent
80d229041a
commit
86d9e769f2
@ -40,6 +40,7 @@ export interface NekoEvents {
|
||||
}
|
||||
|
||||
export class NekoMessages extends EventEmitter<NekoEvents> {
|
||||
private websocket: NekoWebSocket
|
||||
private state: NekoState
|
||||
private _log: Logger
|
||||
|
||||
@ -48,7 +49,9 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
|
||||
|
||||
this._log = new Logger('messages')
|
||||
this.state = state
|
||||
websocket.on('message', async (event: string, payload: any) => {
|
||||
this.websocket = websocket
|
||||
|
||||
this.websocket.on('message', async (event: string, payload: any) => {
|
||||
// @ts-ignore
|
||||
if (typeof this[event] === 'function') {
|
||||
// @ts-ignore
|
||||
@ -95,6 +98,7 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
|
||||
|
||||
protected [EVENT.SYSTEM_DISCONNECT]({ message }: message.SystemDisconnect) {
|
||||
this._log.debug('EVENT.SYSTEM_DISCONNECT')
|
||||
this.websocket.disconnect(new Error(message))
|
||||
this.emit('connection.disconnect', message)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user