@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
|
@@ -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;
|
package/esm/simple/utils.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;
|