fix(core): update

This commit is contained in:
2019-11-09 12:23:33 +01:00
parent 40beec1166
commit 73f4600c2a
4 changed files with 39 additions and 16 deletions
+12 -6
View File
@@ -106,23 +106,29 @@ export class UniverseConnection {
public failedToJoinChannels: UniverseChannel[] = [];
/**
* terminates the connection
* disconnect the connection
*/
public async terminateUniverseConnection() {
await this.socketConnection.disconnect();
public async disconnect(reason: 'upstreamevent' | 'triggered' = 'triggered') {
if (reason === 'triggered') {
await this.socketConnection.disconnect();
}
this.universeRef.universeCache.connectionMap.remove(this);
this.terminatedDeferred.resolve();
}
constructor(optionsArg: {
universe: Universe,
universe: Universe;
socketConnection: plugins.smartsocket.SocketConnection;
authenticationRequests: Array<interfaces.ISocketRequest_SubscribeChannel['request']>;
}) {
this.authenticationRequests = optionsArg.authenticationRequests;
this.socketConnection = optionsArg.socketConnection;
this.socketConnection.eventSubject.subscribe(async(event) => {
await this.terminateUniverseConnection();
this.socketConnection.eventSubject.subscribe(async eventArg => {
switch (eventArg) {
case 'disconnected':
await this.disconnect('upstreamevent');
break;
}
});
}
}