fix(core): update

This commit is contained in:
2019-11-09 12:59:51 +01:00
parent 736240b978
commit ffeed0565c
5 changed files with 16 additions and 10 deletions

View File

@ -12,6 +12,7 @@ import { ClientUniverseCache } from './smartuniverse.classes.clientuniversecache
export interface IClientOptions {
serverAddress: string;
autoReconnect: boolean;
}
/**
@ -165,12 +166,14 @@ export class ClientUniverse {
}
public async disconnect(reason: 'upstreamEvent' | 'triggered' = 'triggered', tryReconnect = false) {
if ('triggered') {
this.smartsocketClient.disconnect();
if (reason === 'triggered') {
const smartsocketToDisconnect = this.smartsocketClient;
this.smartsocketClient = null; // making sure the upstreamEvent does not interfere
await smartsocketToDisconnect.disconnect();
}
this.smartsocketClient = null;
if (tryReconnect) {
if (this.options.autoReconnect && reason === 'upstreamEvent' && this.smartsocketClient) {
await plugins.smartdelay.delayForRandom(5000, 20000);
this.smartsocketClient = null;
this.checkConnection();
}
}

View File

@ -121,6 +121,7 @@ export class UniverseConnection {
socketConnection: plugins.smartsocket.SocketConnection;
authenticationRequests: Array<interfaces.ISocketRequest_SubscribeChannel['request']>;
}) {
this.universeRef = optionsArg.universe;
this.authenticationRequests = optionsArg.authenticationRequests;
this.socketConnection = optionsArg.socketConnection;
this.socketConnection.eventSubject.subscribe(async eventArg => {