@koi-design/callkit 1.0.24-beta.12 → 1.0.24-beta.13
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 +2 -4
- package/dist/index.global.js +19 -11
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +19 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -318,6 +318,7 @@ declare class Connect {
|
|
|
318
318
|
* Whether it's an active hangup
|
|
319
319
|
*/
|
|
320
320
|
isUnprompted: boolean;
|
|
321
|
+
private reconnectConfig;
|
|
321
322
|
/**
|
|
322
323
|
* Whether registered
|
|
323
324
|
* @param
|
|
@@ -362,10 +363,7 @@ declare class Connect {
|
|
|
362
363
|
*/
|
|
363
364
|
isInit(): boolean;
|
|
364
365
|
register(): Promise<void>;
|
|
365
|
-
reconnect(
|
|
366
|
-
retryInterval: number;
|
|
367
|
-
maxRetryCount: number;
|
|
368
|
-
}): Promise<void>;
|
|
366
|
+
reconnect(): Promise<void>;
|
|
369
367
|
stop(): Promise<void>;
|
|
370
368
|
unregister(): Promise<void>;
|
|
371
369
|
call(callback: Function): Promise<void>;
|
package/dist/index.global.js
CHANGED
|
@@ -18244,6 +18244,10 @@ var WebCall = (() => {
|
|
|
18244
18244
|
};
|
|
18245
18245
|
|
|
18246
18246
|
// package/connect.ts
|
|
18247
|
+
var DEFAULT_RECONNECT_CONFIG = {
|
|
18248
|
+
maxAttempts: 3,
|
|
18249
|
+
delay: 500
|
|
18250
|
+
};
|
|
18247
18251
|
function convertObjectStringToJSON(input) {
|
|
18248
18252
|
const corrected = input.replace(/(\w+):\s*'(.*?)'/g, '"$1": "$2"').replace(/'/g, '"');
|
|
18249
18253
|
return corrected;
|
|
@@ -18289,6 +18293,7 @@ var WebCall = (() => {
|
|
|
18289
18293
|
* Whether it's an active hangup
|
|
18290
18294
|
*/
|
|
18291
18295
|
isUnprompted = false;
|
|
18296
|
+
reconnectConfig;
|
|
18292
18297
|
/**
|
|
18293
18298
|
* Whether registered
|
|
18294
18299
|
* @param
|
|
@@ -18308,6 +18313,11 @@ var WebCall = (() => {
|
|
|
18308
18313
|
isMute = false;
|
|
18309
18314
|
constructor(callKit) {
|
|
18310
18315
|
this.callKit = callKit;
|
|
18316
|
+
const { reconnect = {} } = this.callKit.config.getConfig();
|
|
18317
|
+
this.reconnectConfig = {
|
|
18318
|
+
...DEFAULT_RECONNECT_CONFIG,
|
|
18319
|
+
...reconnect
|
|
18320
|
+
};
|
|
18311
18321
|
}
|
|
18312
18322
|
reset() {
|
|
18313
18323
|
if (this.connectStatus !== CallStatus.init) {
|
|
@@ -18566,15 +18576,11 @@ var WebCall = (() => {
|
|
|
18566
18576
|
});
|
|
18567
18577
|
});
|
|
18568
18578
|
}
|
|
18569
|
-
async reconnect(
|
|
18570
|
-
retryInterval: 500,
|
|
18571
|
-
maxRetryCount: 3
|
|
18572
|
-
}) {
|
|
18573
|
-
const { retryInterval, maxRetryCount } = params;
|
|
18579
|
+
async reconnect() {
|
|
18574
18580
|
let currentRetry = 0;
|
|
18575
18581
|
let reconnectTimer = null;
|
|
18576
18582
|
const scheduleReconnect = async () => {
|
|
18577
|
-
if (currentRetry >=
|
|
18583
|
+
if (currentRetry >= this.reconnectConfig.maxAttempts) {
|
|
18578
18584
|
console.error("Maximum retry attempts reached, stopping reconnection");
|
|
18579
18585
|
return;
|
|
18580
18586
|
}
|
|
@@ -18584,22 +18590,24 @@ var WebCall = (() => {
|
|
|
18584
18590
|
try {
|
|
18585
18591
|
currentRetry += 1;
|
|
18586
18592
|
console.log(
|
|
18587
|
-
`Attempting to reconnect SIP... (Attempt ${currentRetry}/${
|
|
18593
|
+
`Attempting to reconnect SIP... (Attempt ${currentRetry}/${this.reconnectConfig.maxAttempts})`
|
|
18588
18594
|
);
|
|
18589
|
-
await this.
|
|
18595
|
+
await this.unregister();
|
|
18596
|
+
await this.stop();
|
|
18597
|
+
await this.register();
|
|
18590
18598
|
console.log("Reconnection successful");
|
|
18591
18599
|
reconnectTimer = null;
|
|
18592
18600
|
} catch (err) {
|
|
18593
18601
|
console.error("Reconnection failed:", err);
|
|
18594
18602
|
reconnectTimer = null;
|
|
18595
|
-
if (currentRetry <
|
|
18603
|
+
if (currentRetry < this.reconnectConfig.maxAttempts) {
|
|
18596
18604
|
await scheduleReconnect();
|
|
18597
18605
|
} else {
|
|
18598
18606
|
this.callKit.trigger(ConnectEvent.SIP_RECONNECT_ERROR, {});
|
|
18599
18607
|
this.callKit.logger.error("No registerer to unregister.");
|
|
18600
18608
|
}
|
|
18601
18609
|
}
|
|
18602
|
-
},
|
|
18610
|
+
}, this.reconnectConfig.delay);
|
|
18603
18611
|
};
|
|
18604
18612
|
await scheduleReconnect();
|
|
18605
18613
|
}
|
|
@@ -18909,7 +18917,7 @@ var WebCall = (() => {
|
|
|
18909
18917
|
}
|
|
18910
18918
|
}
|
|
18911
18919
|
onError(ev) {
|
|
18912
|
-
this.callKit.logger.
|
|
18920
|
+
this.callKit.logger.debug("socket onError", {
|
|
18913
18921
|
errCode: ErrorCode.SOCKET_CONNECT_ERROR,
|
|
18914
18922
|
data: ev
|
|
18915
18923
|
});
|