Compare commits

..

4 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
8d358dd93d 1.1.49 2019-09-10 00:21:48 +02:00
e576d6058a fix(core): update 2019-09-10 00:21:47 +02:00
4 changed files with 23 additions and 6 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartsocket", "name": "@pushrocks/smartsocket",
"version": "1.1.48", "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.48", "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,9 +86,18 @@ export class SmartsocketClient {
* disconnect from the server * disconnect from the server
*/ */
public async disconnect() { public async disconnect() {
this.socketConnection.socket.disconnect(true); if (this.socketConnection) {
this.socketConnection = undefined; this.socketConnection.socket.disconnect(true);
plugins.smartlog.defaultLogger.log('ok', 'disconnected!'); this.socketConnection = undefined;
plugins.smartlog.defaultLogger.log('ok', 'disconnected!');
}
}
/**
* try a reconnection
*/
public async tryReconnect() {
} }
/** /**

View File

@ -13,7 +13,7 @@ import { SmartsocketClient } from './smartsocket.classes.smartsocketclient';
* interface of the contructor options of class SocketFunction * interface of the contructor options of class SocketFunction
*/ */
export interface ISocketFunctionConstructorOptions<T extends plugins.typedrequestInterfaces.ITypedRequest> { export interface ISocketFunctionConstructorOptions<T extends plugins.typedrequestInterfaces.ITypedRequest> {
funcName: string; funcName: T['method'];
funcDef: TFuncDef<T>; funcDef: TFuncDef<T>;
allowedRoles: SocketRole[]; // all roles that are allowed to execute a SocketFunction allowedRoles: SocketRole[]; // all roles that are allowed to execute a SocketFunction
} }