@koi-design/callkit 2.0.0-beta.3 → 2.0.0-beta.5
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 +21 -17
- package/dist/index.global.js +177 -138
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +177 -138
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +177 -138
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ declare class Call {
|
|
|
39
39
|
callEnd(isUnprompted?: boolean, isError?: boolean): Promise<void>;
|
|
40
40
|
callHold(): Promise<void>;
|
|
41
41
|
callUnhold(): Promise<void>;
|
|
42
|
+
callMute(): Promise<void>;
|
|
43
|
+
callUnmute(): Promise<void>;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
declare const CallStatus: {
|
|
@@ -50,10 +52,6 @@ declare const CallStatus: {
|
|
|
50
52
|
* Connecting
|
|
51
53
|
*/
|
|
52
54
|
connecting: number;
|
|
53
|
-
/**
|
|
54
|
-
* Call on hold
|
|
55
|
-
*/
|
|
56
|
-
holding: number;
|
|
57
55
|
/**
|
|
58
56
|
* Ringing
|
|
59
57
|
*/
|
|
@@ -144,7 +142,8 @@ declare const KitEvent: {
|
|
|
144
142
|
* User status change
|
|
145
143
|
*/
|
|
146
144
|
USER_STATUS_CHANGE: string;
|
|
147
|
-
|
|
145
|
+
INCALL_CONNECT_EVENT: string;
|
|
146
|
+
SIP_CONNECT_EVENT: string;
|
|
148
147
|
SIP_REGISTERER_EVENT: string;
|
|
149
148
|
SIP_SESSION_EVENT: string;
|
|
150
149
|
};
|
|
@@ -173,6 +172,14 @@ declare const SocketSendEvent: {
|
|
|
173
172
|
* Unhold
|
|
174
173
|
*/
|
|
175
174
|
UNHOLD: string;
|
|
175
|
+
/**
|
|
176
|
+
* Mute
|
|
177
|
+
*/
|
|
178
|
+
MUTE: string;
|
|
179
|
+
/**
|
|
180
|
+
* Unmute
|
|
181
|
+
*/
|
|
182
|
+
UNMUTE: string;
|
|
176
183
|
/**
|
|
177
184
|
* Call
|
|
178
185
|
*/
|
|
@@ -249,6 +256,7 @@ declare class Socket {
|
|
|
249
256
|
private reconnectTimer?;
|
|
250
257
|
private isReconnecting;
|
|
251
258
|
private reconnectAttempts;
|
|
259
|
+
private socketError;
|
|
252
260
|
constructor(callKit: CallKit);
|
|
253
261
|
init(): void;
|
|
254
262
|
private handleDisconnect;
|
|
@@ -264,8 +272,7 @@ declare class Socket {
|
|
|
264
272
|
private ping;
|
|
265
273
|
private checkPing;
|
|
266
274
|
/**
|
|
267
|
-
*
|
|
268
|
-
* @param isWaitConfirm Whether need to wait for close confirmation
|
|
275
|
+
* reset socket connection and all states
|
|
269
276
|
*/
|
|
270
277
|
reset(): Promise<void>;
|
|
271
278
|
private attemptReconnect;
|
|
@@ -351,11 +358,15 @@ declare class Connect {
|
|
|
351
358
|
/**
|
|
352
359
|
* Whether muted
|
|
353
360
|
*/
|
|
354
|
-
isMute
|
|
361
|
+
private isMute;
|
|
355
362
|
/**
|
|
356
363
|
* Whether registered
|
|
357
364
|
*/
|
|
358
365
|
private isRegister;
|
|
366
|
+
/**
|
|
367
|
+
* Whether holding
|
|
368
|
+
*/
|
|
369
|
+
private isHold;
|
|
359
370
|
constructor(callKit: CallKit);
|
|
360
371
|
reset(): void;
|
|
361
372
|
private getAduioReference;
|
|
@@ -424,17 +435,8 @@ declare class Connect {
|
|
|
424
435
|
*/
|
|
425
436
|
getRemoteMediaStream(session: any): any;
|
|
426
437
|
setupRemoteMedia(session: any): void;
|
|
427
|
-
/**
|
|
428
|
-
* Update hold
|
|
429
|
-
* @param hold
|
|
430
|
-
*/
|
|
431
|
-
setHoldStatus(hold: boolean): void;
|
|
432
438
|
setHold(hold: boolean): Promise<void>;
|
|
433
|
-
hold(): Promise<void>;
|
|
434
|
-
unhold(): Promise<void>;
|
|
435
439
|
setMute(mute: boolean): Promise<void>;
|
|
436
|
-
mute(): Promise<void>;
|
|
437
|
-
unmute(): Promise<void>;
|
|
438
440
|
refer(referTo: string, extra?: any): Promise<void>;
|
|
439
441
|
}
|
|
440
442
|
|
|
@@ -477,6 +479,8 @@ declare class CallKit {
|
|
|
477
479
|
hangup(): Promise<void>;
|
|
478
480
|
hold(): void;
|
|
479
481
|
unhold(): void;
|
|
482
|
+
mute(): void;
|
|
483
|
+
unmute(): void;
|
|
480
484
|
/**
|
|
481
485
|
* set userstatus
|
|
482
486
|
* @param status
|
package/dist/index.global.js
CHANGED
|
@@ -3310,10 +3310,10 @@ var WebCall = (() => {
|
|
|
3310
3310
|
* Connecting
|
|
3311
3311
|
*/
|
|
3312
3312
|
connecting: 2,
|
|
3313
|
-
/**
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
holding: 3,
|
|
3313
|
+
// /**
|
|
3314
|
+
// * Call on hold
|
|
3315
|
+
// */
|
|
3316
|
+
// holding: 3,
|
|
3317
3317
|
/**
|
|
3318
3318
|
* Ringing
|
|
3319
3319
|
*/
|
|
@@ -3408,7 +3408,8 @@ var WebCall = (() => {
|
|
|
3408
3408
|
* User status change
|
|
3409
3409
|
*/
|
|
3410
3410
|
USER_STATUS_CHANGE: "userStatusChange",
|
|
3411
|
-
|
|
3411
|
+
INCALL_CONNECT_EVENT: "IncallConnectEvent",
|
|
3412
|
+
SIP_CONNECT_EVENT: "sipConnectEvent",
|
|
3412
3413
|
SIP_REGISTERER_EVENT: "sipRegistererEvent",
|
|
3413
3414
|
SIP_SESSION_EVENT: "sipSessionEvent"
|
|
3414
3415
|
};
|
|
@@ -3530,6 +3531,14 @@ var WebCall = (() => {
|
|
|
3530
3531
|
* Unhold
|
|
3531
3532
|
*/
|
|
3532
3533
|
UNHOLD: "AGENT_UN_HOLD",
|
|
3534
|
+
/**
|
|
3535
|
+
* Mute
|
|
3536
|
+
*/
|
|
3537
|
+
MUTE: "AGENT_MUTE",
|
|
3538
|
+
/**
|
|
3539
|
+
* Unmute
|
|
3540
|
+
*/
|
|
3541
|
+
UNMUTE: "AGENT_UN_MUTE",
|
|
3533
3542
|
/**
|
|
3534
3543
|
* Call
|
|
3535
3544
|
*/
|
|
@@ -3704,28 +3713,58 @@ var WebCall = (() => {
|
|
|
3704
3713
|
this.callKit.logger.warn("Current state cannot be held", {
|
|
3705
3714
|
caller: "Call.callHold",
|
|
3706
3715
|
content: {
|
|
3716
|
+
isHold: this.callKit.connect.isHolding(),
|
|
3707
3717
|
isCalling: this.callKit.connect.isCalling()
|
|
3708
3718
|
}
|
|
3709
3719
|
});
|
|
3710
3720
|
return;
|
|
3711
3721
|
}
|
|
3712
|
-
this.callKit.
|
|
3713
|
-
this.callKit.connect.setConnectStatus(CallStatus.holding);
|
|
3722
|
+
this.callKit.connect.setHold(true);
|
|
3714
3723
|
}
|
|
3715
3724
|
async callUnhold() {
|
|
3716
3725
|
if (!this.callKit.config.check())
|
|
3717
3726
|
return;
|
|
3718
|
-
if (!this.callKit.connect.
|
|
3727
|
+
if (!this.callKit.connect.isCalling()) {
|
|
3719
3728
|
this.callKit.logger.warn("Current state cannot unhold", {
|
|
3720
3729
|
caller: "Call.callUnhold",
|
|
3721
3730
|
content: {
|
|
3722
|
-
|
|
3731
|
+
isHold: this.callKit.connect.isHolding(),
|
|
3732
|
+
isCalling: this.callKit.connect.isCalling()
|
|
3733
|
+
}
|
|
3734
|
+
});
|
|
3735
|
+
return;
|
|
3736
|
+
}
|
|
3737
|
+
this.callKit.connect.setHold(false);
|
|
3738
|
+
}
|
|
3739
|
+
async callMute() {
|
|
3740
|
+
if (!this.callKit.config.check())
|
|
3741
|
+
return;
|
|
3742
|
+
if (!this.callKit.connect.isCalling()) {
|
|
3743
|
+
this.callKit.logger.warn("Current state cannot be muted", {
|
|
3744
|
+
caller: "Call.callMute",
|
|
3745
|
+
content: {
|
|
3746
|
+
isMuted: this.callKit.connect.isMuted(),
|
|
3747
|
+
isCalling: this.callKit.connect.isCalling()
|
|
3748
|
+
}
|
|
3749
|
+
});
|
|
3750
|
+
return;
|
|
3751
|
+
}
|
|
3752
|
+
this.callKit.connect.setMute(true);
|
|
3753
|
+
}
|
|
3754
|
+
async callUnmute() {
|
|
3755
|
+
if (!this.callKit.config.check())
|
|
3756
|
+
return;
|
|
3757
|
+
if (!this.callKit.connect.isCalling()) {
|
|
3758
|
+
this.callKit.logger.warn("Current state cannot be unmuted", {
|
|
3759
|
+
caller: "Call.callUnmute",
|
|
3760
|
+
content: {
|
|
3761
|
+
isMuted: this.callKit.connect.isMuted(),
|
|
3762
|
+
isCalling: this.callKit.connect.isCalling()
|
|
3723
3763
|
}
|
|
3724
3764
|
});
|
|
3725
3765
|
return;
|
|
3726
3766
|
}
|
|
3727
|
-
this.callKit.
|
|
3728
|
-
this.callKit.connect.setConnectStatus(CallStatus.calling);
|
|
3767
|
+
this.callKit.connect.setMute(false);
|
|
3729
3768
|
}
|
|
3730
3769
|
};
|
|
3731
3770
|
|
|
@@ -18433,6 +18472,10 @@ var WebCall = (() => {
|
|
|
18433
18472
|
* Whether registered
|
|
18434
18473
|
*/
|
|
18435
18474
|
isRegister = false;
|
|
18475
|
+
/**
|
|
18476
|
+
* Whether holding
|
|
18477
|
+
*/
|
|
18478
|
+
isHold = false;
|
|
18436
18479
|
constructor(callKit) {
|
|
18437
18480
|
this.callKit = callKit;
|
|
18438
18481
|
const { reconnect = {} } = this.callKit.config.getConfig();
|
|
@@ -18443,12 +18486,12 @@ var WebCall = (() => {
|
|
|
18443
18486
|
}
|
|
18444
18487
|
reset() {
|
|
18445
18488
|
if (this.isHolding()) {
|
|
18446
|
-
this.
|
|
18489
|
+
this.setHold(false);
|
|
18447
18490
|
}
|
|
18448
18491
|
if (this.connectStatus !== CallStatus.init) {
|
|
18449
18492
|
this.setConnectStatus(CallStatus.init);
|
|
18450
18493
|
}
|
|
18451
|
-
if (this.isRegistered) {
|
|
18494
|
+
if (this.isRegistered()) {
|
|
18452
18495
|
this.unregister();
|
|
18453
18496
|
}
|
|
18454
18497
|
this.currentSession = void 0;
|
|
@@ -18518,7 +18561,7 @@ var WebCall = (() => {
|
|
|
18518
18561
|
* isHolding
|
|
18519
18562
|
*/
|
|
18520
18563
|
isHolding() {
|
|
18521
|
-
return this.
|
|
18564
|
+
return this.isHold;
|
|
18522
18565
|
}
|
|
18523
18566
|
/**
|
|
18524
18567
|
* isRegistered
|
|
@@ -18552,7 +18595,7 @@ var WebCall = (() => {
|
|
|
18552
18595
|
this.heartbeatFlag -= 1;
|
|
18553
18596
|
if (this.heartbeatFlag <= 0) {
|
|
18554
18597
|
this.heartbeatFlag = MAX_HEARTBEAT_COUNT;
|
|
18555
|
-
this.callKit.trigger(KitEvent.
|
|
18598
|
+
this.callKit.trigger(KitEvent.SIP_CONNECT_EVENT, {
|
|
18556
18599
|
event: "OPTIONS_HEARTBEAT_EXPIRED"
|
|
18557
18600
|
});
|
|
18558
18601
|
}
|
|
@@ -18733,8 +18776,8 @@ var WebCall = (() => {
|
|
|
18733
18776
|
this.setRegister(false);
|
|
18734
18777
|
this.setConnectStatus(CallStatus.init);
|
|
18735
18778
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
18736
|
-
|
|
18737
|
-
|
|
18779
|
+
registererState: state,
|
|
18780
|
+
isRegistered: this.isRegistered()
|
|
18738
18781
|
});
|
|
18739
18782
|
break;
|
|
18740
18783
|
case RegistererState.Unregistered:
|
|
@@ -18749,8 +18792,8 @@ var WebCall = (() => {
|
|
|
18749
18792
|
this.setRegister(false);
|
|
18750
18793
|
this.setConnectStatus(CallStatus.init);
|
|
18751
18794
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
18752
|
-
|
|
18753
|
-
|
|
18795
|
+
registererState: state,
|
|
18796
|
+
isRegistered: this.isRegistered()
|
|
18754
18797
|
});
|
|
18755
18798
|
break;
|
|
18756
18799
|
default:
|
|
@@ -18841,7 +18884,6 @@ var WebCall = (() => {
|
|
|
18841
18884
|
};
|
|
18842
18885
|
if (this.isOutgoing) {
|
|
18843
18886
|
this.currentSession.accept(options);
|
|
18844
|
-
this.setConnectStatus(CallStatus.connecting);
|
|
18845
18887
|
this.callKit.trigger(KitEvent.KIT_OUTGOING_INVITE, {
|
|
18846
18888
|
getInviteData: () => {
|
|
18847
18889
|
const { request: request2 } = this.currentSession;
|
|
@@ -19205,133 +19247,102 @@ var WebCall = (() => {
|
|
|
19205
19247
|
});
|
|
19206
19248
|
}
|
|
19207
19249
|
}
|
|
19208
|
-
/**
|
|
19209
|
-
* Update hold
|
|
19210
|
-
* @param hold
|
|
19211
|
-
*/
|
|
19212
|
-
setHoldStatus(hold) {
|
|
19213
|
-
this.callKit.logger.info("connect setHold", {
|
|
19214
|
-
caller: "Connect.setHoldStatus",
|
|
19215
|
-
type: "SIP",
|
|
19216
|
-
content: {
|
|
19217
|
-
hold
|
|
19218
|
-
}
|
|
19219
|
-
});
|
|
19220
|
-
this.callKit.trigger(KitEvent.KIT_SET_HOLD, hold);
|
|
19221
|
-
}
|
|
19222
19250
|
async setHold(hold) {
|
|
19223
|
-
this.
|
|
19224
|
-
|
|
19225
|
-
|
|
19226
|
-
this.callKit.logger.info("connect hold", {
|
|
19227
|
-
caller: "Connect.hold",
|
|
19228
|
-
type: "SIP",
|
|
19229
|
-
content: {
|
|
19230
|
-
hold: true
|
|
19231
|
-
}
|
|
19232
|
-
});
|
|
19233
|
-
if (this.connectStatus !== CallStatus.calling || !this.currentSession) {
|
|
19234
|
-
this.callKit.logger.error("Current status is not in call", {
|
|
19235
|
-
caller: "Connect.hold",
|
|
19251
|
+
if (this.isHold === hold) {
|
|
19252
|
+
this.callKit.logger.warn("Already holding", {
|
|
19253
|
+
caller: "Connect.setHold",
|
|
19236
19254
|
type: "SIP",
|
|
19237
19255
|
content: {
|
|
19238
|
-
|
|
19256
|
+
isHold: this.isHold
|
|
19239
19257
|
}
|
|
19240
19258
|
});
|
|
19259
|
+
return;
|
|
19241
19260
|
}
|
|
19242
|
-
|
|
19243
|
-
|
|
19244
|
-
|
|
19245
|
-
|
|
19261
|
+
this.callKit.socket.send(
|
|
19262
|
+
hold ? SocketSendEvent.HOLD : SocketSendEvent.UNHOLD
|
|
19263
|
+
);
|
|
19264
|
+
this.isHold = hold;
|
|
19265
|
+
this.callKit.logger.info("connect setHold", {
|
|
19266
|
+
caller: "Connect.setHold",
|
|
19246
19267
|
type: "SIP",
|
|
19247
19268
|
content: {
|
|
19248
|
-
hold
|
|
19269
|
+
hold
|
|
19249
19270
|
}
|
|
19250
19271
|
});
|
|
19272
|
+
this.callKit.trigger(KitEvent.KIT_SET_HOLD, hold);
|
|
19251
19273
|
}
|
|
19274
|
+
// /**
|
|
19275
|
+
// * Set mute
|
|
19276
|
+
// * @param mute Whether to mute
|
|
19277
|
+
// * @deprecated just send socket event to server to mute or unmute
|
|
19278
|
+
// */
|
|
19279
|
+
// async setMute(mute: boolean) {
|
|
19280
|
+
// this.callKit.logger.info('connect setMute', {
|
|
19281
|
+
// caller: 'Connect.setMute',
|
|
19282
|
+
// type: 'SIP',
|
|
19283
|
+
// content: {
|
|
19284
|
+
// mute
|
|
19285
|
+
// }
|
|
19286
|
+
// });
|
|
19287
|
+
// if (!this.currentSession) {
|
|
19288
|
+
// this.callKit.logger.error('No active session', {
|
|
19289
|
+
// caller: 'Connect.setMute',
|
|
19290
|
+
// type: 'SIP',
|
|
19291
|
+
// content: {
|
|
19292
|
+
// errCode: ErrorCode.WEBRTC_MUTE_STATUS_ERROR
|
|
19293
|
+
// }
|
|
19294
|
+
// });
|
|
19295
|
+
// this.callKit.reset();
|
|
19296
|
+
// return;
|
|
19297
|
+
// }
|
|
19298
|
+
// try {
|
|
19299
|
+
// // Get SessionDescriptionHandler
|
|
19300
|
+
// const sdh = this.currentSession.sessionDescriptionHandler;
|
|
19301
|
+
// if (!sdh || !('peerConnection' in sdh)) {
|
|
19302
|
+
// throw new Error('Invalid session description handler');
|
|
19303
|
+
// }
|
|
19304
|
+
// // Get PeerConnection
|
|
19305
|
+
// const pc = (sdh as any).peerConnection as RTCPeerConnection;
|
|
19306
|
+
// // Get local audio track and set status
|
|
19307
|
+
// const audioSender = pc
|
|
19308
|
+
// .getSenders()
|
|
19309
|
+
// .find((sender) => sender.track?.kind === 'audio');
|
|
19310
|
+
// if (audioSender && audioSender.track) {
|
|
19311
|
+
// audioSender.track.enabled = !mute;
|
|
19312
|
+
// // Update status and trigger event
|
|
19313
|
+
// this.isMute = mute;
|
|
19314
|
+
// this.callKit.trigger(KitEvent.KIT_SET_MUTE, mute);
|
|
19315
|
+
// } else {
|
|
19316
|
+
// throw new Error('No audio track found');
|
|
19317
|
+
// }
|
|
19318
|
+
// } catch (error) {
|
|
19319
|
+
// this.callKit.logger.error('Failed to set mute state', {
|
|
19320
|
+
// caller: 'Connect.setMute',
|
|
19321
|
+
// type: 'SIP',
|
|
19322
|
+
// content: {
|
|
19323
|
+
// err: error.message,
|
|
19324
|
+
// errCode: ErrorCode.WEBRTC_MUTE_ERROR
|
|
19325
|
+
// }
|
|
19326
|
+
// });
|
|
19327
|
+
// }
|
|
19328
|
+
// }
|
|
19252
19329
|
async setMute(mute) {
|
|
19253
|
-
this.
|
|
19254
|
-
|
|
19255
|
-
type: "SIP",
|
|
19256
|
-
content: {
|
|
19257
|
-
mute
|
|
19258
|
-
}
|
|
19259
|
-
});
|
|
19260
|
-
if (!this.currentSession) {
|
|
19261
|
-
this.callKit.logger.error("No active session", {
|
|
19330
|
+
if (this.isMute === mute) {
|
|
19331
|
+
this.callKit.logger.warn("Already muted", {
|
|
19262
19332
|
caller: "Connect.setMute",
|
|
19263
19333
|
type: "SIP",
|
|
19264
19334
|
content: {
|
|
19265
|
-
|
|
19266
|
-
|
|
19267
|
-
});
|
|
19268
|
-
this.callKit.reset();
|
|
19269
|
-
return;
|
|
19270
|
-
}
|
|
19271
|
-
try {
|
|
19272
|
-
const sdh = this.currentSession.sessionDescriptionHandler;
|
|
19273
|
-
if (!sdh || !("peerConnection" in sdh)) {
|
|
19274
|
-
throw new Error("Invalid session description handler");
|
|
19275
|
-
}
|
|
19276
|
-
const pc = sdh.peerConnection;
|
|
19277
|
-
const audioSender = pc.getSenders().find((sender) => sender.track?.kind === "audio");
|
|
19278
|
-
if (audioSender && audioSender.track) {
|
|
19279
|
-
audioSender.track.enabled = !mute;
|
|
19280
|
-
this.isMute = mute;
|
|
19281
|
-
this.callKit.trigger(KitEvent.KIT_SET_MUTE, mute);
|
|
19282
|
-
} else {
|
|
19283
|
-
throw new Error("No audio track found");
|
|
19284
|
-
}
|
|
19285
|
-
} catch (error) {
|
|
19286
|
-
this.callKit.logger.error("Failed to set mute state", {
|
|
19287
|
-
caller: "Connect.setMute",
|
|
19288
|
-
type: "SIP",
|
|
19289
|
-
content: {
|
|
19290
|
-
err: error.message,
|
|
19291
|
-
errCode: ErrorCode.WEBRTC_MUTE_ERROR
|
|
19292
|
-
}
|
|
19293
|
-
});
|
|
19294
|
-
}
|
|
19295
|
-
}
|
|
19296
|
-
async mute() {
|
|
19297
|
-
this.callKit.logger.info("connect mute", {
|
|
19298
|
-
caller: "Connect.mute",
|
|
19299
|
-
type: "SIP",
|
|
19300
|
-
content: {
|
|
19301
|
-
mute: true
|
|
19302
|
-
}
|
|
19303
|
-
});
|
|
19304
|
-
if (this.connectStatus !== CallStatus.calling || !this.currentSession) {
|
|
19305
|
-
this.callKit.logger.warn("Current status is not in call", {
|
|
19306
|
-
caller: "Connect.mute",
|
|
19307
|
-
type: "SIP",
|
|
19308
|
-
content: {
|
|
19309
|
-
errCode: ErrorCode.WEBRTC_MUTE_STATUS_ERROR
|
|
19310
|
-
}
|
|
19311
|
-
});
|
|
19312
|
-
return;
|
|
19313
|
-
}
|
|
19314
|
-
await this.setMute(true);
|
|
19315
|
-
}
|
|
19316
|
-
async unmute() {
|
|
19317
|
-
this.callKit.logger.info("connect unmute", {
|
|
19318
|
-
caller: "Connect.unmute",
|
|
19319
|
-
type: "SIP",
|
|
19320
|
-
content: {
|
|
19321
|
-
mute: false
|
|
19322
|
-
}
|
|
19323
|
-
});
|
|
19324
|
-
if (this.connectStatus !== CallStatus.calling || !this.currentSession) {
|
|
19325
|
-
this.callKit.logger.warn("Current status is not in call", {
|
|
19326
|
-
caller: "Connect.unmute",
|
|
19327
|
-
type: "SIP",
|
|
19328
|
-
content: {
|
|
19329
|
-
errCode: ErrorCode.WEBRTC_MUTE_STATUS_ERROR
|
|
19335
|
+
isCalling: this.isCalling(),
|
|
19336
|
+
isMuted: this.isMuted()
|
|
19330
19337
|
}
|
|
19331
19338
|
});
|
|
19332
19339
|
return;
|
|
19333
19340
|
}
|
|
19334
|
-
|
|
19341
|
+
this.callKit.socket.send(
|
|
19342
|
+
mute ? SocketSendEvent.MUTE : SocketSendEvent.UNMUTE
|
|
19343
|
+
);
|
|
19344
|
+
this.isMute = mute;
|
|
19345
|
+
this.callKit.trigger(KitEvent.KIT_SET_MUTE, mute);
|
|
19335
19346
|
}
|
|
19336
19347
|
async refer(referTo, extra) {
|
|
19337
19348
|
this.callKit.logger.info("connect refer", {
|
|
@@ -19353,7 +19364,7 @@ var WebCall = (() => {
|
|
|
19353
19364
|
// package/socket.ts
|
|
19354
19365
|
var RECONNECT_CONFIG = {
|
|
19355
19366
|
enabled: true,
|
|
19356
|
-
maxAttempts:
|
|
19367
|
+
maxAttempts: 3,
|
|
19357
19368
|
delay: 500,
|
|
19358
19369
|
backoffMultiplier: 1.5,
|
|
19359
19370
|
pingInterval: 3e4,
|
|
@@ -19371,6 +19382,7 @@ var WebCall = (() => {
|
|
|
19371
19382
|
reconnectTimer;
|
|
19372
19383
|
isReconnecting = false;
|
|
19373
19384
|
reconnectAttempts = 0;
|
|
19385
|
+
socketError = false;
|
|
19374
19386
|
constructor(callKit) {
|
|
19375
19387
|
this.callKit = callKit;
|
|
19376
19388
|
const { reconnect } = this.callKit.config.getConfig();
|
|
@@ -19394,7 +19406,7 @@ var WebCall = (() => {
|
|
|
19394
19406
|
this.isConnected = false;
|
|
19395
19407
|
if (!this.callKit.config.isLogin() || !this.socketConfig.enabled) {
|
|
19396
19408
|
this.reset();
|
|
19397
|
-
this.callKit.trigger(KitEvent.
|
|
19409
|
+
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
19398
19410
|
event: "INCALL_NOT_CONNECTED"
|
|
19399
19411
|
});
|
|
19400
19412
|
return;
|
|
@@ -19414,6 +19426,7 @@ var WebCall = (() => {
|
|
|
19414
19426
|
type: "INCALL",
|
|
19415
19427
|
content: { ev }
|
|
19416
19428
|
});
|
|
19429
|
+
this.socketError = false;
|
|
19417
19430
|
this.isConnected = true;
|
|
19418
19431
|
this.lastPingTime = Date.now();
|
|
19419
19432
|
this.checkPing();
|
|
@@ -19426,7 +19439,7 @@ var WebCall = (() => {
|
|
|
19426
19439
|
reconnectAttempts: this.reconnectAttempts
|
|
19427
19440
|
}
|
|
19428
19441
|
});
|
|
19429
|
-
this.callKit.trigger(KitEvent.
|
|
19442
|
+
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
19430
19443
|
event: "INCALL_RECONNECT_SUCCESS"
|
|
19431
19444
|
});
|
|
19432
19445
|
}
|
|
@@ -19446,10 +19459,13 @@ var WebCall = (() => {
|
|
|
19446
19459
|
type: "INCALL",
|
|
19447
19460
|
content: { ev }
|
|
19448
19461
|
});
|
|
19449
|
-
this.callKit.trigger(KitEvent.
|
|
19462
|
+
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
19450
19463
|
event: "INCALL_CONNECT_ERROR",
|
|
19451
19464
|
err: ev
|
|
19452
19465
|
});
|
|
19466
|
+
if (this.socketError) {
|
|
19467
|
+
return;
|
|
19468
|
+
}
|
|
19453
19469
|
this.handleDisconnect();
|
|
19454
19470
|
}
|
|
19455
19471
|
onError(ev) {
|
|
@@ -19461,6 +19477,7 @@ var WebCall = (() => {
|
|
|
19461
19477
|
data: ev
|
|
19462
19478
|
}
|
|
19463
19479
|
});
|
|
19480
|
+
this.socketError = true;
|
|
19464
19481
|
}
|
|
19465
19482
|
confirmAck(data) {
|
|
19466
19483
|
const { ack, messageId } = data;
|
|
@@ -19618,7 +19635,7 @@ var WebCall = (() => {
|
|
|
19618
19635
|
}
|
|
19619
19636
|
send(event, message) {
|
|
19620
19637
|
if (!this.isConnected) {
|
|
19621
|
-
this.callKit.trigger(KitEvent.
|
|
19638
|
+
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
19622
19639
|
event: "INCALL_NOT_CONNECTED"
|
|
19623
19640
|
});
|
|
19624
19641
|
this.callKit.logger.error("socket not connected", {
|
|
@@ -19677,7 +19694,7 @@ var WebCall = (() => {
|
|
|
19677
19694
|
}
|
|
19678
19695
|
async sendMessage(event, message) {
|
|
19679
19696
|
if (!this.isConnected) {
|
|
19680
|
-
this.callKit.trigger(KitEvent.
|
|
19697
|
+
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
19681
19698
|
event: "INCALL_NOT_CONNECTED"
|
|
19682
19699
|
});
|
|
19683
19700
|
this.callKit.logger.error("socket not connected", {
|
|
@@ -19731,8 +19748,7 @@ var WebCall = (() => {
|
|
|
19731
19748
|
}, this.socketConfig.pingInterval);
|
|
19732
19749
|
}
|
|
19733
19750
|
/**
|
|
19734
|
-
*
|
|
19735
|
-
* @param isWaitConfirm Whether need to wait for close confirmation
|
|
19751
|
+
* reset socket connection and all states
|
|
19736
19752
|
*/
|
|
19737
19753
|
async reset() {
|
|
19738
19754
|
if (this.pingTimer) {
|
|
@@ -19742,6 +19758,7 @@ var WebCall = (() => {
|
|
|
19742
19758
|
this.resetReconnectState();
|
|
19743
19759
|
this.lastPingTime = void 0;
|
|
19744
19760
|
this.satrtConfirm = false;
|
|
19761
|
+
this.socketError = false;
|
|
19745
19762
|
if (this.ws && this.isConnected) {
|
|
19746
19763
|
this.callKit.logger.info("Closing socket connection", {
|
|
19747
19764
|
caller: "Socket.reset",
|
|
@@ -19762,14 +19779,14 @@ var WebCall = (() => {
|
|
|
19762
19779
|
reconnectAttempts: this.reconnectAttempts
|
|
19763
19780
|
}
|
|
19764
19781
|
});
|
|
19765
|
-
this.callKit.trigger(KitEvent.
|
|
19782
|
+
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
19766
19783
|
event: "INCALL_RECONNECT_ERROR"
|
|
19767
19784
|
});
|
|
19768
19785
|
this.reset();
|
|
19769
19786
|
return;
|
|
19770
19787
|
}
|
|
19771
19788
|
if (this.reconnectAttempts === 0) {
|
|
19772
|
-
this.callKit.trigger(KitEvent.
|
|
19789
|
+
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
19773
19790
|
event: "INCALL_RECONNECT_START"
|
|
19774
19791
|
});
|
|
19775
19792
|
}
|
|
@@ -20031,6 +20048,28 @@ var WebCall = (() => {
|
|
|
20031
20048
|
});
|
|
20032
20049
|
this.callCenter.callUnhold();
|
|
20033
20050
|
}
|
|
20051
|
+
mute() {
|
|
20052
|
+
if (!this.config.check())
|
|
20053
|
+
return;
|
|
20054
|
+
this.logger.info("mute", {
|
|
20055
|
+
caller: "CallKit.mute",
|
|
20056
|
+
content: {
|
|
20057
|
+
connectStatus: this.connect.connectStatus
|
|
20058
|
+
}
|
|
20059
|
+
});
|
|
20060
|
+
this.callCenter.callMute();
|
|
20061
|
+
}
|
|
20062
|
+
unmute() {
|
|
20063
|
+
if (!this.config.check())
|
|
20064
|
+
return;
|
|
20065
|
+
this.logger.info("unmute", {
|
|
20066
|
+
caller: "CallKit.unmute",
|
|
20067
|
+
content: {
|
|
20068
|
+
connectStatus: this.connect.connectStatus
|
|
20069
|
+
}
|
|
20070
|
+
});
|
|
20071
|
+
this.callCenter.callUnmute();
|
|
20072
|
+
}
|
|
20034
20073
|
/**
|
|
20035
20074
|
* set userstatus
|
|
20036
20075
|
* @param status
|