@koi-design/callkit 2.3.1-beta.1 → 2.3.1-beta.2
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 +8 -0
- package/dist/index.global.js +75 -9
- package/dist/index.js +75 -9
- package/dist/index.mjs +75 -9
- package/package.json +2 -2
- package/dist/index.global.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -4800,6 +4800,8 @@ interface SipConfig {
|
|
|
4800
4800
|
maxAttempts: number;
|
|
4801
4801
|
delay: number;
|
|
4802
4802
|
registererOptions: RegistererOptions;
|
|
4803
|
+
enableMessageKeepalive: boolean;
|
|
4804
|
+
messageKeepaliveInterval: number;
|
|
4803
4805
|
}
|
|
4804
4806
|
declare class Socket {
|
|
4805
4807
|
private callKit;
|
|
@@ -4911,6 +4913,8 @@ interface IConfig {
|
|
|
4911
4913
|
encryptionMethod: EncryptionMethodType;
|
|
4912
4914
|
logGather: boolean;
|
|
4913
4915
|
keepaliveInterval?: number;
|
|
4916
|
+
enableMessageKeepalive?: boolean;
|
|
4917
|
+
messageKeepaliveInterval?: number;
|
|
4914
4918
|
/** Ping timeout reconnection max attempts */
|
|
4915
4919
|
pingTryCount?: number;
|
|
4916
4920
|
/** Ping timeout reconnection interval (seconds) */
|
|
@@ -5274,7 +5278,11 @@ declare class Connect {
|
|
|
5274
5278
|
register(): Promise<void>;
|
|
5275
5279
|
private reconnectTimer?;
|
|
5276
5280
|
private reconnectAttempts;
|
|
5281
|
+
private messageKeepaliveTimer?;
|
|
5277
5282
|
private startReconnectTimer;
|
|
5283
|
+
private stopMessageKeepalive;
|
|
5284
|
+
private startMessageKeepalive;
|
|
5285
|
+
private sendKeepaliveMessage;
|
|
5278
5286
|
stop(): Promise<void>;
|
|
5279
5287
|
unregister(): Promise<void>;
|
|
5280
5288
|
call(callback: (userInfo: IConfig['userInfo']) => void): Promise<void>;
|
package/dist/index.global.js
CHANGED
|
@@ -3749,7 +3749,9 @@ var WebCall = (() => {
|
|
|
3749
3749
|
delay: 1e3,
|
|
3750
3750
|
registererOptions: {
|
|
3751
3751
|
refreshFrequency: 90
|
|
3752
|
-
}
|
|
3752
|
+
},
|
|
3753
|
+
enableMessageKeepalive: true,
|
|
3754
|
+
messageKeepaliveInterval: 30
|
|
3753
3755
|
};
|
|
3754
3756
|
|
|
3755
3757
|
// core/call.ts
|
|
@@ -3893,13 +3895,13 @@ var WebCall = (() => {
|
|
|
3893
3895
|
// package.json
|
|
3894
3896
|
var package_default = {
|
|
3895
3897
|
name: "@koi-design/callkit",
|
|
3896
|
-
version: "2.3.1-beta.
|
|
3898
|
+
version: "2.3.1-beta.2",
|
|
3897
3899
|
description: "callkit",
|
|
3898
3900
|
author: "koi",
|
|
3899
3901
|
license: "ISC",
|
|
3900
3902
|
scripts: {
|
|
3901
3903
|
build: "tsup",
|
|
3902
|
-
start: "
|
|
3904
|
+
start: "vite --host 0.0.0.0",
|
|
3903
3905
|
dev: "tsup --watch",
|
|
3904
3906
|
lint: "eslint -c ../../.eslintrc.js --ext .jsx,.js,.tsx,.ts ./package --fix",
|
|
3905
3907
|
release: "tsup && node scripts/pkg.js"
|
|
@@ -18734,7 +18736,15 @@ ${log}` : log;
|
|
|
18734
18736
|
this.callKit = callKit;
|
|
18735
18737
|
}
|
|
18736
18738
|
get reconnectConfig() {
|
|
18737
|
-
|
|
18739
|
+
const { userInfo } = this.callKit.config.getConfig();
|
|
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;
|
|
18738
18748
|
}
|
|
18739
18749
|
// current call id for invite data
|
|
18740
18750
|
currentCallId = null;
|
|
@@ -18858,6 +18868,7 @@ ${log}` : log;
|
|
|
18858
18868
|
}
|
|
18859
18869
|
}
|
|
18860
18870
|
this.setConnectStatus(CallStatus.init);
|
|
18871
|
+
this.stopMessageKeepalive();
|
|
18861
18872
|
}
|
|
18862
18873
|
getAduioReference() {
|
|
18863
18874
|
const { audioRef } = this.callKit.config.getConfig();
|
|
@@ -19010,6 +19021,7 @@ ${log}` : log;
|
|
|
19010
19021
|
if (!this.isInCallRefering()) {
|
|
19011
19022
|
this.setConnectStatus(CallStatus.init);
|
|
19012
19023
|
}
|
|
19024
|
+
this.stopMessageKeepalive();
|
|
19013
19025
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
19014
19026
|
registererState: state,
|
|
19015
19027
|
isRegistered: this.isRegistered()
|
|
@@ -19066,6 +19078,7 @@ ${log}` : log;
|
|
|
19066
19078
|
}
|
|
19067
19079
|
this.setIsReConnected(false);
|
|
19068
19080
|
}
|
|
19081
|
+
this.startMessageKeepalive();
|
|
19069
19082
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
19070
19083
|
registererState: state,
|
|
19071
19084
|
isRegistered: this.isRegistered()
|
|
@@ -19085,6 +19098,7 @@ ${log}` : log;
|
|
|
19085
19098
|
if (!this.isInCallRefering()) {
|
|
19086
19099
|
this.setConnectStatus(CallStatus.init);
|
|
19087
19100
|
}
|
|
19101
|
+
this.stopMessageKeepalive();
|
|
19088
19102
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
19089
19103
|
registererState: state,
|
|
19090
19104
|
isRegistered: this.isRegistered(),
|
|
@@ -19105,6 +19119,7 @@ ${log}` : log;
|
|
|
19105
19119
|
if (!this.isInCallRefering()) {
|
|
19106
19120
|
this.setConnectStatus(CallStatus.init);
|
|
19107
19121
|
}
|
|
19122
|
+
this.stopMessageKeepalive();
|
|
19108
19123
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
19109
19124
|
registererState: state,
|
|
19110
19125
|
isRegistered: this.isRegistered(),
|
|
@@ -19160,9 +19175,9 @@ ${log}` : log;
|
|
|
19160
19175
|
traceSip: true
|
|
19161
19176
|
},
|
|
19162
19177
|
logLevel: "error",
|
|
19163
|
-
allowLegacyNotifications: true,
|
|
19164
|
-
authorizationPassword: fsPassword,
|
|
19165
19178
|
authorizationUsername: userPart,
|
|
19179
|
+
authorizationPassword: fsPassword,
|
|
19180
|
+
allowLegacyNotifications: true,
|
|
19166
19181
|
contactName: userPart,
|
|
19167
19182
|
contactParams: { transport: "wss" },
|
|
19168
19183
|
sessionDescriptionHandlerFactory: web_exports.defaultSessionDescriptionHandlerFactory(localStreamFactory),
|
|
@@ -19417,7 +19432,10 @@ ${log}` : log;
|
|
|
19417
19432
|
}
|
|
19418
19433
|
});
|
|
19419
19434
|
this.setupRegisterer();
|
|
19420
|
-
|
|
19435
|
+
try {
|
|
19436
|
+
await this.registerer.register();
|
|
19437
|
+
this.startMessageKeepalive();
|
|
19438
|
+
} catch (err) {
|
|
19421
19439
|
this.callKit.reset();
|
|
19422
19440
|
this.callKit.logger.error(err?.message, {
|
|
19423
19441
|
caller: "Connect.register",
|
|
@@ -19426,9 +19444,10 @@ ${log}` : log;
|
|
|
19426
19444
|
errCode: ErrorCode.WEBRTC_REGISTER_ERROR
|
|
19427
19445
|
}
|
|
19428
19446
|
});
|
|
19429
|
-
}
|
|
19447
|
+
}
|
|
19430
19448
|
},
|
|
19431
19449
|
onDisconnect: (error) => {
|
|
19450
|
+
this.stopMessageKeepalive();
|
|
19432
19451
|
if (error) {
|
|
19433
19452
|
this.callKit.logger.warn("SIP User Agent Disconnected with error", {
|
|
19434
19453
|
caller: "Connect.register",
|
|
@@ -19464,6 +19483,7 @@ ${log}` : log;
|
|
|
19464
19483
|
}
|
|
19465
19484
|
reconnectTimer;
|
|
19466
19485
|
reconnectAttempts = 0;
|
|
19486
|
+
messageKeepaliveTimer;
|
|
19467
19487
|
startReconnectTimer() {
|
|
19468
19488
|
if (this._isError || this.isReConnected)
|
|
19469
19489
|
return;
|
|
@@ -19517,8 +19537,53 @@ ${log}` : log;
|
|
|
19517
19537
|
}
|
|
19518
19538
|
}, this.reconnectConfig.delay);
|
|
19519
19539
|
}
|
|
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
|
+
}
|
|
19520
19584
|
async stop() {
|
|
19521
19585
|
await this.userAgent.stop();
|
|
19586
|
+
this.stopMessageKeepalive();
|
|
19522
19587
|
}
|
|
19523
19588
|
async unregister() {
|
|
19524
19589
|
this.callKit.logger.info("connect unregister", {
|
|
@@ -19528,6 +19593,7 @@ ${log}` : log;
|
|
|
19528
19593
|
isRegistered: this.isRegistered()
|
|
19529
19594
|
}
|
|
19530
19595
|
});
|
|
19596
|
+
this.stopMessageKeepalive();
|
|
19531
19597
|
if (!this.isRegistered() || !this.registerer) {
|
|
19532
19598
|
this.callKit.logger.warn("No registerer to unregister.", {
|
|
19533
19599
|
caller: "Connect.unregister",
|
|
@@ -20767,6 +20833,7 @@ self.onmessage = function(e) {
|
|
|
20767
20833
|
});
|
|
20768
20834
|
if (user) {
|
|
20769
20835
|
this.config.setConfig("userInfo", {
|
|
20836
|
+
...user,
|
|
20770
20837
|
wsUrl: `wss://${user.wsUrl}`,
|
|
20771
20838
|
sessionId: user.sessionId,
|
|
20772
20839
|
username,
|
|
@@ -21060,4 +21127,3 @@ self.onmessage = function(e) {
|
|
|
21060
21127
|
};
|
|
21061
21128
|
return __toCommonJS(core_exports);
|
|
21062
21129
|
})();
|
|
21063
|
-
//# sourceMappingURL=index.global.js.map
|
package/dist/index.js
CHANGED
|
@@ -584,7 +584,9 @@ var SIP_RECONNECT_CONFIG = {
|
|
|
584
584
|
delay: 1e3,
|
|
585
585
|
registererOptions: {
|
|
586
586
|
refreshFrequency: 90
|
|
587
|
-
}
|
|
587
|
+
},
|
|
588
|
+
enableMessageKeepalive: true,
|
|
589
|
+
messageKeepaliveInterval: 30
|
|
588
590
|
};
|
|
589
591
|
|
|
590
592
|
// core/call.ts
|
|
@@ -728,13 +730,13 @@ var Call = class {
|
|
|
728
730
|
// package.json
|
|
729
731
|
var package_default = {
|
|
730
732
|
name: "@koi-design/callkit",
|
|
731
|
-
version: "2.3.1-beta.
|
|
733
|
+
version: "2.3.1-beta.2",
|
|
732
734
|
description: "callkit",
|
|
733
735
|
author: "koi",
|
|
734
736
|
license: "ISC",
|
|
735
737
|
scripts: {
|
|
736
738
|
build: "tsup",
|
|
737
|
-
start: "
|
|
739
|
+
start: "vite --host 0.0.0.0",
|
|
738
740
|
dev: "tsup --watch",
|
|
739
741
|
lint: "eslint -c ../../.eslintrc.js --ext .jsx,.js,.tsx,.ts ./package --fix",
|
|
740
742
|
release: "tsup && node scripts/pkg.js"
|
|
@@ -15569,7 +15571,15 @@ var Connect = class {
|
|
|
15569
15571
|
this.callKit = callKit;
|
|
15570
15572
|
}
|
|
15571
15573
|
get reconnectConfig() {
|
|
15572
|
-
|
|
15574
|
+
const { userInfo } = this.callKit.config.getConfig();
|
|
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;
|
|
15573
15583
|
}
|
|
15574
15584
|
// current call id for invite data
|
|
15575
15585
|
currentCallId = null;
|
|
@@ -15693,6 +15703,7 @@ var Connect = class {
|
|
|
15693
15703
|
}
|
|
15694
15704
|
}
|
|
15695
15705
|
this.setConnectStatus(CallStatus.init);
|
|
15706
|
+
this.stopMessageKeepalive();
|
|
15696
15707
|
}
|
|
15697
15708
|
getAduioReference() {
|
|
15698
15709
|
const { audioRef } = this.callKit.config.getConfig();
|
|
@@ -15845,6 +15856,7 @@ var Connect = class {
|
|
|
15845
15856
|
if (!this.isInCallRefering()) {
|
|
15846
15857
|
this.setConnectStatus(CallStatus.init);
|
|
15847
15858
|
}
|
|
15859
|
+
this.stopMessageKeepalive();
|
|
15848
15860
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15849
15861
|
registererState: state,
|
|
15850
15862
|
isRegistered: this.isRegistered()
|
|
@@ -15901,6 +15913,7 @@ var Connect = class {
|
|
|
15901
15913
|
}
|
|
15902
15914
|
this.setIsReConnected(false);
|
|
15903
15915
|
}
|
|
15916
|
+
this.startMessageKeepalive();
|
|
15904
15917
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15905
15918
|
registererState: state,
|
|
15906
15919
|
isRegistered: this.isRegistered()
|
|
@@ -15920,6 +15933,7 @@ var Connect = class {
|
|
|
15920
15933
|
if (!this.isInCallRefering()) {
|
|
15921
15934
|
this.setConnectStatus(CallStatus.init);
|
|
15922
15935
|
}
|
|
15936
|
+
this.stopMessageKeepalive();
|
|
15923
15937
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15924
15938
|
registererState: state,
|
|
15925
15939
|
isRegistered: this.isRegistered(),
|
|
@@ -15940,6 +15954,7 @@ var Connect = class {
|
|
|
15940
15954
|
if (!this.isInCallRefering()) {
|
|
15941
15955
|
this.setConnectStatus(CallStatus.init);
|
|
15942
15956
|
}
|
|
15957
|
+
this.stopMessageKeepalive();
|
|
15943
15958
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15944
15959
|
registererState: state,
|
|
15945
15960
|
isRegistered: this.isRegistered(),
|
|
@@ -15995,9 +16010,9 @@ var Connect = class {
|
|
|
15995
16010
|
traceSip: true
|
|
15996
16011
|
},
|
|
15997
16012
|
logLevel: "error",
|
|
15998
|
-
allowLegacyNotifications: true,
|
|
15999
|
-
authorizationPassword: fsPassword,
|
|
16000
16013
|
authorizationUsername: userPart,
|
|
16014
|
+
authorizationPassword: fsPassword,
|
|
16015
|
+
allowLegacyNotifications: true,
|
|
16001
16016
|
contactName: userPart,
|
|
16002
16017
|
contactParams: { transport: "wss" },
|
|
16003
16018
|
sessionDescriptionHandlerFactory: web_exports.defaultSessionDescriptionHandlerFactory(localStreamFactory),
|
|
@@ -16252,7 +16267,10 @@ var Connect = class {
|
|
|
16252
16267
|
}
|
|
16253
16268
|
});
|
|
16254
16269
|
this.setupRegisterer();
|
|
16255
|
-
|
|
16270
|
+
try {
|
|
16271
|
+
await this.registerer.register();
|
|
16272
|
+
this.startMessageKeepalive();
|
|
16273
|
+
} catch (err) {
|
|
16256
16274
|
this.callKit.reset();
|
|
16257
16275
|
this.callKit.logger.error(err?.message, {
|
|
16258
16276
|
caller: "Connect.register",
|
|
@@ -16261,9 +16279,10 @@ var Connect = class {
|
|
|
16261
16279
|
errCode: ErrorCode.WEBRTC_REGISTER_ERROR
|
|
16262
16280
|
}
|
|
16263
16281
|
});
|
|
16264
|
-
}
|
|
16282
|
+
}
|
|
16265
16283
|
},
|
|
16266
16284
|
onDisconnect: (error) => {
|
|
16285
|
+
this.stopMessageKeepalive();
|
|
16267
16286
|
if (error) {
|
|
16268
16287
|
this.callKit.logger.warn("SIP User Agent Disconnected with error", {
|
|
16269
16288
|
caller: "Connect.register",
|
|
@@ -16299,6 +16318,7 @@ var Connect = class {
|
|
|
16299
16318
|
}
|
|
16300
16319
|
reconnectTimer;
|
|
16301
16320
|
reconnectAttempts = 0;
|
|
16321
|
+
messageKeepaliveTimer;
|
|
16302
16322
|
startReconnectTimer() {
|
|
16303
16323
|
if (this._isError || this.isReConnected)
|
|
16304
16324
|
return;
|
|
@@ -16352,8 +16372,53 @@ var Connect = class {
|
|
|
16352
16372
|
}
|
|
16353
16373
|
}, this.reconnectConfig.delay);
|
|
16354
16374
|
}
|
|
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
|
+
}
|
|
16355
16419
|
async stop() {
|
|
16356
16420
|
await this.userAgent.stop();
|
|
16421
|
+
this.stopMessageKeepalive();
|
|
16357
16422
|
}
|
|
16358
16423
|
async unregister() {
|
|
16359
16424
|
this.callKit.logger.info("connect unregister", {
|
|
@@ -16363,6 +16428,7 @@ var Connect = class {
|
|
|
16363
16428
|
isRegistered: this.isRegistered()
|
|
16364
16429
|
}
|
|
16365
16430
|
});
|
|
16431
|
+
this.stopMessageKeepalive();
|
|
16366
16432
|
if (!this.isRegistered() || !this.registerer) {
|
|
16367
16433
|
this.callKit.logger.warn("No registerer to unregister.", {
|
|
16368
16434
|
caller: "Connect.unregister",
|
|
@@ -17602,6 +17668,7 @@ var CallKit = class {
|
|
|
17602
17668
|
});
|
|
17603
17669
|
if (user) {
|
|
17604
17670
|
this.config.setConfig("userInfo", {
|
|
17671
|
+
...user,
|
|
17605
17672
|
wsUrl: `wss://${user.wsUrl}`,
|
|
17606
17673
|
sessionId: user.sessionId,
|
|
17607
17674
|
username,
|
|
@@ -17897,4 +17964,3 @@ var CallKit = class {
|
|
|
17897
17964
|
0 && (module.exports = {
|
|
17898
17965
|
CallKit
|
|
17899
17966
|
});
|
|
17900
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.mjs
CHANGED
|
@@ -557,7 +557,9 @@ var SIP_RECONNECT_CONFIG = {
|
|
|
557
557
|
delay: 1e3,
|
|
558
558
|
registererOptions: {
|
|
559
559
|
refreshFrequency: 90
|
|
560
|
-
}
|
|
560
|
+
},
|
|
561
|
+
enableMessageKeepalive: true,
|
|
562
|
+
messageKeepaliveInterval: 30
|
|
561
563
|
};
|
|
562
564
|
|
|
563
565
|
// core/call.ts
|
|
@@ -701,13 +703,13 @@ var Call = class {
|
|
|
701
703
|
// package.json
|
|
702
704
|
var package_default = {
|
|
703
705
|
name: "@koi-design/callkit",
|
|
704
|
-
version: "2.3.1-beta.
|
|
706
|
+
version: "2.3.1-beta.2",
|
|
705
707
|
description: "callkit",
|
|
706
708
|
author: "koi",
|
|
707
709
|
license: "ISC",
|
|
708
710
|
scripts: {
|
|
709
711
|
build: "tsup",
|
|
710
|
-
start: "
|
|
712
|
+
start: "vite --host 0.0.0.0",
|
|
711
713
|
dev: "tsup --watch",
|
|
712
714
|
lint: "eslint -c ../../.eslintrc.js --ext .jsx,.js,.tsx,.ts ./package --fix",
|
|
713
715
|
release: "tsup && node scripts/pkg.js"
|
|
@@ -15542,7 +15544,15 @@ var Connect = class {
|
|
|
15542
15544
|
this.callKit = callKit;
|
|
15543
15545
|
}
|
|
15544
15546
|
get reconnectConfig() {
|
|
15545
|
-
|
|
15547
|
+
const { userInfo } = this.callKit.config.getConfig();
|
|
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;
|
|
15546
15556
|
}
|
|
15547
15557
|
// current call id for invite data
|
|
15548
15558
|
currentCallId = null;
|
|
@@ -15666,6 +15676,7 @@ var Connect = class {
|
|
|
15666
15676
|
}
|
|
15667
15677
|
}
|
|
15668
15678
|
this.setConnectStatus(CallStatus.init);
|
|
15679
|
+
this.stopMessageKeepalive();
|
|
15669
15680
|
}
|
|
15670
15681
|
getAduioReference() {
|
|
15671
15682
|
const { audioRef } = this.callKit.config.getConfig();
|
|
@@ -15818,6 +15829,7 @@ var Connect = class {
|
|
|
15818
15829
|
if (!this.isInCallRefering()) {
|
|
15819
15830
|
this.setConnectStatus(CallStatus.init);
|
|
15820
15831
|
}
|
|
15832
|
+
this.stopMessageKeepalive();
|
|
15821
15833
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15822
15834
|
registererState: state,
|
|
15823
15835
|
isRegistered: this.isRegistered()
|
|
@@ -15874,6 +15886,7 @@ var Connect = class {
|
|
|
15874
15886
|
}
|
|
15875
15887
|
this.setIsReConnected(false);
|
|
15876
15888
|
}
|
|
15889
|
+
this.startMessageKeepalive();
|
|
15877
15890
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15878
15891
|
registererState: state,
|
|
15879
15892
|
isRegistered: this.isRegistered()
|
|
@@ -15893,6 +15906,7 @@ var Connect = class {
|
|
|
15893
15906
|
if (!this.isInCallRefering()) {
|
|
15894
15907
|
this.setConnectStatus(CallStatus.init);
|
|
15895
15908
|
}
|
|
15909
|
+
this.stopMessageKeepalive();
|
|
15896
15910
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15897
15911
|
registererState: state,
|
|
15898
15912
|
isRegistered: this.isRegistered(),
|
|
@@ -15913,6 +15927,7 @@ var Connect = class {
|
|
|
15913
15927
|
if (!this.isInCallRefering()) {
|
|
15914
15928
|
this.setConnectStatus(CallStatus.init);
|
|
15915
15929
|
}
|
|
15930
|
+
this.stopMessageKeepalive();
|
|
15916
15931
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
15917
15932
|
registererState: state,
|
|
15918
15933
|
isRegistered: this.isRegistered(),
|
|
@@ -15968,9 +15983,9 @@ var Connect = class {
|
|
|
15968
15983
|
traceSip: true
|
|
15969
15984
|
},
|
|
15970
15985
|
logLevel: "error",
|
|
15971
|
-
allowLegacyNotifications: true,
|
|
15972
|
-
authorizationPassword: fsPassword,
|
|
15973
15986
|
authorizationUsername: userPart,
|
|
15987
|
+
authorizationPassword: fsPassword,
|
|
15988
|
+
allowLegacyNotifications: true,
|
|
15974
15989
|
contactName: userPart,
|
|
15975
15990
|
contactParams: { transport: "wss" },
|
|
15976
15991
|
sessionDescriptionHandlerFactory: web_exports.defaultSessionDescriptionHandlerFactory(localStreamFactory),
|
|
@@ -16225,7 +16240,10 @@ var Connect = class {
|
|
|
16225
16240
|
}
|
|
16226
16241
|
});
|
|
16227
16242
|
this.setupRegisterer();
|
|
16228
|
-
|
|
16243
|
+
try {
|
|
16244
|
+
await this.registerer.register();
|
|
16245
|
+
this.startMessageKeepalive();
|
|
16246
|
+
} catch (err) {
|
|
16229
16247
|
this.callKit.reset();
|
|
16230
16248
|
this.callKit.logger.error(err?.message, {
|
|
16231
16249
|
caller: "Connect.register",
|
|
@@ -16234,9 +16252,10 @@ var Connect = class {
|
|
|
16234
16252
|
errCode: ErrorCode.WEBRTC_REGISTER_ERROR
|
|
16235
16253
|
}
|
|
16236
16254
|
});
|
|
16237
|
-
}
|
|
16255
|
+
}
|
|
16238
16256
|
},
|
|
16239
16257
|
onDisconnect: (error) => {
|
|
16258
|
+
this.stopMessageKeepalive();
|
|
16240
16259
|
if (error) {
|
|
16241
16260
|
this.callKit.logger.warn("SIP User Agent Disconnected with error", {
|
|
16242
16261
|
caller: "Connect.register",
|
|
@@ -16272,6 +16291,7 @@ var Connect = class {
|
|
|
16272
16291
|
}
|
|
16273
16292
|
reconnectTimer;
|
|
16274
16293
|
reconnectAttempts = 0;
|
|
16294
|
+
messageKeepaliveTimer;
|
|
16275
16295
|
startReconnectTimer() {
|
|
16276
16296
|
if (this._isError || this.isReConnected)
|
|
16277
16297
|
return;
|
|
@@ -16325,8 +16345,53 @@ var Connect = class {
|
|
|
16325
16345
|
}
|
|
16326
16346
|
}, this.reconnectConfig.delay);
|
|
16327
16347
|
}
|
|
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
|
+
}
|
|
16328
16392
|
async stop() {
|
|
16329
16393
|
await this.userAgent.stop();
|
|
16394
|
+
this.stopMessageKeepalive();
|
|
16330
16395
|
}
|
|
16331
16396
|
async unregister() {
|
|
16332
16397
|
this.callKit.logger.info("connect unregister", {
|
|
@@ -16336,6 +16401,7 @@ var Connect = class {
|
|
|
16336
16401
|
isRegistered: this.isRegistered()
|
|
16337
16402
|
}
|
|
16338
16403
|
});
|
|
16404
|
+
this.stopMessageKeepalive();
|
|
16339
16405
|
if (!this.isRegistered() || !this.registerer) {
|
|
16340
16406
|
this.callKit.logger.warn("No registerer to unregister.", {
|
|
16341
16407
|
caller: "Connect.unregister",
|
|
@@ -17575,6 +17641,7 @@ var CallKit = class {
|
|
|
17575
17641
|
});
|
|
17576
17642
|
if (user) {
|
|
17577
17643
|
this.config.setConfig("userInfo", {
|
|
17644
|
+
...user,
|
|
17578
17645
|
wsUrl: `wss://${user.wsUrl}`,
|
|
17579
17646
|
sessionId: user.sessionId,
|
|
17580
17647
|
username,
|
|
@@ -17869,4 +17936,3 @@ var CallKit = class {
|
|
|
17869
17936
|
export {
|
|
17870
17937
|
CallKit
|
|
17871
17938
|
};
|
|
17872
|
-
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koi-design/callkit",
|
|
3
|
-
"version": "2.3.1-beta.
|
|
3
|
+
"version": "2.3.1-beta.2",
|
|
4
4
|
"description": "callkit",
|
|
5
5
|
"author": "koi",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsup",
|
|
9
|
-
"start": "
|
|
9
|
+
"start": "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"
|