@stream-io/video-client 0.0.1-alpha.83 → 0.0.1-alpha.84

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.
@@ -5887,6 +5887,7 @@ class Call {
5887
5887
  this.dispatcher = new Dispatcher();
5888
5888
  this.trackSubscriptionsSubject = new Subject();
5889
5889
  this.reconnectAttempts = 0;
5890
+ this.maxReconnectAttempts = 10;
5890
5891
  /**
5891
5892
  * Remove subscription for WebSocket events that were created by the `on` method.
5892
5893
  * @param eventName
@@ -6004,12 +6005,15 @@ class Call {
6004
6005
  // do nothing if the connection was closed on purpose
6005
6006
  if (e.code === 1000)
6006
6007
  return;
6007
- if (this.reconnectAttempts >= 10) {
6008
- console.log('Reconnect attempts exceeded. Giving up...');
6009
- this.state.setCurrentValue(this.state.callingStateSubject, CallingState.RECONNECTING_FAILED);
6008
+ if (this.reconnectAttempts < this.maxReconnectAttempts) {
6009
+ rejoin().catch(() => {
6010
+ console.log(`Rejoin failed for ${this.reconnectAttempts} times. Giving up.`);
6011
+ this.state.setCurrentValue(this.state.callingStateSubject, CallingState.RECONNECTING_FAILED);
6012
+ });
6010
6013
  }
6011
6014
  else {
6012
- void rejoin();
6015
+ console.log('Reconnect attempts exceeded. Giving up...');
6016
+ this.state.setCurrentValue(this.state.callingStateSubject, CallingState.RECONNECTING_FAILED);
6013
6017
  }
6014
6018
  });
6015
6019
  });
@@ -6026,7 +6030,10 @@ class Call {
6026
6030
  if (this.state.getCurrentValue(this.state.callingState$) ===
6027
6031
  CallingState.OFFLINE) {
6028
6032
  console.log('Join: Going online...');
6029
- rejoin();
6033
+ rejoin().catch(() => {
6034
+ console.log(`Rejoin failed for ${this.reconnectAttempts} times. Giving up.`);
6035
+ this.state.setCurrentValue(this.state.callingStateSubject, CallingState.RECONNECTING_FAILED);
6036
+ });
6030
6037
  }
6031
6038
  };
6032
6039
  window.addEventListener('offline', handleOnOffline);
@@ -6088,7 +6095,7 @@ class Call {
6088
6095
  }
6089
6096
  catch (err) {
6090
6097
  // join failed, try to rejoin
6091
- if (this.reconnectAttempts < 10) {
6098
+ if (this.reconnectAttempts < this.maxReconnectAttempts) {
6092
6099
  yield rejoin();
6093
6100
  console.log(`Rejoin ${this.reconnectAttempts} successful!`);
6094
6101
  }
@@ -8728,7 +8735,7 @@ class StreamClient {
8728
8735
  }
8729
8736
  getUserAgent() {
8730
8737
  return (this.userAgent ||
8731
- `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.1-alpha.82"}`);
8738
+ `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.1-alpha.83"}`);
8732
8739
  }
8733
8740
  setUserAgent(userAgent) {
8734
8741
  this.userAgent = userAgent;