Compare commits

..

4 Commits

Author SHA1 Message Date
7f73664970 1.2.22 2022-01-20 18:38:18 +01:00
71452a293f fix(core): update 2022-01-20 18:38:17 +01:00
c5e60d804a 1.2.21 2022-01-20 18:33:47 +01:00
c5d52013e6 fix(core): update 2022-01-20 18:33:46 +01:00
4 changed files with 11 additions and 16 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@pushrocks/smartsocket", "name": "@pushrocks/smartsocket",
"version": "1.2.20", "version": "1.2.22",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@pushrocks/smartsocket", "name": "@pushrocks/smartsocket",
"version": "1.2.20", "version": "1.2.22",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@apiglobal/typedrequest-interfaces": "^1.0.15", "@apiglobal/typedrequest-interfaces": "^1.0.15",

View File

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

View File

@ -7,4 +7,5 @@ export type TConnectionStatus =
| 'connecting' | 'connecting'
| 'connected' | 'connected'
| 'disconnecting' | 'disconnecting'
| 'disconnected'; | 'disconnected'
| 'timedOut';

View File

@ -118,6 +118,7 @@ export class SmartsocketClient {
const timer = new plugins.smarttime.Timer(5000); const timer = new plugins.smarttime.Timer(5000);
timer.start(); timer.start();
timer.completed.then(() => { timer.completed.then(() => {
this.updateStatus('timedOut');
logger.log('warn', 'connection to server timed out.'); logger.log('warn', 'connection to server timed out.');
this.disconnect(true); this.disconnect(true);
}); });
@ -189,7 +190,7 @@ export class SmartsocketClient {
/** /**
* disconnect from the server * disconnect from the server
*/ */
public async disconnect(useAutoconnectSetting = false) { public async disconnect(useAutoReconnectSetting = false) {
if (this.disconnectRunning) { if (this.disconnectRunning) {
return; return;
} }
@ -209,10 +210,12 @@ export class SmartsocketClient {
logger.log('warn', `disconnected from server ${this.remoteShortId}`); logger.log('warn', `disconnected from server ${this.remoteShortId}`);
this.remoteShortId = null; this.remoteShortId = null;
if (this.autoReconnect && useAutoconnectSetting && this.eventStatus !== 'connecting') { if (this.autoReconnect && useAutoReconnectSetting && this.eventStatus !== 'connecting') {
this.updateStatus('connecting'); this.updateStatus('connecting');
await this.tryDebouncedReconnect(); console.log('debounced reconnect!');
await plugins.smartdelay.delayForRandom(10000, 20000);
this.disconnectRunning = false; this.disconnectRunning = false;
await this.connect();
} else { } else {
this.disconnectRunning = false; this.disconnectRunning = false;
} }
@ -226,15 +229,6 @@ export class SmartsocketClient {
await this.disconnect(); await this.disconnect();
} }
/**
* try a reconnection
*/
public async tryDebouncedReconnect() {
console.log('debounced reconnect!');
await plugins.smartdelay.delayForRandom(10000, 20000);
await this.connect();
}
/** /**
* dispatches a server call * dispatches a server call
* @param functionNameArg * @param functionNameArg