Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
64195e4c78 | |||
01b5b3dc1a |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@pushrocks/smartsocket",
|
||||
"version": "1.2.19",
|
||||
"version": "1.2.20",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@pushrocks/smartsocket",
|
||||
"version": "1.2.19",
|
||||
"version": "1.2.20",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@apiglobal/typedrequest-interfaces": "^1.0.15",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartsocket",
|
||||
"version": "1.2.19",
|
||||
"version": "1.2.20",
|
||||
"description": "easy and secure websocket communication",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
|
@ -184,28 +184,37 @@ export class SmartsocketClient {
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
private disconnectRunning = false;
|
||||
|
||||
/**
|
||||
* disconnect from the server
|
||||
*/
|
||||
public async disconnect(useAutoconnectSetting = false) {
|
||||
if (this.eventStatus === 'disconnecting') {
|
||||
if (this.disconnectRunning) {
|
||||
return;
|
||||
}
|
||||
this.disconnectRunning = true;
|
||||
this.updateStatus('disconnecting');
|
||||
this.tagStoreSubscription?.unsubscribe();
|
||||
if (this.socketConnection) {
|
||||
await this.socketConnection.disconnect();
|
||||
this.socketConnection = undefined;
|
||||
logger.log('ok', 'disconnected socket!');
|
||||
} else {
|
||||
this.disconnectRunning = false;
|
||||
logger.log('warn', 'tried to disconnect, without a SocketConnection');
|
||||
return;
|
||||
}
|
||||
|
||||
logger.log('warn', `disconnected from server ${this.remoteShortId}`);
|
||||
this.remoteShortId = null;
|
||||
|
||||
if (this.autoReconnect && useAutoconnectSetting && this.eventStatus !== 'connecting') {
|
||||
this.updateStatus('connecting');
|
||||
this.tryDebouncedReconnect();
|
||||
} else if (this.eventStatus === 'connected') {
|
||||
this.updateStatus('disconnected');
|
||||
await this.tryDebouncedReconnect();
|
||||
this.disconnectRunning = false;
|
||||
} else {
|
||||
this.disconnectRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user