fix(core): update

This commit is contained in:
Philipp Kunz 2019-11-03 16:48:35 +01:00
parent 8d358dd93d
commit 075c59ed2c

View File

@ -70,6 +70,14 @@ export class SmartsocketClient {
this.socketConnection.listenToFunctionRequests(); this.socketConnection.listenToFunctionRequests();
done.resolve(); done.resolve();
}); });
// handle errors
this.socketConnection.socket.on('reconnect_failed', async () => {
this.disconnect();
});
this.socketConnection.socket.on('connect_error', async () => {
this.disconnect();
});
}); });
return done.promise; return done.promise;
} }
@ -78,10 +86,19 @@ export class SmartsocketClient {
* disconnect from the server * disconnect from the server
*/ */
public async disconnect() { public async disconnect() {
if (this.socketConnection) {
this.socketConnection.socket.disconnect(true); this.socketConnection.socket.disconnect(true);
this.socketConnection = undefined; this.socketConnection = undefined;
plugins.smartlog.defaultLogger.log('ok', 'disconnected!'); plugins.smartlog.defaultLogger.log('ok', 'disconnected!');
} }
}
/**
* try a reconnection
*/
public async tryReconnect() {
}
/** /**
* dispatches a server call * dispatches a server call