@wazo/sdk 0.37.29 → 0.37.33
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/README.md +2 -1
- package/dist/wazo-sdk.js +4 -4
- package/esm/__tests__/api-client.test.js +30 -0
- package/esm/__tests__/web-rtc-client.test.js +65 -6
- package/esm/api/calld.js +30 -0
- package/esm/api-client.js +30 -0
- package/esm/checker/Checker.js +65 -6
- package/esm/checker/checks/aor.js +30 -0
- package/esm/checker/checks/api.js +30 -0
- package/esm/checker/checks/index.js +65 -6
- package/esm/checker/checks/webrtc-transport.js +65 -6
- package/esm/checker/checks/webrtc.js +65 -6
- package/esm/domain/AdHocAPIConference.js +30 -0
- package/esm/domain/CallSession.js +9 -1
- package/esm/domain/Features.js +30 -0
- package/esm/domain/MeetingStatus.js +29 -0
- package/esm/domain/Phone/CTIPhone.js +39 -1
- package/esm/domain/Phone/WebRTCPhone.js +20 -4
- package/esm/domain/__tests__/CallSession.test.js +41 -5
- package/esm/domain/__tests__/IndirectTransfer.test.js +9 -1
- package/esm/domain/__tests__/Room.test.js +9 -1
- package/esm/index.js +85 -10
- package/esm/service/CallApi.js +30 -0
- package/esm/service/getApiClient.js +30 -0
- package/esm/simple/Auth.js +85 -10
- package/esm/simple/Configuration.js +85 -10
- package/esm/simple/Directory.js +30 -0
- package/esm/simple/Phone.js +85 -10
- package/esm/simple/index.js +85 -10
- package/esm/simple/room/LocalParticipant.js +85 -10
- package/esm/simple/room/Participant.js +85 -10
- package/esm/simple/room/RemoteParticipant.js +85 -10
- package/esm/simple/room/Room.js +85 -10
- package/esm/simple/room/SipRoom.js +85 -10
- package/esm/simple/room/Stream.js +85 -10
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +85 -10
- package/esm/simple/utils.js +85 -10
- package/esm/web-rtc-client.js +65 -6
- package/lib/__tests__/api-client.test.js +30 -0
- package/lib/__tests__/web-rtc-client.test.js +65 -6
- package/lib/api/calld.js +30 -0
- package/lib/api-client.js +30 -0
- package/lib/checker/Checker.js +65 -6
- package/lib/checker/checks/aor.js +30 -0
- package/lib/checker/checks/api.js +30 -0
- package/lib/checker/checks/index.js +65 -6
- package/lib/checker/checks/webrtc-transport.js +65 -6
- package/lib/checker/checks/webrtc.js +65 -6
- package/lib/domain/AdHocAPIConference.js +30 -0
- package/lib/domain/CallSession.js +9 -1
- package/lib/domain/Features.js +30 -0
- package/lib/domain/MeetingStatus.js +31 -0
- package/lib/domain/Phone/CTIPhone.js +39 -1
- package/lib/domain/Phone/WebRTCPhone.js +20 -4
- package/lib/domain/__tests__/CallSession.test.js +41 -5
- package/lib/domain/__tests__/IndirectTransfer.test.js +9 -1
- package/lib/domain/__tests__/Room.test.js +9 -1
- package/lib/index.js +85 -10
- package/lib/service/CallApi.js +30 -0
- package/lib/service/getApiClient.js +30 -0
- package/lib/simple/Auth.js +85 -10
- package/lib/simple/Configuration.js +85 -10
- package/lib/simple/Directory.js +30 -0
- package/lib/simple/Phone.js +85 -10
- package/lib/simple/index.js +85 -10
- package/lib/simple/room/LocalParticipant.js +85 -10
- package/lib/simple/room/Participant.js +85 -10
- package/lib/simple/room/RemoteParticipant.js +85 -10
- package/lib/simple/room/Room.js +85 -10
- package/lib/simple/room/SipRoom.js +85 -10
- package/lib/simple/room/Stream.js +85 -10
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +85 -10
- package/lib/simple/utils.js +85 -10
- package/lib/web-rtc-client.js +65 -6
- package/package.json +1 -1
- package/src/api/calld.js +3 -0
- package/src/domain/CallSession.js +9 -1
- package/src/domain/MeetingStatus.js +27 -0
- package/src/domain/Phone/WebRTCPhone.js +11 -3
- package/src/domain/__tests__/CallSession.test.js +32 -4
- package/src/web-rtc-client.js +35 -6
|
@@ -3594,13 +3594,21 @@ class CallSession {
|
|
|
3594
3594
|
|
|
3595
3595
|
// Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
|
|
3596
3596
|
set answered(value ) {
|
|
3597
|
-
this.answerTime = value ? new Date() : null;
|
|
3597
|
+
this.answerTime = value ? this.answerTime || new Date() : null;
|
|
3598
3598
|
}
|
|
3599
3599
|
|
|
3600
3600
|
get answered() {
|
|
3601
3601
|
return !!this.answerTime;
|
|
3602
3602
|
}
|
|
3603
3603
|
|
|
3604
|
+
toJSON() {
|
|
3605
|
+
const jsonObj = { ...this };
|
|
3606
|
+
// $FlowFixMe
|
|
3607
|
+
jsonObj.answered = this.answered;
|
|
3608
|
+
|
|
3609
|
+
return jsonObj;
|
|
3610
|
+
}
|
|
3611
|
+
|
|
3604
3612
|
static parseCall(call ) {
|
|
3605
3613
|
return new CallSession({
|
|
3606
3614
|
callId: call.id,
|
|
@@ -4852,6 +4860,34 @@ var chatdMethods = (client , baseUrl ) => ({
|
|
|
4852
4860
|
client.get(`${baseUrl}/users/me/rooms/messages`, options),
|
|
4853
4861
|
});
|
|
4854
4862
|
|
|
4863
|
+
//
|
|
4864
|
+
|
|
4865
|
+
|
|
4866
|
+
|
|
4867
|
+
|
|
4868
|
+
|
|
4869
|
+
class MeetingStatus {
|
|
4870
|
+
|
|
4871
|
+
|
|
4872
|
+
|
|
4873
|
+
|
|
4874
|
+
constructor({
|
|
4875
|
+
full,
|
|
4876
|
+
} = {}) {
|
|
4877
|
+
this.full = full;
|
|
4878
|
+
|
|
4879
|
+
// Useful to compare instead of instanceof with minified code
|
|
4880
|
+
this.type = 'MeetingStatus';
|
|
4881
|
+
}
|
|
4882
|
+
|
|
4883
|
+
static parse(plain ) {
|
|
4884
|
+
return new MeetingStatus({
|
|
4885
|
+
full: plain.full,
|
|
4886
|
+
});
|
|
4887
|
+
}
|
|
4888
|
+
|
|
4889
|
+
}
|
|
4890
|
+
|
|
4855
4891
|
/* */
|
|
4856
4892
|
|
|
4857
4893
|
|
|
@@ -5046,6 +5082,8 @@ var calldMethods = (client , baseUrl ) => ({
|
|
|
5046
5082
|
client.put(`${baseUrl}/users/me/calls/${callId}/record/resume`, null, null,
|
|
5047
5083
|
ApiRequester.successResponseParser),
|
|
5048
5084
|
|
|
5085
|
+
guestGetMeetingStatus: (meetingUuid ) =>
|
|
5086
|
+
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}/status`).then(MeetingStatus.parse),
|
|
5049
5087
|
});
|
|
5050
5088
|
|
|
5051
5089
|
//
|
|
@@ -6647,6 +6685,7 @@ const MAX_REGISTER_TRIES = 10;
|
|
|
6647
6685
|
|
|
6648
6686
|
|
|
6649
6687
|
|
|
6688
|
+
|
|
6650
6689
|
|
|
6651
6690
|
|
|
6652
6691
|
|
|
@@ -6688,6 +6727,7 @@ class WebRTCClient extends Emitter {
|
|
|
6688
6727
|
|
|
6689
6728
|
|
|
6690
6729
|
|
|
6730
|
+
|
|
6691
6731
|
|
|
6692
6732
|
// sugar
|
|
6693
6733
|
|
|
@@ -6750,6 +6790,7 @@ class WebRTCClient extends Emitter {
|
|
|
6750
6790
|
this.conferences = {};
|
|
6751
6791
|
this.networkMonitoringInterval = {};
|
|
6752
6792
|
this.sessionNetworkStats = {};
|
|
6793
|
+
this.forceClosed = false;
|
|
6753
6794
|
|
|
6754
6795
|
this._boundOnHeartbeat = this._onHeartbeat.bind(this);
|
|
6755
6796
|
this.heartbeat = new Heartbeat(config.heartbeatDelay, config.heartbeatTimeout, config.maxHeartbeats);
|
|
@@ -6871,6 +6912,8 @@ class WebRTCClient extends Emitter {
|
|
|
6871
6912
|
skipRegister: this.skipRegister,
|
|
6872
6913
|
};
|
|
6873
6914
|
|
|
6915
|
+
this.forceClosed = false;
|
|
6916
|
+
|
|
6874
6917
|
if (this.skipRegister) {
|
|
6875
6918
|
logger$8.info('sdk webrtc skip register...', logInfo);
|
|
6876
6919
|
return Promise.resolve();
|
|
@@ -6895,7 +6938,15 @@ class WebRTCClient extends Emitter {
|
|
|
6895
6938
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6896
6939
|
|
|
6897
6940
|
const onRegisterFailed = () => {
|
|
6898
|
-
logger$8.info('sdk webrtc registering failed', {
|
|
6941
|
+
logger$8.info('sdk webrtc registering failed', {
|
|
6942
|
+
tries,
|
|
6943
|
+
registerer: !!this.registerer,
|
|
6944
|
+
forceClosed: this.forceClosed,
|
|
6945
|
+
});
|
|
6946
|
+
if (this.forceClosed) {
|
|
6947
|
+
return;
|
|
6948
|
+
}
|
|
6949
|
+
|
|
6899
6950
|
this.connectionPromise = null;
|
|
6900
6951
|
if (this.registerer && this.registerer.waiting) {
|
|
6901
6952
|
this.registerer.waitingToggle(false);
|
|
@@ -7173,8 +7224,9 @@ class WebRTCClient extends Emitter {
|
|
|
7173
7224
|
}
|
|
7174
7225
|
}
|
|
7175
7226
|
|
|
7176
|
-
async close() {
|
|
7177
|
-
logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
7227
|
+
async close(force = false) {
|
|
7228
|
+
logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent, force });
|
|
7229
|
+
this.forceClosed = force;
|
|
7178
7230
|
this._cleanupMedia();
|
|
7179
7231
|
this.connectionPromise = null;
|
|
7180
7232
|
|
|
@@ -7193,7 +7245,7 @@ class WebRTCClient extends Emitter {
|
|
|
7193
7245
|
this.userAgent.delegate = null;
|
|
7194
7246
|
this.userAgent.stateChange.removeAllListeners();
|
|
7195
7247
|
|
|
7196
|
-
await this._disconnectTransport();
|
|
7248
|
+
await this._disconnectTransport(force);
|
|
7197
7249
|
|
|
7198
7250
|
this._cleanupRegister();
|
|
7199
7251
|
|
|
@@ -8263,6 +8315,13 @@ class WebRTCClient extends Emitter {
|
|
|
8263
8315
|
}
|
|
8264
8316
|
|
|
8265
8317
|
_createWebRTCConfiguration(configOverrides = {}) {
|
|
8318
|
+
let { host } = this.config;
|
|
8319
|
+
let port = this.config.port || 443;
|
|
8320
|
+
|
|
8321
|
+
if (this.config.websocketSip) {
|
|
8322
|
+
[host, port = 443] = this.config.websocketSip.split(':');
|
|
8323
|
+
}
|
|
8324
|
+
|
|
8266
8325
|
const config = {
|
|
8267
8326
|
authorizationUsername: this.config.authorizationUser,
|
|
8268
8327
|
authorizationPassword: this.config.password,
|
|
@@ -8298,7 +8357,7 @@ class WebRTCClient extends Emitter {
|
|
|
8298
8357
|
},
|
|
8299
8358
|
transportOptions: {
|
|
8300
8359
|
traceSip: configOverrides.traceSip || false,
|
|
8301
|
-
wsServers: `wss://${
|
|
8360
|
+
wsServers: `wss://${host}:${port}/api/asterisk/ws`,
|
|
8302
8361
|
},
|
|
8303
8362
|
sessionDescriptionHandlerFactoryOptions: {
|
|
8304
8363
|
modifiers: [replaceLocalIpModifier],
|
|
@@ -8622,7 +8681,15 @@ class WebRTCClient extends Emitter {
|
|
|
8622
8681
|
return userAgent.UserAgent.makeURI(`sip:${target}@${this.config.host}`);
|
|
8623
8682
|
}
|
|
8624
8683
|
|
|
8625
|
-
async _disconnectTransport() {
|
|
8684
|
+
async _disconnectTransport(force = false) {
|
|
8685
|
+
if (force) {
|
|
8686
|
+
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
8687
|
+
this.userAgent.transport.disconnectResolve = () => {};
|
|
8688
|
+
// eslint-disable-next-line
|
|
8689
|
+
this.userAgent.transport._ws.close(1000);
|
|
8690
|
+
return;
|
|
8691
|
+
}
|
|
8692
|
+
|
|
8626
8693
|
// Check if `disconnectPromise` is not present to avoid `Disconnect promise must not be defined` errors.
|
|
8627
8694
|
if (this.userAgent && this.userAgent.transport && !this.userAgent.transport.disconnectPromise) {
|
|
8628
8695
|
try {
|
|
@@ -9359,6 +9426,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9359
9426
|
}
|
|
9360
9427
|
|
|
9361
9428
|
callSession.answerTime = new Date();
|
|
9429
|
+
this._updateCallSession(callSession);
|
|
9362
9430
|
this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
|
|
9363
9431
|
|
|
9364
9432
|
return callSession;
|
|
@@ -9575,6 +9643,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9575
9643
|
|
|
9576
9644
|
this.shouldSendReinvite = false;
|
|
9577
9645
|
callSession.answerTime = new Date();
|
|
9646
|
+
this._updateCallSession(callSession);
|
|
9578
9647
|
this.acceptedSessions[callSession.getId()] = true;
|
|
9579
9648
|
|
|
9580
9649
|
this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
|
|
@@ -9674,7 +9743,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9674
9743
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
9675
9744
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
9676
9745
|
logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
9677
|
-
this.holdSipSession(this.currentSipSession,
|
|
9746
|
+
this.holdSipSession(this.currentSipSession, this.currentCallSession);
|
|
9678
9747
|
}
|
|
9679
9748
|
|
|
9680
9749
|
const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
|
|
@@ -9885,6 +9954,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9885
9954
|
}
|
|
9886
9955
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
9887
9956
|
callSession.creationTime = new Date();
|
|
9957
|
+
this._updateCallSession(callSession);
|
|
9888
9958
|
|
|
9889
9959
|
this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
9890
9960
|
|
|
@@ -10026,7 +10096,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10026
10096
|
return this.client && this.client.isConference(callSession.sipCallId);
|
|
10027
10097
|
}
|
|
10028
10098
|
|
|
10029
|
-
async close() {
|
|
10099
|
+
async close(force = false) {
|
|
10030
10100
|
logger$7.info('WebRTC close');
|
|
10031
10101
|
|
|
10032
10102
|
try {
|
|
@@ -10038,7 +10108,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10038
10108
|
logger$7.error('WebRTC close, unregister error', e);
|
|
10039
10109
|
}
|
|
10040
10110
|
|
|
10041
|
-
this.client.close();
|
|
10111
|
+
this.client.close(force);
|
|
10042
10112
|
this.unbind();
|
|
10043
10113
|
|
|
10044
10114
|
this.incomingSessions = [];
|
|
@@ -10164,6 +10234,8 @@ class WebRTCPhone extends Emitter {
|
|
|
10164
10234
|
}
|
|
10165
10235
|
|
|
10166
10236
|
callSession.creationTime = new Date();
|
|
10237
|
+
this._updateCallSession(callSession);
|
|
10238
|
+
|
|
10167
10239
|
this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
|
|
10168
10240
|
});
|
|
10169
10241
|
|
|
@@ -10207,6 +10279,8 @@ class WebRTCPhone extends Emitter {
|
|
|
10207
10279
|
logger$7.info('WebRTC call rejected', session.id);
|
|
10208
10280
|
const callSession = this._createCallSession(session);
|
|
10209
10281
|
callSession.endTime = new Date();
|
|
10282
|
+
this._updateCallSession(callSession);
|
|
10283
|
+
|
|
10210
10284
|
this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
|
|
10211
10285
|
});
|
|
10212
10286
|
|
|
@@ -10431,6 +10505,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10431
10505
|
displayName: identity ? identity.displayName || number : number,
|
|
10432
10506
|
startTime: fromSession ? fromSession.startTime : new Date(),
|
|
10433
10507
|
creationTime: fromSession ? fromSession.creationTime : null,
|
|
10508
|
+
answerTime: fromSession ? fromSession.answerTime : null,
|
|
10434
10509
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10435
10510
|
answered: state === sessionState.SessionState.Established,
|
|
10436
10511
|
paused: this.client.isCallHeld(sipSession),
|
package/lib/simple/room/Room.js
CHANGED
|
@@ -3596,13 +3596,21 @@ class CallSession {
|
|
|
3596
3596
|
|
|
3597
3597
|
// Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
|
|
3598
3598
|
set answered(value ) {
|
|
3599
|
-
this.answerTime = value ? new Date() : null;
|
|
3599
|
+
this.answerTime = value ? this.answerTime || new Date() : null;
|
|
3600
3600
|
}
|
|
3601
3601
|
|
|
3602
3602
|
get answered() {
|
|
3603
3603
|
return !!this.answerTime;
|
|
3604
3604
|
}
|
|
3605
3605
|
|
|
3606
|
+
toJSON() {
|
|
3607
|
+
const jsonObj = { ...this };
|
|
3608
|
+
// $FlowFixMe
|
|
3609
|
+
jsonObj.answered = this.answered;
|
|
3610
|
+
|
|
3611
|
+
return jsonObj;
|
|
3612
|
+
}
|
|
3613
|
+
|
|
3606
3614
|
static parseCall(call ) {
|
|
3607
3615
|
return new CallSession({
|
|
3608
3616
|
callId: call.id,
|
|
@@ -4854,6 +4862,34 @@ var chatdMethods = (client , baseUrl ) => ({
|
|
|
4854
4862
|
client.get(`${baseUrl}/users/me/rooms/messages`, options),
|
|
4855
4863
|
});
|
|
4856
4864
|
|
|
4865
|
+
//
|
|
4866
|
+
|
|
4867
|
+
|
|
4868
|
+
|
|
4869
|
+
|
|
4870
|
+
|
|
4871
|
+
class MeetingStatus {
|
|
4872
|
+
|
|
4873
|
+
|
|
4874
|
+
|
|
4875
|
+
|
|
4876
|
+
constructor({
|
|
4877
|
+
full,
|
|
4878
|
+
} = {}) {
|
|
4879
|
+
this.full = full;
|
|
4880
|
+
|
|
4881
|
+
// Useful to compare instead of instanceof with minified code
|
|
4882
|
+
this.type = 'MeetingStatus';
|
|
4883
|
+
}
|
|
4884
|
+
|
|
4885
|
+
static parse(plain ) {
|
|
4886
|
+
return new MeetingStatus({
|
|
4887
|
+
full: plain.full,
|
|
4888
|
+
});
|
|
4889
|
+
}
|
|
4890
|
+
|
|
4891
|
+
}
|
|
4892
|
+
|
|
4857
4893
|
/* */
|
|
4858
4894
|
|
|
4859
4895
|
|
|
@@ -5048,6 +5084,8 @@ var calldMethods = (client , baseUrl ) => ({
|
|
|
5048
5084
|
client.put(`${baseUrl}/users/me/calls/${callId}/record/resume`, null, null,
|
|
5049
5085
|
ApiRequester.successResponseParser),
|
|
5050
5086
|
|
|
5087
|
+
guestGetMeetingStatus: (meetingUuid ) =>
|
|
5088
|
+
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}/status`).then(MeetingStatus.parse),
|
|
5051
5089
|
});
|
|
5052
5090
|
|
|
5053
5091
|
//
|
|
@@ -6649,6 +6687,7 @@ const MAX_REGISTER_TRIES = 10;
|
|
|
6649
6687
|
|
|
6650
6688
|
|
|
6651
6689
|
|
|
6690
|
+
|
|
6652
6691
|
|
|
6653
6692
|
|
|
6654
6693
|
|
|
@@ -6690,6 +6729,7 @@ class WebRTCClient extends Emitter {
|
|
|
6690
6729
|
|
|
6691
6730
|
|
|
6692
6731
|
|
|
6732
|
+
|
|
6693
6733
|
|
|
6694
6734
|
// sugar
|
|
6695
6735
|
|
|
@@ -6752,6 +6792,7 @@ class WebRTCClient extends Emitter {
|
|
|
6752
6792
|
this.conferences = {};
|
|
6753
6793
|
this.networkMonitoringInterval = {};
|
|
6754
6794
|
this.sessionNetworkStats = {};
|
|
6795
|
+
this.forceClosed = false;
|
|
6755
6796
|
|
|
6756
6797
|
this._boundOnHeartbeat = this._onHeartbeat.bind(this);
|
|
6757
6798
|
this.heartbeat = new Heartbeat(config.heartbeatDelay, config.heartbeatTimeout, config.maxHeartbeats);
|
|
@@ -6873,6 +6914,8 @@ class WebRTCClient extends Emitter {
|
|
|
6873
6914
|
skipRegister: this.skipRegister,
|
|
6874
6915
|
};
|
|
6875
6916
|
|
|
6917
|
+
this.forceClosed = false;
|
|
6918
|
+
|
|
6876
6919
|
if (this.skipRegister) {
|
|
6877
6920
|
logger$8.info('sdk webrtc skip register...', logInfo);
|
|
6878
6921
|
return Promise.resolve();
|
|
@@ -6897,7 +6940,15 @@ class WebRTCClient extends Emitter {
|
|
|
6897
6940
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6898
6941
|
|
|
6899
6942
|
const onRegisterFailed = () => {
|
|
6900
|
-
logger$8.info('sdk webrtc registering failed', {
|
|
6943
|
+
logger$8.info('sdk webrtc registering failed', {
|
|
6944
|
+
tries,
|
|
6945
|
+
registerer: !!this.registerer,
|
|
6946
|
+
forceClosed: this.forceClosed,
|
|
6947
|
+
});
|
|
6948
|
+
if (this.forceClosed) {
|
|
6949
|
+
return;
|
|
6950
|
+
}
|
|
6951
|
+
|
|
6901
6952
|
this.connectionPromise = null;
|
|
6902
6953
|
if (this.registerer && this.registerer.waiting) {
|
|
6903
6954
|
this.registerer.waitingToggle(false);
|
|
@@ -7175,8 +7226,9 @@ class WebRTCClient extends Emitter {
|
|
|
7175
7226
|
}
|
|
7176
7227
|
}
|
|
7177
7228
|
|
|
7178
|
-
async close() {
|
|
7179
|
-
logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
7229
|
+
async close(force = false) {
|
|
7230
|
+
logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent, force });
|
|
7231
|
+
this.forceClosed = force;
|
|
7180
7232
|
this._cleanupMedia();
|
|
7181
7233
|
this.connectionPromise = null;
|
|
7182
7234
|
|
|
@@ -7195,7 +7247,7 @@ class WebRTCClient extends Emitter {
|
|
|
7195
7247
|
this.userAgent.delegate = null;
|
|
7196
7248
|
this.userAgent.stateChange.removeAllListeners();
|
|
7197
7249
|
|
|
7198
|
-
await this._disconnectTransport();
|
|
7250
|
+
await this._disconnectTransport(force);
|
|
7199
7251
|
|
|
7200
7252
|
this._cleanupRegister();
|
|
7201
7253
|
|
|
@@ -8265,6 +8317,13 @@ class WebRTCClient extends Emitter {
|
|
|
8265
8317
|
}
|
|
8266
8318
|
|
|
8267
8319
|
_createWebRTCConfiguration(configOverrides = {}) {
|
|
8320
|
+
let { host } = this.config;
|
|
8321
|
+
let port = this.config.port || 443;
|
|
8322
|
+
|
|
8323
|
+
if (this.config.websocketSip) {
|
|
8324
|
+
[host, port = 443] = this.config.websocketSip.split(':');
|
|
8325
|
+
}
|
|
8326
|
+
|
|
8268
8327
|
const config = {
|
|
8269
8328
|
authorizationUsername: this.config.authorizationUser,
|
|
8270
8329
|
authorizationPassword: this.config.password,
|
|
@@ -8300,7 +8359,7 @@ class WebRTCClient extends Emitter {
|
|
|
8300
8359
|
},
|
|
8301
8360
|
transportOptions: {
|
|
8302
8361
|
traceSip: configOverrides.traceSip || false,
|
|
8303
|
-
wsServers: `wss://${
|
|
8362
|
+
wsServers: `wss://${host}:${port}/api/asterisk/ws`,
|
|
8304
8363
|
},
|
|
8305
8364
|
sessionDescriptionHandlerFactoryOptions: {
|
|
8306
8365
|
modifiers: [replaceLocalIpModifier],
|
|
@@ -8624,7 +8683,15 @@ class WebRTCClient extends Emitter {
|
|
|
8624
8683
|
return userAgent.UserAgent.makeURI(`sip:${target}@${this.config.host}`);
|
|
8625
8684
|
}
|
|
8626
8685
|
|
|
8627
|
-
async _disconnectTransport() {
|
|
8686
|
+
async _disconnectTransport(force = false) {
|
|
8687
|
+
if (force) {
|
|
8688
|
+
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
8689
|
+
this.userAgent.transport.disconnectResolve = () => {};
|
|
8690
|
+
// eslint-disable-next-line
|
|
8691
|
+
this.userAgent.transport._ws.close(1000);
|
|
8692
|
+
return;
|
|
8693
|
+
}
|
|
8694
|
+
|
|
8628
8695
|
// Check if `disconnectPromise` is not present to avoid `Disconnect promise must not be defined` errors.
|
|
8629
8696
|
if (this.userAgent && this.userAgent.transport && !this.userAgent.transport.disconnectPromise) {
|
|
8630
8697
|
try {
|
|
@@ -9361,6 +9428,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9361
9428
|
}
|
|
9362
9429
|
|
|
9363
9430
|
callSession.answerTime = new Date();
|
|
9431
|
+
this._updateCallSession(callSession);
|
|
9364
9432
|
this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
|
|
9365
9433
|
|
|
9366
9434
|
return callSession;
|
|
@@ -9577,6 +9645,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9577
9645
|
|
|
9578
9646
|
this.shouldSendReinvite = false;
|
|
9579
9647
|
callSession.answerTime = new Date();
|
|
9648
|
+
this._updateCallSession(callSession);
|
|
9580
9649
|
this.acceptedSessions[callSession.getId()] = true;
|
|
9581
9650
|
|
|
9582
9651
|
this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
|
|
@@ -9676,7 +9745,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9676
9745
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
9677
9746
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
9678
9747
|
logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
9679
|
-
this.holdSipSession(this.currentSipSession,
|
|
9748
|
+
this.holdSipSession(this.currentSipSession, this.currentCallSession);
|
|
9680
9749
|
}
|
|
9681
9750
|
|
|
9682
9751
|
const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
|
|
@@ -9887,6 +9956,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9887
9956
|
}
|
|
9888
9957
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
9889
9958
|
callSession.creationTime = new Date();
|
|
9959
|
+
this._updateCallSession(callSession);
|
|
9890
9960
|
|
|
9891
9961
|
this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
9892
9962
|
|
|
@@ -10028,7 +10098,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10028
10098
|
return this.client && this.client.isConference(callSession.sipCallId);
|
|
10029
10099
|
}
|
|
10030
10100
|
|
|
10031
|
-
async close() {
|
|
10101
|
+
async close(force = false) {
|
|
10032
10102
|
logger$7.info('WebRTC close');
|
|
10033
10103
|
|
|
10034
10104
|
try {
|
|
@@ -10040,7 +10110,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10040
10110
|
logger$7.error('WebRTC close, unregister error', e);
|
|
10041
10111
|
}
|
|
10042
10112
|
|
|
10043
|
-
this.client.close();
|
|
10113
|
+
this.client.close(force);
|
|
10044
10114
|
this.unbind();
|
|
10045
10115
|
|
|
10046
10116
|
this.incomingSessions = [];
|
|
@@ -10166,6 +10236,8 @@ class WebRTCPhone extends Emitter {
|
|
|
10166
10236
|
}
|
|
10167
10237
|
|
|
10168
10238
|
callSession.creationTime = new Date();
|
|
10239
|
+
this._updateCallSession(callSession);
|
|
10240
|
+
|
|
10169
10241
|
this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
|
|
10170
10242
|
});
|
|
10171
10243
|
|
|
@@ -10209,6 +10281,8 @@ class WebRTCPhone extends Emitter {
|
|
|
10209
10281
|
logger$7.info('WebRTC call rejected', session.id);
|
|
10210
10282
|
const callSession = this._createCallSession(session);
|
|
10211
10283
|
callSession.endTime = new Date();
|
|
10284
|
+
this._updateCallSession(callSession);
|
|
10285
|
+
|
|
10212
10286
|
this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
|
|
10213
10287
|
});
|
|
10214
10288
|
|
|
@@ -10433,6 +10507,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10433
10507
|
displayName: identity ? identity.displayName || number : number,
|
|
10434
10508
|
startTime: fromSession ? fromSession.startTime : new Date(),
|
|
10435
10509
|
creationTime: fromSession ? fromSession.creationTime : null,
|
|
10510
|
+
answerTime: fromSession ? fromSession.answerTime : null,
|
|
10436
10511
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10437
10512
|
answered: state === sessionState.SessionState.Established,
|
|
10438
10513
|
paused: this.client.isCallHeld(sipSession),
|