From 105acaf97b259a42b52eb42080daf01f2cd9f2bf Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Fri, 8 Nov 2019 17:11:41 +0100 Subject: [PATCH] fix(core): update --- ts/interfaces/connection.ts | 4 +++- ts/smartsocket.classes.socketconnection.ts | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ts/interfaces/connection.ts b/ts/interfaces/connection.ts index c8ffbf7..8e79ecb 100644 --- a/ts/interfaces/connection.ts +++ b/ts/interfaces/connection.ts @@ -1,3 +1,5 @@ export interface IRequestAuthPayload { serverShortId: string; -} \ No newline at end of file +} + +export type TConnectionEvent = 'terminated' | 'error'; \ No newline at end of file diff --git a/ts/smartsocket.classes.socketconnection.ts b/ts/smartsocket.classes.socketconnection.ts index 28820f1..6228c46 100644 --- a/ts/smartsocket.classes.socketconnection.ts +++ b/ts/smartsocket.classes.socketconnection.ts @@ -55,7 +55,7 @@ export class SocketConnection { public smartsocketRef: Smartsocket | SmartsocketClient; public socket: SocketIO.Socket | SocketIOClient.Socket; - public eventSubject = new plugins.smartrx.rxjs.Subject(); + public eventSubject = new plugins.smartrx.rxjs.Subject(); constructor(optionsArg: ISocketConnectionConstructorOptions) { this.alias = optionsArg.alias; @@ -67,12 +67,12 @@ export class SocketConnection { // standard behaviour that is always true allSocketConnections.add(this); - this.socket.on('disconnect', () => { + this.socket.on('disconnect', async () => { plugins.smartlog.defaultLogger.log( 'info', `SocketConnection with >alias ${this.alias} on >side ${this.side} disconnected` ); - this.socket.disconnect(); + await this.disconnect(); allSocketConnections.remove(this); }); } @@ -173,5 +173,6 @@ export class SocketConnection { // disconnecting ---------------------- public async disconnect() { this.socket.disconnect(true); + this.eventSubject.next('terminated'); } }