@koi-design/callkit 2.3.0-beta.1 → 2.3.0-beta.10
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 +15 -0
- package/dist/index.global.js +96 -15
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +96 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -508,7 +508,11 @@ var SocketReceiveEvent = {
|
|
|
508
508
|
ERROR: "ERROR",
|
|
509
509
|
SESSION_ERROR: "SESSION_ERROR",
|
|
510
510
|
WAITING_QUEUE: "WAITING_QUEUE",
|
|
511
|
-
CUSTOMER_MATCH_BLACK_PHONE: "CUSTOMER_MATCH_BLACK_PHONE"
|
|
511
|
+
CUSTOMER_MATCH_BLACK_PHONE: "CUSTOMER_MATCH_BLACK_PHONE",
|
|
512
|
+
/**
|
|
513
|
+
* Agent RTP loss
|
|
514
|
+
*/
|
|
515
|
+
AGENT_RTP_LOSS: "AGENT_RTP_LOSS"
|
|
512
516
|
};
|
|
513
517
|
var EncryptionMethod = {
|
|
514
518
|
NONE: "NONE",
|
|
@@ -697,7 +701,7 @@ var Call = class {
|
|
|
697
701
|
// package.json
|
|
698
702
|
var package_default = {
|
|
699
703
|
name: "@koi-design/callkit",
|
|
700
|
-
version: "2.3.0-beta.
|
|
704
|
+
version: "2.3.0-beta.10",
|
|
701
705
|
description: "callkit",
|
|
702
706
|
author: "koi",
|
|
703
707
|
license: "ISC",
|
|
@@ -15797,8 +15801,6 @@ var Connect = class {
|
|
|
15797
15801
|
});
|
|
15798
15802
|
return;
|
|
15799
15803
|
}
|
|
15800
|
-
const { userInfo } = this.callKit.config.getConfig();
|
|
15801
|
-
const { userPart, fsIp, fsPort } = userInfo;
|
|
15802
15804
|
const { registererOptions = {} } = this.reconnectConfig;
|
|
15803
15805
|
this.registerer = new Registerer(this.userAgent, registererOptions);
|
|
15804
15806
|
this.registerer.stateChange.addListener((state) => {
|
|
@@ -15832,27 +15834,26 @@ var Connect = class {
|
|
|
15832
15834
|
});
|
|
15833
15835
|
this.setRegister(true);
|
|
15834
15836
|
if (this.isReConnected) {
|
|
15835
|
-
if (this.
|
|
15836
|
-
const selfUri = `sip:manualCallAgent${userPart}@${fsIp}:${fsPort}`;
|
|
15837
|
+
if (this.canReferInCallToSelf()) {
|
|
15837
15838
|
this.callKit.logger.info(
|
|
15838
15839
|
"Reconnected, referring active session to self",
|
|
15839
15840
|
{
|
|
15840
15841
|
caller: "Connect.setupRegisterer.registererStateChange",
|
|
15841
15842
|
type: "SIP",
|
|
15842
15843
|
content: {
|
|
15843
|
-
selfUri,
|
|
15844
|
+
selfUri: this.getSelfReferUri(),
|
|
15844
15845
|
sessionState: this.currentSession.state,
|
|
15845
15846
|
connectStatus: this.connectStatus
|
|
15846
15847
|
}
|
|
15847
15848
|
}
|
|
15848
15849
|
);
|
|
15849
|
-
this.
|
|
15850
|
+
this.referInCallToSelf().catch((err) => {
|
|
15850
15851
|
this.callKit.logger.error(err, {
|
|
15851
15852
|
caller: "Connect.setupRegisterer.registererStateChange",
|
|
15852
15853
|
type: "SIP",
|
|
15853
15854
|
content: {
|
|
15854
15855
|
errCode: ErrorCode.WEBRTC_CALL_INVITE_ERROR,
|
|
15855
|
-
selfUri
|
|
15856
|
+
selfUri: this.getSelfReferUri()
|
|
15856
15857
|
}
|
|
15857
15858
|
});
|
|
15858
15859
|
});
|
|
@@ -16681,6 +16682,59 @@ var Connect = class {
|
|
|
16681
16682
|
}
|
|
16682
16683
|
this.currentSession.refer(target, extra?.sessionReferOptions);
|
|
16683
16684
|
}
|
|
16685
|
+
/**
|
|
16686
|
+
* Get the SIP URI for "refer to self" (same as reconnection refer logic).
|
|
16687
|
+
* Shared by referInCallToSelf and internal reconnection refer.
|
|
16688
|
+
*/
|
|
16689
|
+
getSelfReferUri() {
|
|
16690
|
+
const { userInfo } = this.callKit.config.getConfig();
|
|
16691
|
+
const { userPart, fsIp, fsPort } = userInfo;
|
|
16692
|
+
return `sip:manualCallAgent${userPart}@${fsIp}:${fsPort}`;
|
|
16693
|
+
}
|
|
16694
|
+
/**
|
|
16695
|
+
* Whether we can refer the current call to self (has active session in Established/Establishing and is calling).
|
|
16696
|
+
* Shared by reconnection logic and referInCallToSelf.
|
|
16697
|
+
*/
|
|
16698
|
+
canReferInCallToSelf() {
|
|
16699
|
+
return !!this.currentSession && (this.currentSession.state === SessionState2.Established || this.currentSession.state === SessionState2.Establishing) && this.isCalling();
|
|
16700
|
+
}
|
|
16701
|
+
/**
|
|
16702
|
+
* Refer the current call to self (e.g. Agent RTP loss recovery, post-reconnect recovery).
|
|
16703
|
+
* Socket and other callers can use this without constructing referTo.
|
|
16704
|
+
*/
|
|
16705
|
+
async referInCallToSelf(callUuid, extra) {
|
|
16706
|
+
if (callUuid && this.currentCallId !== callUuid) {
|
|
16707
|
+
this.callKit.logger.warn(
|
|
16708
|
+
"Cannot refer in call to self: callUuid mismatch",
|
|
16709
|
+
{
|
|
16710
|
+
caller: "Connect.referInCallToSelf",
|
|
16711
|
+
type: "SIP",
|
|
16712
|
+
content: {
|
|
16713
|
+
currentCallId: this.currentCallId,
|
|
16714
|
+
callUuid
|
|
16715
|
+
}
|
|
16716
|
+
}
|
|
16717
|
+
);
|
|
16718
|
+
return;
|
|
16719
|
+
}
|
|
16720
|
+
if (!this.canReferInCallToSelf()) {
|
|
16721
|
+
this.callKit.logger.warn(
|
|
16722
|
+
"Cannot refer in call to self: preconditions not met",
|
|
16723
|
+
{
|
|
16724
|
+
caller: "Connect.referInCallToSelf",
|
|
16725
|
+
type: "SIP",
|
|
16726
|
+
content: {
|
|
16727
|
+
hasCurrentSession: !!this.currentSession,
|
|
16728
|
+
sessionState: this.currentSession?.state,
|
|
16729
|
+
isCalling: this.isCalling()
|
|
16730
|
+
}
|
|
16731
|
+
}
|
|
16732
|
+
);
|
|
16733
|
+
return;
|
|
16734
|
+
}
|
|
16735
|
+
const selfUri = this.getSelfReferUri();
|
|
16736
|
+
return this.referInCall(selfUri, extra);
|
|
16737
|
+
}
|
|
16684
16738
|
};
|
|
16685
16739
|
|
|
16686
16740
|
// core/socket.ts
|
|
@@ -16906,6 +16960,28 @@ var Socket = class {
|
|
|
16906
16960
|
this.setConnectAuthState("startConfirm", true);
|
|
16907
16961
|
this.cleanReconnectState();
|
|
16908
16962
|
}
|
|
16963
|
+
if (data.event === SocketReceiveEvent.AGENT_RTP_LOSS) {
|
|
16964
|
+
this.callKit.logger.warn("Agent RTP loss", {
|
|
16965
|
+
caller: "Socket.onMessage",
|
|
16966
|
+
type: "INCALL",
|
|
16967
|
+
content: {
|
|
16968
|
+
data: {
|
|
16969
|
+
callUuid,
|
|
16970
|
+
...content
|
|
16971
|
+
},
|
|
16972
|
+
event: SocketReceiveEvent.AGENT_RTP_LOSS
|
|
16973
|
+
}
|
|
16974
|
+
});
|
|
16975
|
+
if (callUuid) {
|
|
16976
|
+
this.callKit.connect.referInCallToSelf(callUuid).catch((err) => {
|
|
16977
|
+
this.callKit.logger.error(err, {
|
|
16978
|
+
caller: "Socket.onMessage:AGENT_RTP_LOSS",
|
|
16979
|
+
type: "INCALL",
|
|
16980
|
+
content: { callUuid, event: SocketReceiveEvent.AGENT_RTP_LOSS }
|
|
16981
|
+
});
|
|
16982
|
+
});
|
|
16983
|
+
}
|
|
16984
|
+
}
|
|
16909
16985
|
if (data.event === SocketReceiveEvent.CUSTOMER_RINGING) {
|
|
16910
16986
|
this.callKit.trigger(KitEvent.CALL_RINGING, {
|
|
16911
16987
|
time: /* @__PURE__ */ new Date(),
|
|
@@ -17018,7 +17094,7 @@ var Socket = class {
|
|
|
17018
17094
|
return;
|
|
17019
17095
|
}
|
|
17020
17096
|
const { userInfo, version } = this.callKit.config.getConfig();
|
|
17021
|
-
const { sessionId, extno, agentId
|
|
17097
|
+
const { sessionId, extno, agentId } = userInfo;
|
|
17022
17098
|
if (!sessionId) {
|
|
17023
17099
|
this.callKit.logger.error("sessionId is empty", {
|
|
17024
17100
|
caller: "Socket.send",
|
|
@@ -17038,7 +17114,6 @@ var Socket = class {
|
|
|
17038
17114
|
if (SocketSendEvent.CALL === event) {
|
|
17039
17115
|
msg.phoneNum = extno;
|
|
17040
17116
|
msg.agentId = agentId;
|
|
17041
|
-
msg.phoneType = phoneType;
|
|
17042
17117
|
if (message?.sourceType === CallSourceType.phoneNum) {
|
|
17043
17118
|
delete msg.workOrderId;
|
|
17044
17119
|
} else if (message?.sourceType === CallSourceType.workOrderId) {
|
|
@@ -17358,7 +17433,10 @@ var CallKit = class {
|
|
|
17358
17433
|
caller: "CallKit.register",
|
|
17359
17434
|
content: {}
|
|
17360
17435
|
});
|
|
17361
|
-
this.
|
|
17436
|
+
const { userInfo } = this.config.getConfig();
|
|
17437
|
+
if (userInfo.phoneType === PhoneTypeEnum.SIP) {
|
|
17438
|
+
this.connect.register();
|
|
17439
|
+
}
|
|
17362
17440
|
}
|
|
17363
17441
|
async unregister() {
|
|
17364
17442
|
if (!this.config.check())
|
|
@@ -17468,10 +17546,13 @@ var CallKit = class {
|
|
|
17468
17546
|
force
|
|
17469
17547
|
}
|
|
17470
17548
|
});
|
|
17471
|
-
|
|
17472
|
-
|
|
17549
|
+
const { userInfo } = this.config.getConfig();
|
|
17550
|
+
if (userInfo.phoneType === PhoneTypeEnum.SIP) {
|
|
17551
|
+
if (this.connect.isCalling()) {
|
|
17552
|
+
await this.hangup();
|
|
17553
|
+
}
|
|
17554
|
+
await this.connect.reset({ force });
|
|
17473
17555
|
}
|
|
17474
|
-
await this.connect.reset({ force });
|
|
17475
17556
|
if (this.config.isLogin()) {
|
|
17476
17557
|
await this.logout({ isReset: false });
|
|
17477
17558
|
} else {
|