@matter/protocol 0.16.0-alpha.0-20251210-206ca2db7 → 0.16.0-alpha.0-20251211-0f80042cf

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 (63) hide show
  1. package/dist/cjs/action/client/ClientInteraction.d.ts +10 -3
  2. package/dist/cjs/action/client/ClientInteraction.d.ts.map +1 -1
  3. package/dist/cjs/action/client/ClientInteraction.js +35 -14
  4. package/dist/cjs/action/client/ClientInteraction.js.map +1 -1
  5. package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.d.ts.map +1 -1
  6. package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.js +22 -23
  7. package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.js.map +1 -1
  8. package/dist/cjs/action/client/subscription/PeerSubscription.d.ts +2 -0
  9. package/dist/cjs/action/client/subscription/PeerSubscription.d.ts.map +1 -1
  10. package/dist/cjs/action/client/subscription/PeerSubscription.js +7 -2
  11. package/dist/cjs/action/client/subscription/PeerSubscription.js.map +1 -1
  12. package/dist/cjs/action/request/Subscribe.d.ts +0 -1
  13. package/dist/cjs/action/request/Subscribe.d.ts.map +1 -1
  14. package/dist/cjs/action/request/Subscribe.js.map +1 -1
  15. package/dist/cjs/interaction/AttributeDataDecoder.d.ts +1 -2
  16. package/dist/cjs/interaction/AttributeDataDecoder.d.ts.map +1 -1
  17. package/dist/cjs/peer/index.d.ts +1 -0
  18. package/dist/cjs/peer/index.d.ts.map +1 -1
  19. package/dist/cjs/peer/index.js +1 -0
  20. package/dist/cjs/peer/index.js.map +1 -1
  21. package/dist/cjs/protocol/ExchangeManager.d.ts.map +1 -1
  22. package/dist/cjs/protocol/ExchangeManager.js +5 -6
  23. package/dist/cjs/protocol/ExchangeManager.js.map +1 -1
  24. package/dist/cjs/protocol/MessageExchange.d.ts +6 -1
  25. package/dist/cjs/protocol/MessageExchange.d.ts.map +1 -1
  26. package/dist/cjs/protocol/MessageExchange.js +11 -6
  27. package/dist/cjs/protocol/MessageExchange.js.map +1 -1
  28. package/dist/esm/action/client/ClientInteraction.d.ts +10 -3
  29. package/dist/esm/action/client/ClientInteraction.d.ts.map +1 -1
  30. package/dist/esm/action/client/ClientInteraction.js +35 -14
  31. package/dist/esm/action/client/ClientInteraction.js.map +1 -1
  32. package/dist/esm/action/client/subscription/ClientSubscriptionHandler.d.ts.map +1 -1
  33. package/dist/esm/action/client/subscription/ClientSubscriptionHandler.js +22 -23
  34. package/dist/esm/action/client/subscription/ClientSubscriptionHandler.js.map +1 -1
  35. package/dist/esm/action/client/subscription/PeerSubscription.d.ts +2 -0
  36. package/dist/esm/action/client/subscription/PeerSubscription.d.ts.map +1 -1
  37. package/dist/esm/action/client/subscription/PeerSubscription.js +7 -2
  38. package/dist/esm/action/client/subscription/PeerSubscription.js.map +1 -1
  39. package/dist/esm/action/request/Subscribe.d.ts +0 -1
  40. package/dist/esm/action/request/Subscribe.d.ts.map +1 -1
  41. package/dist/esm/action/request/Subscribe.js.map +1 -1
  42. package/dist/esm/interaction/AttributeDataDecoder.d.ts +1 -2
  43. package/dist/esm/interaction/AttributeDataDecoder.d.ts.map +1 -1
  44. package/dist/esm/peer/index.d.ts +1 -0
  45. package/dist/esm/peer/index.d.ts.map +1 -1
  46. package/dist/esm/peer/index.js +1 -0
  47. package/dist/esm/peer/index.js.map +1 -1
  48. package/dist/esm/protocol/ExchangeManager.d.ts.map +1 -1
  49. package/dist/esm/protocol/ExchangeManager.js +5 -6
  50. package/dist/esm/protocol/ExchangeManager.js.map +1 -1
  51. package/dist/esm/protocol/MessageExchange.d.ts +6 -1
  52. package/dist/esm/protocol/MessageExchange.d.ts.map +1 -1
  53. package/dist/esm/protocol/MessageExchange.js +11 -6
  54. package/dist/esm/protocol/MessageExchange.js.map +1 -1
  55. package/package.json +6 -6
  56. package/src/action/client/ClientInteraction.ts +45 -16
  57. package/src/action/client/subscription/ClientSubscriptionHandler.ts +29 -30
  58. package/src/action/client/subscription/PeerSubscription.ts +8 -2
  59. package/src/action/request/Subscribe.ts +0 -1
  60. package/src/interaction/AttributeDataDecoder.ts +1 -1
  61. package/src/peer/index.ts +1 -0
  62. package/src/protocol/ExchangeManager.ts +5 -6
  63. package/src/protocol/MessageExchange.ts +14 -9
