xcraft-core-busclient 5.0.3 → 5.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +14 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -448,16 +448,24 @@ class BusClient extends EventEmitter {
448
448
  stop(callback) {
449
449
  xLog.verb(`Stopping for ${this._orcName || 'greathall'}...`);
450
450
 
451
- const unsubscribe = this._subscribeClose((err) => {
452
- unsubscribe();
453
- if (callback) {
454
- callback(err);
455
- }
456
- });
451
+ const isConnected = this._connected;
452
+
453
+ if (isConnected) {
454
+ const unsubscribe = this._subscribeClose((err) => {
455
+ unsubscribe();
456
+ if (callback) {
457
+ callback(err);
458
+ }
459
+ });
460
+ }
457
461
 
458
462
  this._connected = false;
459
463
  this._subSocket.stop();
460
464
  this._pushSocket.stop();
465
+
466
+ if (!isConnected && callback) {
467
+ callback();
468
+ }
461
469
  }
462
470
 
463
471
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xcraft-core-busclient",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "description": "Xcraft bus client",
5
5
  "main": "index.js",
6
6
  "engines": {