fix(core): update

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

6
package-lock.json generated
View File

@ -538,9 +538,9 @@
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
},
"@types/node": {
"version": "12.12.6",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.12.6.tgz",
"integrity": "sha512-FjsYUPzEJdGXjwKqSpE0/9QEh6kzhTAeObA54rn6j3rR4C/mzpI9L0KNfoeASSPMMdxIsoJuCLDWcM/rVjIsSA=="
"version": "12.12.7",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.12.7.tgz",
"integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w=="
},
"@types/range-parser": {
"version": "1.2.3",

View File

@ -17,7 +17,7 @@
"@gitzone/tsbuild": "^2.1.17",
"@gitzone/tstest": "^1.0.28",
"@pushrocks/tapbundle": "^3.0.13",
"@types/node": "^12.12.6",
"@types/node": "^12.12.7",
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0"
},

View File

@ -31,7 +31,8 @@ tap.test('add a message to the SmartUniverse', async () => {
// testing message handling
tap.test('create smartuniverse client', async () => {
testClientUniverse = new smartuniverse.ClientUniverse({
serverAddress: testServerData.serverAddress
serverAddress: testServerData.serverAddress,
autoReconnect: true
});
expect(testClientUniverse).to.be.instanceof(smartuniverse.ClientUniverse);
});
@ -65,7 +66,8 @@ tap.test('universe should contain the sent message', async () => {
tap.test('a second client should be able to subscibe', async () => {
testClientUniverse2 = new smartuniverse.ClientUniverse({
serverAddress: testServerData.serverAddress
serverAddress: testServerData.serverAddress,
autoReconnect: true
});
testClientUniverse2.addChannel(testChannelData.channelName, testChannelData.channelPass);

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 => {