@fairfox/polly 0.74.0 → 0.75.0

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/src/mesh.js CHANGED
@@ -2702,6 +2702,7 @@ class MeshWebRTCAdapter extends NetworkAdapter2 {
2702
2702
  }
2703
2703
  handlePeerJoined(remotePeerId) {
2704
2704
  this.presentPeers.add(remotePeerId);
2705
+ this.evictStaleSlotForRejoin(remotePeerId);
2705
2706
  if (!this.shouldInitiateTo(remotePeerId))
2706
2707
  return;
2707
2708
  this.tryCreateInitiatingSlot(remotePeerId);
@@ -2709,11 +2710,24 @@ class MeshWebRTCAdapter extends NetworkAdapter2 {
2709
2710
  handlePeersPresent(peerIds) {
2710
2711
  for (const remotePeerId of peerIds) {
2711
2712
  this.presentPeers.add(remotePeerId);
2713
+ this.evictStaleSlotForRejoin(remotePeerId);
2712
2714
  if (!this.shouldInitiateTo(remotePeerId))
2713
2715
  continue;
2714
2716
  this.tryCreateInitiatingSlot(remotePeerId);
2715
2717
  }
2716
2718
  }
2719
+ evictStaleSlotForRejoin(remotePeerId) {
2720
+ const slot = this.slots.get(remotePeerId);
2721
+ if (!slot)
2722
+ return;
2723
+ const state = slot.connection.connectionState;
2724
+ if (state === "connected" && slot.channel?.readyState === "open")
2725
+ return;
2726
+ if (this.slotNeverConnectedTimeoutMs > 0 && (state === "new" || state === "connecting") && performance.now() - slot.createdAt < this.slotNeverConnectedTimeoutMs) {
2727
+ return;
2728
+ }
2729
+ this.tearDownWedgedSlot(remotePeerId);
2730
+ }
2717
2731
  tryCreateInitiatingSlot(remotePeerId) {
2718
2732
  try {
2719
2733
  this.createInitiatingSlot(remotePeerId);
@@ -4296,4 +4310,4 @@ export {
4296
4310
  $meshCounter
4297
4311
  };
4298
4312
 
4299
- //# debugId=3C4A71059C481C0664756E2164756E21
4313
+ //# debugId=0D84EA4EDCC2765464756E2164756E21