@@ -217,6 +217,10 @@ export class MessageExchange {
217
217
  return this.#closed;
218
218
  }
219
219
 
220
+ get considerClosed() {
221
+ return this.#closed.value || (this.#isInitiator && this.#closing.value);
222
+ }
223
+
220
224
  /**
221
225
  * Emit when the exchange is closing, but not yet closed. We only wait for acks and retries to happen, but the
222
226
  * actual interaction logic is already done.
@@ -225,10 +229,6 @@ export class MessageExchange {
225
229
  return this.#closing;
226
230
  }
227
231
 
228
- get isClosing() {
229
- return this.#closing.value;
230
- }
231
-
232
232
  get id() {
233
233
  return this.#exchangeId;
234
234
  }
@@ -505,10 +505,10 @@ export class MessageExchange {
505
505
 
506
506
  #retransmitMessage(message: Message, expectedProcessingTime?: Duration) {
507
507
  this.#retransmissionCounter++;
508
- if (this.isClosing || this.#retransmissionCounter >= MRP.MAX_TRANSMISSIONS) {
508
+ if (this.considerClosed || this.#retransmissionCounter >= MRP.MAX_TRANSMISSIONS) {
509
509
  // Ok all 4 resubmissions are done, but we need to wait a bit longer because of processing time and
510
510
  // the resubmissions from the other side
511
- if (expectedProcessingTime && !this.isClosing) {
511
+ if (expectedProcessingTime && !this.considerClosed) {
512
512
  // We already have waited after the last message was sent, so deduct this time from the final wait time
513
513
  const finalWaitTime = Millis(
514
514
  this.channel.calculateMaximumPeerResponseTime(
@@ -642,7 +642,12 @@ export class MessageExchange {
642
642
  return this.#timedInteractionTimer !== undefined && !this.#timedInteractionTimer.isRunning;
643
643
  }
644
644
 
645
- async close(force = this.isInitiator) {
645
+ /**
646
+ * Closes the exchange.
647
+ * If force is true, the exchange will be closed immediately, even if there are still messages to send.
648
+ * If force is false, the exchange will be closed only after all messages have been sent.
649
+ */
650
+ async close(force = false) {
646
651
  if (this.#isDestroyed) {
647
652
  return;
648
653
  }
@@ -660,7 +665,7 @@ export class MessageExchange {
660
665
  }
661
666
  if (!this.#used) {
662
667
  // The exchange was never in use, so we can close it directly
663
- // If we see that in the wild we should fix the reasons
668
+ // If we see that in the wild, we should fix the reasons
664
669
  logger.info(this.via, `Exchange never used, closing directly`);
665
670
  return this.#close();
666
671
  }
@@ -685,7 +690,7 @@ export class MessageExchange {
685
690
  }
686
691
 
687
692
  // Wait until all potential outstanding Resubmissions are done, also for Standalone-Acks.
688
- // We might wait a bit longer then needed but because this is mainly a failsafe mechanism it is acceptable.
693
+ // We might wait a bit longer than needed, but because this is mainly a failsafe mechanism, it is acceptable.
689
694
  // in normal case this timer is cancelled before it triggers when all retries are done.
690
695
  let maxResubmissionTime = Instant;
691
696
  for (let i = this.#retransmissionCounter; i <= MRP.MAX_TRANSMISSIONS; i++) {