@actuallab/rpc 12.1.69 → 12.1.100

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.
package/dist/index.cjs CHANGED
@@ -383,17 +383,19 @@ var RpcObjectKind = { Local: 0, Remote: 1 };
383
383
  function parseStreamRef(value) {
384
384
  if (typeof value !== "string") return null;
385
385
  const parts = value.split(",");
386
- if (parts.length !== 4) return null;
386
+ if (parts.length < 4 || parts.length > 5) return null;
387
387
  const hostId = parts[0];
388
388
  const localId = parseInt(parts[1], 10);
389
389
  const ackPeriod = parseInt(parts[2], 10);
390
390
  const ackAdvance = parseInt(parts[3], 10);
391
391
  if (isNaN(localId) || isNaN(ackPeriod) || isNaN(ackAdvance)) return null;
392
- return { hostId, localId, ackPeriod, ackAdvance };
392
+ const allowReconnect = parts.length < 5 || parts[4] !== "0";
393
+ return { hostId, localId, ackPeriod, ackAdvance, allowReconnect };
393
394
  }
394
395
  var RpcStream = class {
395
396
  id;
396
397
  kind = RpcObjectKind.Remote;
398
+ allowReconnect;
397
399
  peer;
398
400
  ackPeriod;
399
401
  ackAdvance;
@@ -408,6 +410,7 @@ var RpcStream = class {
408
410
  _ackSentUpTo = 0;
409
411
  constructor(ref, peer) {
410
412
  this.id = { hostId: ref.hostId, localId: ref.localId };
413
+ this.allowReconnect = ref.allowReconnect;
411
414
  this.peer = peer;
412
415
  this.ackPeriod = ref.ackPeriod;
413
416
  this.ackAdvance = ref.ackAdvance;
@@ -453,7 +456,11 @@ var RpcStream = class {
453
456
  }
454
457
  // -- IRpcObject --
455
458
  reconnect() {
456
- this._sendAck(this._nextExpectedIndex, true);
459
+ if (this.allowReconnect) {
460
+ this._sendAck(this._nextExpectedIndex, true);
461
+ } else {
462
+ this.disconnect();
463
+ }
457
464
  }
458
465
  disconnect() {
459
466
  if (this._completed) return;
@@ -706,22 +713,24 @@ var DEFAULT_ACK_ADVANCE = 128;
706
713
  var RpcStreamSender = class {
707
714
  id;
708
715
  kind = RpcObjectKind.Local;
716
+ allowReconnect;
709
717
  peer;
710
718
  ackPeriod;
711
719
  ackAdvance;
712
720
  _nextIndex = 0;
713
721
  _ended = false;
714
722
  _started = new import_core5.PromiseSource();
715
- constructor(peer, ackPeriod = DEFAULT_ACK_PERIOD, ackAdvance = DEFAULT_ACK_ADVANCE) {
723
+ constructor(peer, ackPeriod = DEFAULT_ACK_PERIOD, ackAdvance = DEFAULT_ACK_ADVANCE, allowReconnect = true) {
716
724
  const localId = peer.sharedObjects.nextId();
717
725
  this.id = { hostId: peer.hub.hubId, localId };
726
+ this.allowReconnect = allowReconnect;
718
727
  this.peer = peer;
719
728
  this.ackPeriod = ackPeriod;
720
729
  this.ackAdvance = ackAdvance;
721
730
  }
722
731
  /** Returns the stream reference string for the $sys.Ok response. */
723
732
  toRef() {
724
- return `${this.id.hostId},${this.id.localId},${this.ackPeriod},${this.ackAdvance}`;
733
+ return `${this.id.hostId},${this.id.localId},${this.ackPeriod},${this.ackAdvance},${this.allowReconnect ? "1" : "0"}`;
725
734
  }
726
735
  /** Called by system call handler when $sys.Ack is received from the client. */
727
736
  onAck(_nextIndex, _hostId) {
@@ -811,7 +820,10 @@ var RpcRemoteObjectTracker = class {
811
820
  }
812
821
  reconnectAll() {
813
822
  for (const obj of this._objects.values()) {
814
- obj.reconnect();
823
+ if (obj.allowReconnect)
824
+ obj.reconnect();
825
+ else
826
+ obj.disconnect();
815
827
  }
816
828
  }
817
829
  };