@wazo/sdk 0.37.20 → 0.37.24
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 +6 -6
- package/esm/__tests__/api-client.test.js +91 -21
- package/esm/__tests__/web-rtc-client.test.js +214 -165
- package/esm/api/agentd.js +25 -2
- package/esm/api/amid.js +26 -3
- package/esm/api/application.js +25 -2
- package/esm/api/auth.js +25 -2
- package/esm/api/call-logd.js +34 -4
- package/esm/api/calld.js +35 -2
- package/esm/api/chatd.js +32 -2
- package/esm/api/confd.js +56 -9
- package/esm/api/ctid-ng.js +38 -5
- package/esm/api/dird.js +29 -3
- package/esm/api/webhookd.js +26 -3
- package/esm/api-client.js +91 -21
- package/esm/checker/Checker.js +241 -190
- package/esm/checker/checks/aor.js +91 -21
- package/esm/checker/checks/api.js +91 -21
- package/esm/checker/checks/index.js +231 -180
- package/esm/checker/checks/wazo-websocket.js +42 -17
- package/esm/checker/checks/webrtc-transport.js +214 -165
- package/esm/checker/checks/webrtc.js +214 -165
- package/esm/domain/AdHocAPIConference.js +91 -21
- package/esm/domain/Call.js +3 -0
- package/esm/domain/CallLog.js +8 -1
- package/esm/domain/ChatMessage.js +4 -0
- package/esm/domain/ChatRoom.js +3 -0
- package/esm/domain/Contact.js +4 -1
- package/esm/domain/Features.js +91 -21
- package/esm/domain/Meeting.js +28 -5
- package/esm/domain/Phone/CTIPhone.js +109 -35
- package/esm/domain/Phone/WebRTCPhone.js +159 -102
- package/esm/domain/Recording.js +3 -0
- package/esm/domain/Voicemail.js +3 -0
- package/esm/domain/__tests__/Call.test.js +3 -0
- package/esm/domain/__tests__/CallLog.test.js +8 -1
- package/esm/domain/__tests__/Contact.test.js +4 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +509 -414
- package/esm/lib/WazoSessionDescriptionHandler.js +26 -41
- package/esm/service/CallApi.js +91 -21
- package/esm/service/IssueReporter.js +26 -3
- package/esm/service/__tests__/IssueReporter.test.js +26 -3
- package/esm/service/getApiClient.js +91 -21
- package/esm/simple/Auth.js +499 -404
- package/esm/simple/Configuration.js +499 -404
- package/esm/simple/Directory.js +91 -21
- package/esm/simple/Phone.js +499 -404
- package/esm/simple/Websocket.js +45 -19
- package/esm/simple/index.js +503 -408
- package/esm/simple/room/LocalParticipant.js +503 -408
- package/esm/simple/room/Participant.js +503 -408
- package/esm/simple/room/RemoteParticipant.js +503 -408
- package/esm/simple/room/Room.js +504 -409
- package/esm/simple/room/SipRoom.js +503 -408
- package/esm/simple/room/Stream.js +503 -408
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/esm/simple/utils.js +503 -408
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/utils/__tests__/api-requester.test.js +25 -2
- package/esm/utils/api-requester.js +25 -2
- package/esm/web-rtc-client.js +214 -165
- package/esm/websocket-client.js +43 -18
- package/lib/__tests__/api-client.test.js +91 -21
- package/lib/__tests__/web-rtc-client.test.js +214 -165
- package/lib/api/agentd.js +25 -2
- package/lib/api/amid.js +26 -3
- package/lib/api/application.js +25 -2
- package/lib/api/auth.js +25 -2
- package/lib/api/call-logd.js +34 -4
- package/lib/api/calld.js +35 -2
- package/lib/api/chatd.js +32 -2
- package/lib/api/confd.js +56 -9
- package/lib/api/ctid-ng.js +38 -5
- package/lib/api/dird.js +29 -3
- package/lib/api/webhookd.js +26 -3
- package/lib/api-client.js +91 -21
- package/lib/checker/Checker.js +241 -190
- package/lib/checker/checks/aor.js +91 -21
- package/lib/checker/checks/api.js +91 -21
- package/lib/checker/checks/index.js +231 -180
- package/lib/checker/checks/wazo-websocket.js +42 -17
- package/lib/checker/checks/webrtc-transport.js +214 -165
- package/lib/checker/checks/webrtc.js +214 -165
- package/lib/domain/AdHocAPIConference.js +91 -21
- package/lib/domain/Call.js +3 -0
- package/lib/domain/CallLog.js +8 -1
- package/lib/domain/ChatMessage.js +4 -0
- package/lib/domain/ChatRoom.js +3 -0
- package/lib/domain/Contact.js +4 -1
- package/lib/domain/Features.js +91 -21
- package/lib/domain/Meeting.js +32 -5
- package/lib/domain/Phone/CTIPhone.js +109 -35
- package/lib/domain/Phone/WebRTCPhone.js +159 -102
- package/lib/domain/Recording.js +3 -0
- package/lib/domain/Voicemail.js +3 -0
- package/lib/domain/__tests__/Call.test.js +3 -0
- package/lib/domain/__tests__/CallLog.test.js +8 -1
- package/lib/domain/__tests__/Contact.test.js +4 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +509 -414
- package/lib/lib/WazoSessionDescriptionHandler.js +26 -41
- package/lib/service/CallApi.js +91 -21
- package/lib/service/IssueReporter.js +26 -3
- package/lib/service/__tests__/IssueReporter.test.js +26 -3
- package/lib/service/getApiClient.js +91 -21
- package/lib/simple/Auth.js +499 -404
- package/lib/simple/Configuration.js +499 -404
- package/lib/simple/Directory.js +91 -21
- package/lib/simple/Phone.js +499 -404
- package/lib/simple/Websocket.js +45 -19
- package/lib/simple/index.js +503 -408
- package/lib/simple/room/LocalParticipant.js +503 -408
- package/lib/simple/room/Participant.js +503 -408
- package/lib/simple/room/RemoteParticipant.js +503 -408
- package/lib/simple/room/Room.js +504 -409
- package/lib/simple/room/SipRoom.js +503 -408
- package/lib/simple/room/Stream.js +503 -408
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/lib/simple/utils.js +503 -408
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/utils/__tests__/api-requester.test.js +25 -2
- package/lib/utils/api-requester.js +25 -2
- package/lib/web-rtc-client.js +214 -165
- package/lib/websocket-client.js +43 -17
- package/package.json +1 -1
- package/src/api/confd.js +5 -2
- package/src/domain/Call.js +3 -0
- package/src/domain/CallLog.js +4 -0
- package/src/domain/ChatMessage.js +4 -0
- package/src/domain/ChatRoom.js +3 -0
- package/src/domain/Contact.js +3 -0
- package/src/domain/Meeting.js +28 -5
- package/src/domain/Phone/CTIPhone.js +4 -0
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +49 -15
- package/src/domain/Recording.js +3 -0
- package/src/domain/Voicemail.js +3 -0
- package/src/domain/__tests__/Meeting.test.js +50 -0
- package/src/lib/WazoSessionDescriptionHandler.js +1 -35
- package/src/service/IssueReporter.js +25 -2
- package/src/simple/Phone.js +5 -0
- package/src/types/WebSocketMessage.js +5 -1
- package/src/web-rtc-client.js +41 -24
- package/src/websocket-client.js +2 -0
|
@@ -148,6 +148,7 @@ class IssueReporter {
|
|
|
148
148
|
|
|
149
149
|
|
|
150
150
|
|
|
151
|
+
|
|
151
152
|
|
|
152
153
|
constructor() {
|
|
153
154
|
addLevelsTo(this);
|
|
@@ -159,12 +160,17 @@ class IssueReporter {
|
|
|
159
160
|
this.bufferTimeout = null;
|
|
160
161
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
161
162
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
163
|
+
this._callback = null;
|
|
162
164
|
}
|
|
163
165
|
|
|
164
166
|
init() {
|
|
165
167
|
this._catchConsole();
|
|
166
168
|
}
|
|
167
169
|
|
|
170
|
+
setCallback(cb ) {
|
|
171
|
+
this._callback = cb;
|
|
172
|
+
}
|
|
173
|
+
|
|
168
174
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
169
175
|
this.remoteClientConfiguration = configuration;
|
|
170
176
|
}
|
|
@@ -200,6 +206,7 @@ class IssueReporter {
|
|
|
200
206
|
|
|
201
207
|
// Handle category label
|
|
202
208
|
let category = null;
|
|
209
|
+
let skipSendToRemote = false;
|
|
203
210
|
let extra = {};
|
|
204
211
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
205
212
|
category = args[0].split('=')[1];
|
|
@@ -215,6 +222,7 @@ class IssueReporter {
|
|
|
215
222
|
errorMessage: lastArg.message,
|
|
216
223
|
errorStack: lastArg.stack,
|
|
217
224
|
errorType: lastArg.constructor.name,
|
|
225
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
218
226
|
};
|
|
219
227
|
} else {
|
|
220
228
|
extra = lastArg;
|
|
@@ -223,6 +231,11 @@ class IssueReporter {
|
|
|
223
231
|
args.splice(1, 1);
|
|
224
232
|
}
|
|
225
233
|
|
|
234
|
+
if (extra.skipSendToRemote) {
|
|
235
|
+
skipSendToRemote = true;
|
|
236
|
+
delete extra.skipSendToRemote;
|
|
237
|
+
}
|
|
238
|
+
|
|
226
239
|
const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
227
240
|
const message = args.join(', ');
|
|
228
241
|
let consoleMessage = message;
|
|
@@ -243,7 +256,13 @@ class IssueReporter {
|
|
|
243
256
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
244
257
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
245
258
|
|
|
246
|
-
this.
|
|
259
|
+
if (this._callback) {
|
|
260
|
+
this._callback(level, consoleMessage);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (!skipSendToRemote) {
|
|
264
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
265
|
+
}
|
|
247
266
|
}
|
|
248
267
|
|
|
249
268
|
logRequest(url , options , response , start ) {
|
|
@@ -388,7 +407,11 @@ class IssueReporter {
|
|
|
388
407
|
},
|
|
389
408
|
// $FlowFixMe
|
|
390
409
|
body,
|
|
391
|
-
}).catch(() => {
|
|
410
|
+
}).catch((e ) => {
|
|
411
|
+
// $FlowFixMe
|
|
412
|
+
e.skipSendToRemote = true;
|
|
413
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
414
|
+
|
|
392
415
|
setTimeout(() => {
|
|
393
416
|
if (isArray) {
|
|
394
417
|
payload = payload.map(message => {
|
|
@@ -435,7 +458,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
435
458
|
|
|
436
459
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
437
460
|
|
|
438
|
-
const logger
|
|
461
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
439
462
|
|
|
440
463
|
// Use a function here to be able to mock it in tests
|
|
441
464
|
const realFetch = () => {
|
|
@@ -574,7 +597,7 @@ class ApiRequester {
|
|
|
574
597
|
};
|
|
575
598
|
|
|
576
599
|
if (this.refreshTokenPromise) {
|
|
577
|
-
logger
|
|
600
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
578
601
|
await this.refreshTokenPromise;
|
|
579
602
|
}
|
|
580
603
|
|
|
@@ -594,7 +617,7 @@ class ApiRequester {
|
|
|
594
617
|
return promise.then(async (err ) => {
|
|
595
618
|
// Check if the token is still valid
|
|
596
619
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
597
|
-
logger
|
|
620
|
+
logger.warn('token expired', { error: err.reason });
|
|
598
621
|
// Replay the call after refreshing the token
|
|
599
622
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
600
623
|
}
|
|
@@ -604,7 +627,7 @@ class ApiRequester {
|
|
|
604
627
|
: exceptionClass.fromResponse(err, response.status);
|
|
605
628
|
|
|
606
629
|
if (this.shouldLogErrors) {
|
|
607
|
-
logger
|
|
630
|
+
logger.error('API error', error);
|
|
608
631
|
}
|
|
609
632
|
|
|
610
633
|
throw error;
|
|
@@ -614,7 +637,7 @@ class ApiRequester {
|
|
|
614
637
|
return newParse(response, isJson);
|
|
615
638
|
}).catch(error => {
|
|
616
639
|
if (this.shouldLogErrors) {
|
|
617
|
-
logger
|
|
640
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
618
641
|
}
|
|
619
642
|
|
|
620
643
|
throw error;
|
|
@@ -642,13 +665,13 @@ class ApiRequester {
|
|
|
642
665
|
) {
|
|
643
666
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
644
667
|
let newPath = path;
|
|
645
|
-
logger
|
|
668
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
646
669
|
|
|
647
670
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
648
671
|
|
|
649
672
|
return this.refreshTokenPromise.then(() => {
|
|
650
673
|
this.refreshTokenPromise = null;
|
|
651
|
-
logger
|
|
674
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
652
675
|
if (isTokenNotFound) {
|
|
653
676
|
const pathParts = path.split('/');
|
|
654
677
|
pathParts.pop();
|
|
@@ -1526,6 +1549,9 @@ class Contact {
|
|
|
1526
1549
|
}
|
|
1527
1550
|
|
|
1528
1551
|
static parseMany(response ) {
|
|
1552
|
+
if (!response || !response.results) {
|
|
1553
|
+
return [];
|
|
1554
|
+
}
|
|
1529
1555
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
1530
1556
|
}
|
|
1531
1557
|
|
|
@@ -2603,8 +2629,9 @@ class ExternalApp {
|
|
|
2603
2629
|
|
|
2604
2630
|
|
|
2605
2631
|
|
|
2606
|
-
|
|
2632
|
+
|
|
2607
2633
|
|
|
2634
|
+
|
|
2608
2635
|
|
|
2609
2636
|
|
|
2610
2637
|
class Meeting {
|
|
@@ -2615,9 +2642,10 @@ class Meeting {
|
|
|
2615
2642
|
|
|
2616
2643
|
|
|
2617
2644
|
|
|
2618
|
-
|
|
2645
|
+
|
|
2619
2646
|
|
|
2620
2647
|
|
|
2648
|
+
|
|
2621
2649
|
|
|
2622
2650
|
static parse(plain ) {
|
|
2623
2651
|
return new Meeting({
|
|
@@ -2627,24 +2655,43 @@ class Meeting {
|
|
|
2627
2655
|
ownerUuids: plain.owner_uuids,
|
|
2628
2656
|
port: plain.port,
|
|
2629
2657
|
uuid: plain.uuid,
|
|
2630
|
-
|
|
2658
|
+
extension: plain.exten,
|
|
2631
2659
|
persistent: plain.persistent,
|
|
2660
|
+
creationTime: moment(plain.creation_time).toDate(),
|
|
2632
2661
|
});
|
|
2633
2662
|
}
|
|
2634
2663
|
|
|
2664
|
+
static parseMany(items ) {
|
|
2665
|
+
if (!items) {
|
|
2666
|
+
return [];
|
|
2667
|
+
}
|
|
2668
|
+
return items.map(plain => Meeting.parse(plain));
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2635
2671
|
static newFrom(meeting ) {
|
|
2636
2672
|
return newFrom(meeting, Meeting);
|
|
2637
2673
|
}
|
|
2638
2674
|
|
|
2639
|
-
constructor({
|
|
2675
|
+
constructor({
|
|
2676
|
+
uuid,
|
|
2677
|
+
name,
|
|
2678
|
+
guestSipAuthorization,
|
|
2679
|
+
ownerUuids,
|
|
2680
|
+
port,
|
|
2681
|
+
uri,
|
|
2682
|
+
extension,
|
|
2683
|
+
persistent,
|
|
2684
|
+
creationTime,
|
|
2685
|
+
} = {}) {
|
|
2640
2686
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2641
2687
|
this.uri = uri;
|
|
2642
2688
|
this.name = name;
|
|
2643
2689
|
this.ownerUuids = ownerUuids;
|
|
2644
2690
|
this.port = port;
|
|
2645
2691
|
this.uuid = uuid;
|
|
2646
|
-
this.
|
|
2692
|
+
this.extension = extension;
|
|
2647
2693
|
this.persistent = persistent;
|
|
2694
|
+
this.creationTime = creationTime;
|
|
2648
2695
|
|
|
2649
2696
|
// Useful to compare instead of instanceof with minified code
|
|
2650
2697
|
this.type = 'Meeting';
|
|
@@ -2722,8 +2769,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2722
2769
|
}
|
|
2723
2770
|
},
|
|
2724
2771
|
|
|
2725
|
-
|
|
2726
|
-
client.
|
|
2772
|
+
getMyMeetings: () =>
|
|
2773
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
2774
|
+
|
|
2775
|
+
createMyMeeting: (name , persistent ) =>
|
|
2776
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
2727
2777
|
|
|
2728
2778
|
deleteMyMeeting: (meetingUuid ) =>
|
|
2729
2779
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -2819,6 +2869,10 @@ class ChatMessage {
|
|
|
2819
2869
|
|
|
2820
2870
|
|
|
2821
2871
|
static parseMany(plain ) {
|
|
2872
|
+
if (!plain || !plain.items) {
|
|
2873
|
+
return [];
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2822
2876
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
2823
2877
|
}
|
|
2824
2878
|
|
|
@@ -2928,6 +2982,9 @@ class Voicemail {
|
|
|
2928
2982
|
}
|
|
2929
2983
|
|
|
2930
2984
|
static parseMany(plain ) {
|
|
2985
|
+
if (!plain) {
|
|
2986
|
+
return [];
|
|
2987
|
+
}
|
|
2931
2988
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
2932
2989
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
2933
2990
|
|
|
@@ -3037,6 +3094,9 @@ class Call {
|
|
|
3037
3094
|
|
|
3038
3095
|
|
|
3039
3096
|
static parseMany(plain ) {
|
|
3097
|
+
if (!plain) {
|
|
3098
|
+
return [];
|
|
3099
|
+
}
|
|
3040
3100
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
3041
3101
|
}
|
|
3042
3102
|
|
|
@@ -3235,6 +3295,9 @@ class Recording {
|
|
|
3235
3295
|
|
|
3236
3296
|
|
|
3237
3297
|
static parseMany(recordings = []) {
|
|
3298
|
+
if (!recordings) {
|
|
3299
|
+
return [];
|
|
3300
|
+
}
|
|
3238
3301
|
return recordings.map(item => Recording.parse(item));
|
|
3239
3302
|
}
|
|
3240
3303
|
|
|
@@ -3336,6 +3399,10 @@ class CallLog {
|
|
|
3336
3399
|
}
|
|
3337
3400
|
|
|
3338
3401
|
static parseMany(plain ) {
|
|
3402
|
+
if (!plain || !plain.items) {
|
|
3403
|
+
return [];
|
|
3404
|
+
}
|
|
3405
|
+
|
|
3339
3406
|
return plain.items.map(item => CallLog.parse(item));
|
|
3340
3407
|
}
|
|
3341
3408
|
|
|
@@ -3572,7 +3639,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3572
3639
|
|
|
3573
3640
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3574
3641
|
|
|
3575
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3642
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3576
3643
|
|
|
3577
3644
|
/* */
|
|
3578
3645
|
|
|
@@ -3908,6 +3975,9 @@ class ChatRoom {
|
|
|
3908
3975
|
|
|
3909
3976
|
|
|
3910
3977
|
static parseMany(plain ) {
|
|
3978
|
+
if (!plain || !plain.items) {
|
|
3979
|
+
return [];
|
|
3980
|
+
}
|
|
3911
3981
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
3912
3982
|
}
|
|
3913
3983
|
|
|
@@ -4903,6 +4973,7 @@ const AGENT_PAUSED = 'agent_paused';
|
|
|
4903
4973
|
const AGENT_UNPAUSED = 'agent_unpaused';
|
|
4904
4974
|
const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
|
|
4905
4975
|
const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
|
|
4976
|
+
const MEETING_USER_PROGRESS = 'meeting_user_progress';
|
|
4906
4977
|
|
|
4907
4978
|
const BLACKLIST_EVENTS = [
|
|
4908
4979
|
CHAT_MESSAGE_SENT,
|
|
@@ -4912,7 +4983,7 @@ const BLACKLIST_EVENTS = [
|
|
|
4912
4983
|
];
|
|
4913
4984
|
|
|
4914
4985
|
const HEARTBEAT_ENGINE_VERSION = '20.09';
|
|
4915
|
-
const logger$
|
|
4986
|
+
const logger$3 = IssueReporter$1.loggerFor('wazo-ws');
|
|
4916
4987
|
const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
|
|
4917
4988
|
|
|
4918
4989
|
class WebSocketClient extends Emitter {
|
|
@@ -4961,19 +5032,19 @@ class WebSocketClient extends Emitter {
|
|
|
4961
5032
|
}
|
|
4962
5033
|
|
|
4963
5034
|
connect() {
|
|
4964
|
-
logger$
|
|
5035
|
+
logger$3.info('connect method started', { host: this.host, token: this.token });
|
|
4965
5036
|
this.socket = new ReconnectingWebSocket(this._getUrl.bind(this), [], this.options);
|
|
4966
5037
|
if (this.options.binaryType) {
|
|
4967
5038
|
this.socket.binaryType = this.options.binaryType;
|
|
4968
5039
|
}
|
|
4969
5040
|
|
|
4970
5041
|
this.socket.onopen = () => {
|
|
4971
|
-
logger$
|
|
5042
|
+
logger$3.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
4972
5043
|
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
4973
5044
|
};
|
|
4974
5045
|
|
|
4975
5046
|
this.socket.onerror = event => {
|
|
4976
|
-
logger$
|
|
5047
|
+
logger$3.error('on Wazo WS error', event.target);
|
|
4977
5048
|
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
4978
5049
|
};
|
|
4979
5050
|
|
|
@@ -5003,7 +5074,7 @@ class WebSocketClient extends Emitter {
|
|
|
5003
5074
|
|
|
5004
5075
|
this.socket.onclose = event => {
|
|
5005
5076
|
// Can't be converted to JSON (circular structure)
|
|
5006
|
-
logger$
|
|
5077
|
+
logger$3.info('on Wazo WS close', {
|
|
5007
5078
|
reason: event.reason,
|
|
5008
5079
|
code: event.code,
|
|
5009
5080
|
readyState: event.target.readyState,
|
|
@@ -5021,12 +5092,12 @@ class WebSocketClient extends Emitter {
|
|
|
5021
5092
|
};
|
|
5022
5093
|
|
|
5023
5094
|
this.socket.onerror = event => {
|
|
5024
|
-
logger$
|
|
5095
|
+
logger$3.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
5025
5096
|
};
|
|
5026
5097
|
}
|
|
5027
5098
|
|
|
5028
5099
|
close(force = false) {
|
|
5029
|
-
logger$
|
|
5100
|
+
logger$3.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
5030
5101
|
|
|
5031
5102
|
if (!this.socket) {
|
|
5032
5103
|
return;
|
|
@@ -5044,7 +5115,7 @@ class WebSocketClient extends Emitter {
|
|
|
5044
5115
|
|
|
5045
5116
|
updateToken(token ) {
|
|
5046
5117
|
this.token = token;
|
|
5047
|
-
logger$
|
|
5118
|
+
logger$3.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
5048
5119
|
|
|
5049
5120
|
if (this.socket) {
|
|
5050
5121
|
// If still connected, send the token to the WS
|
|
@@ -5062,7 +5133,7 @@ class WebSocketClient extends Emitter {
|
|
|
5062
5133
|
}
|
|
5063
5134
|
|
|
5064
5135
|
startHeartbeat() {
|
|
5065
|
-
logger$
|
|
5136
|
+
logger$3.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
5066
5137
|
|
|
5067
5138
|
if (!this.socket) {
|
|
5068
5139
|
this.heartbeat.stop();
|
|
@@ -5076,7 +5147,7 @@ class WebSocketClient extends Emitter {
|
|
|
5076
5147
|
}
|
|
5077
5148
|
|
|
5078
5149
|
stopHeartbeat() {
|
|
5079
|
-
logger$
|
|
5150
|
+
logger$3.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
5080
5151
|
|
|
5081
5152
|
this.heartbeat.stop();
|
|
5082
5153
|
}
|
|
@@ -5106,7 +5177,7 @@ class WebSocketClient extends Emitter {
|
|
|
5106
5177
|
}
|
|
5107
5178
|
|
|
5108
5179
|
reconnect(reason ) {
|
|
5109
|
-
logger$
|
|
5180
|
+
logger$3.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
5110
5181
|
if (!this.socket) {
|
|
5111
5182
|
return;
|
|
5112
5183
|
}
|
|
@@ -5162,7 +5233,7 @@ class WebSocketClient extends Emitter {
|
|
|
5162
5233
|
this.close();
|
|
5163
5234
|
}
|
|
5164
5235
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
5165
|
-
logger$
|
|
5236
|
+
logger$3.log('Wazo WS url computed to reconnect', { url });
|
|
5166
5237
|
|
|
5167
5238
|
return url;
|
|
5168
5239
|
}
|
|
@@ -5170,12 +5241,12 @@ class WebSocketClient extends Emitter {
|
|
|
5170
5241
|
_onHeartbeat(message ) {
|
|
5171
5242
|
if (message.payload === 'pong') {
|
|
5172
5243
|
this.heartbeat.onHeartbeat();
|
|
5173
|
-
logger$
|
|
5244
|
+
logger$3.log('on heartbeat received from Wazo WS');
|
|
5174
5245
|
}
|
|
5175
5246
|
}
|
|
5176
5247
|
|
|
5177
5248
|
async _onHeartbeatTimeout() {
|
|
5178
|
-
logger$
|
|
5249
|
+
logger$3.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
5179
5250
|
|
|
5180
5251
|
this.close();
|
|
5181
5252
|
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
@@ -5253,6 +5324,7 @@ WebSocketClient.eventLists = [
|
|
|
5253
5324
|
AGENT_UNPAUSED,
|
|
5254
5325
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
5255
5326
|
CONFERENCE_ADHOC_DELETED,
|
|
5327
|
+
MEETING_USER_PROGRESS,
|
|
5256
5328
|
];
|
|
5257
5329
|
|
|
5258
5330
|
var wazoWebsocket = {
|
|
@@ -5295,7 +5367,7 @@ var wazoWebsocket = {
|
|
|
5295
5367
|
|
|
5296
5368
|
/* */
|
|
5297
5369
|
|
|
5298
|
-
const parseCandidate
|
|
5370
|
+
const parseCandidate = (candidate ) => {
|
|
5299
5371
|
if (!candidate) {
|
|
5300
5372
|
return null;
|
|
5301
5373
|
}
|
|
@@ -5308,10 +5380,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
5308
5380
|
candidates
|
|
5309
5381
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
5310
5382
|
|
|
5311
|
-
const areCandidateValid = (candidates ) =>
|
|
5312
|
-
getSrflxOrRelay(candidates)
|
|
5313
|
-
.length > 0;
|
|
5314
|
-
|
|
5315
5383
|
const getVideoDirection = (sdp ) => {
|
|
5316
5384
|
const parsedSdp = sdpParser.parse(sdp);
|
|
5317
5385
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -5364,8 +5432,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
5364
5432
|
/* global RTCSessionDescriptionInit, navigator */
|
|
5365
5433
|
|
|
5366
5434
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
5367
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
5368
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
5369
5435
|
|
|
5370
5436
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
5371
5437
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -5455,7 +5521,7 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5455
5521
|
this.peerConnectionDelegate.onicecandidate = event => {
|
|
5456
5522
|
wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
|
|
5457
5523
|
if (event.candidate) {
|
|
5458
|
-
this.gatheredCandidates.push(parseCandidate
|
|
5524
|
+
this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
|
|
5459
5525
|
}
|
|
5460
5526
|
};
|
|
5461
5527
|
|
|
@@ -5555,38 +5621,6 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5555
5621
|
this._peerConnection = undefined;
|
|
5556
5622
|
}
|
|
5557
5623
|
|
|
5558
|
-
async _waitForValidGatheredIce() {
|
|
5559
|
-
let tries = 0;
|
|
5560
|
-
|
|
5561
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
5562
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
5563
|
-
tries,
|
|
5564
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
5565
|
-
});
|
|
5566
|
-
|
|
5567
|
-
tries++;
|
|
5568
|
-
|
|
5569
|
-
// eslint-disable-next-line no-await-in-loop
|
|
5570
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
5571
|
-
}
|
|
5572
|
-
|
|
5573
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
5574
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
5575
|
-
const error = new Error(errorMsg);
|
|
5576
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
5577
|
-
|
|
5578
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
5579
|
-
this.eventEmitter.emit('error', error);
|
|
5580
|
-
|
|
5581
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5582
|
-
}
|
|
5583
|
-
|
|
5584
|
-
// eslint-disable-next-line
|
|
5585
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5586
|
-
|
|
5587
|
-
return this.getLocalSessionDescription();
|
|
5588
|
-
}
|
|
5589
|
-
|
|
5590
5624
|
// Overridden to send `inactive` in conference
|
|
5591
5625
|
updateDirection(options , isConference = false,
|
|
5592
5626
|
audioOnly = false) {
|
|
@@ -5856,7 +5890,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
5856
5890
|
const SEND_STATS_DELAY = 5000;
|
|
5857
5891
|
|
|
5858
5892
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
5859
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
5893
|
+
const logger$4 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
5860
5894
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
5861
5895
|
|
|
5862
5896
|
// events
|
|
@@ -6032,13 +6066,13 @@ class WebRTCClient extends Emitter {
|
|
|
6032
6066
|
|
|
6033
6067
|
createUserAgent(configOverrides ) {
|
|
6034
6068
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6035
|
-
logger.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6069
|
+
logger$4.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6036
6070
|
|
|
6037
6071
|
webRTCConfiguration.delegate = {
|
|
6038
6072
|
onConnect: this.onConnect.bind(this),
|
|
6039
6073
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6040
6074
|
onInvite: (invitation ) => {
|
|
6041
|
-
logger.info('sdk webrtc on invite', {
|
|
6075
|
+
logger$4.info('sdk webrtc on invite', {
|
|
6042
6076
|
method: 'delegate.onInvite',
|
|
6043
6077
|
id: invitation.id,
|
|
6044
6078
|
remoteURI: invitation.remoteURI,
|
|
@@ -6081,7 +6115,7 @@ class WebRTCClient extends Emitter {
|
|
|
6081
6115
|
}
|
|
6082
6116
|
|
|
6083
6117
|
onConnect() {
|
|
6084
|
-
logger.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6118
|
+
logger$4.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6085
6119
|
this.eventEmitter.emit(CONNECTED);
|
|
6086
6120
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6087
6121
|
this.registerer.waitingToggle(false);
|
|
@@ -6090,7 +6124,7 @@ class WebRTCClient extends Emitter {
|
|
|
6090
6124
|
}
|
|
6091
6125
|
|
|
6092
6126
|
async onDisconnect(error ) {
|
|
6093
|
-
logger.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6127
|
+
logger$4.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6094
6128
|
this.connectionPromise = null;
|
|
6095
6129
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6096
6130
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6115,37 +6149,37 @@ class WebRTCClient extends Emitter {
|
|
|
6115
6149
|
};
|
|
6116
6150
|
|
|
6117
6151
|
if (this.skipRegister) {
|
|
6118
|
-
logger.info('sdk webrtc skip register...', logInfo);
|
|
6152
|
+
logger$4.info('sdk webrtc skip register...', logInfo);
|
|
6119
6153
|
return Promise.resolve();
|
|
6120
6154
|
}
|
|
6121
6155
|
|
|
6122
|
-
logger.info('sdk webrtc registering...', logInfo);
|
|
6156
|
+
logger$4.info('sdk webrtc registering...', logInfo);
|
|
6123
6157
|
|
|
6124
6158
|
if (!this.userAgent) {
|
|
6125
|
-
logger.info('sdk webrtc recreating User Agent');
|
|
6159
|
+
logger$4.info('sdk webrtc recreating User Agent');
|
|
6126
6160
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6127
6161
|
}
|
|
6128
6162
|
if (!this.userAgent || this.isRegistered()) {
|
|
6129
|
-
logger.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6163
|
+
logger$4.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6130
6164
|
return Promise.resolve();
|
|
6131
6165
|
}
|
|
6132
6166
|
|
|
6133
6167
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6134
|
-
logger.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6168
|
+
logger$4.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6135
6169
|
return Promise.resolve();
|
|
6136
6170
|
}
|
|
6137
6171
|
|
|
6138
6172
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6139
6173
|
|
|
6140
6174
|
const onRegisterFailed = () => {
|
|
6141
|
-
logger.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6175
|
+
logger$4.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6142
6176
|
this.connectionPromise = null;
|
|
6143
6177
|
if (this.registerer && this.registerer.waiting) {
|
|
6144
6178
|
this.registerer.waitingToggle(false);
|
|
6145
6179
|
}
|
|
6146
6180
|
|
|
6147
6181
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6148
|
-
logger.info('sdk webrtc registering, retrying...', { tries });
|
|
6182
|
+
logger$4.info('sdk webrtc registering, retrying...', { tries });
|
|
6149
6183
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6150
6184
|
}
|
|
6151
6185
|
};
|
|
@@ -6154,18 +6188,18 @@ class WebRTCClient extends Emitter {
|
|
|
6154
6188
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6155
6189
|
// during the resolution of the primise.
|
|
6156
6190
|
if (!this.userAgent) {
|
|
6157
|
-
logger.info('sdk webrtc recreating User Agent after connection');
|
|
6191
|
+
logger$4.info('sdk webrtc recreating User Agent after connection');
|
|
6158
6192
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6159
6193
|
}
|
|
6160
6194
|
|
|
6161
|
-
logger.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6195
|
+
logger$4.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6162
6196
|
this.registerer = new Registerer(this.userAgent, registerOptions);
|
|
6163
6197
|
this.connectionPromise = null;
|
|
6164
6198
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6165
6199
|
|
|
6166
6200
|
// Bind registerer events
|
|
6167
6201
|
this.registerer.stateChange.addListener(newState => {
|
|
6168
|
-
logger.info('sdk webrtc registering, state changed', { newState });
|
|
6202
|
+
logger$4.info('sdk webrtc registering, state changed', { newState });
|
|
6169
6203
|
|
|
6170
6204
|
if (newState === RegistererState.Registered && this.registerer
|
|
6171
6205
|
&& this.registerer.state === RegistererState.Registered) {
|
|
@@ -6178,7 +6212,7 @@ class WebRTCClient extends Emitter {
|
|
|
6178
6212
|
const options = {
|
|
6179
6213
|
requestDelegate: {
|
|
6180
6214
|
onReject: response => {
|
|
6181
|
-
logger.error('sdk webrtc registering, rejected', { response });
|
|
6215
|
+
logger$4.error('sdk webrtc registering, rejected', { response });
|
|
6182
6216
|
|
|
6183
6217
|
onRegisterFailed();
|
|
6184
6218
|
},
|
|
@@ -6186,13 +6220,13 @@ class WebRTCClient extends Emitter {
|
|
|
6186
6220
|
};
|
|
6187
6221
|
|
|
6188
6222
|
return this.registerer.register(options).catch((e) => {
|
|
6189
|
-
logger.error('sdk webrtc registering, error', e);
|
|
6223
|
+
logger$4.error('sdk webrtc registering, error', e);
|
|
6190
6224
|
|
|
6191
6225
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6192
6226
|
return e;
|
|
6193
6227
|
});
|
|
6194
6228
|
}).catch(error => {
|
|
6195
|
-
logger.error('sdk webrtc registering, transport error', error);
|
|
6229
|
+
logger$4.error('sdk webrtc registering, transport error', error);
|
|
6196
6230
|
onRegisterFailed();
|
|
6197
6231
|
});
|
|
6198
6232
|
}
|
|
@@ -6221,21 +6255,21 @@ class WebRTCClient extends Emitter {
|
|
|
6221
6255
|
}
|
|
6222
6256
|
|
|
6223
6257
|
unregister() {
|
|
6224
|
-
logger.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6258
|
+
logger$4.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6225
6259
|
if (!this.registerer) {
|
|
6226
6260
|
return Promise.resolve();
|
|
6227
6261
|
}
|
|
6228
6262
|
|
|
6229
6263
|
try {
|
|
6230
6264
|
return this.registerer.unregister().then(() => {
|
|
6231
|
-
logger.info('sdk webrtc unregistered');
|
|
6265
|
+
logger$4.info('sdk webrtc unregistered');
|
|
6232
6266
|
this._cleanupRegister();
|
|
6233
6267
|
}).catch(e => {
|
|
6234
|
-
logger.error('sdk webrtc unregistering, promise error', e);
|
|
6268
|
+
logger$4.error('sdk webrtc unregistering, promise error', e);
|
|
6235
6269
|
this._cleanupRegister();
|
|
6236
6270
|
});
|
|
6237
6271
|
} catch (e) {
|
|
6238
|
-
logger.error('sdk webrtc unregistering, error', e);
|
|
6272
|
+
logger$4.error('sdk webrtc unregistering, error', e);
|
|
6239
6273
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6240
6274
|
// error when the registerer is in a bad state
|
|
6241
6275
|
this._cleanupRegister();
|
|
@@ -6243,7 +6277,7 @@ class WebRTCClient extends Emitter {
|
|
|
6243
6277
|
}
|
|
6244
6278
|
|
|
6245
6279
|
stop() {
|
|
6246
|
-
logger.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6280
|
+
logger$4.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6247
6281
|
if (!this.userAgent) {
|
|
6248
6282
|
return Promise.resolve();
|
|
6249
6283
|
}
|
|
@@ -6251,12 +6285,12 @@ class WebRTCClient extends Emitter {
|
|
|
6251
6285
|
return this.userAgent.stop().then(() => {
|
|
6252
6286
|
return this._cleanupRegister();
|
|
6253
6287
|
}).catch(e => {
|
|
6254
|
-
logger.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6288
|
+
logger$4.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6255
6289
|
});
|
|
6256
6290
|
}
|
|
6257
6291
|
|
|
6258
6292
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6259
|
-
logger.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6293
|
+
logger$4.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6260
6294
|
const inviterOptions = {
|
|
6261
6295
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6262
6296
|
conference,
|
|
@@ -6281,11 +6315,13 @@ class WebRTCClient extends Emitter {
|
|
|
6281
6315
|
const inviteOptions = {
|
|
6282
6316
|
requestDelegate: {
|
|
6283
6317
|
onAccept: (response ) => {
|
|
6284
|
-
session.sessionDescriptionHandler.peerConnection
|
|
6318
|
+
if (session.sessionDescriptionHandler.peerConnection) {
|
|
6319
|
+
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
6320
|
+
}
|
|
6285
6321
|
this._onAccepted(session, response.session, true);
|
|
6286
6322
|
},
|
|
6287
6323
|
onReject: (response ) => {
|
|
6288
|
-
logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6324
|
+
logger$4.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6289
6325
|
this._stopSendingStats(session);
|
|
6290
6326
|
this.stopNetworkMonitoring(session);
|
|
6291
6327
|
|
|
@@ -6308,11 +6344,11 @@ class WebRTCClient extends Emitter {
|
|
|
6308
6344
|
}
|
|
6309
6345
|
|
|
6310
6346
|
answer(session , enableVideo ) {
|
|
6311
|
-
logger.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
6347
|
+
logger$4.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
6312
6348
|
|
|
6313
6349
|
if (!session || !session.accept) {
|
|
6314
6350
|
const error = 'No session to answer, or not an invitation';
|
|
6315
|
-
logger.warn(error);
|
|
6351
|
+
logger$4.warn(error);
|
|
6316
6352
|
return Promise.reject(new Error(error));
|
|
6317
6353
|
}
|
|
6318
6354
|
const options = {
|
|
@@ -6322,15 +6358,15 @@ class WebRTCClient extends Emitter {
|
|
|
6322
6358
|
return session.accept(options).then(() => {
|
|
6323
6359
|
if (session.isCanceled) {
|
|
6324
6360
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
6325
|
-
logger.error(message, { id: session.id });
|
|
6361
|
+
logger$4.error(message, { id: session.id });
|
|
6326
6362
|
this.onCallEnded(session);
|
|
6327
6363
|
|
|
6328
6364
|
throw new CanceledCallError(message);
|
|
6329
6365
|
}
|
|
6330
|
-
logger.info('sdk webrtc answer, accepted.');
|
|
6366
|
+
logger$4.info('sdk webrtc answer, accepted.');
|
|
6331
6367
|
this._onAccepted(session);
|
|
6332
6368
|
}).catch(e => {
|
|
6333
|
-
logger.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
6369
|
+
logger$4.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
6334
6370
|
|
|
6335
6371
|
throw e;
|
|
6336
6372
|
});
|
|
@@ -6338,7 +6374,7 @@ class WebRTCClient extends Emitter {
|
|
|
6338
6374
|
|
|
6339
6375
|
hangup(session ) {
|
|
6340
6376
|
const { state, id } = session;
|
|
6341
|
-
logger.info('sdk webrtc hangup call', { id, state });
|
|
6377
|
+
logger$4.info('sdk webrtc hangup call', { id, state });
|
|
6342
6378
|
|
|
6343
6379
|
try {
|
|
6344
6380
|
this._stopSendingStats(session);
|
|
@@ -6367,7 +6403,7 @@ class WebRTCClient extends Emitter {
|
|
|
6367
6403
|
|
|
6368
6404
|
return bye();
|
|
6369
6405
|
} catch (error) {
|
|
6370
|
-
logger.warn('sdk webrtc hangup, error', error);
|
|
6406
|
+
logger$4.warn('sdk webrtc hangup, error', error);
|
|
6371
6407
|
}
|
|
6372
6408
|
|
|
6373
6409
|
return null;
|
|
@@ -6385,7 +6421,7 @@ class WebRTCClient extends Emitter {
|
|
|
6385
6421
|
// Fetch and emit an event at `interval` with session network stats
|
|
6386
6422
|
startNetworkMonitoring(session , interval = 1000) {
|
|
6387
6423
|
const sessionId = this.getSipSessionId(session);
|
|
6388
|
-
logger.info('starting network inspection', { id: sessionId });
|
|
6424
|
+
logger$4.info('starting network inspection', { id: sessionId });
|
|
6389
6425
|
|
|
6390
6426
|
this.sessionNetworkStats[sessionId] = [];
|
|
6391
6427
|
|
|
@@ -6395,7 +6431,7 @@ class WebRTCClient extends Emitter {
|
|
|
6395
6431
|
stopNetworkMonitoring(session ) {
|
|
6396
6432
|
const sessionId = this.getSipSessionId(session);
|
|
6397
6433
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
6398
|
-
logger.info('stopping network inspection', { id: sessionId, exists });
|
|
6434
|
+
logger$4.info('stopping network inspection', { id: sessionId, exists });
|
|
6399
6435
|
|
|
6400
6436
|
if (exists) {
|
|
6401
6437
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -6405,17 +6441,17 @@ class WebRTCClient extends Emitter {
|
|
|
6405
6441
|
}
|
|
6406
6442
|
|
|
6407
6443
|
reject(session ) {
|
|
6408
|
-
logger.info('sdk webrtc reject call', { id: session.id });
|
|
6444
|
+
logger$4.info('sdk webrtc reject call', { id: session.id });
|
|
6409
6445
|
|
|
6410
6446
|
try {
|
|
6411
6447
|
return session.reject ? session.reject() : session.cancel();
|
|
6412
6448
|
} catch (e) {
|
|
6413
|
-
logger.warn('Error when rejecting call', e.message, e.stack);
|
|
6449
|
+
logger$4.warn('Error when rejecting call', e.message, e.stack);
|
|
6414
6450
|
}
|
|
6415
6451
|
}
|
|
6416
6452
|
|
|
6417
6453
|
async close() {
|
|
6418
|
-
logger.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
6454
|
+
logger$4.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
6419
6455
|
this._cleanupMedia();
|
|
6420
6456
|
this.connectionPromise = null;
|
|
6421
6457
|
|
|
@@ -6446,7 +6482,7 @@ class WebRTCClient extends Emitter {
|
|
|
6446
6482
|
// eg: "INVITE not rejectable in state Completed"
|
|
6447
6483
|
}
|
|
6448
6484
|
this.userAgent = null;
|
|
6449
|
-
logger.info('sdk webrtc client closed');
|
|
6485
|
+
logger$4.info('sdk webrtc client closed');
|
|
6450
6486
|
}
|
|
6451
6487
|
|
|
6452
6488
|
getNumber(session ) {
|
|
@@ -6459,13 +6495,13 @@ class WebRTCClient extends Emitter {
|
|
|
6459
6495
|
}
|
|
6460
6496
|
|
|
6461
6497
|
mute(session ) {
|
|
6462
|
-
logger.info('sdk webrtc mute', { id: session.id });
|
|
6498
|
+
logger$4.info('sdk webrtc mute', { id: session.id });
|
|
6463
6499
|
|
|
6464
6500
|
this._toggleAudio(session, true);
|
|
6465
6501
|
}
|
|
6466
6502
|
|
|
6467
6503
|
unmute(session ) {
|
|
6468
|
-
logger.info('sdk webrtc unmute', { id: session.id });
|
|
6504
|
+
logger$4.info('sdk webrtc unmute', { id: session.id });
|
|
6469
6505
|
|
|
6470
6506
|
this._toggleAudio(session, false);
|
|
6471
6507
|
}
|
|
@@ -6505,13 +6541,13 @@ class WebRTCClient extends Emitter {
|
|
|
6505
6541
|
}
|
|
6506
6542
|
|
|
6507
6543
|
toggleCameraOn(session ) {
|
|
6508
|
-
logger.info('sdk webrtc toggle camera on', { id: session.id });
|
|
6544
|
+
logger$4.info('sdk webrtc toggle camera on', { id: session.id });
|
|
6509
6545
|
|
|
6510
6546
|
this._toggleVideo(session, false);
|
|
6511
6547
|
}
|
|
6512
6548
|
|
|
6513
6549
|
toggleCameraOff(session ) {
|
|
6514
|
-
logger.info('sdk webrtc toggle camera off', { id: session.id });
|
|
6550
|
+
logger$4.info('sdk webrtc toggle camera off', { id: session.id });
|
|
6515
6551
|
|
|
6516
6552
|
this._toggleVideo(session, true);
|
|
6517
6553
|
}
|
|
@@ -6520,7 +6556,7 @@ class WebRTCClient extends Emitter {
|
|
|
6520
6556
|
const sessionId = this.getSipSessionId(session);
|
|
6521
6557
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
6522
6558
|
|
|
6523
|
-
logger.info('sdk webrtc hold', {
|
|
6559
|
+
logger$4.info('sdk webrtc hold', {
|
|
6524
6560
|
sessionId,
|
|
6525
6561
|
keys: Object.keys(this.heldSessions),
|
|
6526
6562
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6569,7 +6605,7 @@ class WebRTCClient extends Emitter {
|
|
|
6569
6605
|
const sessionId = this.getSipSessionId(session);
|
|
6570
6606
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
6571
6607
|
|
|
6572
|
-
logger.info('sdk webrtc unhold', {
|
|
6608
|
+
logger$4.info('sdk webrtc unhold', {
|
|
6573
6609
|
sessionId,
|
|
6574
6610
|
keys: Object.keys(this.heldSessions),
|
|
6575
6611
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6717,7 +6753,7 @@ class WebRTCClient extends Emitter {
|
|
|
6717
6753
|
if (!session.sessionDescriptionHandler) {
|
|
6718
6754
|
return;
|
|
6719
6755
|
}
|
|
6720
|
-
logger.info('Sending DTMF', {
|
|
6756
|
+
logger$4.info('Sending DTMF', {
|
|
6721
6757
|
id: this.getSipSessionId(session),
|
|
6722
6758
|
tone,
|
|
6723
6759
|
});
|
|
@@ -6733,7 +6769,7 @@ class WebRTCClient extends Emitter {
|
|
|
6733
6769
|
transfer(session , target ) {
|
|
6734
6770
|
this.hold(session);
|
|
6735
6771
|
|
|
6736
|
-
logger.info('Transfering a session', {
|
|
6772
|
+
logger$4.info('Transfering a session', {
|
|
6737
6773
|
id: this.getSipSessionId(session),
|
|
6738
6774
|
target,
|
|
6739
6775
|
});
|
|
@@ -6755,17 +6791,17 @@ class WebRTCClient extends Emitter {
|
|
|
6755
6791
|
atxfer(session ) {
|
|
6756
6792
|
this.hold(session);
|
|
6757
6793
|
|
|
6758
|
-
logger.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
6794
|
+
logger$4.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
6759
6795
|
|
|
6760
6796
|
const result = {
|
|
6761
6797
|
newSession: null,
|
|
6762
6798
|
init: async (target ) => {
|
|
6763
|
-
logger.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
6799
|
+
logger$4.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
6764
6800
|
|
|
6765
6801
|
result.newSession = await this.call(target);
|
|
6766
6802
|
},
|
|
6767
6803
|
complete: () => {
|
|
6768
|
-
logger.info('webrtc transfer completed', {
|
|
6804
|
+
logger$4.info('webrtc transfer completed', {
|
|
6769
6805
|
id: this.getSipSessionId(session),
|
|
6770
6806
|
referId: this.getSipSessionId(result.newSession),
|
|
6771
6807
|
});
|
|
@@ -6786,7 +6822,7 @@ class WebRTCClient extends Emitter {
|
|
|
6786
6822
|
return;
|
|
6787
6823
|
}
|
|
6788
6824
|
|
|
6789
|
-
logger.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
6825
|
+
logger$4.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
6790
6826
|
|
|
6791
6827
|
try {
|
|
6792
6828
|
sipSession.message({
|
|
@@ -6828,7 +6864,7 @@ class WebRTCClient extends Emitter {
|
|
|
6828
6864
|
}
|
|
6829
6865
|
|
|
6830
6866
|
changeAudioOutputVolume(volume ) {
|
|
6831
|
-
logger.info('Changing audio output volume', { volume });
|
|
6867
|
+
logger$4.info('Changing audio output volume', { volume });
|
|
6832
6868
|
|
|
6833
6869
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
6834
6870
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -6840,7 +6876,7 @@ class WebRTCClient extends Emitter {
|
|
|
6840
6876
|
}
|
|
6841
6877
|
|
|
6842
6878
|
changeAudioOutputDevice(id ) {
|
|
6843
|
-
logger.info('Changing audio output device', { id });
|
|
6879
|
+
logger$4.info('Changing audio output device', { id });
|
|
6844
6880
|
|
|
6845
6881
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
6846
6882
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -6857,7 +6893,7 @@ class WebRTCClient extends Emitter {
|
|
|
6857
6893
|
|
|
6858
6894
|
changeAudioInputDevice(id , session ) {
|
|
6859
6895
|
const currentId = this.getAudioDeviceId();
|
|
6860
|
-
logger.info('setting audio input device', { id, currentId, session: !!session });
|
|
6896
|
+
logger$4.info('setting audio input device', { id, currentId, session: !!session });
|
|
6861
6897
|
|
|
6862
6898
|
if (id === currentId) {
|
|
6863
6899
|
return null;
|
|
@@ -6903,7 +6939,7 @@ class WebRTCClient extends Emitter {
|
|
|
6903
6939
|
|
|
6904
6940
|
setVideoInputDevice(id ) {
|
|
6905
6941
|
const currentId = this.getVideoDeviceId();
|
|
6906
|
-
logger.info('setting video input device', { id, currentId });
|
|
6942
|
+
logger$4.info('setting video input device', { id, currentId });
|
|
6907
6943
|
|
|
6908
6944
|
if (id === currentId) {
|
|
6909
6945
|
return null;
|
|
@@ -6928,7 +6964,7 @@ class WebRTCClient extends Emitter {
|
|
|
6928
6964
|
const sessionId = this.getSipSessionId(session);
|
|
6929
6965
|
const localStream = this.getLocalStream(sessionId);
|
|
6930
6966
|
|
|
6931
|
-
logger.info('changing video input device', { id, sessionId });
|
|
6967
|
+
logger$4.info('changing video input device', { id, sessionId });
|
|
6932
6968
|
|
|
6933
6969
|
// Release old video stream
|
|
6934
6970
|
if (localStream) {
|
|
@@ -6996,7 +7032,7 @@ class WebRTCClient extends Emitter {
|
|
|
6996
7032
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
6997
7033
|
const desktop = newConstraints && newConstraints.desktop;
|
|
6998
7034
|
|
|
6999
|
-
logger.info('Sending reinvite', {
|
|
7035
|
+
logger$4.info('Sending reinvite', {
|
|
7000
7036
|
id: this.getSipSessionId(sipSession),
|
|
7001
7037
|
newConstraints,
|
|
7002
7038
|
conference,
|
|
@@ -7034,7 +7070,7 @@ class WebRTCClient extends Emitter {
|
|
|
7034
7070
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
7035
7071
|
}
|
|
7036
7072
|
|
|
7037
|
-
logger.info('on re-INVITE accepted', {
|
|
7073
|
+
logger$4.info('on re-INVITE accepted', {
|
|
7038
7074
|
id: this.getSipSessionId(sipSession),
|
|
7039
7075
|
wasMuted,
|
|
7040
7076
|
shouldDoScreenSharing,
|
|
@@ -7153,6 +7189,16 @@ class WebRTCClient extends Emitter {
|
|
|
7153
7189
|
return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
|
|
7154
7190
|
}
|
|
7155
7191
|
|
|
7192
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
7193
|
+
getRemoteVideoStreamFromPc(sessionId ) {
|
|
7194
|
+
const pc = this.getPeerConnection(sessionId);
|
|
7195
|
+
if (!pc) {
|
|
7196
|
+
return null;
|
|
7197
|
+
}
|
|
7198
|
+
|
|
7199
|
+
return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
|
|
7200
|
+
}
|
|
7201
|
+
|
|
7156
7202
|
hasVideo(sessionId ) {
|
|
7157
7203
|
return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
|
|
7158
7204
|
}
|
|
@@ -7199,7 +7245,7 @@ class WebRTCClient extends Emitter {
|
|
|
7199
7245
|
}
|
|
7200
7246
|
|
|
7201
7247
|
startHeartbeat() {
|
|
7202
|
-
logger.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7248
|
+
logger$4.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7203
7249
|
if (!this.userAgent) {
|
|
7204
7250
|
this.heartbeat.stop();
|
|
7205
7251
|
return;
|
|
@@ -7212,7 +7258,7 @@ class WebRTCClient extends Emitter {
|
|
|
7212
7258
|
}
|
|
7213
7259
|
|
|
7214
7260
|
stopHeartbeat() {
|
|
7215
|
-
logger.info('sdk webrtc stop heartbeat');
|
|
7261
|
+
logger$4.info('sdk webrtc stop heartbeat');
|
|
7216
7262
|
this.heartbeat.stop();
|
|
7217
7263
|
}
|
|
7218
7264
|
|
|
@@ -7233,7 +7279,7 @@ class WebRTCClient extends Emitter {
|
|
|
7233
7279
|
}
|
|
7234
7280
|
|
|
7235
7281
|
attemptReconnection() {
|
|
7236
|
-
logger.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7282
|
+
logger$4.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7237
7283
|
if (!this.userAgent) {
|
|
7238
7284
|
return;
|
|
7239
7285
|
}
|
|
@@ -7258,7 +7304,7 @@ class WebRTCClient extends Emitter {
|
|
|
7258
7304
|
return;
|
|
7259
7305
|
}
|
|
7260
7306
|
|
|
7261
|
-
logger.info('setting local media stream', {
|
|
7307
|
+
logger$4.info('setting local media stream', {
|
|
7262
7308
|
sipSessionId,
|
|
7263
7309
|
tracks: newStream ? newStream.getTracks() : null,
|
|
7264
7310
|
});
|
|
@@ -7275,7 +7321,7 @@ class WebRTCClient extends Emitter {
|
|
|
7275
7321
|
|
|
7276
7322
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
7277
7323
|
|
|
7278
|
-
logger.info('updating local stream', {
|
|
7324
|
+
logger$4.info('updating local stream', {
|
|
7279
7325
|
sipSessionId,
|
|
7280
7326
|
oldStream: !!oldStream,
|
|
7281
7327
|
tracks: newStream.getTracks(),
|
|
@@ -7295,7 +7341,7 @@ class WebRTCClient extends Emitter {
|
|
|
7295
7341
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
7296
7342
|
const pc = this.getPeerConnection(sessionId);
|
|
7297
7343
|
|
|
7298
|
-
logger.info('Updating remote stream', {
|
|
7344
|
+
logger$4.info('Updating remote stream', {
|
|
7299
7345
|
sessionId,
|
|
7300
7346
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
7301
7347
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -7321,7 +7367,7 @@ class WebRTCClient extends Emitter {
|
|
|
7321
7367
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
7322
7368
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
7323
7369
|
|
|
7324
|
-
logger.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
7370
|
+
logger$4.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
7325
7371
|
|
|
7326
7372
|
return {
|
|
7327
7373
|
constraints: {
|
|
@@ -7370,7 +7416,7 @@ class WebRTCClient extends Emitter {
|
|
|
7370
7416
|
}
|
|
7371
7417
|
|
|
7372
7418
|
_onTransportError() {
|
|
7373
|
-
logger.error('on transport error');
|
|
7419
|
+
logger$4.error('on transport error');
|
|
7374
7420
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
7375
7421
|
this.attemptReconnection();
|
|
7376
7422
|
}
|
|
@@ -7379,7 +7425,7 @@ class WebRTCClient extends Emitter {
|
|
|
7379
7425
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
7380
7426
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
7381
7427
|
if (this.hasHeartbeat()) {
|
|
7382
|
-
logger.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
7428
|
+
logger$4.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
7383
7429
|
|
|
7384
7430
|
this.heartbeat.onHeartbeat();
|
|
7385
7431
|
if (this.heartbeatCb) {
|
|
@@ -7390,7 +7436,7 @@ class WebRTCClient extends Emitter {
|
|
|
7390
7436
|
}
|
|
7391
7437
|
|
|
7392
7438
|
async _onHeartbeatTimeout() {
|
|
7393
|
-
logger.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
7439
|
+
logger$4.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
7394
7440
|
|
|
7395
7441
|
if (this.heartbeatTimeoutCb) {
|
|
7396
7442
|
this.heartbeatTimeoutCb();
|
|
@@ -7402,7 +7448,7 @@ class WebRTCClient extends Emitter {
|
|
|
7402
7448
|
try {
|
|
7403
7449
|
await this.userAgent.transport.disconnect();
|
|
7404
7450
|
} catch (e) {
|
|
7405
|
-
logger.error('Transport disconnection after heartbeat timeout, error', e);
|
|
7451
|
+
logger$4.error('Transport disconnection after heartbeat timeout, error', e);
|
|
7406
7452
|
}
|
|
7407
7453
|
}
|
|
7408
7454
|
|
|
@@ -7435,31 +7481,31 @@ class WebRTCClient extends Emitter {
|
|
|
7435
7481
|
}
|
|
7436
7482
|
|
|
7437
7483
|
_connectIfNeeded() {
|
|
7438
|
-
logger.info('connect if needed, checking', { connected: this.isConnected() });
|
|
7484
|
+
logger$4.info('connect if needed, checking', { connected: this.isConnected() });
|
|
7439
7485
|
if (!this.userAgent) {
|
|
7440
|
-
logger.info('need to recreate User Agent');
|
|
7486
|
+
logger$4.info('need to recreate User Agent');
|
|
7441
7487
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
7442
7488
|
}
|
|
7443
7489
|
|
|
7444
7490
|
if (this.isConnected()) {
|
|
7445
|
-
logger.info('webrtc sdk, already connected');
|
|
7491
|
+
logger$4.info('webrtc sdk, already connected');
|
|
7446
7492
|
return Promise.resolve();
|
|
7447
7493
|
}
|
|
7448
7494
|
|
|
7449
7495
|
if (this.isConnecting()) {
|
|
7450
|
-
logger.info('webrtc sdk, already connecting...');
|
|
7496
|
+
logger$4.info('webrtc sdk, already connecting...');
|
|
7451
7497
|
|
|
7452
7498
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
7453
7499
|
return this.connectionPromise;
|
|
7454
7500
|
}
|
|
7455
7501
|
|
|
7456
7502
|
if (this.connectionPromise) {
|
|
7457
|
-
logger.info('webrtc sdk, connection promise connecting...');
|
|
7503
|
+
logger$4.info('webrtc sdk, connection promise connecting...');
|
|
7458
7504
|
// $FlowFixMe
|
|
7459
7505
|
return this.connectionPromise;
|
|
7460
7506
|
}
|
|
7461
7507
|
|
|
7462
|
-
logger.info('WebRTC UA needs to connect');
|
|
7508
|
+
logger$4.info('WebRTC UA needs to connect');
|
|
7463
7509
|
|
|
7464
7510
|
// Force UA to reconnect
|
|
7465
7511
|
if (this.userAgent && this.userAgent.state !== UserAgentState.Stopped) {
|
|
@@ -7584,7 +7630,7 @@ class WebRTCClient extends Emitter {
|
|
|
7584
7630
|
|
|
7585
7631
|
sdh.peerConnectionDelegate = {
|
|
7586
7632
|
onicecandidateerror: (error ) => {
|
|
7587
|
-
logger.error('on icecandidate error', {
|
|
7633
|
+
logger$4.error('on icecandidate error', {
|
|
7588
7634
|
address: error.address,
|
|
7589
7635
|
port: error.port,
|
|
7590
7636
|
errorCode: error.errorCode,
|
|
@@ -7613,7 +7659,7 @@ class WebRTCClient extends Emitter {
|
|
|
7613
7659
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
7614
7660
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
7615
7661
|
}
|
|
7616
|
-
logger.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
7662
|
+
logger$4.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
7617
7663
|
|
|
7618
7664
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
7619
7665
|
|
|
@@ -7634,7 +7680,7 @@ class WebRTCClient extends Emitter {
|
|
|
7634
7680
|
}
|
|
7635
7681
|
|
|
7636
7682
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
7637
|
-
logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7683
|
+
logger$4.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7638
7684
|
|
|
7639
7685
|
this.storeSipSession(session);
|
|
7640
7686
|
|
|
@@ -7646,7 +7692,7 @@ class WebRTCClient extends Emitter {
|
|
|
7646
7692
|
const onTrack = (event ) => {
|
|
7647
7693
|
const isAudioOnly = this._isAudioOnly(session);
|
|
7648
7694
|
const { kind, label, readyState, id, muted } = event.track;
|
|
7649
|
-
logger.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
7695
|
+
logger$4.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
7650
7696
|
|
|
7651
7697
|
// Stop video track in audio only mode
|
|
7652
7698
|
if (isAudioOnly && kind === 'video') {
|
|
@@ -7663,6 +7709,7 @@ class WebRTCClient extends Emitter {
|
|
|
7663
7709
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
7664
7710
|
|
|
7665
7711
|
pc.oniceconnectionstatechange = () => {
|
|
7712
|
+
logger$4.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
7666
7713
|
if (pc.iceConnectionState === 'disconnected') {
|
|
7667
7714
|
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
7668
7715
|
}
|
|
@@ -7835,10 +7882,10 @@ class WebRTCClient extends Emitter {
|
|
|
7835
7882
|
|
|
7836
7883
|
_stopSendingStats(session ) {
|
|
7837
7884
|
const sessionId = this.getSipSessionId(session);
|
|
7838
|
-
logger.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
7885
|
+
logger$4.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
7839
7886
|
|
|
7840
7887
|
if (sessionId in this.statsIntervals) {
|
|
7841
|
-
logger.trace('Stop sending stats for call', { sessionId });
|
|
7888
|
+
logger$4.trace('Stop sending stats for call', { sessionId });
|
|
7842
7889
|
this.statsIntervals[sessionId]();
|
|
7843
7890
|
delete this.statsIntervals[sessionId];
|
|
7844
7891
|
}
|
|
@@ -7854,7 +7901,7 @@ class WebRTCClient extends Emitter {
|
|
|
7854
7901
|
try {
|
|
7855
7902
|
await this.userAgent.transport.disconnect();
|
|
7856
7903
|
} catch (e) {
|
|
7857
|
-
logger.error('WebRTC transport disconnect, error', e);
|
|
7904
|
+
logger$4.error('WebRTC transport disconnect, error', e);
|
|
7858
7905
|
}
|
|
7859
7906
|
}
|
|
7860
7907
|
}
|
|
@@ -7891,25 +7938,25 @@ class WebRTCClient extends Emitter {
|
|
|
7891
7938
|
|
|
7892
7939
|
stats.forEach(report => {
|
|
7893
7940
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
7894
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
7941
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
7895
7942
|
}
|
|
7896
7943
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
7897
|
-
audioBytesSent += report.bytesSent;
|
|
7944
|
+
audioBytesSent += Number(report.bytesSent);
|
|
7898
7945
|
}
|
|
7899
7946
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
7900
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
7947
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
7901
7948
|
}
|
|
7902
7949
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
7903
|
-
packetsLost += report.packetsLost;
|
|
7904
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
7905
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
7950
|
+
packetsLost += Number(report.packetsLost);
|
|
7951
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
7952
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
7906
7953
|
}
|
|
7907
7954
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
7908
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
7955
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
7909
7956
|
}
|
|
7910
7957
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
7911
7958
|
if ('framesPerSecond' in report) {
|
|
7912
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
7959
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
7913
7960
|
}
|
|
7914
7961
|
if ('framerateMean' in report) {
|
|
7915
7962
|
// framerateMean is only available in FF
|
|
@@ -7917,32 +7964,36 @@ class WebRTCClient extends Emitter {
|
|
|
7917
7964
|
}
|
|
7918
7965
|
}
|
|
7919
7966
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
7920
|
-
packetsLost += report.packetsLost;
|
|
7921
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
7922
|
-
networkStats.jitter = report.jitter;
|
|
7967
|
+
packetsLost += Number(report.packetsLost);
|
|
7968
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
7969
|
+
networkStats.jitter = Number(report.jitter);
|
|
7923
7970
|
}
|
|
7924
7971
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
7925
|
-
packetsLost += report.packetsLost;
|
|
7972
|
+
packetsLost += Number(report.packetsLost);
|
|
7926
7973
|
}
|
|
7927
7974
|
if (report.type === 'transport') {
|
|
7928
|
-
transportSent += report.bytesSent;
|
|
7929
|
-
transportReceived += report.bytesReceived;
|
|
7975
|
+
transportSent += Number(report.bytesSent);
|
|
7976
|
+
transportReceived += Number(report.bytesReceived);
|
|
7930
7977
|
}
|
|
7931
7978
|
});
|
|
7932
7979
|
|
|
7933
7980
|
networkStats.packetsLost = packetsLost;
|
|
7934
|
-
networkStats.
|
|
7981
|
+
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
7982
|
+
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
7983
|
+
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
7935
7984
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
7936
|
-
networkStats.
|
|
7937
|
-
networkStats.
|
|
7985
|
+
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
7986
|
+
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
7987
|
+
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
7988
|
+
networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
|
|
7989
|
+
networkStats.totalTransportSent = transportSent - lastTransportSent;
|
|
7938
7990
|
networkStats.transportSent = transportSent;
|
|
7939
|
-
networkStats.
|
|
7940
|
-
|
|
7941
|
-
const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
|
|
7942
|
-
+ (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
|
|
7943
|
-
+ (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
|
|
7991
|
+
networkStats.totalTransportReceived = transportReceived;
|
|
7992
|
+
networkStats.transportReceived = transportReceived - lastTransportReceived;
|
|
7944
7993
|
|
|
7945
|
-
networkStats.bandwidth =
|
|
7994
|
+
networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
|
|
7995
|
+
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
7996
|
+
+ networkStats.transportSent;
|
|
7946
7997
|
|
|
7947
7998
|
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
7948
7999
|
this.sessionNetworkStats[sessionId].push(networkStats);
|
|
@@ -8033,7 +8084,7 @@ var webrtc = {
|
|
|
8033
8084
|
}),
|
|
8034
8085
|
};
|
|
8035
8086
|
|
|
8036
|
-
const parseCandidate = line => {
|
|
8087
|
+
const parseCandidate$1 = line => {
|
|
8037
8088
|
let parts;
|
|
8038
8089
|
// Parse both variants.
|
|
8039
8090
|
if (line.indexOf('a=candidate:') === 0) {
|
|
@@ -8124,7 +8175,7 @@ var SymmetricNat = {
|
|
|
8124
8175
|
}
|
|
8125
8176
|
|
|
8126
8177
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
8127
|
-
const cand = parseCandidate(e.candidate.candidate);
|
|
8178
|
+
const cand = parseCandidate$1(e.candidate.candidate);
|
|
8128
8179
|
if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
|
|
8129
8180
|
candidates[cand.relatedPort].push(cand.port);
|
|
8130
8181
|
} else if (!e.candidate) {
|
|
@@ -8192,7 +8243,7 @@ var iceIpv4 = {
|
|
|
8192
8243
|
const rawCandidate = e.candidate.candidate;
|
|
8193
8244
|
if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
|
|
8194
8245
|
hasSrflxOrRelay = true;
|
|
8195
|
-
const candidate = parseCandidate(e.candidate.candidate);
|
|
8246
|
+
const candidate = parseCandidate$1(e.candidate.candidate);
|
|
8196
8247
|
ips.push(candidate.ip);
|
|
8197
8248
|
}
|
|
8198
8249
|
} else if (!e.candidate) {
|