fix(core): update

This commit is contained in:
2019-11-07 00:59:45 +01:00
parent 80aacd17a6
commit 972ddbf327
4 changed files with 33 additions and 41 deletions

View File

@ -112,6 +112,7 @@ export class Universe {
funcName: 'subscribeChannel',
funcDef: async (dataArg, socketConnectionArg) => {
const universeConnection = new UniverseConnection({
universe: this,
socketConnection: socketConnectionArg,
authenticationRequests: [dataArg]
});

View File

@ -93,6 +93,8 @@ export class UniverseConnection {
return universeConnection;
}
// INSTANCE
public universeRef: Universe;
public terminatedDeferred = plugins.smartpromise.defer();
/**
@ -100,23 +102,27 @@ export class UniverseConnection {
*/
public socketConnection: plugins.smartsocket.SocketConnection;
public authenticationRequests: Array<interfaces.ISocketRequest_SubscribeChannel['request']> = [];
public subscribedChannels: UniverseChannel[] = [];
public authenticatedChannels: UniverseChannel[] = [];
public failedToJoinChannels: UniverseChannel[] = [];
/**
* terminates the connection
*/
public terminateConnection() {
this.socketConnection.socket.disconnect();
public async terminateUniverseConnection() {
await this.socketConnection.disconnect();
this.universeRef.universeCache.connectionMap.remove(this);
this.terminatedDeferred.resolve();
}
constructor(optionsArg: {
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();
});
}
}