@koi-design/callkit 2.3.1-beta.2 → 2.3.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 +7 -76
- package/dist/index.js +7 -76
- package/dist/index.mjs +7 -76
- 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.1
|
|
3896
|
+
version: "2.3.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",
|
|
@@ -20833,7 +20765,6 @@ self.onmessage = function(e) {
|
|
|
20833
20765
|
});
|
|
20834
20766
|
if (user) {
|
|
20835
20767
|
this.config.setConfig("userInfo", {
|
|
20836
|
-
...user,
|
|
20837
20768
|
wsUrl: `wss://${user.wsUrl}`,
|
|
20838
20769
|
sessionId: user.sessionId,
|
|
20839
20770
|
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.1
|
|
731
|
+
version: "2.3.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",
|
|
@@ -17668,7 +17600,6 @@ var CallKit = class {
|
|
|
17668
17600
|
});
|
|
17669
17601
|
if (user) {
|
|
17670
17602
|
this.config.setConfig("userInfo", {
|
|
17671
|
-
...user,
|
|
17672
17603
|
wsUrl: `wss://${user.wsUrl}`,
|
|
17673
17604
|
sessionId: user.sessionId,
|
|
17674
17605
|
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.1
|
|
704
|
+
version: "2.3.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",
|
|
@@ -17641,7 +17573,6 @@ var CallKit = class {
|
|
|
17641
17573
|
});
|
|
17642
17574
|
if (user) {
|
|
17643
17575
|
this.config.setConfig("userInfo", {
|
|
17644
|
-
...user,
|
|
17645
17576
|
wsUrl: `wss://${user.wsUrl}`,
|
|
17646
17577
|
sessionId: user.sessionId,
|
|
17647
17578
|
username,
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koi-design/callkit",
|
|
3
|
-
"version": "2.3.1
|
|
3
|
+
"version": "2.3.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"
|