@wazo/sdk 0.37.31 → 0.37.35
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/wazo-sdk.js +2 -2
- package/esm/__tests__/api-client.test.js +41 -0
- package/esm/__tests__/web-rtc-client.test.js +68 -6
- package/esm/api/auth.js +5 -0
- package/esm/api/call-logd.js +6 -0
- package/esm/api/calld.js +30 -0
- package/esm/api-client.js +41 -0
- package/esm/checker/Checker.js +68 -6
- package/esm/checker/checks/aor.js +41 -0
- package/esm/checker/checks/api.js +41 -0
- package/esm/checker/checks/index.js +68 -6
- package/esm/checker/checks/webrtc-transport.js +68 -6
- package/esm/checker/checks/webrtc.js +68 -6
- package/esm/domain/AdHocAPIConference.js +41 -0
- package/esm/domain/CallLog.js +6 -0
- package/esm/domain/CallSession.js +8 -0
- package/esm/domain/Features.js +41 -0
- package/esm/domain/MeetingStatus.js +29 -0
- package/esm/domain/Phone/CTIPhone.js +49 -0
- package/esm/domain/Phone/WebRTCPhone.js +33 -6
- package/esm/domain/__tests__/CallLog.test.js +6 -0
- package/esm/domain/__tests__/CallSession.test.js +40 -4
- package/esm/domain/__tests__/IndirectTransfer.test.js +8 -0
- package/esm/domain/__tests__/Room.test.js +8 -0
- package/esm/index.js +101 -12
- package/esm/service/CallApi.js +41 -0
- package/esm/service/getApiClient.js +41 -0
- package/esm/simple/Auth.js +101 -12
- package/esm/simple/Configuration.js +101 -12
- package/esm/simple/Directory.js +41 -0
- package/esm/simple/Phone.js +101 -12
- package/esm/simple/index.js +101 -12
- package/esm/simple/room/LocalParticipant.js +101 -12
- package/esm/simple/room/Participant.js +101 -12
- package/esm/simple/room/RemoteParticipant.js +101 -12
- package/esm/simple/room/Room.js +101 -12
- package/esm/simple/room/SipRoom.js +101 -12
- package/esm/simple/room/Stream.js +101 -12
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +101 -12
- package/esm/simple/utils.js +101 -12
- package/esm/web-rtc-client.js +68 -6
- package/lib/__tests__/api-client.test.js +41 -0
- package/lib/__tests__/web-rtc-client.test.js +68 -6
- package/lib/api/auth.js +5 -0
- package/lib/api/call-logd.js +6 -0
- package/lib/api/calld.js +30 -0
- package/lib/api-client.js +41 -0
- package/lib/checker/Checker.js +68 -6
- package/lib/checker/checks/aor.js +41 -0
- package/lib/checker/checks/api.js +41 -0
- package/lib/checker/checks/index.js +68 -6
- package/lib/checker/checks/webrtc-transport.js +68 -6
- package/lib/checker/checks/webrtc.js +68 -6
- package/lib/domain/AdHocAPIConference.js +41 -0
- package/lib/domain/CallLog.js +6 -0
- package/lib/domain/CallSession.js +8 -0
- package/lib/domain/Features.js +41 -0
- package/lib/domain/MeetingStatus.js +31 -0
- package/lib/domain/Phone/CTIPhone.js +49 -0
- package/lib/domain/Phone/WebRTCPhone.js +33 -6
- package/lib/domain/__tests__/CallLog.test.js +6 -0
- package/lib/domain/__tests__/CallSession.test.js +40 -4
- package/lib/domain/__tests__/IndirectTransfer.test.js +8 -0
- package/lib/domain/__tests__/Room.test.js +8 -0
- package/lib/index.js +101 -12
- package/lib/service/CallApi.js +41 -0
- package/lib/service/getApiClient.js +41 -0
- package/lib/simple/Auth.js +101 -12
- package/lib/simple/Configuration.js +101 -12
- package/lib/simple/Directory.js +41 -0
- package/lib/simple/Phone.js +101 -12
- package/lib/simple/index.js +101 -12
- package/lib/simple/room/LocalParticipant.js +101 -12
- package/lib/simple/room/Participant.js +101 -12
- package/lib/simple/room/RemoteParticipant.js +101 -12
- package/lib/simple/room/Room.js +101 -12
- package/lib/simple/room/SipRoom.js +101 -12
- package/lib/simple/room/Stream.js +101 -12
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +101 -12
- package/lib/simple/utils.js +101 -12
- package/lib/web-rtc-client.js +68 -6
- package/package.json +1 -1
- package/src/api/auth.js +5 -0
- package/src/api/calld.js +3 -0
- package/src/domain/CallLog.js +6 -0
- package/src/domain/CallSession.js +8 -0
- package/src/domain/MeetingStatus.js +27 -0
- package/src/domain/Phone/WebRTCPhone.js +25 -6
- package/src/domain/__tests__/CallSession.test.js +32 -4
- package/src/web-rtc-client.js +27 -6
package/esm/simple/Phone.js
CHANGED
|
@@ -591,6 +591,14 @@ class CallSession {
|
|
|
591
591
|
return !!this.answerTime;
|
|
592
592
|
}
|
|
593
593
|
|
|
594
|
+
toJSON() {
|
|
595
|
+
const jsonObj = { ...this };
|
|
596
|
+
// $FlowFixMe
|
|
597
|
+
jsonObj.answered = this.answered;
|
|
598
|
+
|
|
599
|
+
return jsonObj;
|
|
600
|
+
}
|
|
601
|
+
|
|
594
602
|
static parseCall(call ) {
|
|
595
603
|
return new CallSession({
|
|
596
604
|
callId: call.id,
|
|
@@ -2797,6 +2805,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2797
2805
|
|
|
2798
2806
|
|
|
2799
2807
|
|
|
2808
|
+
|
|
2800
2809
|
) {
|
|
2801
2810
|
const body = {
|
|
2802
2811
|
backend: params.backend || DEFAULT_BACKEND_USER,
|
|
@@ -2816,6 +2825,10 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2816
2825
|
headers['Wazo-Session-Type'] = 'mobile';
|
|
2817
2826
|
}
|
|
2818
2827
|
|
|
2828
|
+
if (params.tenantId) {
|
|
2829
|
+
body.tenant_id = params.tenantId;
|
|
2830
|
+
}
|
|
2831
|
+
|
|
2819
2832
|
return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
|
|
2820
2833
|
},
|
|
2821
2834
|
|
|
@@ -3701,11 +3714,13 @@ class Recording {
|
|
|
3701
3714
|
|
|
3702
3715
|
|
|
3703
3716
|
|
|
3717
|
+
|
|
3704
3718
|
|
|
3705
3719
|
|
|
3706
3720
|
|
|
3707
3721
|
|
|
3708
3722
|
|
|
3723
|
+
|
|
3709
3724
|
|
|
3710
3725
|
|
|
3711
3726
|
|
|
@@ -3726,10 +3741,12 @@ class Recording {
|
|
|
3726
3741
|
|
|
3727
3742
|
|
|
3728
3743
|
|
|
3744
|
+
|
|
3729
3745
|
|
|
3730
3746
|
|
|
3731
3747
|
|
|
3732
3748
|
|
|
3749
|
+
|
|
3733
3750
|
|
|
3734
3751
|
|
|
3735
3752
|
|
|
@@ -3791,10 +3808,12 @@ class CallLog {
|
|
|
3791
3808
|
|| plain.destination_extension
|
|
3792
3809
|
|| `meeting-${plain.requested_name || plain.destination_name || ''}`,
|
|
3793
3810
|
name: plain.requested_name || plain.destination_name || '',
|
|
3811
|
+
uuid: plain.destination_user_uuid,
|
|
3794
3812
|
},
|
|
3795
3813
|
source: {
|
|
3796
3814
|
extension: plain.source_extension,
|
|
3797
3815
|
name: plain.source_name,
|
|
3816
|
+
uuid: plain.source_user_uuid,
|
|
3798
3817
|
},
|
|
3799
3818
|
id: plain.id,
|
|
3800
3819
|
duration: (plain.duration || 0) * 1000, // duration is in seconds
|
|
@@ -4842,6 +4861,34 @@ var chatdMethods = (client , baseUrl ) => ({
|
|
|
4842
4861
|
client.get(`${baseUrl}/users/me/rooms/messages`, options),
|
|
4843
4862
|
});
|
|
4844
4863
|
|
|
4864
|
+
//
|
|
4865
|
+
|
|
4866
|
+
|
|
4867
|
+
|
|
4868
|
+
|
|
4869
|
+
|
|
4870
|
+
class MeetingStatus {
|
|
4871
|
+
|
|
4872
|
+
|
|
4873
|
+
|
|
4874
|
+
|
|
4875
|
+
constructor({
|
|
4876
|
+
full,
|
|
4877
|
+
} = {}) {
|
|
4878
|
+
this.full = full;
|
|
4879
|
+
|
|
4880
|
+
// Useful to compare instead of instanceof with minified code
|
|
4881
|
+
this.type = 'MeetingStatus';
|
|
4882
|
+
}
|
|
4883
|
+
|
|
4884
|
+
static parse(plain ) {
|
|
4885
|
+
return new MeetingStatus({
|
|
4886
|
+
full: plain.full,
|
|
4887
|
+
});
|
|
4888
|
+
}
|
|
4889
|
+
|
|
4890
|
+
}
|
|
4891
|
+
|
|
4845
4892
|
/* */
|
|
4846
4893
|
|
|
4847
4894
|
|
|
@@ -5036,6 +5083,8 @@ var calldMethods = (client , baseUrl ) => ({
|
|
|
5036
5083
|
client.put(`${baseUrl}/users/me/calls/${callId}/record/resume`, null, null,
|
|
5037
5084
|
ApiRequester.successResponseParser),
|
|
5038
5085
|
|
|
5086
|
+
guestGetMeetingStatus: (meetingUuid ) =>
|
|
5087
|
+
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}/status`).then(MeetingStatus.parse),
|
|
5039
5088
|
});
|
|
5040
5089
|
|
|
5041
5090
|
//
|
|
@@ -6361,7 +6410,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
|
6361
6410
|
const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
6362
6411
|
class CanceledCallError extends Error {}
|
|
6363
6412
|
|
|
6364
|
-
const MAX_REGISTER_TRIES =
|
|
6413
|
+
const MAX_REGISTER_TRIES = 5;
|
|
6365
6414
|
|
|
6366
6415
|
|
|
6367
6416
|
|
|
@@ -6415,6 +6464,7 @@ class WebRTCClient extends Emitter {
|
|
|
6415
6464
|
|
|
6416
6465
|
|
|
6417
6466
|
|
|
6467
|
+
|
|
6418
6468
|
|
|
6419
6469
|
// sugar
|
|
6420
6470
|
|
|
@@ -6477,6 +6527,7 @@ class WebRTCClient extends Emitter {
|
|
|
6477
6527
|
this.conferences = {};
|
|
6478
6528
|
this.networkMonitoringInterval = {};
|
|
6479
6529
|
this.sessionNetworkStats = {};
|
|
6530
|
+
this.forceClosed = false;
|
|
6480
6531
|
|
|
6481
6532
|
this._boundOnHeartbeat = this._onHeartbeat.bind(this);
|
|
6482
6533
|
this.heartbeat = new Heartbeat(config.heartbeatDelay, config.heartbeatTimeout, config.maxHeartbeats);
|
|
@@ -6598,6 +6649,8 @@ class WebRTCClient extends Emitter {
|
|
|
6598
6649
|
skipRegister: this.skipRegister,
|
|
6599
6650
|
};
|
|
6600
6651
|
|
|
6652
|
+
this.forceClosed = false;
|
|
6653
|
+
|
|
6601
6654
|
if (this.skipRegister) {
|
|
6602
6655
|
logger$9.info('sdk webrtc skip register...', logInfo);
|
|
6603
6656
|
return Promise.resolve();
|
|
@@ -6622,7 +6675,15 @@ class WebRTCClient extends Emitter {
|
|
|
6622
6675
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6623
6676
|
|
|
6624
6677
|
const onRegisterFailed = () => {
|
|
6625
|
-
logger$9.info('sdk webrtc registering failed', {
|
|
6678
|
+
logger$9.info('sdk webrtc registering failed', {
|
|
6679
|
+
tries,
|
|
6680
|
+
registerer: !!this.registerer,
|
|
6681
|
+
forceClosed: this.forceClosed,
|
|
6682
|
+
});
|
|
6683
|
+
if (this.forceClosed) {
|
|
6684
|
+
return;
|
|
6685
|
+
}
|
|
6686
|
+
|
|
6626
6687
|
this.connectionPromise = null;
|
|
6627
6688
|
if (this.registerer && this.registerer.waiting) {
|
|
6628
6689
|
this.registerer.waitingToggle(false);
|
|
@@ -6900,8 +6961,9 @@ class WebRTCClient extends Emitter {
|
|
|
6900
6961
|
}
|
|
6901
6962
|
}
|
|
6902
6963
|
|
|
6903
|
-
async close() {
|
|
6904
|
-
logger$9.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
6964
|
+
async close(force = false) {
|
|
6965
|
+
logger$9.info('sdk webrtc closing client', { userAgent: !!this.userAgent, force });
|
|
6966
|
+
this.forceClosed = force;
|
|
6905
6967
|
this._cleanupMedia();
|
|
6906
6968
|
this.connectionPromise = null;
|
|
6907
6969
|
|
|
@@ -6920,7 +6982,7 @@ class WebRTCClient extends Emitter {
|
|
|
6920
6982
|
this.userAgent.delegate = null;
|
|
6921
6983
|
this.userAgent.stateChange.removeAllListeners();
|
|
6922
6984
|
|
|
6923
|
-
await this._disconnectTransport();
|
|
6985
|
+
await this._disconnectTransport(force);
|
|
6924
6986
|
|
|
6925
6987
|
this._cleanupRegister();
|
|
6926
6988
|
|
|
@@ -8356,7 +8418,15 @@ class WebRTCClient extends Emitter {
|
|
|
8356
8418
|
return UserAgent.makeURI(`sip:${target}@${this.config.host}`);
|
|
8357
8419
|
}
|
|
8358
8420
|
|
|
8359
|
-
async _disconnectTransport() {
|
|
8421
|
+
async _disconnectTransport(force = false) {
|
|
8422
|
+
if (force) {
|
|
8423
|
+
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
8424
|
+
this.userAgent.transport.disconnectResolve = () => {};
|
|
8425
|
+
// eslint-disable-next-line
|
|
8426
|
+
this.userAgent.transport._ws.close(1000);
|
|
8427
|
+
return;
|
|
8428
|
+
}
|
|
8429
|
+
|
|
8360
8430
|
// Check if `disconnectPromise` is not present to avoid `Disconnect promise must not be defined` errors.
|
|
8361
8431
|
if (this.userAgent && this.userAgent.transport && !this.userAgent.transport.disconnectPromise) {
|
|
8362
8432
|
try {
|
|
@@ -9303,6 +9373,12 @@ class WebRTCPhone extends Emitter {
|
|
|
9303
9373
|
return Promise.resolve(null);
|
|
9304
9374
|
}
|
|
9305
9375
|
|
|
9376
|
+
const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
|
|
9377
|
+
if (sipSessionId && !(sipSessionId in this.callSessions)) {
|
|
9378
|
+
logger$8.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
|
|
9379
|
+
return Promise.resolve(null);
|
|
9380
|
+
}
|
|
9381
|
+
|
|
9306
9382
|
if (callSession.getId() in this.acceptedSessions) {
|
|
9307
9383
|
logger$8.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9308
9384
|
return Promise.resolve(callSession.sipCallId);
|
|
@@ -9763,7 +9839,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9763
9839
|
return this.client && this.client.isConference(callSession.sipCallId);
|
|
9764
9840
|
}
|
|
9765
9841
|
|
|
9766
|
-
async close() {
|
|
9842
|
+
async close(force = false) {
|
|
9767
9843
|
logger$8.info('WebRTC close');
|
|
9768
9844
|
|
|
9769
9845
|
try {
|
|
@@ -9775,7 +9851,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9775
9851
|
logger$8.error('WebRTC close, unregister error', e);
|
|
9776
9852
|
}
|
|
9777
9853
|
|
|
9778
|
-
this.client.close();
|
|
9854
|
+
this.client.close(force);
|
|
9779
9855
|
this.unbind();
|
|
9780
9856
|
|
|
9781
9857
|
this.incomingSessions = [];
|
|
@@ -9927,9 +10003,17 @@ class WebRTCPhone extends Emitter {
|
|
|
9927
10003
|
});
|
|
9928
10004
|
|
|
9929
10005
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
9930
|
-
|
|
10006
|
+
const sessionId = this.getSipSessionId(sipSession);
|
|
10007
|
+
const hasSession = sessionId in this.callSessions;
|
|
10008
|
+
|
|
10009
|
+
logger$8.info('WebRTC call accepted', { sipId: sessionId, hasSession });
|
|
10010
|
+
|
|
10011
|
+
if (!hasSession) {
|
|
10012
|
+
logger$8.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
|
|
10013
|
+
return;
|
|
10014
|
+
}
|
|
9931
10015
|
|
|
9932
|
-
this._onCallAccepted(sipSession, this.client.hasVideo(
|
|
10016
|
+
this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
|
|
9933
10017
|
|
|
9934
10018
|
if (this.audioOutputDeviceId) {
|
|
9935
10019
|
this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
|
|
@@ -10065,9 +10149,14 @@ class WebRTCPhone extends Emitter {
|
|
|
10065
10149
|
return this.client.getSipSessionId(sipSession);
|
|
10066
10150
|
}
|
|
10067
10151
|
|
|
10068
|
-
|
|
10152
|
+
getSipSessionIdFromCallSession(callSession ) {
|
|
10069
10153
|
const sipSession = this.findSipSession(callSession);
|
|
10070
|
-
|
|
10154
|
+
|
|
10155
|
+
return sipSession ? this.getSipSessionId(sipSession) : null;
|
|
10156
|
+
}
|
|
10157
|
+
|
|
10158
|
+
_updateCallSession(callSession ) {
|
|
10159
|
+
const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
|
|
10071
10160
|
|
|
10072
10161
|
if (sipSessionId) {
|
|
10073
10162
|
this.callSessions[sipSessionId] = callSession;
|
package/esm/simple/index.js
CHANGED
|
@@ -2216,6 +2216,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2216
2216
|
|
|
2217
2217
|
|
|
2218
2218
|
|
|
2219
|
+
|
|
2219
2220
|
) {
|
|
2220
2221
|
const body = {
|
|
2221
2222
|
backend: params.backend || DEFAULT_BACKEND_USER,
|
|
@@ -2235,6 +2236,10 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2235
2236
|
headers['Wazo-Session-Type'] = 'mobile';
|
|
2236
2237
|
}
|
|
2237
2238
|
|
|
2239
|
+
if (params.tenantId) {
|
|
2240
|
+
body.tenant_id = params.tenantId;
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2238
2243
|
return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
|
|
2239
2244
|
},
|
|
2240
2245
|
|
|
@@ -3591,6 +3596,14 @@ class CallSession {
|
|
|
3591
3596
|
return !!this.answerTime;
|
|
3592
3597
|
}
|
|
3593
3598
|
|
|
3599
|
+
toJSON() {
|
|
3600
|
+
const jsonObj = { ...this };
|
|
3601
|
+
// $FlowFixMe
|
|
3602
|
+
jsonObj.answered = this.answered;
|
|
3603
|
+
|
|
3604
|
+
return jsonObj;
|
|
3605
|
+
}
|
|
3606
|
+
|
|
3594
3607
|
static parseCall(call ) {
|
|
3595
3608
|
return new CallSession({
|
|
3596
3609
|
callId: call.id,
|
|
@@ -3701,11 +3714,13 @@ class Recording {
|
|
|
3701
3714
|
|
|
3702
3715
|
|
|
3703
3716
|
|
|
3717
|
+
|
|
3704
3718
|
|
|
3705
3719
|
|
|
3706
3720
|
|
|
3707
3721
|
|
|
3708
3722
|
|
|
3723
|
+
|
|
3709
3724
|
|
|
3710
3725
|
|
|
3711
3726
|
|
|
@@ -3726,10 +3741,12 @@ class Recording {
|
|
|
3726
3741
|
|
|
3727
3742
|
|
|
3728
3743
|
|
|
3744
|
+
|
|
3729
3745
|
|
|
3730
3746
|
|
|
3731
3747
|
|
|
3732
3748
|
|
|
3749
|
+
|
|
3733
3750
|
|
|
3734
3751
|
|
|
3735
3752
|
|
|
@@ -3791,10 +3808,12 @@ class CallLog {
|
|
|
3791
3808
|
|| plain.destination_extension
|
|
3792
3809
|
|| `meeting-${plain.requested_name || plain.destination_name || ''}`,
|
|
3793
3810
|
name: plain.requested_name || plain.destination_name || '',
|
|
3811
|
+
uuid: plain.destination_user_uuid,
|
|
3794
3812
|
},
|
|
3795
3813
|
source: {
|
|
3796
3814
|
extension: plain.source_extension,
|
|
3797
3815
|
name: plain.source_name,
|
|
3816
|
+
uuid: plain.source_user_uuid,
|
|
3798
3817
|
},
|
|
3799
3818
|
id: plain.id,
|
|
3800
3819
|
duration: (plain.duration || 0) * 1000, // duration is in seconds
|
|
@@ -4842,6 +4861,34 @@ var chatdMethods = (client , baseUrl ) => ({
|
|
|
4842
4861
|
client.get(`${baseUrl}/users/me/rooms/messages`, options),
|
|
4843
4862
|
});
|
|
4844
4863
|
|
|
4864
|
+
//
|
|
4865
|
+
|
|
4866
|
+
|
|
4867
|
+
|
|
4868
|
+
|
|
4869
|
+
|
|
4870
|
+
class MeetingStatus {
|
|
4871
|
+
|
|
4872
|
+
|
|
4873
|
+
|
|
4874
|
+
|
|
4875
|
+
constructor({
|
|
4876
|
+
full,
|
|
4877
|
+
} = {}) {
|
|
4878
|
+
this.full = full;
|
|
4879
|
+
|
|
4880
|
+
// Useful to compare instead of instanceof with minified code
|
|
4881
|
+
this.type = 'MeetingStatus';
|
|
4882
|
+
}
|
|
4883
|
+
|
|
4884
|
+
static parse(plain ) {
|
|
4885
|
+
return new MeetingStatus({
|
|
4886
|
+
full: plain.full,
|
|
4887
|
+
});
|
|
4888
|
+
}
|
|
4889
|
+
|
|
4890
|
+
}
|
|
4891
|
+
|
|
4845
4892
|
/* */
|
|
4846
4893
|
|
|
4847
4894
|
|
|
@@ -5036,6 +5083,8 @@ var calldMethods = (client , baseUrl ) => ({
|
|
|
5036
5083
|
client.put(`${baseUrl}/users/me/calls/${callId}/record/resume`, null, null,
|
|
5037
5084
|
ApiRequester.successResponseParser),
|
|
5038
5085
|
|
|
5086
|
+
guestGetMeetingStatus: (meetingUuid ) =>
|
|
5087
|
+
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}/status`).then(MeetingStatus.parse),
|
|
5039
5088
|
});
|
|
5040
5089
|
|
|
5041
5090
|
//
|
|
@@ -6625,7 +6674,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
|
6625
6674
|
const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
6626
6675
|
class CanceledCallError extends Error {}
|
|
6627
6676
|
|
|
6628
|
-
const MAX_REGISTER_TRIES =
|
|
6677
|
+
const MAX_REGISTER_TRIES = 5;
|
|
6629
6678
|
|
|
6630
6679
|
|
|
6631
6680
|
|
|
@@ -6679,6 +6728,7 @@ class WebRTCClient extends Emitter {
|
|
|
6679
6728
|
|
|
6680
6729
|
|
|
6681
6730
|
|
|
6731
|
+
|
|
6682
6732
|
|
|
6683
6733
|
// sugar
|
|
6684
6734
|
|
|
@@ -6741,6 +6791,7 @@ class WebRTCClient extends Emitter {
|
|
|
6741
6791
|
this.conferences = {};
|
|
6742
6792
|
this.networkMonitoringInterval = {};
|
|
6743
6793
|
this.sessionNetworkStats = {};
|
|
6794
|
+
this.forceClosed = false;
|
|
6744
6795
|
|
|
6745
6796
|
this._boundOnHeartbeat = this._onHeartbeat.bind(this);
|
|
6746
6797
|
this.heartbeat = new Heartbeat(config.heartbeatDelay, config.heartbeatTimeout, config.maxHeartbeats);
|
|
@@ -6862,6 +6913,8 @@ class WebRTCClient extends Emitter {
|
|
|
6862
6913
|
skipRegister: this.skipRegister,
|
|
6863
6914
|
};
|
|
6864
6915
|
|
|
6916
|
+
this.forceClosed = false;
|
|
6917
|
+
|
|
6865
6918
|
if (this.skipRegister) {
|
|
6866
6919
|
logger$8.info('sdk webrtc skip register...', logInfo);
|
|
6867
6920
|
return Promise.resolve();
|
|
@@ -6886,7 +6939,15 @@ class WebRTCClient extends Emitter {
|
|
|
6886
6939
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6887
6940
|
|
|
6888
6941
|
const onRegisterFailed = () => {
|
|
6889
|
-
logger$8.info('sdk webrtc registering failed', {
|
|
6942
|
+
logger$8.info('sdk webrtc registering failed', {
|
|
6943
|
+
tries,
|
|
6944
|
+
registerer: !!this.registerer,
|
|
6945
|
+
forceClosed: this.forceClosed,
|
|
6946
|
+
});
|
|
6947
|
+
if (this.forceClosed) {
|
|
6948
|
+
return;
|
|
6949
|
+
}
|
|
6950
|
+
|
|
6890
6951
|
this.connectionPromise = null;
|
|
6891
6952
|
if (this.registerer && this.registerer.waiting) {
|
|
6892
6953
|
this.registerer.waitingToggle(false);
|
|
@@ -7164,8 +7225,9 @@ class WebRTCClient extends Emitter {
|
|
|
7164
7225
|
}
|
|
7165
7226
|
}
|
|
7166
7227
|
|
|
7167
|
-
async close() {
|
|
7168
|
-
logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
7228
|
+
async close(force = false) {
|
|
7229
|
+
logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent, force });
|
|
7230
|
+
this.forceClosed = force;
|
|
7169
7231
|
this._cleanupMedia();
|
|
7170
7232
|
this.connectionPromise = null;
|
|
7171
7233
|
|
|
@@ -7184,7 +7246,7 @@ class WebRTCClient extends Emitter {
|
|
|
7184
7246
|
this.userAgent.delegate = null;
|
|
7185
7247
|
this.userAgent.stateChange.removeAllListeners();
|
|
7186
7248
|
|
|
7187
|
-
await this._disconnectTransport();
|
|
7249
|
+
await this._disconnectTransport(force);
|
|
7188
7250
|
|
|
7189
7251
|
this._cleanupRegister();
|
|
7190
7252
|
|
|
@@ -8620,7 +8682,15 @@ class WebRTCClient extends Emitter {
|
|
|
8620
8682
|
return UserAgent.makeURI(`sip:${target}@${this.config.host}`);
|
|
8621
8683
|
}
|
|
8622
8684
|
|
|
8623
|
-
async _disconnectTransport() {
|
|
8685
|
+
async _disconnectTransport(force = false) {
|
|
8686
|
+
if (force) {
|
|
8687
|
+
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
8688
|
+
this.userAgent.transport.disconnectResolve = () => {};
|
|
8689
|
+
// eslint-disable-next-line
|
|
8690
|
+
this.userAgent.transport._ws.close(1000);
|
|
8691
|
+
return;
|
|
8692
|
+
}
|
|
8693
|
+
|
|
8624
8694
|
// Check if `disconnectPromise` is not present to avoid `Disconnect promise must not be defined` errors.
|
|
8625
8695
|
if (this.userAgent && this.userAgent.transport && !this.userAgent.transport.disconnectPromise) {
|
|
8626
8696
|
try {
|
|
@@ -9567,6 +9637,12 @@ class WebRTCPhone extends Emitter {
|
|
|
9567
9637
|
return Promise.resolve(null);
|
|
9568
9638
|
}
|
|
9569
9639
|
|
|
9640
|
+
const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
|
|
9641
|
+
if (sipSessionId && !(sipSessionId in this.callSessions)) {
|
|
9642
|
+
logger$7.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
|
|
9643
|
+
return Promise.resolve(null);
|
|
9644
|
+
}
|
|
9645
|
+
|
|
9570
9646
|
if (callSession.getId() in this.acceptedSessions) {
|
|
9571
9647
|
logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9572
9648
|
return Promise.resolve(callSession.sipCallId);
|
|
@@ -10027,7 +10103,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10027
10103
|
return this.client && this.client.isConference(callSession.sipCallId);
|
|
10028
10104
|
}
|
|
10029
10105
|
|
|
10030
|
-
async close() {
|
|
10106
|
+
async close(force = false) {
|
|
10031
10107
|
logger$7.info('WebRTC close');
|
|
10032
10108
|
|
|
10033
10109
|
try {
|
|
@@ -10039,7 +10115,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10039
10115
|
logger$7.error('WebRTC close, unregister error', e);
|
|
10040
10116
|
}
|
|
10041
10117
|
|
|
10042
|
-
this.client.close();
|
|
10118
|
+
this.client.close(force);
|
|
10043
10119
|
this.unbind();
|
|
10044
10120
|
|
|
10045
10121
|
this.incomingSessions = [];
|
|
@@ -10191,9 +10267,17 @@ class WebRTCPhone extends Emitter {
|
|
|
10191
10267
|
});
|
|
10192
10268
|
|
|
10193
10269
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
10194
|
-
|
|
10270
|
+
const sessionId = this.getSipSessionId(sipSession);
|
|
10271
|
+
const hasSession = sessionId in this.callSessions;
|
|
10272
|
+
|
|
10273
|
+
logger$7.info('WebRTC call accepted', { sipId: sessionId, hasSession });
|
|
10274
|
+
|
|
10275
|
+
if (!hasSession) {
|
|
10276
|
+
logger$7.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
|
|
10277
|
+
return;
|
|
10278
|
+
}
|
|
10195
10279
|
|
|
10196
|
-
this._onCallAccepted(sipSession, this.client.hasVideo(
|
|
10280
|
+
this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
|
|
10197
10281
|
|
|
10198
10282
|
if (this.audioOutputDeviceId) {
|
|
10199
10283
|
this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
|
|
@@ -10329,9 +10413,14 @@ class WebRTCPhone extends Emitter {
|
|
|
10329
10413
|
return this.client.getSipSessionId(sipSession);
|
|
10330
10414
|
}
|
|
10331
10415
|
|
|
10332
|
-
|
|
10416
|
+
getSipSessionIdFromCallSession(callSession ) {
|
|
10333
10417
|
const sipSession = this.findSipSession(callSession);
|
|
10334
|
-
|
|
10418
|
+
|
|
10419
|
+
return sipSession ? this.getSipSessionId(sipSession) : null;
|
|
10420
|
+
}
|
|
10421
|
+
|
|
10422
|
+
_updateCallSession(callSession ) {
|
|
10423
|
+
const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
|
|
10335
10424
|
|
|
10336
10425
|
if (sipSessionId) {
|
|
10337
10426
|
this.callSessions[sipSessionId] = callSession;
|