fix(core): update

This commit is contained in:
Philipp Kunz 2021-02-01 22:36:37 +00:00
parent 2a9e58cc35
commit 23cca6cce3
2 changed files with 7 additions and 0 deletions

View File

@ -124,6 +124,12 @@ export class Smartsocket {
}); });
logger.log('info', 'Socket connected. Trying to authenticate...'); logger.log('info', 'Socket connected. Trying to authenticate...');
this.socketConnections.add(socketConnection); this.socketConnections.add(socketConnection);
const disconnectSubscription = socketConnection.eventSubject.subscribe((eventArg) => {
if (eventArg === 'disconnected') {
this.socketConnections.remove(socketConnection);
disconnectSubscription.unsubscribe();
}
})
await socketConnection.authenticate(); await socketConnection.authenticate();
await socketConnection.listenToFunctionRequests(); await socketConnection.listenToFunctionRequests();
} }

View File

@ -83,6 +83,7 @@ export class SocketConnection {
); );
await this.disconnect(); await this.disconnect();
allSocketConnections.remove(this); allSocketConnections.remove(this);
this.eventSubject.next('disconnected');
}); });
} }