@cloudflare/realtimekit 1.5.2-staging.7 → 1.5.2-staging.8

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.d.ts CHANGED
@@ -3690,7 +3690,9 @@ declare class MediaNodeClient {
3690
3690
  constructor(context: Context<ContextState>, options: MediaNodeClientOptions);
3691
3691
  get mediaJoined(): boolean;
3692
3692
  set mediaJoined(joined: boolean);
3693
- reset(): void;
3693
+ reset({ resetTransportQueue }: {
3694
+ resetTransportQueue: boolean;
3695
+ }): void;
3694
3696
  joinRoom(displayName: string, roomUuid: string, rejoining?: boolean, permissions?: MediaPermissions): Promise<{
3695
3697
  roomJoined: boolean;
3696
3698
  error?: Error;
package/dist/index.es.js CHANGED
@@ -18456,7 +18456,7 @@ const Af = (Sg = class {
18456
18456
  this.waitingRoomRequestHandler.bind(this)
18457
18457
  ), this.context.getValue("peerSessionStore").on(b.SOCKET_PEERS, (s) => {
18458
18458
  const t = this.participants.joined.size > 0;
18459
- this.participants.joined.clear(), this.participants.videoSubscribed.clear(), this.participants.audioSubscribed.clear(), this.participants.pinned.clear(), this.participants.currentPage = 0, this.participants.viewMode = "ACTIVE_GRID", t && this.participants.emit("viewModeChanged", {
18459
+ this.participants.videoSubscribed.clear(), this.participants.audioSubscribed.clear(), this.participants.pinned.clear(), this.participants.joined.clear(), this.participants.currentPage = 0, this.participants.viewMode = "ACTIVE_GRID", t && this.participants.emit("viewModeChanged", {
18460
18460
  viewMode: "ACTIVE_GRID",
18461
18461
  currentPage: this.participants.currentPage,
18462
18462
  pageCount: this.participants.pageCount
@@ -23910,8 +23910,8 @@ class ne {
23910
23910
  set mediaJoined(t) {
23911
23911
  a(this, Js, Xr).mediaJoined = t;
23912
23912
  }
23913
- reset() {
23914
- a(this, G).closeAllProducers(), a(this, G).closeAllConsumers(), a(this, tt).clear(), a(this, _s).clear(), S(this, At, null), a(this, xi).stop(), a(this, G).stopAllTransports(), a(this, G).reset(), S(this, xi, new Ru());
23913
+ reset({ resetTransportQueue: t }) {
23914
+ this.logger.info(`Resetting media node client: closing all transports, producers, consumers, and queues(resetTransportQueue: ${t}).`), a(this, G).closeAllProducers(), a(this, G).closeAllConsumers(), a(this, tt).clear(), a(this, _s).clear(), S(this, At, null), t && a(this, xi).stop(), a(this, G).stopAllTransports(), a(this, G).reset(), t && S(this, xi, new Ru());
23915
23915
  }
23916
23916
  joinRoom(n, o) {
23917
23917
  return u(this, arguments, function* (t, e, r = !1, i = {}) {
@@ -24466,7 +24466,7 @@ lc = new WeakMap(), uc = new WeakMap(), et = new WeakMap(), G = new WeakMap(), t
24466
24466
  let n = !1;
24467
24467
  if (r) {
24468
24468
  const { recv: c, send: d } = (o = a(this, Js, Xr).mediaState) != null ? o : {};
24469
- (d == null ? void 0 : d.state) === Hr.CONNECTED && (c == null ? void 0 : c.state) === Hr.CONNECTED ? (this.logger.info("MediaNodeClient.joinRoom: transports healthy — partial reset (producers only)"), a(this, G).closeAllProducersLocally(), a(this, tt).clear(), a(this, _s).clear(), S(this, At, null), n = !0) : (this.logger.info("MediaNodeClient.joinRoom: transports unhealthy — full reset"), this.reset());
24469
+ (d == null ? void 0 : d.state) === Hr.CONNECTED && (c == null ? void 0 : c.state) === Hr.CONNECTED ? (this.logger.info("MediaNodeClient.joinRoom: transports healthy — partial reset (producers only)"), a(this, G).closeAllProducersLocally(), a(this, tt).clear(), a(this, _s).clear(), S(this, At, null), n = !0) : (this.logger.info("MediaNodeClient.joinRoom: transports unhealthy — full reset"), this.reset({ resetTransportQueue: !1 }));
24470
24470
  }
24471
24471
  try {
24472
24472
  a(this, At) ? yield a(this, At) : yield V(this, pc, Lu).call(this, t, e, r, i, n), V(this, il, eS).call(this, e);
@@ -24851,7 +24851,7 @@ const oS = (Tg = class {
24851
24851
  }
24852
24852
  resetSelf(s) {
24853
24853
  return u(this, null, function* () {
24854
- a(this, ee).getValue("callstats").callEnded(), s ? yield this.joinRoom(s) : a(this, ft, $t).reset();
24854
+ a(this, ee).getValue("callstats").callEnded(), s ? (this.logger.info("Resetting Self post reconnect. Peer has earlier tried joining the meeting. State cleanup will be done during room rejoin."), yield this.joinRoom(s)) : (this.logger.info("Resetting Self post reconnect. User never joined the room so doing full reset."), a(this, ft, $t).reset({ resetTransportQueue: !0 }));
24855
24855
  });
24856
24856
  }
24857
24857
  setupEvents() {
@@ -24862,7 +24862,7 @@ const oS = (Tg = class {
24862
24862
  }), a(this, ee).getValue("peerSessionStore").on(b.ROOM_NODE_DISCONNECTED, () => {
24863
24863
  this.self.roomState !== "disconnected" && (this.self.roomState = "disconnected", this.self.emit("roomLeft", { state: "disconnected" }));
24864
24864
  }), a(this, ee).getValue("peerSessionStore").on(b.ROOM_NODE_FAILED, () => {
24865
- this.self.roomState = "failed", this.self.emit("roomLeft", { state: "failed" });
24865
+ this.logger.error("Room node failed. SDK re-initialization is required."), this.self.roomState = "failed", this.self.emit("roomLeft", { state: "failed" });
24866
24866
  }), a(this, ee).getValue("peerSessionStore").on(b.SOCKET_SERVICE_RECONNECTED, ({ wasJoinAttempted: s }) => {
24867
24867
  s === !1 && (this.self.roomState = "init"), this.resetSelf(s);
24868
24868
  }), a(this, ee).getValue("peerSessionStore").on(b.SOCKET_SERVICE_DISCONNECTED, ({ joinAttempted: s }) => {
@@ -24871,7 +24871,7 @@ const oS = (Tg = class {
24871
24871
  const { peerId: t } = this;
24872
24872
  a(this, ha).updateURL(t), a(this, ee).getValue("telemetry").resetPeerId(t), vt().setHeader("tracing-id", t), $r.remapContext(t, a(this, ee)), this.self.roomState = "disconnected", this.self.emit("roomLeft", { state: "disconnected" });
24873
24873
  }), a(this, ee).getValue("peerSessionStore").on(b.SOCKET_SERVICE_FAILED, () => {
24874
- this.self.roomState = "failed", this.self.emit("roomLeft", { state: "failed" });
24874
+ this.logger.error("Socket reconnection failed after exhausting all attempts. SDK re-initialization is required."), this.self.roomState = "failed", this.self.emit("roomLeft", { state: "failed" });
24875
24875
  }), a(this, cs).on(x.waitingRoomRequestAccepted, () => {
24876
24876
  this.waitlistAcceptHandler();
24877
24877
  }), a(this, cs).on(Wc.updateUserPreset, (s) => {
@@ -24917,20 +24917,21 @@ const oS = (Tg = class {
24917
24917
  joinRoom(s = !1) {
24918
24918
  return u(this, null, function* () {
24919
24919
  try {
24920
+ this.logger.info("Joining socket room.");
24920
24921
  const { peer: t } = yield a(this, cs).joinRoom(
24921
24922
  this.self
24922
24923
  );
24923
- a(this, cs).socket.flush();
24924
+ this.logger.info("Joined socket room."), a(this, cs).socket.flush();
24924
24925
  const e = lh(t.stageType);
24925
24926
  if (a(this, ee).setValue("stageStatus", e, !1), t.waitlisted) {
24926
- this.waitlistedHandler();
24927
+ this.logger.info("Peer was waitlisted. Skipped joining media room."), this.waitlistedHandler();
24927
24928
  return;
24928
24929
  }
24929
24930
  } catch (t) {
24930
24931
  throw this.logger.error("SelfController.joinRoom: socket join failed", { error: t }), new A("Check the network and try again.", "0002");
24931
24932
  }
24932
24933
  try {
24933
- yield this.joinMediaRoom(s), a(this, ee).notify("stageStatus");
24934
+ this.logger.info("Joining media room."), yield this.joinMediaRoom(s), this.logger.info("Joined media room."), a(this, ee).notify("stageStatus");
24934
24935
  } catch (t) {
24935
24936
  throw this.logger.error("SelfController.joinRoom: media room join failed", { error: t }), t instanceof fr && t.message === "ice connection failed" ? new A(
24936
24937
  "A firewall or network restriction may be blocking the connection.",
@@ -24981,7 +24982,7 @@ const oS = (Tg = class {
24981
24982
  )) != null ? o : {};
24982
24983
  if (!h)
24983
24984
  throw g != null ? g : new Error("Could not connect to media server");
24984
- i === "ON_STAGE" && (yield this.shareMediaTracks()), this.self.roomState = "joined", this.self.emit("roomJoined", { reconnected: s });
24985
+ this.logger.info(i === "ON_STAGE" ? "Peer is on stage. Sharing media tracks" : "Peer is not on stage. Not sharing media tracks"), i === "ON_STAGE" && (yield this.shareMediaTracks()), this.logger.info(i === "ON_STAGE" ? "Peer is on stage. Shared media tracks" : "Peer is not on stage. Did not share media tracks"), this.self.roomState = "joined", this.self.emit("roomJoined", { reconnected: s });
24985
24986
  } catch (c) {
24986
24987
  throw this.logger.error("SelfController.mediaRoomJoin", { error: c }), c;
24987
24988
  }
@@ -26392,12 +26393,30 @@ const _S = (yg = class {
26392
26393
  S(this, Ee, new UD(a(this, Nr), {
26393
26394
  autoReconnect: !0,
26394
26395
  disconnectOnPingTimeout: n,
26395
- queueOnDisconnect: !0,
26396
+ queueOnDisconnect: !1,
26396
26397
  flushOnReconnect: !1,
26397
26398
  logger: this.logger,
26398
26399
  clientInitiatedPings: !n,
26399
- clientInitiatedPingInterval: 3e4
26400
- // 30 seconds
26400
+ /**
26401
+ * NOTE(ravindra-cloudflare):
26402
+ *
26403
+ * After exhausting maxReconnectionAttempts, socket will go in failed state,
26404
+ * never to connect again.
26405
+ *
26406
+ * Sockrates uses https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ for exponential backoffs.
26407
+ * Full Jitter: random(0, min(cap, base * 2^attempt)), base=1s, cap=10s.
26408
+ * Default maxReconnectionAttempts - 10.
26409
+ * Avg occurs when internet is down (connection fails instantly).
26410
+ * Max occurs when internet or backend is slow (each attempt hits 5s connection timeout).
26411
+ * Attempt - Avg timing - Max timing
26412
+ * 10 ~42s ~2 min 14s
26413
+ * 20 ~1 min 32s ~4 min 44s
26414
+ * 30 ~2 min 22s ~7 min 14s
26415
+ * 50 ~4 min 2s ~12 min 14s
26416
+ */
26417
+ maxReconnectionAttempts: 50,
26418
+ clientInitiatedPingInterval: 15e3
26419
+ // 15 seconds
26401
26420
  })), this.handleSocketConnectionEvents();
26402
26421
  }
26403
26422
  get joinAttempted() {
@@ -27497,7 +27516,7 @@ let Fr = (Pg = class {
27497
27516
  video: !0
27498
27517
  };
27499
27518
  return n.setValue("options", e), n.setValue("peerId", t), n.setValue("modules", o), n.setValue("sdkName", "web-core"), n.setValue("meetingId", r), n.setValue("apiBase", i.apiBase), n.setValue("baseURI", i.baseURI), n.setValue("userId", i.participantId), n.setValue("organizationId", i.orgId), n.setValue("authToken", e.authToken), n.setValue("overrides", (d = e.overrides) != null ? d : {}), n.setValue("env", yC({ baseURI: i.baseURI })), n.setValue("defaults", c), n.setValue("onError", e.onError || (() => {
27500
- })), n.setValue("cachedUserDetails", Cs(e.cachedUserDetails)), n.setValue("sdkVersion", "1.5.2-staging.7"), (l = e.modules) != null && l.experimentalAudioPlayback && n.setValue("audioPlayback", new ZD()), n;
27519
+ })), n.setValue("cachedUserDetails", Cs(e.cachedUserDetails)), n.setValue("sdkVersion", "1.5.2-staging.8"), (l = e.modules) != null && l.experimentalAudioPlayback && n.setValue("audioPlayback", new ZD()), n;
27501
27520
  }
27502
27521
  join() {
27503
27522
  return u(this, null, function* () {
package/dist/index.es5.js CHANGED
@@ -18627,7 +18627,7 @@ var AM = Object.defineProperty, IM = Object.getOwnPropertyDescriptor, Ls = funct
18627
18627
  var e = this;
18628
18628
  this.roomSocketHandler.on(Y.getWaitingRoomRequests, this.waitingRoomRequestHandler.bind(this)), this.context.getValue("peerSessionStore").on(F.SOCKET_PEERS, function(r) {
18629
18629
  var n = e.participants.joined.size > 0;
18630
- e.participants.joined.clear(), e.participants.videoSubscribed.clear(), e.participants.audioSubscribed.clear(), e.participants.pinned.clear(), e.participants.currentPage = 0, e.participants.viewMode = "ACTIVE_GRID", n && e.participants.emit("viewModeChanged", { viewMode: "ACTIVE_GRID", currentPage: e.participants.currentPage, pageCount: e.participants.pageCount }), r == null || r.forEach(function(i) {
18630
+ e.participants.videoSubscribed.clear(), e.participants.audioSubscribed.clear(), e.participants.pinned.clear(), e.participants.joined.clear(), e.participants.currentPage = 0, e.participants.viewMode = "ACTIVE_GRID", n && e.participants.emit("viewModeChanged", { viewMode: "ACTIVE_GRID", currentPage: e.participants.currentPage, pageCount: e.participants.pageCount }), r == null || r.forEach(function(i) {
18631
18631
  i.waitlisted || e.onParticipantSocketJoined(e.createParticipantObjFromSocketPeer(i));
18632
18632
  });
18633
18633
  }), this.roomSocketHandler.on(this.events.peerJoinedBroadcast, function(r) {
@@ -24882,8 +24882,9 @@ var j_ = Object.defineProperty, F_ = Object.getOwnPropertyDescriptor, Ze = funct
24882
24882
  return c(this, Nt)[Nt].mediaJoined;
24883
24883
  }, set: function(e) {
24884
24884
  c(this, Nt)[Nt].mediaJoined = e;
24885
- } }, { key: "reset", value: function() {
24886
- c(this, W)[W].closeAllProducers(), c(this, W)[W].closeAllConsumers(), c(this, tr)[tr].clear(), c(this, ut)[ut].clear(), c(this, Lr)[Lr] = null, c(this, ui)[ui].stop(), c(this, W)[W].stopAllTransports(), c(this, W)[W].reset(), c(this, ui)[ui] = new vd();
24885
+ } }, { key: "reset", value: function(e) {
24886
+ var r = e.resetTransportQueue;
24887
+ this.logger.info("Resetting media node client: closing all transports, producers, consumers, and queues(resetTransportQueue: ".concat(r, ").")), c(this, W)[W].closeAllProducers(), c(this, W)[W].closeAllConsumers(), c(this, tr)[tr].clear(), c(this, ut)[ut].clear(), c(this, Lr)[Lr] = null, r && c(this, ui)[ui].stop(), c(this, W)[W].stopAllTransports(), c(this, W)[W].reset(), r && (c(this, ui)[ui] = new vd());
24887
24888
  } }, { key: "joinRoom", value: function() {
24888
24889
  var t = m(/* @__PURE__ */ h().mark(function r(n, i) {
24889
24890
  var a = this, o, u, l, d = arguments;
@@ -25764,7 +25765,7 @@ function jd() {
25764
25765
  for (; ; )
25765
25766
  switch (k.prev = k.next) {
25766
25767
  case 0:
25767
- if (c(this, ku)[ku] = t, i = !1, r && (o = (a = c(this, Nt)[Nt].mediaState) !== null && a !== void 0 ? a : {}, u = o.recv, l = o.send, d = (l == null ? void 0 : l.state) === ha.CONNECTED && (u == null ? void 0 : u.state) === ha.CONNECTED, d ? (this.logger.info("MediaNodeClient.joinRoom: transports healthy — partial reset (producers only)"), c(this, W)[W].closeAllProducersLocally(), c(this, tr)[tr].clear(), c(this, ut)[ut].clear(), c(this, Lr)[Lr] = null, i = !0) : (this.logger.info("MediaNodeClient.joinRoom: transports unhealthy — full reset"), this.reset())), k.prev = 3, !c(this, Lr)[Lr]) {
25768
+ if (c(this, ku)[ku] = t, i = !1, r && (o = (a = c(this, Nt)[Nt].mediaState) !== null && a !== void 0 ? a : {}, u = o.recv, l = o.send, d = (l == null ? void 0 : l.state) === ha.CONNECTED && (u == null ? void 0 : u.state) === ha.CONNECTED, d ? (this.logger.info("MediaNodeClient.joinRoom: transports healthy — partial reset (producers only)"), c(this, W)[W].closeAllProducersLocally(), c(this, tr)[tr].clear(), c(this, ut)[ut].clear(), c(this, Lr)[Lr] = null, i = !0) : (this.logger.info("MediaNodeClient.joinRoom: transports unhealthy — full reset"), this.reset({ resetTransportQueue: !1 }))), k.prev = 3, !c(this, Lr)[Lr]) {
25768
25769
  k.next = 9;
25769
25770
  break;
25770
25771
  }
@@ -26119,16 +26120,16 @@ var eO = Object.defineProperty, rO = Object.getOwnPropertyDescriptor, Ns = funct
26119
26120
  switch (a.prev = a.next) {
26120
26121
  case 0:
26121
26122
  if (c(this, X)[X].getValue("callstats").callEnded(), !n) {
26122
- a.next = 6;
26123
+ a.next = 7;
26123
26124
  break;
26124
26125
  }
26125
- return a.next = 4, this.joinRoom(n);
26126
- case 4:
26127
- a.next = 7;
26126
+ return this.logger.info("Resetting Self post reconnect. Peer has earlier tried joining the meeting. State cleanup will be done during room rejoin."), a.next = 5, this.joinRoom(n);
26127
+ case 5:
26128
+ a.next = 9;
26128
26129
  break;
26129
- case 6:
26130
- c(this, yr)[yr].reset();
26131
26130
  case 7:
26131
+ this.logger.info("Resetting Self post reconnect. User never joined the room so doing full reset."), c(this, yr)[yr].reset({ resetTransportQueue: !0 });
26132
+ case 9:
26132
26133
  case "end":
26133
26134
  return a.stop();
26134
26135
  }
@@ -26162,7 +26163,7 @@ var eO = Object.defineProperty, rO = Object.getOwnPropertyDescriptor, Ns = funct
26162
26163
  }), c(this, X)[X].getValue("peerSessionStore").on(F.ROOM_NODE_DISCONNECTED, function() {
26163
26164
  e.self.roomState !== "disconnected" && (e.self.roomState = "disconnected", e.self.emit("roomLeft", { state: "disconnected" }));
26164
26165
  }), c(this, X)[X].getValue("peerSessionStore").on(F.ROOM_NODE_FAILED, function() {
26165
- e.self.roomState = "failed", e.self.emit("roomLeft", { state: "failed" });
26166
+ e.logger.error("Room node failed. SDK re-initialization is required."), e.self.roomState = "failed", e.self.emit("roomLeft", { state: "failed" });
26166
26167
  }), c(this, X)[X].getValue("peerSessionStore").on(F.SOCKET_SERVICE_RECONNECTED, function(r) {
26167
26168
  var n = r.wasJoinAttempted;
26168
26169
  n === !1 && (e.self.roomState = "init"), e.resetSelf(n);
@@ -26177,7 +26178,7 @@ var eO = Object.defineProperty, rO = Object.getOwnPropertyDescriptor, Ns = funct
26177
26178
  o.setHeader("tracing-id", i), la.remapContext(i, c(e, X)[X]), e.self.roomState = "disconnected", e.self.emit("roomLeft", { state: "disconnected" });
26178
26179
  }
26179
26180
  }), c(this, X)[X].getValue("peerSessionStore").on(F.SOCKET_SERVICE_FAILED, function() {
26180
- e.self.roomState = "failed", e.self.emit("roomLeft", { state: "failed" });
26181
+ e.logger.error("Socket reconnection failed after exhausting all attempts. SDK re-initialization is required."), e.self.roomState = "failed", e.self.emit("roomLeft", { state: "failed" });
26181
26182
  }), c(this, Jr)[Jr].on(Y.waitingRoomRequestAccepted, function() {
26182
26183
  e.waitlistAcceptHandler();
26183
26184
  }), c(this, Jr)[Jr].on(hc.updateUserPreset, function(r) {
@@ -26235,36 +26236,36 @@ var eO = Object.defineProperty, rO = Object.getOwnPropertyDescriptor, Ns = funct
26235
26236
  for (; ; )
26236
26237
  switch (d.prev = d.next) {
26237
26238
  case 0:
26238
- return n = u.length > 0 && u[0] !== void 0 ? u[0] : !1, d.prev = 1, d.next = 4, c(this, Jr)[Jr].joinRoom(this.self);
26239
- case 4:
26240
- if (i = d.sent, a = i.peer, c(this, Jr)[Jr].socket.flush(), o = kp(a.stageType), c(this, X)[X].setValue("stageStatus", o, !1), !a.waitlisted) {
26241
- d.next = 12;
26239
+ return n = u.length > 0 && u[0] !== void 0 ? u[0] : !1, d.prev = 1, this.logger.info("Joining socket room."), d.next = 5, c(this, Jr)[Jr].joinRoom(this.self);
26240
+ case 5:
26241
+ if (i = d.sent, a = i.peer, this.logger.info("Joined socket room."), c(this, Jr)[Jr].socket.flush(), o = kp(a.stageType), c(this, X)[X].setValue("stageStatus", o, !1), !a.waitlisted) {
26242
+ d.next = 15;
26242
26243
  break;
26243
26244
  }
26244
- return this.waitlistedHandler(), d.abrupt("return");
26245
- case 12:
26246
- d.next = 18;
26245
+ return this.logger.info("Peer was waitlisted. Skipped joining media room."), this.waitlistedHandler(), d.abrupt("return");
26246
+ case 15:
26247
+ d.next = 21;
26247
26248
  break;
26248
- case 14:
26249
- throw d.prev = 14, d.t0 = d.catch(1), this.logger.error("SelfController.joinRoom: socket join failed", { error: d.t0 }), new B("Check the network and try again.", "0002");
26250
- case 18:
26251
- return d.prev = 18, d.next = 21, this.joinMediaRoom(n);
26249
+ case 17:
26250
+ throw d.prev = 17, d.t0 = d.catch(1), this.logger.error("SelfController.joinRoom: socket join failed", { error: d.t0 }), new B("Check the network and try again.", "0002");
26252
26251
  case 21:
26253
- c(this, X)[X].notify("stageStatus"), d.next = 30;
26252
+ return d.prev = 21, this.logger.info("Joining media room."), d.next = 25, this.joinMediaRoom(n);
26253
+ case 25:
26254
+ this.logger.info("Joined media room."), c(this, X)[X].notify("stageStatus"), d.next = 35;
26254
26255
  break;
26255
- case 24:
26256
- if (d.prev = 24, d.t1 = d.catch(18), this.logger.error("SelfController.joinRoom: media room join failed", { error: d.t1 }), !(d.t1 instanceof pa && d.t1.message === "ice connection failed")) {
26257
- d.next = 29;
26256
+ case 29:
26257
+ if (d.prev = 29, d.t1 = d.catch(21), this.logger.error("SelfController.joinRoom: media room join failed", { error: d.t1 }), !(d.t1 instanceof pa && d.t1.message === "ice connection failed")) {
26258
+ d.next = 34;
26258
26259
  break;
26259
26260
  }
26260
26261
  throw new B("A firewall or network restriction may be blocking the connection.", "0014");
26261
- case 29:
26262
+ case 34:
26262
26263
  throw new B("Check the network and try again.", "0014");
26263
- case 30:
26264
+ case 35:
26264
26265
  case "end":
26265
26266
  return d.stop();
26266
26267
  }
26267
- }, r, this, [[1, 14], [18, 24]]);
26268
+ }, r, this, [[1, 17], [21, 29]]);
26268
26269
  }));
26269
26270
  function e() {
26270
26271
  return t.apply(this, arguments);
@@ -26338,21 +26339,21 @@ var eO = Object.defineProperty, rO = Object.getOwnPropertyDescriptor, Ns = funct
26338
26339
  }
26339
26340
  throw T != null ? T : new Error("Could not connect to media server");
26340
26341
  case 26:
26341
- if (l !== "ON_STAGE") {
26342
- M.next = 29;
26342
+ if (this.logger.info(l === "ON_STAGE" ? "Peer is on stage. Sharing media tracks" : "Peer is not on stage. Not sharing media tracks"), l !== "ON_STAGE") {
26343
+ M.next = 30;
26343
26344
  break;
26344
26345
  }
26345
- return M.next = 29, this.shareMediaTracks();
26346
- case 29:
26347
- this.self.roomState = "joined", this.self.emit("roomJoined", { reconnected: n }), M.next = 37;
26346
+ return M.next = 30, this.shareMediaTracks();
26347
+ case 30:
26348
+ this.logger.info(l === "ON_STAGE" ? "Peer is on stage. Shared media tracks" : "Peer is not on stage. Did not share media tracks"), this.self.roomState = "joined", this.self.emit("roomJoined", { reconnected: n }), M.next = 39;
26348
26349
  break;
26349
- case 33:
26350
- throw M.prev = 33, M.t3 = M.catch(2), this.logger.error("SelfController.mediaRoomJoin", { error: M.t3 }), M.t3;
26351
- case 37:
26350
+ case 35:
26351
+ throw M.prev = 35, M.t3 = M.catch(2), this.logger.error("SelfController.mediaRoomJoin", { error: M.t3 }), M.t3;
26352
+ case 39:
26352
26353
  case "end":
26353
26354
  return M.stop();
26354
26355
  }
26355
- }, r, this, [[2, 33]]);
26356
+ }, r, this, [[2, 35]]);
26356
26357
  }));
26357
26358
  function e() {
26358
26359
  return t.apply(this, arguments);
@@ -27955,12 +27956,30 @@ var RO = Object.defineProperty, AO = Object.getOwnPropertyDescriptor, rl = funct
27955
27956
  c(this, ye)[ye] = new CO(c(this, Yt)[Yt], {
27956
27957
  autoReconnect: !0,
27957
27958
  disconnectOnPingTimeout: o,
27958
- queueOnDisconnect: !0,
27959
+ queueOnDisconnect: !1,
27959
27960
  flushOnReconnect: !1,
27960
27961
  logger: this.logger,
27961
27962
  clientInitiatedPings: !o,
27962
- clientInitiatedPingInterval: 3e4
27963
- // 30 seconds
27963
+ /**
27964
+ * NOTE(ravindra-cloudflare):
27965
+ *
27966
+ * After exhausting maxReconnectionAttempts, socket will go in failed state,
27967
+ * never to connect again.
27968
+ *
27969
+ * Sockrates uses https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ for exponential backoffs.
27970
+ * Full Jitter: random(0, min(cap, base * 2^attempt)), base=1s, cap=10s.
27971
+ * Default maxReconnectionAttempts - 10.
27972
+ * Avg occurs when internet is down (connection fails instantly).
27973
+ * Max occurs when internet or backend is slow (each attempt hits 5s connection timeout).
27974
+ * Attempt - Avg timing - Max timing
27975
+ * 10 ~42s ~2 min 14s
27976
+ * 20 ~1 min 32s ~4 min 44s
27977
+ * 30 ~2 min 22s ~7 min 14s
27978
+ * 50 ~4 min 2s ~12 min 14s
27979
+ */
27980
+ maxReconnectionAttempts: 50,
27981
+ clientInitiatedPingInterval: 15e3
27982
+ // 15 seconds
27964
27983
  }), this.handleSocketConnectionEvents();
27965
27984
  }
27966
27985
  return S(s, [{ key: "joinAttempted", get: function() {