@koi-design/callkit 1.0.24-beta.20 → 1.0.24-beta.22

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.
@@ -18980,8 +18980,16 @@ var WebCall = (() => {
18980
18980
  this.isConnected = true;
18981
18981
  this.lastPingTime = Date.now();
18982
18982
  this.checkPing();
18983
- if (this.reconnectTimer) {
18984
- clearTimeout(this.reconnectTimer);
18983
+ if (this.isReconnecting) {
18984
+ this.callKit.logger.debug(ConnectEvent.INCALL_RECONNECT_SUCCESS);
18985
+ this.callKit.trigger(KitEvent.CONNECT_EVENT, {
18986
+ event: ConnectEvent.INCALL_RECONNECT_SUCCESS
18987
+ });
18988
+ this.isReconnecting = false;
18989
+ if (this.reconnectTimer) {
18990
+ clearTimeout(this.reconnectTimer);
18991
+ this.reconnectTimer = void 0;
18992
+ }
18985
18993
  }
18986
18994
  this.reconnectAttempts = 0;
18987
18995
  }
@@ -19209,25 +19217,25 @@ var WebCall = (() => {
19209
19217
  }
19210
19218
  }
19211
19219
  attemptReconnect() {
19212
- if (this.isReconnecting) {
19220
+ if (this.isReconnecting || this.reconnectAttempts >= this.socketConfig.maxAttempts) {
19213
19221
  return;
19214
19222
  }
19215
19223
  this.isReconnecting = true;
19216
- const delay = this.socketConfig.delay * this.socketConfig.backoffMultiplier ** this.reconnectAttempts;
19224
+ this.reconnectAttempts += 1;
19225
+ const { delay } = this.socketConfig;
19217
19226
  this.callKit.logger.debug(
19218
- `Preparing reconnection attempt ${this.reconnectAttempts + 1}, delay: ${delay}ms`
19227
+ `Preparing reconnection attempt ${this.reconnectAttempts}/${this.socketConfig.maxAttempts}, delay: ${delay}ms`
19219
19228
  );
19220
19229
  this.reconnectTimer = setTimeout(() => {
19221
- try {
19222
- const { socket } = this.callKit.config.getConfig();
19223
- this.connect(socket);
19230
+ const { socket } = this.callKit.config.getConfig();
19231
+ this.connect(socket);
19232
+ this.callKit.logger.debug("Reconnection attempt failed");
19233
+ if (this.reconnectAttempts >= this.socketConfig.maxAttempts) {
19224
19234
  this.callKit.trigger(KitEvent.CONNECT_EVENT, {
19225
- event: ConnectEvent.INCALL_RECONNECT_SUCCESS
19235
+ event: ConnectEvent.INCALL_RECONNECT_ERROR
19226
19236
  });
19227
- this.reconnectAttempts += 1;
19228
19237
  this.isReconnecting = false;
19229
- } catch (err) {
19230
- this.callKit.logger.error(err);
19238
+ this.reset();
19231
19239
  }
19232
19240
  }, delay);
19233
19241
  }