@whereby.com/media 2.5.3 → 2.5.4

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
@@ -640,6 +640,7 @@ function rtcStatsConnection(wsURL, logger = console) {
640
640
  let featureFlags;
641
641
  const connection = {
642
642
  connected: false,
643
+ attemptedConnectedAtLeastOnce: false,
643
644
  trace: (...args) => {
644
645
  args.push(Date.now());
645
646
  if (args[0] === "customEvent" && args[2].type === "roomSessionId") {
@@ -712,6 +713,7 @@ function rtcStatsConnection(wsURL, logger = console) {
712
713
  connectionAttempt += 1;
713
714
  ws === null || ws === void 0 ? void 0 : ws.close();
714
715
  connection.connected = true;
716
+ connection.attemptedConnectedAtLeastOnce = true;
715
717
  ws = new WebSocket(wsURL + window.location.pathname, RTCSTATS_PROTOCOL_VERSION);
716
718
  ws.onerror = (e) => {
717
719
  connection.connected = false;
@@ -2809,11 +2811,16 @@ class P2pRtcManager {
2809
2811
  sendStatsCustomEvent(eventName, data) {
2810
2812
  rtcStats.sendEvent(eventName, data);
2811
2813
  }
2814
+ rtcStatsConnect() {
2815
+ if (!rtcStats.server.connected) {
2816
+ rtcStats.server.connect();
2817
+ }
2818
+ }
2812
2819
  rtcStatsDisconnect() {
2813
2820
  rtcStats.server.close();
2814
2821
  }
2815
2822
  rtcStatsReconnect() {
2816
- if (!rtcStats.server.connected) {
2823
+ if (!rtcStats.server.connected && rtcStats.server.attemptedConnectedAtLeastOnce) {
2817
2824
  rtcStats.server.connect();
2818
2825
  }
2819
2826
  }
@@ -3203,6 +3210,10 @@ class P2pRtcManager {
3203
3210
  this._videoTrackBeingMonitored = track;
3204
3211
  }
3205
3212
  _connect(clientId) {
3213
+ try {
3214
+ this.rtcStatsReconnect();
3215
+ }
3216
+ catch (_) { }
3206
3217
  let session = this._getSession(clientId);
3207
3218
  let initialBandwidth = (session && session.bandwidth) || 0;
3208
3219
  if (session) {
@@ -5554,11 +5565,16 @@ class VegaRtcManager {
5554
5565
  sendStatsCustomEvent(eventName, data) {
5555
5566
  rtcStats.sendEvent(eventName, data);
5556
5567
  }
5568
+ rtcStatsConnect() {
5569
+ if (!rtcStats.server.connected) {
5570
+ rtcStats.server.connect();
5571
+ }
5572
+ }
5557
5573
  rtcStatsDisconnect() {
5558
5574
  rtcStats.server.close();
5559
5575
  }
5560
5576
  rtcStatsReconnect() {
5561
- if (!rtcStats.server.connected) {
5577
+ if (!rtcStats.server.connected && rtcStats.server.attemptedConnectedAtLeastOnce) {
5562
5578
  rtcStats.server.connect();
5563
5579
  }
5564
5580
  }
@@ -5884,7 +5900,7 @@ class RtcManagerDispatcher {
5884
5900
  else {
5885
5901
  rtcManager = new P2pRtcManager(config);
5886
5902
  }
5887
- rtcManager.rtcStatsReconnect();
5903
+ rtcManager.rtcStatsConnect();
5888
5904
  rtcManager.setupSocketListeners();
5889
5905
  emitter.emit(EVENTS.RTC_MANAGER_CREATED, { rtcManager });
5890
5906
  this.currentManager = rtcManager;
package/dist/index.d.cts CHANGED
@@ -1133,6 +1133,7 @@ declare class P2pRtcManager implements RtcManager {
1133
1133
  sendAudioMutedStats(muted: boolean): void;
1134
1134
  sendVideoMutedStats(muted: boolean): void;
1135
1135
  sendStatsCustomEvent(eventName: string, data: any): void;
1136
+ rtcStatsConnect(): void;
1136
1137
  rtcStatsDisconnect(): void;
1137
1138
  rtcStatsReconnect(): void;
1138
1139
  setAudioOnly(audioOnly: any): void;
@@ -1254,6 +1255,7 @@ declare const rtcStats: {
1254
1255
  sendVideoMuted: (muted: boolean) => void;
1255
1256
  server: {
1256
1257
  connected: boolean;
1258
+ attemptedConnectedAtLeastOnce: boolean;
1257
1259
  trace: (...args: any) => void;
1258
1260
  close: () => void;
1259
1261
  connect: () => void;
@@ -1633,6 +1635,7 @@ declare class VegaRtcManager implements RtcManager {
1633
1635
  sendAudioMutedStats(muted: boolean): void;
1634
1636
  sendVideoMutedStats(muted: boolean): void;
1635
1637
  sendStatsCustomEvent(eventName: string, data?: any): void;
1638
+ rtcStatsConnect(): void;
1636
1639
  rtcStatsDisconnect(): void;
1637
1640
  rtcStatsReconnect(): void;
1638
1641
  _monitorAudioTrack(track: any): void;
package/dist/index.d.mts CHANGED
@@ -1133,6 +1133,7 @@ declare class P2pRtcManager implements RtcManager {
1133
1133
  sendAudioMutedStats(muted: boolean): void;
1134
1134
  sendVideoMutedStats(muted: boolean): void;
1135
1135
  sendStatsCustomEvent(eventName: string, data: any): void;
1136
+ rtcStatsConnect(): void;
1136
1137
  rtcStatsDisconnect(): void;
1137
1138
  rtcStatsReconnect(): void;
1138
1139
  setAudioOnly(audioOnly: any): void;
@@ -1254,6 +1255,7 @@ declare const rtcStats: {
1254
1255
  sendVideoMuted: (muted: boolean) => void;
1255
1256
  server: {
1256
1257
  connected: boolean;
1258
+ attemptedConnectedAtLeastOnce: boolean;
1257
1259
  trace: (...args: any) => void;
1258
1260
  close: () => void;
1259
1261
  connect: () => void;
@@ -1633,6 +1635,7 @@ declare class VegaRtcManager implements RtcManager {
1633
1635
  sendAudioMutedStats(muted: boolean): void;
1634
1636
  sendVideoMutedStats(muted: boolean): void;
1635
1637
  sendStatsCustomEvent(eventName: string, data?: any): void;
1638
+ rtcStatsConnect(): void;
1636
1639
  rtcStatsDisconnect(): void;
1637
1640
  rtcStatsReconnect(): void;
1638
1641
  _monitorAudioTrack(track: any): void;
package/dist/index.d.ts CHANGED
@@ -1133,6 +1133,7 @@ declare class P2pRtcManager implements RtcManager {
1133
1133
  sendAudioMutedStats(muted: boolean): void;
1134
1134
  sendVideoMutedStats(muted: boolean): void;
1135
1135
  sendStatsCustomEvent(eventName: string, data: any): void;
1136
+ rtcStatsConnect(): void;
1136
1137
  rtcStatsDisconnect(): void;
1137
1138
  rtcStatsReconnect(): void;
1138
1139
  setAudioOnly(audioOnly: any): void;
@@ -1254,6 +1255,7 @@ declare const rtcStats: {
1254
1255
  sendVideoMuted: (muted: boolean) => void;
1255
1256
  server: {
1256
1257
  connected: boolean;
1258
+ attemptedConnectedAtLeastOnce: boolean;
1257
1259
  trace: (...args: any) => void;
1258
1260
  close: () => void;
1259
1261
  connect: () => void;
@@ -1633,6 +1635,7 @@ declare class VegaRtcManager implements RtcManager {
1633
1635
  sendAudioMutedStats(muted: boolean): void;
1634
1636
  sendVideoMutedStats(muted: boolean): void;
1635
1637
  sendStatsCustomEvent(eventName: string, data?: any): void;
1638
+ rtcStatsConnect(): void;
1636
1639
  rtcStatsDisconnect(): void;
1637
1640
  rtcStatsReconnect(): void;
1638
1641
  _monitorAudioTrack(track: any): void;
package/dist/index.mjs CHANGED
@@ -619,6 +619,7 @@ function rtcStatsConnection(wsURL, logger = console) {
619
619
  let featureFlags;
620
620
  const connection = {
621
621
  connected: false,
622
+ attemptedConnectedAtLeastOnce: false,
622
623
  trace: (...args) => {
623
624
  args.push(Date.now());
624
625
  if (args[0] === "customEvent" && args[2].type === "roomSessionId") {
@@ -691,6 +692,7 @@ function rtcStatsConnection(wsURL, logger = console) {
691
692
  connectionAttempt += 1;
692
693
  ws === null || ws === void 0 ? void 0 : ws.close();
693
694
  connection.connected = true;
695
+ connection.attemptedConnectedAtLeastOnce = true;
694
696
  ws = new WebSocket(wsURL + window.location.pathname, RTCSTATS_PROTOCOL_VERSION);
695
697
  ws.onerror = (e) => {
696
698
  connection.connected = false;
@@ -2788,11 +2790,16 @@ class P2pRtcManager {
2788
2790
  sendStatsCustomEvent(eventName, data) {
2789
2791
  rtcStats.sendEvent(eventName, data);
2790
2792
  }
2793
+ rtcStatsConnect() {
2794
+ if (!rtcStats.server.connected) {
2795
+ rtcStats.server.connect();
2796
+ }
2797
+ }
2791
2798
  rtcStatsDisconnect() {
2792
2799
  rtcStats.server.close();
2793
2800
  }
2794
2801
  rtcStatsReconnect() {
2795
- if (!rtcStats.server.connected) {
2802
+ if (!rtcStats.server.connected && rtcStats.server.attemptedConnectedAtLeastOnce) {
2796
2803
  rtcStats.server.connect();
2797
2804
  }
2798
2805
  }
@@ -3182,6 +3189,10 @@ class P2pRtcManager {
3182
3189
  this._videoTrackBeingMonitored = track;
3183
3190
  }
3184
3191
  _connect(clientId) {
3192
+ try {
3193
+ this.rtcStatsReconnect();
3194
+ }
3195
+ catch (_) { }
3185
3196
  let session = this._getSession(clientId);
3186
3197
  let initialBandwidth = (session && session.bandwidth) || 0;
3187
3198
  if (session) {
@@ -5533,11 +5544,16 @@ class VegaRtcManager {
5533
5544
  sendStatsCustomEvent(eventName, data) {
5534
5545
  rtcStats.sendEvent(eventName, data);
5535
5546
  }
5547
+ rtcStatsConnect() {
5548
+ if (!rtcStats.server.connected) {
5549
+ rtcStats.server.connect();
5550
+ }
5551
+ }
5536
5552
  rtcStatsDisconnect() {
5537
5553
  rtcStats.server.close();
5538
5554
  }
5539
5555
  rtcStatsReconnect() {
5540
- if (!rtcStats.server.connected) {
5556
+ if (!rtcStats.server.connected && rtcStats.server.attemptedConnectedAtLeastOnce) {
5541
5557
  rtcStats.server.connect();
5542
5558
  }
5543
5559
  }
@@ -5863,7 +5879,7 @@ class RtcManagerDispatcher {
5863
5879
  else {
5864
5880
  rtcManager = new P2pRtcManager(config);
5865
5881
  }
5866
- rtcManager.rtcStatsReconnect();
5882
+ rtcManager.rtcStatsConnect();
5867
5883
  rtcManager.setupSocketListeners();
5868
5884
  emitter.emit(EVENTS.RTC_MANAGER_CREATED, { rtcManager });
5869
5885
  this.currentManager = rtcManager;
@@ -619,6 +619,7 @@ function rtcStatsConnection(wsURL, logger = console) {
619
619
  let featureFlags;
620
620
  const connection = {
621
621
  connected: false,
622
+ attemptedConnectedAtLeastOnce: false,
622
623
  trace: (...args) => {
623
624
  args.push(Date.now());
624
625
  if (args[0] === "customEvent" && args[2].type === "roomSessionId") {
@@ -691,6 +692,7 @@ function rtcStatsConnection(wsURL, logger = console) {
691
692
  connectionAttempt += 1;
692
693
  ws === null || ws === void 0 ? void 0 : ws.close();
693
694
  connection.connected = true;
695
+ connection.attemptedConnectedAtLeastOnce = true;
694
696
  ws = new WebSocket(wsURL + window.location.pathname, RTCSTATS_PROTOCOL_VERSION);
695
697
  ws.onerror = (e) => {
696
698
  connection.connected = false;
@@ -2788,11 +2790,16 @@ class P2pRtcManager {
2788
2790
  sendStatsCustomEvent(eventName, data) {
2789
2791
  rtcStats.sendEvent(eventName, data);
2790
2792
  }
2793
+ rtcStatsConnect() {
2794
+ if (!rtcStats.server.connected) {
2795
+ rtcStats.server.connect();
2796
+ }
2797
+ }
2791
2798
  rtcStatsDisconnect() {
2792
2799
  rtcStats.server.close();
2793
2800
  }
2794
2801
  rtcStatsReconnect() {
2795
- if (!rtcStats.server.connected) {
2802
+ if (!rtcStats.server.connected && rtcStats.server.attemptedConnectedAtLeastOnce) {
2796
2803
  rtcStats.server.connect();
2797
2804
  }
2798
2805
  }
@@ -3182,6 +3189,10 @@ class P2pRtcManager {
3182
3189
  this._videoTrackBeingMonitored = track;
3183
3190
  }
3184
3191
  _connect(clientId) {
3192
+ try {
3193
+ this.rtcStatsReconnect();
3194
+ }
3195
+ catch (_) { }
3185
3196
  let session = this._getSession(clientId);
3186
3197
  let initialBandwidth = (session && session.bandwidth) || 0;
3187
3198
  if (session) {
@@ -5533,11 +5544,16 @@ class VegaRtcManager {
5533
5544
  sendStatsCustomEvent(eventName, data) {
5534
5545
  rtcStats.sendEvent(eventName, data);
5535
5546
  }
5547
+ rtcStatsConnect() {
5548
+ if (!rtcStats.server.connected) {
5549
+ rtcStats.server.connect();
5550
+ }
5551
+ }
5536
5552
  rtcStatsDisconnect() {
5537
5553
  rtcStats.server.close();
5538
5554
  }
5539
5555
  rtcStatsReconnect() {
5540
- if (!rtcStats.server.connected) {
5556
+ if (!rtcStats.server.connected && rtcStats.server.attemptedConnectedAtLeastOnce) {
5541
5557
  rtcStats.server.connect();
5542
5558
  }
5543
5559
  }
@@ -5863,7 +5879,7 @@ class RtcManagerDispatcher {
5863
5879
  else {
5864
5880
  rtcManager = new P2pRtcManager(config);
5865
5881
  }
5866
- rtcManager.rtcStatsReconnect();
5882
+ rtcManager.rtcStatsConnect();
5867
5883
  rtcManager.setupSocketListeners();
5868
5884
  emitter.emit(EVENTS.RTC_MANAGER_CREATED, { rtcManager });
5869
5885
  this.currentManager = rtcManager;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@whereby.com/media",
3
3
  "description": "Media library for Whereby",
4
- "version": "2.5.3",
4
+ "version": "2.5.4",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {