@riddix/hamh 2.1.0-alpha.379 → 2.1.0-alpha.381

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.
@@ -163850,9 +163850,13 @@ var Bridge = class {
163850
163850
  // Tracks the last synced state JSON per entity to avoid pushing unchanged states.
163851
163851
  // Key: entity_id, Value: JSON.stringify of entity.state
163852
163852
  lastSyncedStates = /* @__PURE__ */ new Map();
163853
- // Session lifecycle diagnostic handler (non-destructive, logging only).
163853
+ // Session lifecycle diagnostic handlers (non-destructive, logging only).
163854
163854
  // biome-ignore lint/suspicious/noExplicitAny: matter.js internal types
163855
163855
  sessionDiagHandler;
163856
+ // biome-ignore lint/suspicious/noExplicitAny: matter.js internal types
163857
+ sessionAddedHandler;
163858
+ // biome-ignore lint/suspicious/noExplicitAny: matter.js internal types
163859
+ sessionDeletedHandler;
163856
163860
  get id() {
163857
163861
  return this.dataProvider.id;
163858
163862
  }
@@ -163995,20 +163999,46 @@ ${e?.toString()}`);
163995
163999
  this.log.info(
163996
164000
  `Session ${session.id} (peer ${session.peerNodeId}): subscriptions=${session.subscriptions.size} | total: sessions=${sessions.length} subscriptions=${totalSubs}`
163997
164001
  );
164002
+ if (totalSubs === 0 && sessions.length > 0) {
164003
+ this.log.warn(
164004
+ `All subscriptions lost \u2014 ${sessions.length} session(s) still active, waiting for controller to re-subscribe`
164005
+ );
164006
+ }
163998
164007
  };
163999
164008
  sessionManager.subscriptionsChanged.on(this.sessionDiagHandler);
164009
+ this.sessionAddedHandler = (session) => {
164010
+ this.log.info(
164011
+ `Session opened: id=${session.id} peer=${session.peerNodeId}`
164012
+ );
164013
+ };
164014
+ this.sessionDeletedHandler = (session) => {
164015
+ const sessions = [...sessionManager.sessions];
164016
+ this.log.warn(
164017
+ `Session closed: id=${session.id} peer=${session.peerNodeId} | remaining sessions=${sessions.length}`
164018
+ );
164019
+ };
164020
+ sessionManager.sessions.added.on(this.sessionAddedHandler);
164021
+ sessionManager.sessions.deleted.on(this.sessionDeletedHandler);
164000
164022
  } catch {
164001
164023
  }
164002
164024
  }
164003
164025
  unwireSessionDiagnostics() {
164004
- if (this.sessionDiagHandler) {
164005
- try {
164006
- const sessionManager = this.server.env.get(SessionManager);
164026
+ try {
164027
+ const sessionManager = this.server.env.get(SessionManager);
164028
+ if (this.sessionDiagHandler) {
164007
164029
  sessionManager.subscriptionsChanged.off(this.sessionDiagHandler);
164008
- } catch {
164009
164030
  }
164010
- this.sessionDiagHandler = void 0;
164031
+ if (this.sessionAddedHandler) {
164032
+ sessionManager.sessions.added.off(this.sessionAddedHandler);
164033
+ }
164034
+ if (this.sessionDeletedHandler) {
164035
+ sessionManager.sessions.deleted.off(this.sessionDeletedHandler);
164036
+ }
164037
+ } catch {
164011
164038
  }
164039
+ this.sessionDiagHandler = void 0;
164040
+ this.sessionAddedHandler = void 0;
164041
+ this.sessionDeletedHandler = void 0;
164012
164042
  }
164013
164043
  stopAutoForceSync() {
164014
164044
  if (this.autoForceSyncTimer) {
@@ -175036,9 +175066,13 @@ var ServerModeBridge = class {
175036
175066
  warmStartTimer = null;
175037
175067
  // Tracks the last synced state JSON per entity to avoid pushing unchanged states.
175038
175068
  lastSyncedState;
175039
- // Session lifecycle diagnostic handler (non-destructive, logging only).
175069
+ // Session lifecycle diagnostic handlers (non-destructive, logging only).
175040
175070
  // biome-ignore lint/suspicious/noExplicitAny: matter.js internal types
175041
175071
  sessionDiagHandler;
175072
+ // biome-ignore lint/suspicious/noExplicitAny: matter.js internal types
175073
+ sessionAddedHandler;
175074
+ // biome-ignore lint/suspicious/noExplicitAny: matter.js internal types
175075
+ sessionDeletedHandler;
175042
175076
  get id() {
175043
175077
  return this.dataProvider.id;
175044
175078
  }
@@ -175206,20 +175240,46 @@ ${e?.toString()}`);
175206
175240
  this.log.info(
175207
175241
  `Session ${session.id} (peer ${session.peerNodeId}): subscriptions=${session.subscriptions.size} | total: sessions=${sessions.length} subscriptions=${totalSubs}`
175208
175242
  );
175243
+ if (totalSubs === 0 && sessions.length > 0) {
175244
+ this.log.warn(
175245
+ `All subscriptions lost \u2014 ${sessions.length} session(s) still active, waiting for controller to re-subscribe`
175246
+ );
175247
+ }
175209
175248
  };
175210
175249
  sessionManager.subscriptionsChanged.on(this.sessionDiagHandler);
175250
+ this.sessionAddedHandler = (session) => {
175251
+ this.log.info(
175252
+ `Session opened: id=${session.id} peer=${session.peerNodeId}`
175253
+ );
175254
+ };
175255
+ this.sessionDeletedHandler = (session) => {
175256
+ const sessions = [...sessionManager.sessions];
175257
+ this.log.warn(
175258
+ `Session closed: id=${session.id} peer=${session.peerNodeId} | remaining sessions=${sessions.length}`
175259
+ );
175260
+ };
175261
+ sessionManager.sessions.added.on(this.sessionAddedHandler);
175262
+ sessionManager.sessions.deleted.on(this.sessionDeletedHandler);
175211
175263
  } catch {
175212
175264
  }
175213
175265
  }
175214
175266
  unwireSessionDiagnostics() {
175215
- if (this.sessionDiagHandler) {
175216
- try {
175217
- const sessionManager = this.server.env.get(SessionManager);
175267
+ try {
175268
+ const sessionManager = this.server.env.get(SessionManager);
175269
+ if (this.sessionDiagHandler) {
175218
175270
  sessionManager.subscriptionsChanged.off(this.sessionDiagHandler);
175219
- } catch {
175220
175271
  }
175221
- this.sessionDiagHandler = void 0;
175272
+ if (this.sessionAddedHandler) {
175273
+ sessionManager.sessions.added.off(this.sessionAddedHandler);
175274
+ }
175275
+ if (this.sessionDeletedHandler) {
175276
+ sessionManager.sessions.deleted.off(this.sessionDeletedHandler);
175277
+ }
175278
+ } catch {
175222
175279
  }
175280
+ this.sessionDiagHandler = void 0;
175281
+ this.sessionAddedHandler = void 0;
175282
+ this.sessionDeletedHandler = void 0;
175223
175283
  }
175224
175284
  stopAutoForceSync() {
175225
175285
  if (this.autoForceSyncTimer) {