@koi-design/callkit 1.0.24-beta.13 → 1.0.24-beta.15
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 +4 -0
- package/dist/index.global.js +53 -6
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +53 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -140,6 +140,7 @@ declare const KitEvent: {
|
|
|
140
140
|
* User status change
|
|
141
141
|
*/
|
|
142
142
|
USER_STATUS_CHANGE: string;
|
|
143
|
+
CONNECT_EVENT: string;
|
|
143
144
|
};
|
|
144
145
|
declare const SocketSendEvent: {
|
|
145
146
|
/**
|
|
@@ -309,6 +310,8 @@ declare class Connect {
|
|
|
309
310
|
mediaStream?: MediaStream;
|
|
310
311
|
userAgent?: UserAgent;
|
|
311
312
|
registerer?: Registerer;
|
|
313
|
+
lastOptionsUpdateTime: number;
|
|
314
|
+
observeOptionsHeartbeatHandler: ReturnType<typeof setTimeout> | null;
|
|
312
315
|
sipConnected: boolean;
|
|
313
316
|
/**
|
|
314
317
|
* Whether it's an outgoing call
|
|
@@ -362,6 +365,7 @@ declare class Connect {
|
|
|
362
365
|
* @returns
|
|
363
366
|
*/
|
|
364
367
|
isInit(): boolean;
|
|
368
|
+
clearObserveOptionsHeartbeatInterval(): void;
|
|
365
369
|
register(): Promise<void>;
|
|
366
370
|
reconnect(): Promise<void>;
|
|
367
371
|
stop(): Promise<void>;
|
package/dist/index.global.js
CHANGED
|
@@ -3378,7 +3378,8 @@ var WebCall = (() => {
|
|
|
3378
3378
|
/**
|
|
3379
3379
|
* User status change
|
|
3380
3380
|
*/
|
|
3381
|
-
USER_STATUS_CHANGE: "userStatusChange"
|
|
3381
|
+
USER_STATUS_CHANGE: "userStatusChange",
|
|
3382
|
+
CONNECT_EVENT: "CONNECT_EVENT"
|
|
3382
3383
|
};
|
|
3383
3384
|
var ErrorCode = {
|
|
3384
3385
|
/**
|
|
@@ -3592,7 +3593,8 @@ var WebCall = (() => {
|
|
|
3592
3593
|
SIP_CONNECT_ERROR: "SIP_CONNECT_ERROR",
|
|
3593
3594
|
SIP_RECONNECT_ERROR: "SIP_RECONNECT_ERROR",
|
|
3594
3595
|
INCALL_CONNECT_ERROR: "INCALL_CONNECT_ERROR",
|
|
3595
|
-
INCALL_RECONNECT_ERROR: "INCALL_RECONNECT_ERROR"
|
|
3596
|
+
INCALL_RECONNECT_ERROR: "INCALL_RECONNECT_ERROR",
|
|
3597
|
+
OPTIONS_HEARTBEAT_EXPIRED: "OPTIONS_HEARTBEAT_EXPIRED"
|
|
3596
3598
|
};
|
|
3597
3599
|
|
|
3598
3600
|
// package/call.ts
|
|
@@ -18284,6 +18286,8 @@ var WebCall = (() => {
|
|
|
18284
18286
|
mediaStream;
|
|
18285
18287
|
userAgent;
|
|
18286
18288
|
registerer;
|
|
18289
|
+
lastOptionsUpdateTime = 0;
|
|
18290
|
+
observeOptionsHeartbeatHandler = null;
|
|
18287
18291
|
sipConnected = false;
|
|
18288
18292
|
/**
|
|
18289
18293
|
* Whether it's an outgoing call
|
|
@@ -18333,6 +18337,7 @@ var WebCall = (() => {
|
|
|
18333
18337
|
this.isOutgoing = false;
|
|
18334
18338
|
this.isUnprompted = false;
|
|
18335
18339
|
this.sipConnected = false;
|
|
18340
|
+
this.clearObserveOptionsHeartbeatInterval();
|
|
18336
18341
|
if (this.isHold) {
|
|
18337
18342
|
this.setHoldStatus(false);
|
|
18338
18343
|
}
|
|
@@ -18392,6 +18397,13 @@ var WebCall = (() => {
|
|
|
18392
18397
|
isInit() {
|
|
18393
18398
|
return this.connectStatus === CallStatus.init;
|
|
18394
18399
|
}
|
|
18400
|
+
clearObserveOptionsHeartbeatInterval() {
|
|
18401
|
+
if (this.observeOptionsHeartbeatHandler !== null) {
|
|
18402
|
+
clearInterval(this.observeOptionsHeartbeatHandler);
|
|
18403
|
+
this.observeOptionsHeartbeatHandler = null;
|
|
18404
|
+
}
|
|
18405
|
+
this.lastOptionsUpdateTime = 0;
|
|
18406
|
+
}
|
|
18395
18407
|
async register() {
|
|
18396
18408
|
if (this.connectStatus !== CallStatus.init) {
|
|
18397
18409
|
if (this.connectStatus === CallStatus.registered) {
|
|
@@ -18459,6 +18471,33 @@ var WebCall = (() => {
|
|
|
18459
18471
|
});
|
|
18460
18472
|
}
|
|
18461
18473
|
};
|
|
18474
|
+
const observeOptionsHeartbeat = (userAgent, extra) => {
|
|
18475
|
+
const { that = this } = extra;
|
|
18476
|
+
that.clearObserveOptionsHeartbeatInterval();
|
|
18477
|
+
setInterval(() => {
|
|
18478
|
+
if (that.lastOptionsUpdateTime !== 0) {
|
|
18479
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
18480
|
+
const diff = now - that.lastOptionsUpdateTime;
|
|
18481
|
+
if (diff > 6e4) {
|
|
18482
|
+
that.callKit.trigger(KitEvent.CONNECT_EVENT, {
|
|
18483
|
+
event: ConnectEvent.OPTIONS_HEARTBEAT_EXPIRED,
|
|
18484
|
+
lastOptionsUpdateTime: that.lastOptionsUpdateTime,
|
|
18485
|
+
now
|
|
18486
|
+
});
|
|
18487
|
+
that.clearObserveOptionsHeartbeatInterval();
|
|
18488
|
+
}
|
|
18489
|
+
}
|
|
18490
|
+
}, 6e4);
|
|
18491
|
+
that.lastOptionsUpdateTime = 0;
|
|
18492
|
+
const core = userAgent.userAgentCore;
|
|
18493
|
+
const originalReceiveRequest = core.receiveRequest.bind(core);
|
|
18494
|
+
core.receiveRequest = function(request2) {
|
|
18495
|
+
if (request2.method === "OPTIONS") {
|
|
18496
|
+
that.lastOptionsUpdateTime = (/* @__PURE__ */ new Date()).getTime();
|
|
18497
|
+
}
|
|
18498
|
+
return originalReceiveRequest(request2);
|
|
18499
|
+
};
|
|
18500
|
+
};
|
|
18462
18501
|
const registererOptions = {};
|
|
18463
18502
|
this.registerer = new Registerer(this.userAgent, registererOptions);
|
|
18464
18503
|
this.userAgent.delegate = {
|
|
@@ -18542,7 +18581,8 @@ var WebCall = (() => {
|
|
|
18542
18581
|
if (this.isRegistered() && !(this.sipConnected || this.isRinging() || this.isCalling() || this.isHolding())) {
|
|
18543
18582
|
this.reconnect();
|
|
18544
18583
|
} else {
|
|
18545
|
-
this.callKit.trigger(
|
|
18584
|
+
this.callKit.trigger(KitEvent.CONNECT_EVENT, {
|
|
18585
|
+
event: ConnectEvent.SIP_CONNECT_ERROR,
|
|
18546
18586
|
err: error
|
|
18547
18587
|
});
|
|
18548
18588
|
this.callKit.callCenter.callEnd();
|
|
@@ -18566,6 +18606,9 @@ var WebCall = (() => {
|
|
|
18566
18606
|
// });
|
|
18567
18607
|
// }
|
|
18568
18608
|
};
|
|
18609
|
+
observeOptionsHeartbeat(this.userAgent, {
|
|
18610
|
+
that: this
|
|
18611
|
+
});
|
|
18569
18612
|
await this.userAgent.start().catch((err) => {
|
|
18570
18613
|
this.callKit.callCenter.callEnd(false, true);
|
|
18571
18614
|
this.callKit.user.sendHangUpReason({
|
|
@@ -18603,7 +18646,9 @@ var WebCall = (() => {
|
|
|
18603
18646
|
if (currentRetry < this.reconnectConfig.maxAttempts) {
|
|
18604
18647
|
await scheduleReconnect();
|
|
18605
18648
|
} else {
|
|
18606
|
-
this.callKit.trigger(
|
|
18649
|
+
this.callKit.trigger(KitEvent.CONNECT_EVENT, {
|
|
18650
|
+
event: ConnectEvent.SIP_RECONNECT_ERROR
|
|
18651
|
+
});
|
|
18607
18652
|
this.callKit.logger.error("No registerer to unregister.");
|
|
18608
18653
|
}
|
|
18609
18654
|
}
|
|
@@ -18869,7 +18914,8 @@ var WebCall = (() => {
|
|
|
18869
18914
|
);
|
|
18870
18915
|
this.attemptReconnect();
|
|
18871
18916
|
} else if (this.reconnectAttempts >= this.socketConfig.maxAttempts) {
|
|
18872
|
-
this.callKit.trigger(
|
|
18917
|
+
this.callKit.trigger(KitEvent.CONNECT_EVENT, {
|
|
18918
|
+
event: ConnectEvent.INCALL_RECONNECT_ERROR,
|
|
18873
18919
|
err: ev
|
|
18874
18920
|
});
|
|
18875
18921
|
this.reset();
|
|
@@ -18901,7 +18947,8 @@ var WebCall = (() => {
|
|
|
18901
18947
|
onClose(ev) {
|
|
18902
18948
|
this.callKit.logger.debug("socket onClose", ev);
|
|
18903
18949
|
if ((ev.code !== 1e3 || !ev.wasClean) && this.callKit.connect.isRegistered()) {
|
|
18904
|
-
this.callKit.trigger(
|
|
18950
|
+
this.callKit.trigger(KitEvent.CONNECT_EVENT, {
|
|
18951
|
+
event: ConnectEvent.INCALL_CONNECT_ERROR,
|
|
18905
18952
|
err: ev
|
|
18906
18953
|
});
|
|
18907
18954
|
this.reconnect(ev);
|