@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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import CallSession from '../CallSession';
|
|
2
2
|
|
|
3
|
+
const stringify = cs => JSON.parse(JSON.stringify(cs));
|
|
4
|
+
|
|
3
5
|
describe('CallSession domain', () => {
|
|
4
6
|
it('should update from another CallSession without data loss', () => {
|
|
5
7
|
const callSession = new CallSession({
|
|
@@ -38,7 +40,7 @@ describe('CallSession domain', () => {
|
|
|
38
40
|
expect(cs2.is(cs1)).toBeTruthy();
|
|
39
41
|
});
|
|
40
42
|
|
|
41
|
-
it('should set answerTime when setting answered', () => {
|
|
43
|
+
it('should set answerTime when setting answered to true', () => {
|
|
42
44
|
const cs1 = new CallSession({});
|
|
43
45
|
cs1.answered = true;
|
|
44
46
|
|
|
@@ -47,11 +49,37 @@ describe('CallSession domain', () => {
|
|
|
47
49
|
|
|
48
50
|
const cs3 = new CallSession({ answered: true });
|
|
49
51
|
|
|
50
|
-
expect(cs1.answered).
|
|
52
|
+
expect(cs1.answered).toEqual(true);
|
|
51
53
|
expect(cs1.answerTime).not.toBeNull();
|
|
52
|
-
expect(cs2.answered).
|
|
54
|
+
expect(cs2.answered).toEqual(true);
|
|
53
55
|
expect(cs2.answerTime).not.toBeNull();
|
|
54
|
-
expect(cs3.answered).
|
|
56
|
+
expect(cs3.answered).toEqual(true);
|
|
55
57
|
expect(cs3.answerTime).not.toBeNull();
|
|
58
|
+
|
|
59
|
+
const cs4 = stringify(cs1);
|
|
60
|
+
const cs5 = stringify(cs2);
|
|
61
|
+
const cs6 = stringify(cs3);
|
|
62
|
+
|
|
63
|
+
expect(cs4.answered).toEqual(true);
|
|
64
|
+
expect(cs5.answered).toEqual(true);
|
|
65
|
+
expect(cs6.answered).toEqual(true);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should reset answerTime when setting answered to false', () => {
|
|
69
|
+
const cs1 = new CallSession({});
|
|
70
|
+
cs1.answered = false;
|
|
71
|
+
|
|
72
|
+
const cs2 = new CallSession({ answered: false });
|
|
73
|
+
|
|
74
|
+
expect(cs1.answered).toEqual(false);
|
|
75
|
+
expect(cs1.answerTime).toBeNull();
|
|
76
|
+
expect(cs2.answered).toEqual(false);
|
|
77
|
+
expect(cs2.answerTime).toBeNull();
|
|
78
|
+
|
|
79
|
+
const cs4 = stringify(cs1);
|
|
80
|
+
const cs5 = stringify(cs2);
|
|
81
|
+
|
|
82
|
+
expect(cs4.answered).toEqual(false);
|
|
83
|
+
expect(cs5.answered).toEqual(false);
|
|
56
84
|
});
|
|
57
85
|
});
|
package/src/web-rtc-client.js
CHANGED
|
@@ -75,7 +75,7 @@ export const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
|
75
75
|
export const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
76
76
|
export class CanceledCallError extends Error {}
|
|
77
77
|
|
|
78
|
-
const MAX_REGISTER_TRIES =
|
|
78
|
+
const MAX_REGISTER_TRIES = 5;
|
|
79
79
|
|
|
80
80
|
type MediaConfig = {
|
|
81
81
|
audio: Object & boolean,
|
|
@@ -129,6 +129,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
129
129
|
skipRegister: boolean;
|
|
130
130
|
networkMonitoringInterval: { [string]: IntervalID };
|
|
131
131
|
sessionNetworkStats: { [string]: Object };
|
|
132
|
+
forceClosed: boolean;
|
|
132
133
|
|
|
133
134
|
// sugar
|
|
134
135
|
ON_USER_AGENT: string;
|
|
@@ -191,6 +192,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
191
192
|
this.conferences = {};
|
|
192
193
|
this.networkMonitoringInterval = {};
|
|
193
194
|
this.sessionNetworkStats = {};
|
|
195
|
+
this.forceClosed = false;
|
|
194
196
|
|
|
195
197
|
this._boundOnHeartbeat = this._onHeartbeat.bind(this);
|
|
196
198
|
this.heartbeat = new Heartbeat(config.heartbeatDelay, config.heartbeatTimeout, config.maxHeartbeats);
|
|
@@ -312,6 +314,8 @@ export default class WebRTCClient extends Emitter {
|
|
|
312
314
|
skipRegister: this.skipRegister,
|
|
313
315
|
};
|
|
314
316
|
|
|
317
|
+
this.forceClosed = false;
|
|
318
|
+
|
|
315
319
|
if (this.skipRegister) {
|
|
316
320
|
logger.info('sdk webrtc skip register...', logInfo);
|
|
317
321
|
return Promise.resolve();
|
|
@@ -336,7 +340,15 @@ export default class WebRTCClient extends Emitter {
|
|
|
336
340
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
337
341
|
|
|
338
342
|
const onRegisterFailed = () => {
|
|
339
|
-
logger.info('sdk webrtc registering failed', {
|
|
343
|
+
logger.info('sdk webrtc registering failed', {
|
|
344
|
+
tries,
|
|
345
|
+
registerer: !!this.registerer,
|
|
346
|
+
forceClosed: this.forceClosed,
|
|
347
|
+
});
|
|
348
|
+
if (this.forceClosed) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
|
|
340
352
|
this.connectionPromise = null;
|
|
341
353
|
if (this.registerer && this.registerer.waiting) {
|
|
342
354
|
this.registerer.waitingToggle(false);
|
|
@@ -614,8 +626,9 @@ export default class WebRTCClient extends Emitter {
|
|
|
614
626
|
}
|
|
615
627
|
}
|
|
616
628
|
|
|
617
|
-
async close() {
|
|
618
|
-
logger.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
629
|
+
async close(force: boolean = false) {
|
|
630
|
+
logger.info('sdk webrtc closing client', { userAgent: !!this.userAgent, force });
|
|
631
|
+
this.forceClosed = force;
|
|
619
632
|
this._cleanupMedia();
|
|
620
633
|
this.connectionPromise = null;
|
|
621
634
|
|
|
@@ -634,7 +647,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
634
647
|
this.userAgent.delegate = null;
|
|
635
648
|
this.userAgent.stateChange.removeAllListeners();
|
|
636
649
|
|
|
637
|
-
await this._disconnectTransport();
|
|
650
|
+
await this._disconnectTransport(force);
|
|
638
651
|
|
|
639
652
|
this._cleanupRegister();
|
|
640
653
|
|
|
@@ -2070,7 +2083,15 @@ export default class WebRTCClient extends Emitter {
|
|
|
2070
2083
|
return UserAgent.makeURI(`sip:${target}@${this.config.host}`);
|
|
2071
2084
|
}
|
|
2072
2085
|
|
|
2073
|
-
async _disconnectTransport() {
|
|
2086
|
+
async _disconnectTransport(force: boolean = false) {
|
|
2087
|
+
if (force) {
|
|
2088
|
+
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
2089
|
+
this.userAgent.transport.disconnectResolve = () => {};
|
|
2090
|
+
// eslint-disable-next-line
|
|
2091
|
+
this.userAgent.transport._ws.close(1000);
|
|
2092
|
+
return;
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2074
2095
|
// Check if `disconnectPromise` is not present to avoid `Disconnect promise must not be defined` errors.
|
|
2075
2096
|
if (this.userAgent && this.userAgent.transport && !this.userAgent.transport.disconnectPromise) {
|
|
2076
2097
|
try {
|