Compare commits

..

2 Commits

Author SHA1 Message Date
c901ab75d3 1.1.50 2019-11-03 16:48:35 +01:00
075c59ed2c fix(core): update 2019-11-03 16:48:35 +01:00
3 changed files with 22 additions and 5 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartsocket", "name": "@pushrocks/smartsocket",
"version": "1.1.49", "version": "1.1.50",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartsocket", "name": "@pushrocks/smartsocket",
"version": "1.1.49", "version": "1.1.50",
"description": "easy and secure websocket communication", "description": "easy and secure websocket communication",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",

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