@riddix/hamh 2.1.0-alpha.478 → 2.1.0-alpha.479

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.
@@ -166505,10 +166505,19 @@ ${e?.toString()}`);
166505
166505
  }
166506
166506
  };
166507
166507
  sessionManager.subscriptionsChanged.on(this.sessionDiagHandler);
166508
- this.sessionAddedHandler = (session) => {
166508
+ this.sessionAddedHandler = (newSession) => {
166509
166509
  this.log.info(
166510
- `Session opened: id=${session.id} peer=${session.peerNodeId}`
166510
+ `Session opened: id=${newSession.id} peer=${newSession.peerNodeId}`
166511
166511
  );
166512
+ for (const s of [...sessionManager.sessions]) {
166513
+ if (s !== newSession && !s.isClosing && s.peerNodeId === newSession.peerNodeId && s.fabric?.fabricIndex === newSession.fabric?.fabricIndex && s.subscriptions.size === 0) {
166514
+ this.log.info(
166515
+ `Closing stale session ${s.id} (peer ${s.peerNodeId}, 0 subs) \u2014 replaced by session ${newSession.id}`
166516
+ );
166517
+ s.initiateForceClose().catch(() => {
166518
+ });
166519
+ }
166520
+ }
166512
166521
  };
166513
166522
  this.sessionDeletedHandler = (session) => {
166514
166523
  const sessions = [...sessionManager.sessions];
@@ -178723,10 +178732,19 @@ ${e?.toString()}`);
178723
178732
  }
178724
178733
  };
178725
178734
  sessionManager.subscriptionsChanged.on(this.sessionDiagHandler);
178726
- this.sessionAddedHandler = (session) => {
178735
+ this.sessionAddedHandler = (newSession) => {
178727
178736
  this.log.info(
178728
- `Session opened: id=${session.id} peer=${session.peerNodeId}`
178737
+ `Session opened: id=${newSession.id} peer=${newSession.peerNodeId}`
178729
178738
  );
178739
+ for (const s of [...sessionManager.sessions]) {
178740
+ if (s !== newSession && !s.isClosing && s.peerNodeId === newSession.peerNodeId && s.fabric?.fabricIndex === newSession.fabric?.fabricIndex && s.subscriptions.size === 0) {
178741
+ this.log.info(
178742
+ `Closing stale session ${s.id} (peer ${s.peerNodeId}, 0 subs) \u2014 replaced by session ${newSession.id}`
178743
+ );
178744
+ s.initiateForceClose().catch(() => {
178745
+ });
178746
+ }
178747
+ }
178730
178748
  };
178731
178749
  this.sessionDeletedHandler = (session) => {
178732
178750
  const sessions = [...sessionManager.sessions];