@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
package/esm/simple/room/Room.js
CHANGED
|
@@ -3584,13 +3584,21 @@ class CallSession {
|
|
|
3584
3584
|
|
|
3585
3585
|
// Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
|
|
3586
3586
|
set answered(value ) {
|
|
3587
|
-
this.answerTime = value ? new Date() : null;
|
|
3587
|
+
this.answerTime = value ? this.answerTime || new Date() : null;
|
|
3588
3588
|
}
|
|
3589
3589
|
|
|
3590
3590
|
get answered() {
|
|
3591
3591
|
return !!this.answerTime;
|
|
3592
3592
|
}
|
|
3593
3593
|
|
|
3594
|
+
toJSON() {
|
|
3595
|
+
const jsonObj = { ...this };
|
|
3596
|
+
// $FlowFixMe
|
|
3597
|
+
jsonObj.answered = this.answered;
|
|
3598
|
+
|
|
3599
|
+
return jsonObj;
|
|
3600
|
+
}
|
|
3601
|
+
|
|
3594
3602
|
static parseCall(call ) {
|
|
3595
3603
|
return new CallSession({
|
|
3596
3604
|
callId: call.id,
|
|
@@ -4842,6 +4850,34 @@ var chatdMethods = (client , baseUrl ) => ({
|
|
|
4842
4850
|
client.get(`${baseUrl}/users/me/rooms/messages`, options),
|
|
4843
4851
|
});
|
|
4844
4852
|
|
|
4853
|
+
//
|
|
4854
|
+
|
|
4855
|
+
|
|
4856
|
+
|
|
4857
|
+
|
|
4858
|
+
|
|
4859
|
+
class MeetingStatus {
|
|
4860
|
+
|
|
4861
|
+
|
|
4862
|
+
|
|
4863
|
+
|
|
4864
|
+
constructor({
|
|
4865
|
+
full,
|
|
4866
|
+
} = {}) {
|
|
4867
|
+
this.full = full;
|
|
4868
|
+
|
|
4869
|
+
// Useful to compare instead of instanceof with minified code
|
|
4870
|
+
this.type = 'MeetingStatus';
|
|
4871
|
+
}
|
|
4872
|
+
|
|
4873
|
+
static parse(plain ) {
|
|
4874
|
+
return new MeetingStatus({
|
|
4875
|
+
full: plain.full,
|
|
4876
|
+
});
|
|
4877
|
+
}
|
|
4878
|
+
|
|
4879
|
+
}
|
|
4880
|
+
|
|
4845
4881
|
/* */
|
|
4846
4882
|
|
|
4847
4883
|
|
|
@@ -5036,6 +5072,8 @@ var calldMethods = (client , baseUrl ) => ({
|
|
|
5036
5072
|
client.put(`${baseUrl}/users/me/calls/${callId}/record/resume`, null, null,
|
|
5037
5073
|
ApiRequester.successResponseParser),
|
|
5038
5074
|
|
|
5075
|
+
guestGetMeetingStatus: (meetingUuid ) =>
|
|
5076
|
+
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}/status`).then(MeetingStatus.parse),
|
|
5039
5077
|
});
|
|
5040
5078
|
|
|
5041
5079
|
//
|
|
@@ -6637,6 +6675,7 @@ const MAX_REGISTER_TRIES = 10;
|
|
|
6637
6675
|
|
|
6638
6676
|
|
|
6639
6677
|
|
|
6678
|
+
|
|
6640
6679
|
|
|
6641
6680
|
|
|
6642
6681
|
|
|
@@ -6678,6 +6717,7 @@ class WebRTCClient extends Emitter {
|
|
|
6678
6717
|
|
|
6679
6718
|
|
|
6680
6719
|
|
|
6720
|
+
|
|
6681
6721
|
|
|
6682
6722
|
// sugar
|
|
6683
6723
|
|
|
@@ -6740,6 +6780,7 @@ class WebRTCClient extends Emitter {
|
|
|
6740
6780
|
this.conferences = {};
|
|
6741
6781
|
this.networkMonitoringInterval = {};
|
|
6742
6782
|
this.sessionNetworkStats = {};
|
|
6783
|
+
this.forceClosed = false;
|
|
6743
6784
|
|
|
6744
6785
|
this._boundOnHeartbeat = this._onHeartbeat.bind(this);
|
|
6745
6786
|
this.heartbeat = new Heartbeat(config.heartbeatDelay, config.heartbeatTimeout, config.maxHeartbeats);
|
|
@@ -6861,6 +6902,8 @@ class WebRTCClient extends Emitter {
|
|
|
6861
6902
|
skipRegister: this.skipRegister,
|
|
6862
6903
|
};
|
|
6863
6904
|
|
|
6905
|
+
this.forceClosed = false;
|
|
6906
|
+
|
|
6864
6907
|
if (this.skipRegister) {
|
|
6865
6908
|
logger$8.info('sdk webrtc skip register...', logInfo);
|
|
6866
6909
|
return Promise.resolve();
|
|
@@ -6885,7 +6928,15 @@ class WebRTCClient extends Emitter {
|
|
|
6885
6928
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6886
6929
|
|
|
6887
6930
|
const onRegisterFailed = () => {
|
|
6888
|
-
logger$8.info('sdk webrtc registering failed', {
|
|
6931
|
+
logger$8.info('sdk webrtc registering failed', {
|
|
6932
|
+
tries,
|
|
6933
|
+
registerer: !!this.registerer,
|
|
6934
|
+
forceClosed: this.forceClosed,
|
|
6935
|
+
});
|
|
6936
|
+
if (this.forceClosed) {
|
|
6937
|
+
return;
|
|
6938
|
+
}
|
|
6939
|
+
|
|
6889
6940
|
this.connectionPromise = null;
|
|
6890
6941
|
if (this.registerer && this.registerer.waiting) {
|
|
6891
6942
|
this.registerer.waitingToggle(false);
|
|
@@ -7163,8 +7214,9 @@ class WebRTCClient extends Emitter {
|
|
|
7163
7214
|
}
|
|
7164
7215
|
}
|
|
7165
7216
|
|
|
7166
|
-
async close() {
|
|
7167
|
-
logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
7217
|
+
async close(force = false) {
|
|
7218
|
+
logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent, force });
|
|
7219
|
+
this.forceClosed = force;
|
|
7168
7220
|
this._cleanupMedia();
|
|
7169
7221
|
this.connectionPromise = null;
|
|
7170
7222
|
|
|
@@ -7183,7 +7235,7 @@ class WebRTCClient extends Emitter {
|
|
|
7183
7235
|
this.userAgent.delegate = null;
|
|
7184
7236
|
this.userAgent.stateChange.removeAllListeners();
|
|
7185
7237
|
|
|
7186
|
-
await this._disconnectTransport();
|
|
7238
|
+
await this._disconnectTransport(force);
|
|
7187
7239
|
|
|
7188
7240
|
this._cleanupRegister();
|
|
7189
7241
|
|
|
@@ -8253,6 +8305,13 @@ class WebRTCClient extends Emitter {
|
|
|
8253
8305
|
}
|
|
8254
8306
|
|
|
8255
8307
|
_createWebRTCConfiguration(configOverrides = {}) {
|
|
8308
|
+
let { host } = this.config;
|
|
8309
|
+
let port = this.config.port || 443;
|
|
8310
|
+
|
|
8311
|
+
if (this.config.websocketSip) {
|
|
8312
|
+
[host, port = 443] = this.config.websocketSip.split(':');
|
|
8313
|
+
}
|
|
8314
|
+
|
|
8256
8315
|
const config = {
|
|
8257
8316
|
authorizationUsername: this.config.authorizationUser,
|
|
8258
8317
|
authorizationPassword: this.config.password,
|
|
@@ -8288,7 +8347,7 @@ class WebRTCClient extends Emitter {
|
|
|
8288
8347
|
},
|
|
8289
8348
|
transportOptions: {
|
|
8290
8349
|
traceSip: configOverrides.traceSip || false,
|
|
8291
|
-
wsServers: `wss://${
|
|
8350
|
+
wsServers: `wss://${host}:${port}/api/asterisk/ws`,
|
|
8292
8351
|
},
|
|
8293
8352
|
sessionDescriptionHandlerFactoryOptions: {
|
|
8294
8353
|
modifiers: [replaceLocalIpModifier],
|
|
@@ -8612,7 +8671,15 @@ class WebRTCClient extends Emitter {
|
|
|
8612
8671
|
return UserAgent.makeURI(`sip:${target}@${this.config.host}`);
|
|
8613
8672
|
}
|
|
8614
8673
|
|
|
8615
|
-
async _disconnectTransport() {
|
|
8674
|
+
async _disconnectTransport(force = false) {
|
|
8675
|
+
if (force) {
|
|
8676
|
+
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
8677
|
+
this.userAgent.transport.disconnectResolve = () => {};
|
|
8678
|
+
// eslint-disable-next-line
|
|
8679
|
+
this.userAgent.transport._ws.close(1000);
|
|
8680
|
+
return;
|
|
8681
|
+
}
|
|
8682
|
+
|
|
8616
8683
|
// Check if `disconnectPromise` is not present to avoid `Disconnect promise must not be defined` errors.
|
|
8617
8684
|
if (this.userAgent && this.userAgent.transport && !this.userAgent.transport.disconnectPromise) {
|
|
8618
8685
|
try {
|
|
@@ -9349,6 +9416,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9349
9416
|
}
|
|
9350
9417
|
|
|
9351
9418
|
callSession.answerTime = new Date();
|
|
9419
|
+
this._updateCallSession(callSession);
|
|
9352
9420
|
this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
|
|
9353
9421
|
|
|
9354
9422
|
return callSession;
|
|
@@ -9565,6 +9633,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9565
9633
|
|
|
9566
9634
|
this.shouldSendReinvite = false;
|
|
9567
9635
|
callSession.answerTime = new Date();
|
|
9636
|
+
this._updateCallSession(callSession);
|
|
9568
9637
|
this.acceptedSessions[callSession.getId()] = true;
|
|
9569
9638
|
|
|
9570
9639
|
this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
|
|
@@ -9664,7 +9733,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9664
9733
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
9665
9734
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
9666
9735
|
logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
9667
|
-
this.holdSipSession(this.currentSipSession,
|
|
9736
|
+
this.holdSipSession(this.currentSipSession, this.currentCallSession);
|
|
9668
9737
|
}
|
|
9669
9738
|
|
|
9670
9739
|
const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
|
|
@@ -9875,6 +9944,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9875
9944
|
}
|
|
9876
9945
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
9877
9946
|
callSession.creationTime = new Date();
|
|
9947
|
+
this._updateCallSession(callSession);
|
|
9878
9948
|
|
|
9879
9949
|
this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
9880
9950
|
|
|
@@ -10016,7 +10086,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10016
10086
|
return this.client && this.client.isConference(callSession.sipCallId);
|
|
10017
10087
|
}
|
|
10018
10088
|
|
|
10019
|
-
async close() {
|
|
10089
|
+
async close(force = false) {
|
|
10020
10090
|
logger$7.info('WebRTC close');
|
|
10021
10091
|
|
|
10022
10092
|
try {
|
|
@@ -10028,7 +10098,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10028
10098
|
logger$7.error('WebRTC close, unregister error', e);
|
|
10029
10099
|
}
|
|
10030
10100
|
|
|
10031
|
-
this.client.close();
|
|
10101
|
+
this.client.close(force);
|
|
10032
10102
|
this.unbind();
|
|
10033
10103
|
|
|
10034
10104
|
this.incomingSessions = [];
|
|
@@ -10154,6 +10224,8 @@ class WebRTCPhone extends Emitter {
|
|
|
10154
10224
|
}
|
|
10155
10225
|
|
|
10156
10226
|
callSession.creationTime = new Date();
|
|
10227
|
+
this._updateCallSession(callSession);
|
|
10228
|
+
|
|
10157
10229
|
this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
|
|
10158
10230
|
});
|
|
10159
10231
|
|
|
@@ -10197,6 +10269,8 @@ class WebRTCPhone extends Emitter {
|
|
|
10197
10269
|
logger$7.info('WebRTC call rejected', session.id);
|
|
10198
10270
|
const callSession = this._createCallSession(session);
|
|
10199
10271
|
callSession.endTime = new Date();
|
|
10272
|
+
this._updateCallSession(callSession);
|
|
10273
|
+
|
|
10200
10274
|
this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
|
|
10201
10275
|
});
|
|
10202
10276
|
|
|
@@ -10421,6 +10495,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10421
10495
|
displayName: identity ? identity.displayName || number : number,
|
|
10422
10496
|
startTime: fromSession ? fromSession.startTime : new Date(),
|
|
10423
10497
|
creationTime: fromSession ? fromSession.creationTime : null,
|
|
10498
|
+
answerTime: fromSession ? fromSession.answerTime : null,
|
|
10424
10499
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10425
10500
|
answered: state === SessionState.Established,
|
|
10426
10501
|
paused: this.client.isCallHeld(sipSession),
|
|
@@ -3584,13 +3584,21 @@ class CallSession {
|
|
|
3584
3584
|
|
|
3585
3585
|
// Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
|
|
3586
3586
|
set answered(value ) {
|
|
3587
|
-
this.answerTime = value ? new Date() : null;
|
|
3587
|
+
this.answerTime = value ? this.answerTime || new Date() : null;
|
|
3588
3588
|
}
|
|
3589
3589
|
|
|
3590
3590
|
get answered() {
|
|
3591
3591
|
return !!this.answerTime;
|
|
3592
3592
|
}
|
|
3593
3593
|
|
|
3594
|
+
toJSON() {
|
|
3595
|
+
const jsonObj = { ...this };
|
|
3596
|
+
// $FlowFixMe
|
|
3597
|
+
jsonObj.answered = this.answered;
|
|
3598
|
+
|
|
3599
|
+
return jsonObj;
|
|
3600
|
+
}
|
|
3601
|
+
|
|
3594
3602
|
static parseCall(call ) {
|
|
3595
3603
|
return new CallSession({
|
|
3596
3604
|
callId: call.id,
|
|
@@ -4842,6 +4850,34 @@ var chatdMethods = (client , baseUrl ) => ({
|
|
|
4842
4850
|
client.get(`${baseUrl}/users/me/rooms/messages`, options),
|
|
4843
4851
|
});
|
|
4844
4852
|
|
|
4853
|
+
//
|
|
4854
|
+
|
|
4855
|
+
|
|
4856
|
+
|
|
4857
|
+
|
|
4858
|
+
|
|
4859
|
+
class MeetingStatus {
|
|
4860
|
+
|
|
4861
|
+
|
|
4862
|
+
|
|
4863
|
+
|
|
4864
|
+
constructor({
|
|
4865
|
+
full,
|
|
4866
|
+
} = {}) {
|
|
4867
|
+
this.full = full;
|
|
4868
|
+
|
|
4869
|
+
// Useful to compare instead of instanceof with minified code
|
|
4870
|
+
this.type = 'MeetingStatus';
|
|
4871
|
+
}
|
|
4872
|
+
|
|
4873
|
+
static parse(plain ) {
|
|
4874
|
+
return new MeetingStatus({
|
|
4875
|
+
full: plain.full,
|
|
4876
|
+
});
|
|
4877
|
+
}
|
|
4878
|
+
|
|
4879
|
+
}
|
|
4880
|
+
|
|
4845
4881
|
/* */
|
|
4846
4882
|
|
|
4847
4883
|
|
|
@@ -5036,6 +5072,8 @@ var calldMethods = (client , baseUrl ) => ({
|
|
|
5036
5072
|
client.put(`${baseUrl}/users/me/calls/${callId}/record/resume`, null, null,
|
|
5037
5073
|
ApiRequester.successResponseParser),
|
|
5038
5074
|
|
|
5075
|
+
guestGetMeetingStatus: (meetingUuid ) =>
|
|
5076
|
+
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}/status`).then(MeetingStatus.parse),
|
|
5039
5077
|
});
|
|
5040
5078
|
|
|
5041
5079
|
//
|
|
@@ -6637,6 +6675,7 @@ const MAX_REGISTER_TRIES = 10;
|
|
|
6637
6675
|
|
|
6638
6676
|
|
|
6639
6677
|
|
|
6678
|
+
|
|
6640
6679
|
|
|
6641
6680
|
|
|
6642
6681
|
|
|
@@ -6678,6 +6717,7 @@ class WebRTCClient extends Emitter {
|
|
|
6678
6717
|
|
|
6679
6718
|
|
|
6680
6719
|
|
|
6720
|
+
|
|
6681
6721
|
|
|
6682
6722
|
// sugar
|
|
6683
6723
|
|
|
@@ -6740,6 +6780,7 @@ class WebRTCClient extends Emitter {
|
|
|
6740
6780
|
this.conferences = {};
|
|
6741
6781
|
this.networkMonitoringInterval = {};
|
|
6742
6782
|
this.sessionNetworkStats = {};
|
|
6783
|
+
this.forceClosed = false;
|
|
6743
6784
|
|
|
6744
6785
|
this._boundOnHeartbeat = this._onHeartbeat.bind(this);
|
|
6745
6786
|
this.heartbeat = new Heartbeat(config.heartbeatDelay, config.heartbeatTimeout, config.maxHeartbeats);
|
|
@@ -6861,6 +6902,8 @@ class WebRTCClient extends Emitter {
|
|
|
6861
6902
|
skipRegister: this.skipRegister,
|
|
6862
6903
|
};
|
|
6863
6904
|
|
|
6905
|
+
this.forceClosed = false;
|
|
6906
|
+
|
|
6864
6907
|
if (this.skipRegister) {
|
|
6865
6908
|
logger$8.info('sdk webrtc skip register...', logInfo);
|
|
6866
6909
|
return Promise.resolve();
|
|
@@ -6885,7 +6928,15 @@ class WebRTCClient extends Emitter {
|
|
|
6885
6928
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6886
6929
|
|
|
6887
6930
|
const onRegisterFailed = () => {
|
|
6888
|
-
logger$8.info('sdk webrtc registering failed', {
|
|
6931
|
+
logger$8.info('sdk webrtc registering failed', {
|
|
6932
|
+
tries,
|
|
6933
|
+
registerer: !!this.registerer,
|
|
6934
|
+
forceClosed: this.forceClosed,
|
|
6935
|
+
});
|
|
6936
|
+
if (this.forceClosed) {
|
|
6937
|
+
return;
|
|
6938
|
+
}
|
|
6939
|
+
|
|
6889
6940
|
this.connectionPromise = null;
|
|
6890
6941
|
if (this.registerer && this.registerer.waiting) {
|
|
6891
6942
|
this.registerer.waitingToggle(false);
|
|
@@ -7163,8 +7214,9 @@ class WebRTCClient extends Emitter {
|
|
|
7163
7214
|
}
|
|
7164
7215
|
}
|
|
7165
7216
|
|
|
7166
|
-
async close() {
|
|
7167
|
-
logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
7217
|
+
async close(force = false) {
|
|
7218
|
+
logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent, force });
|
|
7219
|
+
this.forceClosed = force;
|
|
7168
7220
|
this._cleanupMedia();
|
|
7169
7221
|
this.connectionPromise = null;
|
|
7170
7222
|
|
|
@@ -7183,7 +7235,7 @@ class WebRTCClient extends Emitter {
|
|
|
7183
7235
|
this.userAgent.delegate = null;
|
|
7184
7236
|
this.userAgent.stateChange.removeAllListeners();
|
|
7185
7237
|
|
|
7186
|
-
await this._disconnectTransport();
|
|
7238
|
+
await this._disconnectTransport(force);
|
|
7187
7239
|
|
|
7188
7240
|
this._cleanupRegister();
|
|
7189
7241
|
|
|
@@ -8253,6 +8305,13 @@ class WebRTCClient extends Emitter {
|
|
|
8253
8305
|
}
|
|
8254
8306
|
|
|
8255
8307
|
_createWebRTCConfiguration(configOverrides = {}) {
|
|
8308
|
+
let { host } = this.config;
|
|
8309
|
+
let port = this.config.port || 443;
|
|
8310
|
+
|
|
8311
|
+
if (this.config.websocketSip) {
|
|
8312
|
+
[host, port = 443] = this.config.websocketSip.split(':');
|
|
8313
|
+
}
|
|
8314
|
+
|
|
8256
8315
|
const config = {
|
|
8257
8316
|
authorizationUsername: this.config.authorizationUser,
|
|
8258
8317
|
authorizationPassword: this.config.password,
|
|
@@ -8288,7 +8347,7 @@ class WebRTCClient extends Emitter {
|
|
|
8288
8347
|
},
|
|
8289
8348
|
transportOptions: {
|
|
8290
8349
|
traceSip: configOverrides.traceSip || false,
|
|
8291
|
-
wsServers: `wss://${
|
|
8350
|
+
wsServers: `wss://${host}:${port}/api/asterisk/ws`,
|
|
8292
8351
|
},
|
|
8293
8352
|
sessionDescriptionHandlerFactoryOptions: {
|
|
8294
8353
|
modifiers: [replaceLocalIpModifier],
|
|
@@ -8612,7 +8671,15 @@ class WebRTCClient extends Emitter {
|
|
|
8612
8671
|
return UserAgent.makeURI(`sip:${target}@${this.config.host}`);
|
|
8613
8672
|
}
|
|
8614
8673
|
|
|
8615
|
-
async _disconnectTransport() {
|
|
8674
|
+
async _disconnectTransport(force = false) {
|
|
8675
|
+
if (force) {
|
|
8676
|
+
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
8677
|
+
this.userAgent.transport.disconnectResolve = () => {};
|
|
8678
|
+
// eslint-disable-next-line
|
|
8679
|
+
this.userAgent.transport._ws.close(1000);
|
|
8680
|
+
return;
|
|
8681
|
+
}
|
|
8682
|
+
|
|
8616
8683
|
// Check if `disconnectPromise` is not present to avoid `Disconnect promise must not be defined` errors.
|
|
8617
8684
|
if (this.userAgent && this.userAgent.transport && !this.userAgent.transport.disconnectPromise) {
|
|
8618
8685
|
try {
|
|
@@ -9349,6 +9416,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9349
9416
|
}
|
|
9350
9417
|
|
|
9351
9418
|
callSession.answerTime = new Date();
|
|
9419
|
+
this._updateCallSession(callSession);
|
|
9352
9420
|
this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
|
|
9353
9421
|
|
|
9354
9422
|
return callSession;
|
|
@@ -9565,6 +9633,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9565
9633
|
|
|
9566
9634
|
this.shouldSendReinvite = false;
|
|
9567
9635
|
callSession.answerTime = new Date();
|
|
9636
|
+
this._updateCallSession(callSession);
|
|
9568
9637
|
this.acceptedSessions[callSession.getId()] = true;
|
|
9569
9638
|
|
|
9570
9639
|
this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
|
|
@@ -9664,7 +9733,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9664
9733
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
9665
9734
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
9666
9735
|
logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
9667
|
-
this.holdSipSession(this.currentSipSession,
|
|
9736
|
+
this.holdSipSession(this.currentSipSession, this.currentCallSession);
|
|
9668
9737
|
}
|
|
9669
9738
|
|
|
9670
9739
|
const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
|
|
@@ -9875,6 +9944,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9875
9944
|
}
|
|
9876
9945
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
9877
9946
|
callSession.creationTime = new Date();
|
|
9947
|
+
this._updateCallSession(callSession);
|
|
9878
9948
|
|
|
9879
9949
|
this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
9880
9950
|
|
|
@@ -10016,7 +10086,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10016
10086
|
return this.client && this.client.isConference(callSession.sipCallId);
|
|
10017
10087
|
}
|
|
10018
10088
|
|
|
10019
|
-
async close() {
|
|
10089
|
+
async close(force = false) {
|
|
10020
10090
|
logger$7.info('WebRTC close');
|
|
10021
10091
|
|
|
10022
10092
|
try {
|
|
@@ -10028,7 +10098,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10028
10098
|
logger$7.error('WebRTC close, unregister error', e);
|
|
10029
10099
|
}
|
|
10030
10100
|
|
|
10031
|
-
this.client.close();
|
|
10101
|
+
this.client.close(force);
|
|
10032
10102
|
this.unbind();
|
|
10033
10103
|
|
|
10034
10104
|
this.incomingSessions = [];
|
|
@@ -10154,6 +10224,8 @@ class WebRTCPhone extends Emitter {
|
|
|
10154
10224
|
}
|
|
10155
10225
|
|
|
10156
10226
|
callSession.creationTime = new Date();
|
|
10227
|
+
this._updateCallSession(callSession);
|
|
10228
|
+
|
|
10157
10229
|
this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
|
|
10158
10230
|
});
|
|
10159
10231
|
|
|
@@ -10197,6 +10269,8 @@ class WebRTCPhone extends Emitter {
|
|
|
10197
10269
|
logger$7.info('WebRTC call rejected', session.id);
|
|
10198
10270
|
const callSession = this._createCallSession(session);
|
|
10199
10271
|
callSession.endTime = new Date();
|
|
10272
|
+
this._updateCallSession(callSession);
|
|
10273
|
+
|
|
10200
10274
|
this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
|
|
10201
10275
|
});
|
|
10202
10276
|
|
|
@@ -10421,6 +10495,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10421
10495
|
displayName: identity ? identity.displayName || number : number,
|
|
10422
10496
|
startTime: fromSession ? fromSession.startTime : new Date(),
|
|
10423
10497
|
creationTime: fromSession ? fromSession.creationTime : null,
|
|
10498
|
+
answerTime: fromSession ? fromSession.answerTime : null,
|
|
10424
10499
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10425
10500
|
answered: state === SessionState.Established,
|
|
10426
10501
|
paused: this.client.isCallHeld(sipSession),
|