Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
7f73664970 | |||
71452a293f | |||
c5e60d804a | |||
c5d52013e6 |
4
package-lock.json
generated
4
package-lock.json
generated
@ -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",
|
||||||
|
@ -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",
|
||||||
|
@ -7,4 +7,5 @@ export type TConnectionStatus =
|
|||||||
| 'connecting'
|
| 'connecting'
|
||||||
| 'connected'
|
| 'connected'
|
||||||
| 'disconnecting'
|
| 'disconnecting'
|
||||||
| 'disconnected';
|
| 'disconnected'
|
||||||
|
| 'timedOut';
|
||||||
|
@ -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
|
||||||
|
Reference in New Issue
Block a user