@koi-design/callkit 2.3.1-beta.2 → 2.3.2-beta.1
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 +0 -8
- package/dist/index.global.js +9 -126
- package/dist/index.js +9 -126
- package/dist/index.mjs +9 -126
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -4800,8 +4800,6 @@ interface SipConfig {
|
|
|
4800
4800
|
maxAttempts: number;
|
|
4801
4801
|
delay: number;
|
|
4802
4802
|
registererOptions: RegistererOptions;
|
|
4803
|
-
enableMessageKeepalive: boolean;
|
|
4804
|
-
messageKeepaliveInterval: number;
|
|
4805
4803
|
}
|
|
4806
4804
|
declare class Socket {
|
|
4807
4805
|
private callKit;
|
|
@@ -4913,8 +4911,6 @@ interface IConfig {
|
|
|
4913
4911
|
encryptionMethod: EncryptionMethodType;
|
|
4914
4912
|
logGather: boolean;
|
|
4915
4913
|
keepaliveInterval?: number;
|
|
4916
|
-
enableMessageKeepalive?: boolean;
|
|
4917
|
-
messageKeepaliveInterval?: number;
|
|
4918
4914
|
/** Ping timeout reconnection max attempts */
|
|
4919
4915
|
pingTryCount?: number;
|
|
4920
4916
|
/** Ping timeout reconnection interval (seconds) */
|
|
@@ -5278,11 +5274,7 @@ declare class Connect {
|
|
|
5278
5274
|
register(): Promise<void>;
|
|
5279
5275
|
private reconnectTimer?;
|
|
5280
5276
|
private reconnectAttempts;
|
|
5281
|
-
private messageKeepaliveTimer?;
|
|
5282
5277
|
private startReconnectTimer;
|
|
5283
|
-
private stopMessageKeepalive;
|
|
5284
|
-
private startMessageKeepalive;
|
|
5285
|
-
private sendKeepaliveMessage;
|
|
5286
5278
|
stop(): Promise<void>;
|
|
5287
5279
|
unregister(): Promise<void>;
|
|
5288
5280
|
call(callback: (userInfo: IConfig['userInfo']) => void): Promise<void>;
|
package/dist/index.global.js
CHANGED
|
@@ -3749,9 +3749,7 @@ var WebCall = (() => {
|
|
|
3749
3749
|
delay: 1e3,
|
|
3750
3750
|
registererOptions: {
|
|
3751
3751
|
refreshFrequency: 90
|
|
3752
|
-
}
|
|
3753
|
-
enableMessageKeepalive: true,
|
|
3754
|
-
messageKeepaliveInterval: 30
|
|
3752
|
+
}
|
|
3755
3753
|
};
|
|
3756
3754
|
|
|
3757
3755
|
// core/call.ts
|
|
@@ -3895,13 +3893,13 @@ var WebCall = (() => {
|
|
|
3895
3893
|
// package.json
|
|
3896
3894
|
var package_default = {
|
|
3897
3895
|
name: "@koi-design/callkit",
|
|
3898
|
-
version: "2.3.
|
|
3896
|
+
version: "2.3.2-beta.1",
|
|
3899
3897
|
description: "callkit",
|
|
3900
3898
|
author: "koi",
|
|
3901
3899
|
license: "ISC",
|
|
3902
3900
|
scripts: {
|
|
3903
3901
|
build: "tsup",
|
|
3904
|
-
start: "vite --host 0.0.0.0",
|
|
3902
|
+
start: "pnpm build && vite --host 0.0.0.0",
|
|
3905
3903
|
dev: "tsup --watch",
|
|
3906
3904
|
lint: "eslint -c ../../.eslintrc.js --ext .jsx,.js,.tsx,.ts ./package --fix",
|
|
3907
3905
|
release: "tsup && node scripts/pkg.js"
|
|
@@ -18736,15 +18734,7 @@ ${log}` : log;
|
|
|
18736
18734
|
this.callKit = callKit;
|
|
18737
18735
|
}
|
|
18738
18736
|
get reconnectConfig() {
|
|
18739
|
-
|
|
18740
|
-
const { enableMessageKeepalive } = userInfo;
|
|
18741
|
-
const { messageKeepaliveInterval } = userInfo;
|
|
18742
|
-
const defaultConfig = this.callKit.config.getReconnectConfig("sip");
|
|
18743
|
-
if (enableMessageKeepalive) {
|
|
18744
|
-
defaultConfig.enableMessageKeepalive = enableMessageKeepalive;
|
|
18745
|
-
defaultConfig.messageKeepaliveInterval = messageKeepaliveInterval;
|
|
18746
|
-
}
|
|
18747
|
-
return defaultConfig;
|
|
18737
|
+
return this.callKit.config.getReconnectConfig("sip");
|
|
18748
18738
|
}
|
|
18749
18739
|
// current call id for invite data
|
|
18750
18740
|
currentCallId = null;
|
|
@@ -18868,7 +18858,6 @@ ${log}` : log;
|
|
|
18868
18858
|
}
|
|
18869
18859
|
}
|
|
18870
18860
|
this.setConnectStatus(CallStatus.init);
|
|
18871
|
-
this.stopMessageKeepalive();
|
|
18872
18861
|
}
|
|
18873
18862
|
getAduioReference() {
|
|
18874
18863
|
const { audioRef } = this.callKit.config.getConfig();
|
|
@@ -19021,7 +19010,6 @@ ${log}` : log;
|
|
|
19021
19010
|
if (!this.isInCallRefering()) {
|
|
19022
19011
|
this.setConnectStatus(CallStatus.init);
|
|
19023
19012
|
}
|
|
19024
|
-
this.stopMessageKeepalive();
|
|
19025
19013
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
19026
19014
|
registererState: state,
|
|
19027
19015
|
isRegistered: this.isRegistered()
|
|
@@ -19078,7 +19066,6 @@ ${log}` : log;
|
|
|
19078
19066
|
}
|
|
19079
19067
|
this.setIsReConnected(false);
|
|
19080
19068
|
}
|
|
19081
|
-
this.startMessageKeepalive();
|
|
19082
19069
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
19083
19070
|
registererState: state,
|
|
19084
19071
|
isRegistered: this.isRegistered()
|
|
@@ -19098,7 +19085,6 @@ ${log}` : log;
|
|
|
19098
19085
|
if (!this.isInCallRefering()) {
|
|
19099
19086
|
this.setConnectStatus(CallStatus.init);
|
|
19100
19087
|
}
|
|
19101
|
-
this.stopMessageKeepalive();
|
|
19102
19088
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
19103
19089
|
registererState: state,
|
|
19104
19090
|
isRegistered: this.isRegistered(),
|
|
@@ -19119,7 +19105,6 @@ ${log}` : log;
|
|
|
19119
19105
|
if (!this.isInCallRefering()) {
|
|
19120
19106
|
this.setConnectStatus(CallStatus.init);
|
|
19121
19107
|
}
|
|
19122
|
-
this.stopMessageKeepalive();
|
|
19123
19108
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
19124
19109
|
registererState: state,
|
|
19125
19110
|
isRegistered: this.isRegistered(),
|
|
@@ -19166,7 +19151,7 @@ ${log}` : log;
|
|
|
19166
19151
|
this.mediaStream = await navigator.mediaDevices.getUserMedia(constrains);
|
|
19167
19152
|
return this.mediaStream;
|
|
19168
19153
|
};
|
|
19169
|
-
const { userPart, fsIp, fsPort,
|
|
19154
|
+
const { userPart, fsIp, fsPort, iceInfo, wsUrl } = userInfo;
|
|
19170
19155
|
const connectConfig = {
|
|
19171
19156
|
uri: UserAgent.makeURI(`sip:${userPart}@${fsIp}:${fsPort}`),
|
|
19172
19157
|
displayName: userPart,
|
|
@@ -19175,8 +19160,6 @@ ${log}` : log;
|
|
|
19175
19160
|
traceSip: true
|
|
19176
19161
|
},
|
|
19177
19162
|
logLevel: "error",
|
|
19178
|
-
authorizationUsername: userPart,
|
|
19179
|
-
authorizationPassword: fsPassword,
|
|
19180
19163
|
allowLegacyNotifications: true,
|
|
19181
19164
|
contactName: userPart,
|
|
19182
19165
|
contactParams: { transport: "wss" },
|
|
@@ -19432,10 +19415,7 @@ ${log}` : log;
|
|
|
19432
19415
|
}
|
|
19433
19416
|
});
|
|
19434
19417
|
this.setupRegisterer();
|
|
19435
|
-
|
|
19436
|
-
await this.registerer.register();
|
|
19437
|
-
this.startMessageKeepalive();
|
|
19438
|
-
} catch (err) {
|
|
19418
|
+
await this.registerer.register().catch(async (err) => {
|
|
19439
19419
|
this.callKit.reset();
|
|
19440
19420
|
this.callKit.logger.error(err?.message, {
|
|
19441
19421
|
caller: "Connect.register",
|
|
@@ -19444,10 +19424,9 @@ ${log}` : log;
|
|
|
19444
19424
|
errCode: ErrorCode.WEBRTC_REGISTER_ERROR
|
|
19445
19425
|
}
|
|
19446
19426
|
});
|
|
19447
|
-
}
|
|
19427
|
+
});
|
|
19448
19428
|
},
|
|
19449
19429
|
onDisconnect: (error) => {
|
|
19450
|
-
this.stopMessageKeepalive();
|
|
19451
19430
|
if (error) {
|
|
19452
19431
|
this.callKit.logger.warn("SIP User Agent Disconnected with error", {
|
|
19453
19432
|
caller: "Connect.register",
|
|
@@ -19483,7 +19462,6 @@ ${log}` : log;
|
|
|
19483
19462
|
}
|
|
19484
19463
|
reconnectTimer;
|
|
19485
19464
|
reconnectAttempts = 0;
|
|
19486
|
-
messageKeepaliveTimer;
|
|
19487
19465
|
startReconnectTimer() {
|
|
19488
19466
|
if (this._isError || this.isReConnected)
|
|
19489
19467
|
return;
|
|
@@ -19537,53 +19515,8 @@ ${log}` : log;
|
|
|
19537
19515
|
}
|
|
19538
19516
|
}, this.reconnectConfig.delay);
|
|
19539
19517
|
}
|
|
19540
|
-
stopMessageKeepalive() {
|
|
19541
|
-
if (this.messageKeepaliveTimer) {
|
|
19542
|
-
clearInterval(this.messageKeepaliveTimer);
|
|
19543
|
-
this.messageKeepaliveTimer = void 0;
|
|
19544
|
-
}
|
|
19545
|
-
}
|
|
19546
|
-
startMessageKeepalive() {
|
|
19547
|
-
const { enableMessageKeepalive, messageKeepaliveInterval } = this.reconnectConfig;
|
|
19548
|
-
if (!enableMessageKeepalive)
|
|
19549
|
-
return;
|
|
19550
|
-
this.stopMessageKeepalive();
|
|
19551
|
-
this.messageKeepaliveTimer = setInterval(() => {
|
|
19552
|
-
this.sendKeepaliveMessage();
|
|
19553
|
-
}, messageKeepaliveInterval * 1e3);
|
|
19554
|
-
}
|
|
19555
|
-
async sendKeepaliveMessage() {
|
|
19556
|
-
try {
|
|
19557
|
-
if (!this.isRegistered() || !this.userAgent)
|
|
19558
|
-
return;
|
|
19559
|
-
const { userInfo } = this.callKit.config.getConfig();
|
|
19560
|
-
const { userPart, fsIp, fsPort } = userInfo || {};
|
|
19561
|
-
const target = UserAgent.makeURI(`sip:${userPart}@${fsIp}:${fsPort}`);
|
|
19562
|
-
if (!target)
|
|
19563
|
-
return;
|
|
19564
|
-
const messager = new Messager(this.userAgent, target, "");
|
|
19565
|
-
await messager.message();
|
|
19566
|
-
this.callKit.logger.info("MESSAGE keepalive ok", {
|
|
19567
|
-
caller: "Connect.sendKeepaliveMessage",
|
|
19568
|
-
type: "SIP",
|
|
19569
|
-
content: {}
|
|
19570
|
-
});
|
|
19571
|
-
} catch (err) {
|
|
19572
|
-
this.callKit.logger.error(err, {
|
|
19573
|
-
caller: "Connect.sendKeepaliveMessage",
|
|
19574
|
-
type: "SIP",
|
|
19575
|
-
content: {}
|
|
19576
|
-
});
|
|
19577
|
-
this.stopMessageKeepalive();
|
|
19578
|
-
this.callKit.trigger(KitEvent.SIP_CONNECT_EVENT, {
|
|
19579
|
-
event: "MESSAGE_KEEPALIVE_FAILED"
|
|
19580
|
-
});
|
|
19581
|
-
this.startReconnectTimer();
|
|
19582
|
-
}
|
|
19583
|
-
}
|
|
19584
19518
|
async stop() {
|
|
19585
19519
|
await this.userAgent.stop();
|
|
19586
|
-
this.stopMessageKeepalive();
|
|
19587
19520
|
}
|
|
19588
19521
|
async unregister() {
|
|
19589
19522
|
this.callKit.logger.info("connect unregister", {
|
|
@@ -19593,7 +19526,6 @@ ${log}` : log;
|
|
|
19593
19526
|
isRegistered: this.isRegistered()
|
|
19594
19527
|
}
|
|
19595
19528
|
});
|
|
19596
|
-
this.stopMessageKeepalive();
|
|
19597
19529
|
if (!this.isRegistered() || !this.registerer) {
|
|
19598
19530
|
this.callKit.logger.warn("No registerer to unregister.", {
|
|
19599
19531
|
caller: "Connect.unregister",
|
|
@@ -20225,17 +20157,7 @@ self.onmessage = function(e) {
|
|
|
20225
20157
|
this.setConnectAuthState("isConnected", false);
|
|
20226
20158
|
const { enabled } = this.reconnectConfig;
|
|
20227
20159
|
if (!this.callKit.config.isLogin() || !enabled) {
|
|
20228
|
-
|
|
20229
|
-
this.callKit.logger.warn("Disconnect during call, delay reset", {
|
|
20230
|
-
caller: "Socket.handleDisconnect",
|
|
20231
|
-
type: "INCALL",
|
|
20232
|
-
content: {
|
|
20233
|
-
connectStatus: this.callKit.connect.connectStatus
|
|
20234
|
-
}
|
|
20235
|
-
});
|
|
20236
|
-
} else {
|
|
20237
|
-
this.callKit.reset();
|
|
20238
|
-
}
|
|
20160
|
+
this.callKit.reset();
|
|
20239
20161
|
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
20240
20162
|
event: "INCALL_NOT_CONNECTED"
|
|
20241
20163
|
});
|
|
@@ -20463,18 +20385,6 @@ self.onmessage = function(e) {
|
|
|
20463
20385
|
this.send(SocketSendEvent.END, { agentId: userInfo.agentId, callUuid });
|
|
20464
20386
|
}
|
|
20465
20387
|
if (data.event === SocketReceiveEvent.ERROR) {
|
|
20466
|
-
if (this.callKit.connect.isCalling()) {
|
|
20467
|
-
this.callKit.logger.warn("socket onMessage error during call, ignore", {
|
|
20468
|
-
caller: "Socket.onMessage",
|
|
20469
|
-
type: "INCALL",
|
|
20470
|
-
content: {
|
|
20471
|
-
errCode: ErrorCode.SOCKET_CONNECT_ERROR,
|
|
20472
|
-
isCalling: this.callKit.connect.isCalling(),
|
|
20473
|
-
data: content
|
|
20474
|
-
}
|
|
20475
|
-
});
|
|
20476
|
-
return;
|
|
20477
|
-
}
|
|
20478
20388
|
this.setConnectAuthState("isError", true);
|
|
20479
20389
|
this.callKit.reset();
|
|
20480
20390
|
this.callKit.logger.error(data.msg, {
|
|
@@ -20490,9 +20400,7 @@ self.onmessage = function(e) {
|
|
|
20490
20400
|
}
|
|
20491
20401
|
if (data.event === SocketReceiveEvent.SESSION_ERROR) {
|
|
20492
20402
|
this.setConnectAuthState("isError", true);
|
|
20493
|
-
|
|
20494
|
-
this.callKit.reset();
|
|
20495
|
-
}
|
|
20403
|
+
this.callKit.reset();
|
|
20496
20404
|
this.callKit.logger.error(data.msg, {
|
|
20497
20405
|
caller: `Socket.onMessage:${data.event}`,
|
|
20498
20406
|
type: "INCALL",
|
|
@@ -20532,18 +20440,6 @@ self.onmessage = function(e) {
|
|
|
20532
20440
|
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
20533
20441
|
event: "INCALL_NOT_CONNECTED"
|
|
20534
20442
|
});
|
|
20535
|
-
if (this.callKit.connect.isCalling()) {
|
|
20536
|
-
this.callKit.logger.warn("socket send during call, ignore", {
|
|
20537
|
-
caller: "Socket.onMessage",
|
|
20538
|
-
type: "INCALL",
|
|
20539
|
-
content: {
|
|
20540
|
-
errCode: ErrorCode.SOCKET_CONNECT_ERROR,
|
|
20541
|
-
isCalling: this.callKit.connect.isCalling(),
|
|
20542
|
-
data: message
|
|
20543
|
-
}
|
|
20544
|
-
});
|
|
20545
|
-
return;
|
|
20546
|
-
}
|
|
20547
20443
|
this.callKit.reset();
|
|
20548
20444
|
this.callKit.logger.error("socket not connected", {
|
|
20549
20445
|
caller: "Socket.send",
|
|
@@ -20674,18 +20570,6 @@ self.onmessage = function(e) {
|
|
|
20674
20570
|
}
|
|
20675
20571
|
const { maxAttempts } = this.reconnectConfig;
|
|
20676
20572
|
if (this.reconnectAttempts >= maxAttempts) {
|
|
20677
|
-
if (this.callKit.connect.isCalling()) {
|
|
20678
|
-
this.callKit.logger.warn("reconnect during call, ignore", {
|
|
20679
|
-
caller: "Socket.attemptReconnect",
|
|
20680
|
-
type: "INCALL",
|
|
20681
|
-
content: {
|
|
20682
|
-
errCode: ErrorCode.SOCKET_RECONNECT_FAILED,
|
|
20683
|
-
isCalling: this.callKit.connect.isCalling(),
|
|
20684
|
-
reconnectAttempts: this.reconnectAttempts
|
|
20685
|
-
}
|
|
20686
|
-
});
|
|
20687
|
-
return;
|
|
20688
|
-
}
|
|
20689
20573
|
if (this.isUserSetPingTryCount) {
|
|
20690
20574
|
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
20691
20575
|
event: "INCALL_PING_TIMEOUT_RECONNECT_FAILED_MAX_ATTEMPTS"
|
|
@@ -20833,7 +20717,6 @@ self.onmessage = function(e) {
|
|
|
20833
20717
|
});
|
|
20834
20718
|
if (user) {
|
|
20835
20719
|
this.config.setConfig("userInfo", {
|
|
20836
|
-
...user,
|
|
20837
20720
|
wsUrl: `wss://${user.wsUrl}`,
|
|
20838
20721
|
sessionId: user.sessionId,
|
|
20839
20722
|
username,
|
package/dist/index.js
CHANGED
|
@@ -584,9 +584,7 @@ var SIP_RECONNECT_CONFIG = {
|
|
|
584
584
|
delay: 1e3,
|
|
585
585
|
registererOptions: {
|
|
586
586
|
refreshFrequency: 90
|
|
587
|
-
}
|
|
588
|
-
enableMessageKeepalive: true,
|
|
589
|
-
messageKeepaliveInterval: 30
|
|
587
|
+
}
|
|
590
588
|
};
|
|
591
589
|
|
|
592
590
|
// core/call.ts
|
|
@@ -730,13 +728,13 @@ var Call = class {
|
|
|
730
728
|
// package.json
|
|
731
729
|
var package_default = {
|
|
732
730
|
name: "@koi-design/callkit",
|
|
733
|
-
version: "2.3.
|
|
731
|
+
version: "2.3.2-beta.1",
|
|
734
732
|
description: "callkit",
|
|
735
733
|
author: "koi",
|
|
736
734
|
license: "ISC",
|
|
737
735
|
scripts: {
|
|
738
736
|
build: "tsup",
|
|
739
|
-
start: "vite --host 0.0.0.0",
|
|
737
|
+
start: "pnpm build && vite --host 0.0.0.0",
|
|
740
738
|
dev: "tsup --watch",
|
|
741
739
|
lint: "eslint -c ../../.eslintrc.js --ext .jsx,.js,.tsx,.ts ./package --fix",
|
|
742
740
|
release: "tsup && node scripts/pkg.js"
|
|
@@ -15571,15 +15569,7 @@ var Connect = class {
|
|
|
15571
15569
|
this.callKit = callKit;
|
|
15572
15570
|
}
|
|
15573
15571
|
get reconnectConfig() {
|
|
15574
|
-
|
|
15575
|
-
const { enableMessageKeepalive } = userInfo;
|
|
15576
|
-
const { messageKeepaliveInterval } = userInfo;
|
|
15577
|
-
const defaultConfig = this.callKit.config.getReconnectConfig("sip");
|
|
15578
|
-
if (enableMessageKeepalive) {
|
|
15579
|
-
defaultConfig.enableMessageKeepalive = enableMessageKeepalive;
|
|
15580
|
-
defaultConfig.messageKeepaliveInterval = messageKeepaliveInterval;
|
|
15581
|
-
}
|
|
15582
|
-
return defaultConfig;
|
|
15572
|
+
return this.callKit.config.getReconnectConfig("sip");
|
|
15583
15573
|
}
|
|
15584
15574
|
// current call id for invite data
|
|
15585
15575
|
currentCallId = null;
|
|
@@ -15703,7 +15693,6 @@ var Connect = class {
|
|
|
15703
15693
|
}
|
|
15704
15694
|
}
|
|
15705
15695
|
this.setConnectStatus(CallStatus.init);
|
|
15706
|
-
this.stopMessageKeepalive();
|
|
15707
15696
|
}
|
|
15708
15697
|
getAduioReference() {
|
|
15709
15698
|
const { audioRef } = this.callKit.config.getConfig();
|
|
@@ -15856,7 +15845,6 @@ var Connect = class {
|
|
|
15856
15845
|
if (!this.isInCallRefering()) {
|
|
15857
15846
|
this.setConnectStatus(CallStatus.init);
|
|
15858
15847
|
}
|
|
15859
|
-
this.stopMessageKeepalive();
|
|
15860
15848
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15861
15849
|
registererState: state,
|
|
15862
15850
|
isRegistered: this.isRegistered()
|
|
@@ -15913,7 +15901,6 @@ var Connect = class {
|
|
|
15913
15901
|
}
|
|
15914
15902
|
this.setIsReConnected(false);
|
|
15915
15903
|
}
|
|
15916
|
-
this.startMessageKeepalive();
|
|
15917
15904
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15918
15905
|
registererState: state,
|
|
15919
15906
|
isRegistered: this.isRegistered()
|
|
@@ -15933,7 +15920,6 @@ var Connect = class {
|
|
|
15933
15920
|
if (!this.isInCallRefering()) {
|
|
15934
15921
|
this.setConnectStatus(CallStatus.init);
|
|
15935
15922
|
}
|
|
15936
|
-
this.stopMessageKeepalive();
|
|
15937
15923
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15938
15924
|
registererState: state,
|
|
15939
15925
|
isRegistered: this.isRegistered(),
|
|
@@ -15954,7 +15940,6 @@ var Connect = class {
|
|
|
15954
15940
|
if (!this.isInCallRefering()) {
|
|
15955
15941
|
this.setConnectStatus(CallStatus.init);
|
|
15956
15942
|
}
|
|
15957
|
-
this.stopMessageKeepalive();
|
|
15958
15943
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15959
15944
|
registererState: state,
|
|
15960
15945
|
isRegistered: this.isRegistered(),
|
|
@@ -16001,7 +15986,7 @@ var Connect = class {
|
|
|
16001
15986
|
this.mediaStream = await navigator.mediaDevices.getUserMedia(constrains);
|
|
16002
15987
|
return this.mediaStream;
|
|
16003
15988
|
};
|
|
16004
|
-
const { userPart, fsIp, fsPort,
|
|
15989
|
+
const { userPart, fsIp, fsPort, iceInfo, wsUrl } = userInfo;
|
|
16005
15990
|
const connectConfig = {
|
|
16006
15991
|
uri: UserAgent.makeURI(`sip:${userPart}@${fsIp}:${fsPort}`),
|
|
16007
15992
|
displayName: userPart,
|
|
@@ -16010,8 +15995,6 @@ var Connect = class {
|
|
|
16010
15995
|
traceSip: true
|
|
16011
15996
|
},
|
|
16012
15997
|
logLevel: "error",
|
|
16013
|
-
authorizationUsername: userPart,
|
|
16014
|
-
authorizationPassword: fsPassword,
|
|
16015
15998
|
allowLegacyNotifications: true,
|
|
16016
15999
|
contactName: userPart,
|
|
16017
16000
|
contactParams: { transport: "wss" },
|
|
@@ -16267,10 +16250,7 @@ var Connect = class {
|
|
|
16267
16250
|
}
|
|
16268
16251
|
});
|
|
16269
16252
|
this.setupRegisterer();
|
|
16270
|
-
|
|
16271
|
-
await this.registerer.register();
|
|
16272
|
-
this.startMessageKeepalive();
|
|
16273
|
-
} catch (err) {
|
|
16253
|
+
await this.registerer.register().catch(async (err) => {
|
|
16274
16254
|
this.callKit.reset();
|
|
16275
16255
|
this.callKit.logger.error(err?.message, {
|
|
16276
16256
|
caller: "Connect.register",
|
|
@@ -16279,10 +16259,9 @@ var Connect = class {
|
|
|
16279
16259
|
errCode: ErrorCode.WEBRTC_REGISTER_ERROR
|
|
16280
16260
|
}
|
|
16281
16261
|
});
|
|
16282
|
-
}
|
|
16262
|
+
});
|
|
16283
16263
|
},
|
|
16284
16264
|
onDisconnect: (error) => {
|
|
16285
|
-
this.stopMessageKeepalive();
|
|
16286
16265
|
if (error) {
|
|
16287
16266
|
this.callKit.logger.warn("SIP User Agent Disconnected with error", {
|
|
16288
16267
|
caller: "Connect.register",
|
|
@@ -16318,7 +16297,6 @@ var Connect = class {
|
|
|
16318
16297
|
}
|
|
16319
16298
|
reconnectTimer;
|
|
16320
16299
|
reconnectAttempts = 0;
|
|
16321
|
-
messageKeepaliveTimer;
|
|
16322
16300
|
startReconnectTimer() {
|
|
16323
16301
|
if (this._isError || this.isReConnected)
|
|
16324
16302
|
return;
|
|
@@ -16372,53 +16350,8 @@ var Connect = class {
|
|
|
16372
16350
|
}
|
|
16373
16351
|
}, this.reconnectConfig.delay);
|
|
16374
16352
|
}
|
|
16375
|
-
stopMessageKeepalive() {
|
|
16376
|
-
if (this.messageKeepaliveTimer) {
|
|
16377
|
-
clearInterval(this.messageKeepaliveTimer);
|
|
16378
|
-
this.messageKeepaliveTimer = void 0;
|
|
16379
|
-
}
|
|
16380
|
-
}
|
|
16381
|
-
startMessageKeepalive() {
|
|
16382
|
-
const { enableMessageKeepalive, messageKeepaliveInterval } = this.reconnectConfig;
|
|
16383
|
-
if (!enableMessageKeepalive)
|
|
16384
|
-
return;
|
|
16385
|
-
this.stopMessageKeepalive();
|
|
16386
|
-
this.messageKeepaliveTimer = setInterval(() => {
|
|
16387
|
-
this.sendKeepaliveMessage();
|
|
16388
|
-
}, messageKeepaliveInterval * 1e3);
|
|
16389
|
-
}
|
|
16390
|
-
async sendKeepaliveMessage() {
|
|
16391
|
-
try {
|
|
16392
|
-
if (!this.isRegistered() || !this.userAgent)
|
|
16393
|
-
return;
|
|
16394
|
-
const { userInfo } = this.callKit.config.getConfig();
|
|
16395
|
-
const { userPart, fsIp, fsPort } = userInfo || {};
|
|
16396
|
-
const target = UserAgent.makeURI(`sip:${userPart}@${fsIp}:${fsPort}`);
|
|
16397
|
-
if (!target)
|
|
16398
|
-
return;
|
|
16399
|
-
const messager = new Messager(this.userAgent, target, "");
|
|
16400
|
-
await messager.message();
|
|
16401
|
-
this.callKit.logger.info("MESSAGE keepalive ok", {
|
|
16402
|
-
caller: "Connect.sendKeepaliveMessage",
|
|
16403
|
-
type: "SIP",
|
|
16404
|
-
content: {}
|
|
16405
|
-
});
|
|
16406
|
-
} catch (err) {
|
|
16407
|
-
this.callKit.logger.error(err, {
|
|
16408
|
-
caller: "Connect.sendKeepaliveMessage",
|
|
16409
|
-
type: "SIP",
|
|
16410
|
-
content: {}
|
|
16411
|
-
});
|
|
16412
|
-
this.stopMessageKeepalive();
|
|
16413
|
-
this.callKit.trigger(KitEvent.SIP_CONNECT_EVENT, {
|
|
16414
|
-
event: "MESSAGE_KEEPALIVE_FAILED"
|
|
16415
|
-
});
|
|
16416
|
-
this.startReconnectTimer();
|
|
16417
|
-
}
|
|
16418
|
-
}
|
|
16419
16353
|
async stop() {
|
|
16420
16354
|
await this.userAgent.stop();
|
|
16421
|
-
this.stopMessageKeepalive();
|
|
16422
16355
|
}
|
|
16423
16356
|
async unregister() {
|
|
16424
16357
|
this.callKit.logger.info("connect unregister", {
|
|
@@ -16428,7 +16361,6 @@ var Connect = class {
|
|
|
16428
16361
|
isRegistered: this.isRegistered()
|
|
16429
16362
|
}
|
|
16430
16363
|
});
|
|
16431
|
-
this.stopMessageKeepalive();
|
|
16432
16364
|
if (!this.isRegistered() || !this.registerer) {
|
|
16433
16365
|
this.callKit.logger.warn("No registerer to unregister.", {
|
|
16434
16366
|
caller: "Connect.unregister",
|
|
@@ -17060,17 +16992,7 @@ var Socket = class {
|
|
|
17060
16992
|
this.setConnectAuthState("isConnected", false);
|
|
17061
16993
|
const { enabled } = this.reconnectConfig;
|
|
17062
16994
|
if (!this.callKit.config.isLogin() || !enabled) {
|
|
17063
|
-
|
|
17064
|
-
this.callKit.logger.warn("Disconnect during call, delay reset", {
|
|
17065
|
-
caller: "Socket.handleDisconnect",
|
|
17066
|
-
type: "INCALL",
|
|
17067
|
-
content: {
|
|
17068
|
-
connectStatus: this.callKit.connect.connectStatus
|
|
17069
|
-
}
|
|
17070
|
-
});
|
|
17071
|
-
} else {
|
|
17072
|
-
this.callKit.reset();
|
|
17073
|
-
}
|
|
16995
|
+
this.callKit.reset();
|
|
17074
16996
|
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
17075
16997
|
event: "INCALL_NOT_CONNECTED"
|
|
17076
16998
|
});
|
|
@@ -17298,18 +17220,6 @@ var Socket = class {
|
|
|
17298
17220
|
this.send(SocketSendEvent.END, { agentId: userInfo.agentId, callUuid });
|
|
17299
17221
|
}
|
|
17300
17222
|
if (data.event === SocketReceiveEvent.ERROR) {
|
|
17301
|
-
if (this.callKit.connect.isCalling()) {
|
|
17302
|
-
this.callKit.logger.warn("socket onMessage error during call, ignore", {
|
|
17303
|
-
caller: "Socket.onMessage",
|
|
17304
|
-
type: "INCALL",
|
|
17305
|
-
content: {
|
|
17306
|
-
errCode: ErrorCode.SOCKET_CONNECT_ERROR,
|
|
17307
|
-
isCalling: this.callKit.connect.isCalling(),
|
|
17308
|
-
data: content
|
|
17309
|
-
}
|
|
17310
|
-
});
|
|
17311
|
-
return;
|
|
17312
|
-
}
|
|
17313
17223
|
this.setConnectAuthState("isError", true);
|
|
17314
17224
|
this.callKit.reset();
|
|
17315
17225
|
this.callKit.logger.error(data.msg, {
|
|
@@ -17325,9 +17235,7 @@ var Socket = class {
|
|
|
17325
17235
|
}
|
|
17326
17236
|
if (data.event === SocketReceiveEvent.SESSION_ERROR) {
|
|
17327
17237
|
this.setConnectAuthState("isError", true);
|
|
17328
|
-
|
|
17329
|
-
this.callKit.reset();
|
|
17330
|
-
}
|
|
17238
|
+
this.callKit.reset();
|
|
17331
17239
|
this.callKit.logger.error(data.msg, {
|
|
17332
17240
|
caller: `Socket.onMessage:${data.event}`,
|
|
17333
17241
|
type: "INCALL",
|
|
@@ -17367,18 +17275,6 @@ var Socket = class {
|
|
|
17367
17275
|
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
17368
17276
|
event: "INCALL_NOT_CONNECTED"
|
|
17369
17277
|
});
|
|
17370
|
-
if (this.callKit.connect.isCalling()) {
|
|
17371
|
-
this.callKit.logger.warn("socket send during call, ignore", {
|
|
17372
|
-
caller: "Socket.onMessage",
|
|
17373
|
-
type: "INCALL",
|
|
17374
|
-
content: {
|
|
17375
|
-
errCode: ErrorCode.SOCKET_CONNECT_ERROR,
|
|
17376
|
-
isCalling: this.callKit.connect.isCalling(),
|
|
17377
|
-
data: message
|
|
17378
|
-
}
|
|
17379
|
-
});
|
|
17380
|
-
return;
|
|
17381
|
-
}
|
|
17382
17278
|
this.callKit.reset();
|
|
17383
17279
|
this.callKit.logger.error("socket not connected", {
|
|
17384
17280
|
caller: "Socket.send",
|
|
@@ -17509,18 +17405,6 @@ var Socket = class {
|
|
|
17509
17405
|
}
|
|
17510
17406
|
const { maxAttempts } = this.reconnectConfig;
|
|
17511
17407
|
if (this.reconnectAttempts >= maxAttempts) {
|
|
17512
|
-
if (this.callKit.connect.isCalling()) {
|
|
17513
|
-
this.callKit.logger.warn("reconnect during call, ignore", {
|
|
17514
|
-
caller: "Socket.attemptReconnect",
|
|
17515
|
-
type: "INCALL",
|
|
17516
|
-
content: {
|
|
17517
|
-
errCode: ErrorCode.SOCKET_RECONNECT_FAILED,
|
|
17518
|
-
isCalling: this.callKit.connect.isCalling(),
|
|
17519
|
-
reconnectAttempts: this.reconnectAttempts
|
|
17520
|
-
}
|
|
17521
|
-
});
|
|
17522
|
-
return;
|
|
17523
|
-
}
|
|
17524
17408
|
if (this.isUserSetPingTryCount) {
|
|
17525
17409
|
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
17526
17410
|
event: "INCALL_PING_TIMEOUT_RECONNECT_FAILED_MAX_ATTEMPTS"
|
|
@@ -17668,7 +17552,6 @@ var CallKit = class {
|
|
|
17668
17552
|
});
|
|
17669
17553
|
if (user) {
|
|
17670
17554
|
this.config.setConfig("userInfo", {
|
|
17671
|
-
...user,
|
|
17672
17555
|
wsUrl: `wss://${user.wsUrl}`,
|
|
17673
17556
|
sessionId: user.sessionId,
|
|
17674
17557
|
username,
|
package/dist/index.mjs
CHANGED
|
@@ -557,9 +557,7 @@ var SIP_RECONNECT_CONFIG = {
|
|
|
557
557
|
delay: 1e3,
|
|
558
558
|
registererOptions: {
|
|
559
559
|
refreshFrequency: 90
|
|
560
|
-
}
|
|
561
|
-
enableMessageKeepalive: true,
|
|
562
|
-
messageKeepaliveInterval: 30
|
|
560
|
+
}
|
|
563
561
|
};
|
|
564
562
|
|
|
565
563
|
// core/call.ts
|
|
@@ -703,13 +701,13 @@ var Call = class {
|
|
|
703
701
|
// package.json
|
|
704
702
|
var package_default = {
|
|
705
703
|
name: "@koi-design/callkit",
|
|
706
|
-
version: "2.3.
|
|
704
|
+
version: "2.3.2-beta.1",
|
|
707
705
|
description: "callkit",
|
|
708
706
|
author: "koi",
|
|
709
707
|
license: "ISC",
|
|
710
708
|
scripts: {
|
|
711
709
|
build: "tsup",
|
|
712
|
-
start: "vite --host 0.0.0.0",
|
|
710
|
+
start: "pnpm build && vite --host 0.0.0.0",
|
|
713
711
|
dev: "tsup --watch",
|
|
714
712
|
lint: "eslint -c ../../.eslintrc.js --ext .jsx,.js,.tsx,.ts ./package --fix",
|
|
715
713
|
release: "tsup && node scripts/pkg.js"
|
|
@@ -15544,15 +15542,7 @@ var Connect = class {
|
|
|
15544
15542
|
this.callKit = callKit;
|
|
15545
15543
|
}
|
|
15546
15544
|
get reconnectConfig() {
|
|
15547
|
-
|
|
15548
|
-
const { enableMessageKeepalive } = userInfo;
|
|
15549
|
-
const { messageKeepaliveInterval } = userInfo;
|
|
15550
|
-
const defaultConfig = this.callKit.config.getReconnectConfig("sip");
|
|
15551
|
-
if (enableMessageKeepalive) {
|
|
15552
|
-
defaultConfig.enableMessageKeepalive = enableMessageKeepalive;
|
|
15553
|
-
defaultConfig.messageKeepaliveInterval = messageKeepaliveInterval;
|
|
15554
|
-
}
|
|
15555
|
-
return defaultConfig;
|
|
15545
|
+
return this.callKit.config.getReconnectConfig("sip");
|
|
15556
15546
|
}
|
|
15557
15547
|
// current call id for invite data
|
|
15558
15548
|
currentCallId = null;
|
|
@@ -15676,7 +15666,6 @@ var Connect = class {
|
|
|
15676
15666
|
}
|
|
15677
15667
|
}
|
|
15678
15668
|
this.setConnectStatus(CallStatus.init);
|
|
15679
|
-
this.stopMessageKeepalive();
|
|
15680
15669
|
}
|
|
15681
15670
|
getAduioReference() {
|
|
15682
15671
|
const { audioRef } = this.callKit.config.getConfig();
|
|
@@ -15829,7 +15818,6 @@ var Connect = class {
|
|
|
15829
15818
|
if (!this.isInCallRefering()) {
|
|
15830
15819
|
this.setConnectStatus(CallStatus.init);
|
|
15831
15820
|
}
|
|
15832
|
-
this.stopMessageKeepalive();
|
|
15833
15821
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15834
15822
|
registererState: state,
|
|
15835
15823
|
isRegistered: this.isRegistered()
|
|
@@ -15886,7 +15874,6 @@ var Connect = class {
|
|
|
15886
15874
|
}
|
|
15887
15875
|
this.setIsReConnected(false);
|
|
15888
15876
|
}
|
|
15889
|
-
this.startMessageKeepalive();
|
|
15890
15877
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15891
15878
|
registererState: state,
|
|
15892
15879
|
isRegistered: this.isRegistered()
|
|
@@ -15906,7 +15893,6 @@ var Connect = class {
|
|
|
15906
15893
|
if (!this.isInCallRefering()) {
|
|
15907
15894
|
this.setConnectStatus(CallStatus.init);
|
|
15908
15895
|
}
|
|
15909
|
-
this.stopMessageKeepalive();
|
|
15910
15896
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15911
15897
|
registererState: state,
|
|
15912
15898
|
isRegistered: this.isRegistered(),
|
|
@@ -15927,7 +15913,6 @@ var Connect = class {
|
|
|
15927
15913
|
if (!this.isInCallRefering()) {
|
|
15928
15914
|
this.setConnectStatus(CallStatus.init);
|
|
15929
15915
|
}
|
|
15930
|
-
this.stopMessageKeepalive();
|
|
15931
15916
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15932
15917
|
registererState: state,
|
|
15933
15918
|
isRegistered: this.isRegistered(),
|
|
@@ -15974,7 +15959,7 @@ var Connect = class {
|
|
|
15974
15959
|
this.mediaStream = await navigator.mediaDevices.getUserMedia(constrains);
|
|
15975
15960
|
return this.mediaStream;
|
|
15976
15961
|
};
|
|
15977
|
-
const { userPart, fsIp, fsPort,
|
|
15962
|
+
const { userPart, fsIp, fsPort, iceInfo, wsUrl } = userInfo;
|
|
15978
15963
|
const connectConfig = {
|
|
15979
15964
|
uri: UserAgent.makeURI(`sip:${userPart}@${fsIp}:${fsPort}`),
|
|
15980
15965
|
displayName: userPart,
|
|
@@ -15983,8 +15968,6 @@ var Connect = class {
|
|
|
15983
15968
|
traceSip: true
|
|
15984
15969
|
},
|
|
15985
15970
|
logLevel: "error",
|
|
15986
|
-
authorizationUsername: userPart,
|
|
15987
|
-
authorizationPassword: fsPassword,
|
|
15988
15971
|
allowLegacyNotifications: true,
|
|
15989
15972
|
contactName: userPart,
|
|
15990
15973
|
contactParams: { transport: "wss" },
|
|
@@ -16240,10 +16223,7 @@ var Connect = class {
|
|
|
16240
16223
|
}
|
|
16241
16224
|
});
|
|
16242
16225
|
this.setupRegisterer();
|
|
16243
|
-
|
|
16244
|
-
await this.registerer.register();
|
|
16245
|
-
this.startMessageKeepalive();
|
|
16246
|
-
} catch (err) {
|
|
16226
|
+
await this.registerer.register().catch(async (err) => {
|
|
16247
16227
|
this.callKit.reset();
|
|
16248
16228
|
this.callKit.logger.error(err?.message, {
|
|
16249
16229
|
caller: "Connect.register",
|
|
@@ -16252,10 +16232,9 @@ var Connect = class {
|
|
|
16252
16232
|
errCode: ErrorCode.WEBRTC_REGISTER_ERROR
|
|
16253
16233
|
}
|
|
16254
16234
|
});
|
|
16255
|
-
}
|
|
16235
|
+
});
|
|
16256
16236
|
},
|
|
16257
16237
|
onDisconnect: (error) => {
|
|
16258
|
-
this.stopMessageKeepalive();
|
|
16259
16238
|
if (error) {
|
|
16260
16239
|
this.callKit.logger.warn("SIP User Agent Disconnected with error", {
|
|
16261
16240
|
caller: "Connect.register",
|
|
@@ -16291,7 +16270,6 @@ var Connect = class {
|
|
|
16291
16270
|
}
|
|
16292
16271
|
reconnectTimer;
|
|
16293
16272
|
reconnectAttempts = 0;
|
|
16294
|
-
messageKeepaliveTimer;
|
|
16295
16273
|
startReconnectTimer() {
|
|
16296
16274
|
if (this._isError || this.isReConnected)
|
|
16297
16275
|
return;
|
|
@@ -16345,53 +16323,8 @@ var Connect = class {
|
|
|
16345
16323
|
}
|
|
16346
16324
|
}, this.reconnectConfig.delay);
|
|
16347
16325
|
}
|
|
16348
|
-
stopMessageKeepalive() {
|
|
16349
|
-
if (this.messageKeepaliveTimer) {
|
|
16350
|
-
clearInterval(this.messageKeepaliveTimer);
|
|
16351
|
-
this.messageKeepaliveTimer = void 0;
|
|
16352
|
-
}
|
|
16353
|
-
}
|
|
16354
|
-
startMessageKeepalive() {
|
|
16355
|
-
const { enableMessageKeepalive, messageKeepaliveInterval } = this.reconnectConfig;
|
|
16356
|
-
if (!enableMessageKeepalive)
|
|
16357
|
-
return;
|
|
16358
|
-
this.stopMessageKeepalive();
|
|
16359
|
-
this.messageKeepaliveTimer = setInterval(() => {
|
|
16360
|
-
this.sendKeepaliveMessage();
|
|
16361
|
-
}, messageKeepaliveInterval * 1e3);
|
|
16362
|
-
}
|
|
16363
|
-
async sendKeepaliveMessage() {
|
|
16364
|
-
try {
|
|
16365
|
-
if (!this.isRegistered() || !this.userAgent)
|
|
16366
|
-
return;
|
|
16367
|
-
const { userInfo } = this.callKit.config.getConfig();
|
|
16368
|
-
const { userPart, fsIp, fsPort } = userInfo || {};
|
|
16369
|
-
const target = UserAgent.makeURI(`sip:${userPart}@${fsIp}:${fsPort}`);
|
|
16370
|
-
if (!target)
|
|
16371
|
-
return;
|
|
16372
|
-
const messager = new Messager(this.userAgent, target, "");
|
|
16373
|
-
await messager.message();
|
|
16374
|
-
this.callKit.logger.info("MESSAGE keepalive ok", {
|
|
16375
|
-
caller: "Connect.sendKeepaliveMessage",
|
|
16376
|
-
type: "SIP",
|
|
16377
|
-
content: {}
|
|
16378
|
-
});
|
|
16379
|
-
} catch (err) {
|
|
16380
|
-
this.callKit.logger.error(err, {
|
|
16381
|
-
caller: "Connect.sendKeepaliveMessage",
|
|
16382
|
-
type: "SIP",
|
|
16383
|
-
content: {}
|
|
16384
|
-
});
|
|
16385
|
-
this.stopMessageKeepalive();
|
|
16386
|
-
this.callKit.trigger(KitEvent.SIP_CONNECT_EVENT, {
|
|
16387
|
-
event: "MESSAGE_KEEPALIVE_FAILED"
|
|
16388
|
-
});
|
|
16389
|
-
this.startReconnectTimer();
|
|
16390
|
-
}
|
|
16391
|
-
}
|
|
16392
16326
|
async stop() {
|
|
16393
16327
|
await this.userAgent.stop();
|
|
16394
|
-
this.stopMessageKeepalive();
|
|
16395
16328
|
}
|
|
16396
16329
|
async unregister() {
|
|
16397
16330
|
this.callKit.logger.info("connect unregister", {
|
|
@@ -16401,7 +16334,6 @@ var Connect = class {
|
|
|
16401
16334
|
isRegistered: this.isRegistered()
|
|
16402
16335
|
}
|
|
16403
16336
|
});
|
|
16404
|
-
this.stopMessageKeepalive();
|
|
16405
16337
|
if (!this.isRegistered() || !this.registerer) {
|
|
16406
16338
|
this.callKit.logger.warn("No registerer to unregister.", {
|
|
16407
16339
|
caller: "Connect.unregister",
|
|
@@ -17033,17 +16965,7 @@ var Socket = class {
|
|
|
17033
16965
|
this.setConnectAuthState("isConnected", false);
|
|
17034
16966
|
const { enabled } = this.reconnectConfig;
|
|
17035
16967
|
if (!this.callKit.config.isLogin() || !enabled) {
|
|
17036
|
-
|
|
17037
|
-
this.callKit.logger.warn("Disconnect during call, delay reset", {
|
|
17038
|
-
caller: "Socket.handleDisconnect",
|
|
17039
|
-
type: "INCALL",
|
|
17040
|
-
content: {
|
|
17041
|
-
connectStatus: this.callKit.connect.connectStatus
|
|
17042
|
-
}
|
|
17043
|
-
});
|
|
17044
|
-
} else {
|
|
17045
|
-
this.callKit.reset();
|
|
17046
|
-
}
|
|
16968
|
+
this.callKit.reset();
|
|
17047
16969
|
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
17048
16970
|
event: "INCALL_NOT_CONNECTED"
|
|
17049
16971
|
});
|
|
@@ -17271,18 +17193,6 @@ var Socket = class {
|
|
|
17271
17193
|
this.send(SocketSendEvent.END, { agentId: userInfo.agentId, callUuid });
|
|
17272
17194
|
}
|
|
17273
17195
|
if (data.event === SocketReceiveEvent.ERROR) {
|
|
17274
|
-
if (this.callKit.connect.isCalling()) {
|
|
17275
|
-
this.callKit.logger.warn("socket onMessage error during call, ignore", {
|
|
17276
|
-
caller: "Socket.onMessage",
|
|
17277
|
-
type: "INCALL",
|
|
17278
|
-
content: {
|
|
17279
|
-
errCode: ErrorCode.SOCKET_CONNECT_ERROR,
|
|
17280
|
-
isCalling: this.callKit.connect.isCalling(),
|
|
17281
|
-
data: content
|
|
17282
|
-
}
|
|
17283
|
-
});
|
|
17284
|
-
return;
|
|
17285
|
-
}
|
|
17286
17196
|
this.setConnectAuthState("isError", true);
|
|
17287
17197
|
this.callKit.reset();
|
|
17288
17198
|
this.callKit.logger.error(data.msg, {
|
|
@@ -17298,9 +17208,7 @@ var Socket = class {
|
|
|
17298
17208
|
}
|
|
17299
17209
|
if (data.event === SocketReceiveEvent.SESSION_ERROR) {
|
|
17300
17210
|
this.setConnectAuthState("isError", true);
|
|
17301
|
-
|
|
17302
|
-
this.callKit.reset();
|
|
17303
|
-
}
|
|
17211
|
+
this.callKit.reset();
|
|
17304
17212
|
this.callKit.logger.error(data.msg, {
|
|
17305
17213
|
caller: `Socket.onMessage:${data.event}`,
|
|
17306
17214
|
type: "INCALL",
|
|
@@ -17340,18 +17248,6 @@ var Socket = class {
|
|
|
17340
17248
|
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
17341
17249
|
event: "INCALL_NOT_CONNECTED"
|
|
17342
17250
|
});
|
|
17343
|
-
if (this.callKit.connect.isCalling()) {
|
|
17344
|
-
this.callKit.logger.warn("socket send during call, ignore", {
|
|
17345
|
-
caller: "Socket.onMessage",
|
|
17346
|
-
type: "INCALL",
|
|
17347
|
-
content: {
|
|
17348
|
-
errCode: ErrorCode.SOCKET_CONNECT_ERROR,
|
|
17349
|
-
isCalling: this.callKit.connect.isCalling(),
|
|
17350
|
-
data: message
|
|
17351
|
-
}
|
|
17352
|
-
});
|
|
17353
|
-
return;
|
|
17354
|
-
}
|
|
17355
17251
|
this.callKit.reset();
|
|
17356
17252
|
this.callKit.logger.error("socket not connected", {
|
|
17357
17253
|
caller: "Socket.send",
|
|
@@ -17482,18 +17378,6 @@ var Socket = class {
|
|
|
17482
17378
|
}
|
|
17483
17379
|
const { maxAttempts } = this.reconnectConfig;
|
|
17484
17380
|
if (this.reconnectAttempts >= maxAttempts) {
|
|
17485
|
-
if (this.callKit.connect.isCalling()) {
|
|
17486
|
-
this.callKit.logger.warn("reconnect during call, ignore", {
|
|
17487
|
-
caller: "Socket.attemptReconnect",
|
|
17488
|
-
type: "INCALL",
|
|
17489
|
-
content: {
|
|
17490
|
-
errCode: ErrorCode.SOCKET_RECONNECT_FAILED,
|
|
17491
|
-
isCalling: this.callKit.connect.isCalling(),
|
|
17492
|
-
reconnectAttempts: this.reconnectAttempts
|
|
17493
|
-
}
|
|
17494
|
-
});
|
|
17495
|
-
return;
|
|
17496
|
-
}
|
|
17497
17381
|
if (this.isUserSetPingTryCount) {
|
|
17498
17382
|
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
17499
17383
|
event: "INCALL_PING_TIMEOUT_RECONNECT_FAILED_MAX_ATTEMPTS"
|
|
@@ -17641,7 +17525,6 @@ var CallKit = class {
|
|
|
17641
17525
|
});
|
|
17642
17526
|
if (user) {
|
|
17643
17527
|
this.config.setConfig("userInfo", {
|
|
17644
|
-
...user,
|
|
17645
17528
|
wsUrl: `wss://${user.wsUrl}`,
|
|
17646
17529
|
sessionId: user.sessionId,
|
|
17647
17530
|
username,
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koi-design/callkit",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2-beta.1",
|
|
4
4
|
"description": "callkit",
|
|
5
5
|
"author": "koi",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsup",
|
|
9
|
-
"start": "vite --host 0.0.0.0",
|
|
9
|
+
"start": "pnpm build && vite --host 0.0.0.0",
|
|
10
10
|
"dev": "tsup --watch",
|
|
11
11
|
"lint": "eslint -c ../../.eslintrc.js --ext .jsx,.js,.tsx,.ts ./package --fix",
|
|
12
12
|
"release": "tsup && node scripts/pkg.js"
|