@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
package/lib/checker/Checker.js
CHANGED
|
@@ -158,6 +158,7 @@ class IssueReporter {
|
|
|
158
158
|
|
|
159
159
|
|
|
160
160
|
|
|
161
|
+
|
|
161
162
|
|
|
162
163
|
constructor() {
|
|
163
164
|
addLevelsTo(this);
|
|
@@ -169,12 +170,17 @@ class IssueReporter {
|
|
|
169
170
|
this.bufferTimeout = null;
|
|
170
171
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
171
172
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
173
|
+
this._callback = null;
|
|
172
174
|
}
|
|
173
175
|
|
|
174
176
|
init() {
|
|
175
177
|
this._catchConsole();
|
|
176
178
|
}
|
|
177
179
|
|
|
180
|
+
setCallback(cb ) {
|
|
181
|
+
this._callback = cb;
|
|
182
|
+
}
|
|
183
|
+
|
|
178
184
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
179
185
|
this.remoteClientConfiguration = configuration;
|
|
180
186
|
}
|
|
@@ -210,6 +216,7 @@ class IssueReporter {
|
|
|
210
216
|
|
|
211
217
|
// Handle category label
|
|
212
218
|
let category = null;
|
|
219
|
+
let skipSendToRemote = false;
|
|
213
220
|
let extra = {};
|
|
214
221
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
215
222
|
category = args[0].split('=')[1];
|
|
@@ -225,6 +232,7 @@ class IssueReporter {
|
|
|
225
232
|
errorMessage: lastArg.message,
|
|
226
233
|
errorStack: lastArg.stack,
|
|
227
234
|
errorType: lastArg.constructor.name,
|
|
235
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
228
236
|
};
|
|
229
237
|
} else {
|
|
230
238
|
extra = lastArg;
|
|
@@ -233,6 +241,11 @@ class IssueReporter {
|
|
|
233
241
|
args.splice(1, 1);
|
|
234
242
|
}
|
|
235
243
|
|
|
244
|
+
if (extra.skipSendToRemote) {
|
|
245
|
+
skipSendToRemote = true;
|
|
246
|
+
delete extra.skipSendToRemote;
|
|
247
|
+
}
|
|
248
|
+
|
|
236
249
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
237
250
|
const message = args.join(', ');
|
|
238
251
|
let consoleMessage = message;
|
|
@@ -253,7 +266,13 @@ class IssueReporter {
|
|
|
253
266
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
254
267
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
255
268
|
|
|
256
|
-
this.
|
|
269
|
+
if (this._callback) {
|
|
270
|
+
this._callback(level, consoleMessage);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (!skipSendToRemote) {
|
|
274
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
275
|
+
}
|
|
257
276
|
}
|
|
258
277
|
|
|
259
278
|
logRequest(url , options , response , start ) {
|
|
@@ -398,7 +417,11 @@ class IssueReporter {
|
|
|
398
417
|
},
|
|
399
418
|
// $FlowFixMe
|
|
400
419
|
body,
|
|
401
|
-
}).catch(() => {
|
|
420
|
+
}).catch((e ) => {
|
|
421
|
+
// $FlowFixMe
|
|
422
|
+
e.skipSendToRemote = true;
|
|
423
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
424
|
+
|
|
402
425
|
setTimeout(() => {
|
|
403
426
|
if (isArray) {
|
|
404
427
|
payload = payload.map(message => {
|
|
@@ -445,7 +468,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
445
468
|
|
|
446
469
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
447
470
|
|
|
448
|
-
const logger
|
|
471
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
449
472
|
|
|
450
473
|
// Use a function here to be able to mock it in tests
|
|
451
474
|
const realFetch = () => {
|
|
@@ -584,7 +607,7 @@ class ApiRequester {
|
|
|
584
607
|
};
|
|
585
608
|
|
|
586
609
|
if (this.refreshTokenPromise) {
|
|
587
|
-
logger
|
|
610
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
588
611
|
await this.refreshTokenPromise;
|
|
589
612
|
}
|
|
590
613
|
|
|
@@ -604,7 +627,7 @@ class ApiRequester {
|
|
|
604
627
|
return promise.then(async (err ) => {
|
|
605
628
|
// Check if the token is still valid
|
|
606
629
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
607
|
-
logger
|
|
630
|
+
logger.warn('token expired', { error: err.reason });
|
|
608
631
|
// Replay the call after refreshing the token
|
|
609
632
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
610
633
|
}
|
|
@@ -614,7 +637,7 @@ class ApiRequester {
|
|
|
614
637
|
: exceptionClass.fromResponse(err, response.status);
|
|
615
638
|
|
|
616
639
|
if (this.shouldLogErrors) {
|
|
617
|
-
logger
|
|
640
|
+
logger.error('API error', error);
|
|
618
641
|
}
|
|
619
642
|
|
|
620
643
|
throw error;
|
|
@@ -624,7 +647,7 @@ class ApiRequester {
|
|
|
624
647
|
return newParse(response, isJson);
|
|
625
648
|
}).catch(error => {
|
|
626
649
|
if (this.shouldLogErrors) {
|
|
627
|
-
logger
|
|
650
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
628
651
|
}
|
|
629
652
|
|
|
630
653
|
throw error;
|
|
@@ -652,13 +675,13 @@ class ApiRequester {
|
|
|
652
675
|
) {
|
|
653
676
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
654
677
|
let newPath = path;
|
|
655
|
-
logger
|
|
678
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
656
679
|
|
|
657
680
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
658
681
|
|
|
659
682
|
return this.refreshTokenPromise.then(() => {
|
|
660
683
|
this.refreshTokenPromise = null;
|
|
661
|
-
logger
|
|
684
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
662
685
|
if (isTokenNotFound) {
|
|
663
686
|
const pathParts = path.split('/');
|
|
664
687
|
pathParts.pop();
|
|
@@ -1536,6 +1559,9 @@ class Contact {
|
|
|
1536
1559
|
}
|
|
1537
1560
|
|
|
1538
1561
|
static parseMany(response ) {
|
|
1562
|
+
if (!response || !response.results) {
|
|
1563
|
+
return [];
|
|
1564
|
+
}
|
|
1539
1565
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
1540
1566
|
}
|
|
1541
1567
|
|
|
@@ -2613,8 +2639,9 @@ class ExternalApp {
|
|
|
2613
2639
|
|
|
2614
2640
|
|
|
2615
2641
|
|
|
2616
|
-
|
|
2642
|
+
|
|
2617
2643
|
|
|
2644
|
+
|
|
2618
2645
|
|
|
2619
2646
|
|
|
2620
2647
|
class Meeting {
|
|
@@ -2625,9 +2652,10 @@ class Meeting {
|
|
|
2625
2652
|
|
|
2626
2653
|
|
|
2627
2654
|
|
|
2628
|
-
|
|
2655
|
+
|
|
2629
2656
|
|
|
2630
2657
|
|
|
2658
|
+
|
|
2631
2659
|
|
|
2632
2660
|
static parse(plain ) {
|
|
2633
2661
|
return new Meeting({
|
|
@@ -2637,24 +2665,43 @@ class Meeting {
|
|
|
2637
2665
|
ownerUuids: plain.owner_uuids,
|
|
2638
2666
|
port: plain.port,
|
|
2639
2667
|
uuid: plain.uuid,
|
|
2640
|
-
|
|
2668
|
+
extension: plain.exten,
|
|
2641
2669
|
persistent: plain.persistent,
|
|
2670
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
2642
2671
|
});
|
|
2643
2672
|
}
|
|
2644
2673
|
|
|
2674
|
+
static parseMany(items ) {
|
|
2675
|
+
if (!items) {
|
|
2676
|
+
return [];
|
|
2677
|
+
}
|
|
2678
|
+
return items.map(plain => Meeting.parse(plain));
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2645
2681
|
static newFrom(meeting ) {
|
|
2646
2682
|
return newFrom(meeting, Meeting);
|
|
2647
2683
|
}
|
|
2648
2684
|
|
|
2649
|
-
constructor({
|
|
2685
|
+
constructor({
|
|
2686
|
+
uuid,
|
|
2687
|
+
name,
|
|
2688
|
+
guestSipAuthorization,
|
|
2689
|
+
ownerUuids,
|
|
2690
|
+
port,
|
|
2691
|
+
uri,
|
|
2692
|
+
extension,
|
|
2693
|
+
persistent,
|
|
2694
|
+
creationTime,
|
|
2695
|
+
} = {}) {
|
|
2650
2696
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2651
2697
|
this.uri = uri;
|
|
2652
2698
|
this.name = name;
|
|
2653
2699
|
this.ownerUuids = ownerUuids;
|
|
2654
2700
|
this.port = port;
|
|
2655
2701
|
this.uuid = uuid;
|
|
2656
|
-
this.
|
|
2702
|
+
this.extension = extension;
|
|
2657
2703
|
this.persistent = persistent;
|
|
2704
|
+
this.creationTime = creationTime;
|
|
2658
2705
|
|
|
2659
2706
|
// Useful to compare instead of instanceof with minified code
|
|
2660
2707
|
this.type = 'Meeting';
|
|
@@ -2732,8 +2779,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2732
2779
|
}
|
|
2733
2780
|
},
|
|
2734
2781
|
|
|
2735
|
-
|
|
2736
|
-
client.
|
|
2782
|
+
getMyMeetings: () =>
|
|
2783
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
2784
|
+
|
|
2785
|
+
createMyMeeting: (name , persistent ) =>
|
|
2786
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
2737
2787
|
|
|
2738
2788
|
deleteMyMeeting: (meetingUuid ) =>
|
|
2739
2789
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -2829,6 +2879,10 @@ class ChatMessage {
|
|
|
2829
2879
|
|
|
2830
2880
|
|
|
2831
2881
|
static parseMany(plain ) {
|
|
2882
|
+
if (!plain || !plain.items) {
|
|
2883
|
+
return [];
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2832
2886
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
2833
2887
|
}
|
|
2834
2888
|
|
|
@@ -2938,6 +2992,9 @@ class Voicemail {
|
|
|
2938
2992
|
}
|
|
2939
2993
|
|
|
2940
2994
|
static parseMany(plain ) {
|
|
2995
|
+
if (!plain) {
|
|
2996
|
+
return [];
|
|
2997
|
+
}
|
|
2941
2998
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
2942
2999
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
2943
3000
|
|
|
@@ -3047,6 +3104,9 @@ class Call {
|
|
|
3047
3104
|
|
|
3048
3105
|
|
|
3049
3106
|
static parseMany(plain ) {
|
|
3107
|
+
if (!plain) {
|
|
3108
|
+
return [];
|
|
3109
|
+
}
|
|
3050
3110
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
3051
3111
|
}
|
|
3052
3112
|
|
|
@@ -3245,6 +3305,9 @@ class Recording {
|
|
|
3245
3305
|
|
|
3246
3306
|
|
|
3247
3307
|
static parseMany(recordings = []) {
|
|
3308
|
+
if (!recordings) {
|
|
3309
|
+
return [];
|
|
3310
|
+
}
|
|
3248
3311
|
return recordings.map(item => Recording.parse(item));
|
|
3249
3312
|
}
|
|
3250
3313
|
|
|
@@ -3346,6 +3409,10 @@ class CallLog {
|
|
|
3346
3409
|
}
|
|
3347
3410
|
|
|
3348
3411
|
static parseMany(plain ) {
|
|
3412
|
+
if (!plain || !plain.items) {
|
|
3413
|
+
return [];
|
|
3414
|
+
}
|
|
3415
|
+
|
|
3349
3416
|
return plain.items.map(item => CallLog.parse(item));
|
|
3350
3417
|
}
|
|
3351
3418
|
|
|
@@ -3582,7 +3649,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3582
3649
|
|
|
3583
3650
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3584
3651
|
|
|
3585
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3652
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3586
3653
|
|
|
3587
3654
|
/* */
|
|
3588
3655
|
|
|
@@ -3918,6 +3985,9 @@ class ChatRoom {
|
|
|
3918
3985
|
|
|
3919
3986
|
|
|
3920
3987
|
static parseMany(plain ) {
|
|
3988
|
+
if (!plain || !plain.items) {
|
|
3989
|
+
return [];
|
|
3990
|
+
}
|
|
3921
3991
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
3922
3992
|
}
|
|
3923
3993
|
|
|
@@ -4498,7 +4568,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
4498
4568
|
const WEBHOOKD_VERSION = '1.0';
|
|
4499
4569
|
const AMID_VERSION = '1.0';
|
|
4500
4570
|
|
|
4501
|
-
const logger$
|
|
4571
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
4502
4572
|
|
|
4503
4573
|
class ApiClient {
|
|
4504
4574
|
|
|
@@ -4550,12 +4620,12 @@ class ApiClient {
|
|
|
4550
4620
|
}
|
|
4551
4621
|
|
|
4552
4622
|
async forceRefreshToken() {
|
|
4553
|
-
logger$
|
|
4623
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
4554
4624
|
return this.refreshTokenCallback();
|
|
4555
4625
|
}
|
|
4556
4626
|
|
|
4557
4627
|
async refreshTokenCallback() {
|
|
4558
|
-
logger$
|
|
4628
|
+
logger$2.info('refresh token callback called', {
|
|
4559
4629
|
refreshToken: this.refreshToken,
|
|
4560
4630
|
refreshBackend: this.refreshBackend,
|
|
4561
4631
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -4573,7 +4643,7 @@ class ApiClient {
|
|
|
4573
4643
|
this.isMobile,
|
|
4574
4644
|
);
|
|
4575
4645
|
|
|
4576
|
-
logger$
|
|
4646
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
4577
4647
|
|
|
4578
4648
|
if (this.onRefreshToken) {
|
|
4579
4649
|
this.onRefreshToken(session.token, session);
|
|
@@ -4913,6 +4983,7 @@ const AGENT_PAUSED = 'agent_paused';
|
|
|
4913
4983
|
const AGENT_UNPAUSED = 'agent_unpaused';
|
|
4914
4984
|
const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
|
|
4915
4985
|
const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
|
|
4986
|
+
const MEETING_USER_PROGRESS = 'meeting_user_progress';
|
|
4916
4987
|
|
|
4917
4988
|
const BLACKLIST_EVENTS = [
|
|
4918
4989
|
CHAT_MESSAGE_SENT,
|
|
@@ -4922,7 +4993,7 @@ const BLACKLIST_EVENTS = [
|
|
|
4922
4993
|
];
|
|
4923
4994
|
|
|
4924
4995
|
const HEARTBEAT_ENGINE_VERSION = '20.09';
|
|
4925
|
-
const logger$
|
|
4996
|
+
const logger$3 = IssueReporter$1.loggerFor('wazo-ws');
|
|
4926
4997
|
const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
|
|
4927
4998
|
|
|
4928
4999
|
class WebSocketClient extends Emitter {
|
|
@@ -4971,19 +5042,19 @@ class WebSocketClient extends Emitter {
|
|
|
4971
5042
|
}
|
|
4972
5043
|
|
|
4973
5044
|
connect() {
|
|
4974
|
-
logger$
|
|
5045
|
+
logger$3.info('connect method started', { host: this.host, token: this.token });
|
|
4975
5046
|
this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
|
|
4976
5047
|
if (this.options.binaryType) {
|
|
4977
5048
|
this.socket.binaryType = this.options.binaryType;
|
|
4978
5049
|
}
|
|
4979
5050
|
|
|
4980
5051
|
this.socket.onopen = () => {
|
|
4981
|
-
logger$
|
|
5052
|
+
logger$3.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
4982
5053
|
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
4983
5054
|
};
|
|
4984
5055
|
|
|
4985
5056
|
this.socket.onerror = event => {
|
|
4986
|
-
logger$
|
|
5057
|
+
logger$3.error('on Wazo WS error', event.target);
|
|
4987
5058
|
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
4988
5059
|
};
|
|
4989
5060
|
|
|
@@ -5013,7 +5084,7 @@ class WebSocketClient extends Emitter {
|
|
|
5013
5084
|
|
|
5014
5085
|
this.socket.onclose = event => {
|
|
5015
5086
|
// Can't be converted to JSON (circular structure)
|
|
5016
|
-
logger$
|
|
5087
|
+
logger$3.info('on Wazo WS close', {
|
|
5017
5088
|
reason: event.reason,
|
|
5018
5089
|
code: event.code,
|
|
5019
5090
|
readyState: event.target.readyState,
|
|
@@ -5031,12 +5102,12 @@ class WebSocketClient extends Emitter {
|
|
|
5031
5102
|
};
|
|
5032
5103
|
|
|
5033
5104
|
this.socket.onerror = event => {
|
|
5034
|
-
logger$
|
|
5105
|
+
logger$3.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
5035
5106
|
};
|
|
5036
5107
|
}
|
|
5037
5108
|
|
|
5038
5109
|
close(force = false) {
|
|
5039
|
-
logger$
|
|
5110
|
+
logger$3.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
5040
5111
|
|
|
5041
5112
|
if (!this.socket) {
|
|
5042
5113
|
return;
|
|
@@ -5054,7 +5125,7 @@ class WebSocketClient extends Emitter {
|
|
|
5054
5125
|
|
|
5055
5126
|
updateToken(token ) {
|
|
5056
5127
|
this.token = token;
|
|
5057
|
-
logger$
|
|
5128
|
+
logger$3.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
5058
5129
|
|
|
5059
5130
|
if (this.socket) {
|
|
5060
5131
|
// If still connected, send the token to the WS
|
|
@@ -5072,7 +5143,7 @@ class WebSocketClient extends Emitter {
|
|
|
5072
5143
|
}
|
|
5073
5144
|
|
|
5074
5145
|
startHeartbeat() {
|
|
5075
|
-
logger$
|
|
5146
|
+
logger$3.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
5076
5147
|
|
|
5077
5148
|
if (!this.socket) {
|
|
5078
5149
|
this.heartbeat.stop();
|
|
@@ -5086,7 +5157,7 @@ class WebSocketClient extends Emitter {
|
|
|
5086
5157
|
}
|
|
5087
5158
|
|
|
5088
5159
|
stopHeartbeat() {
|
|
5089
|
-
logger$
|
|
5160
|
+
logger$3.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
5090
5161
|
|
|
5091
5162
|
this.heartbeat.stop();
|
|
5092
5163
|
}
|
|
@@ -5116,7 +5187,7 @@ class WebSocketClient extends Emitter {
|
|
|
5116
5187
|
}
|
|
5117
5188
|
|
|
5118
5189
|
reconnect(reason ) {
|
|
5119
|
-
logger$
|
|
5190
|
+
logger$3.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
5120
5191
|
if (!this.socket) {
|
|
5121
5192
|
return;
|
|
5122
5193
|
}
|
|
@@ -5172,7 +5243,7 @@ class WebSocketClient extends Emitter {
|
|
|
5172
5243
|
this.close();
|
|
5173
5244
|
}
|
|
5174
5245
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
5175
|
-
logger$
|
|
5246
|
+
logger$3.log('Wazo WS url computed to reconnect', { url });
|
|
5176
5247
|
|
|
5177
5248
|
return url;
|
|
5178
5249
|
}
|
|
@@ -5180,12 +5251,12 @@ class WebSocketClient extends Emitter {
|
|
|
5180
5251
|
_onHeartbeat(message ) {
|
|
5181
5252
|
if (message.payload === 'pong') {
|
|
5182
5253
|
this.heartbeat.onHeartbeat();
|
|
5183
|
-
logger$
|
|
5254
|
+
logger$3.log('on heartbeat received from Wazo WS');
|
|
5184
5255
|
}
|
|
5185
5256
|
}
|
|
5186
5257
|
|
|
5187
5258
|
async _onHeartbeatTimeout() {
|
|
5188
|
-
logger$
|
|
5259
|
+
logger$3.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
5189
5260
|
|
|
5190
5261
|
this.close();
|
|
5191
5262
|
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
@@ -5263,6 +5334,7 @@ WebSocketClient.eventLists = [
|
|
|
5263
5334
|
AGENT_UNPAUSED,
|
|
5264
5335
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
5265
5336
|
CONFERENCE_ADHOC_DELETED,
|
|
5337
|
+
MEETING_USER_PROGRESS,
|
|
5266
5338
|
];
|
|
5267
5339
|
|
|
5268
5340
|
var wazoWebsocket = {
|
|
@@ -5305,7 +5377,7 @@ var wazoWebsocket = {
|
|
|
5305
5377
|
|
|
5306
5378
|
/* */
|
|
5307
5379
|
|
|
5308
|
-
const parseCandidate
|
|
5380
|
+
const parseCandidate = (candidate ) => {
|
|
5309
5381
|
if (!candidate) {
|
|
5310
5382
|
return null;
|
|
5311
5383
|
}
|
|
@@ -5318,10 +5390,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
5318
5390
|
candidates
|
|
5319
5391
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
5320
5392
|
|
|
5321
|
-
const areCandidateValid = (candidates ) =>
|
|
5322
|
-
getSrflxOrRelay(candidates)
|
|
5323
|
-
.length > 0;
|
|
5324
|
-
|
|
5325
5393
|
const getVideoDirection = (sdp ) => {
|
|
5326
5394
|
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
5327
5395
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -5374,8 +5442,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
5374
5442
|
/* global RTCSessionDescriptionInit, navigator */
|
|
5375
5443
|
|
|
5376
5444
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
5377
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
5378
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
5379
5445
|
|
|
5380
5446
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
5381
5447
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -5465,7 +5531,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5465
5531
|
this.peerConnectionDelegate.onicecandidate = event => {
|
|
5466
5532
|
wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
|
|
5467
5533
|
if (event.candidate) {
|
|
5468
|
-
this.gatheredCandidates.push(parseCandidate
|
|
5534
|
+
this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
|
|
5469
5535
|
}
|
|
5470
5536
|
};
|
|
5471
5537
|
|
|
@@ -5565,38 +5631,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5565
5631
|
this._peerConnection = undefined;
|
|
5566
5632
|
}
|
|
5567
5633
|
|
|
5568
|
-
async _waitForValidGatheredIce() {
|
|
5569
|
-
let tries = 0;
|
|
5570
|
-
|
|
5571
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
5572
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
5573
|
-
tries,
|
|
5574
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
5575
|
-
});
|
|
5576
|
-
|
|
5577
|
-
tries++;
|
|
5578
|
-
|
|
5579
|
-
// eslint-disable-next-line no-await-in-loop
|
|
5580
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
5581
|
-
}
|
|
5582
|
-
|
|
5583
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
5584
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
5585
|
-
const error = new Error(errorMsg);
|
|
5586
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
5587
|
-
|
|
5588
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
5589
|
-
this.eventEmitter.emit('error', error);
|
|
5590
|
-
|
|
5591
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5592
|
-
}
|
|
5593
|
-
|
|
5594
|
-
// eslint-disable-next-line
|
|
5595
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5596
|
-
|
|
5597
|
-
return this.getLocalSessionDescription();
|
|
5598
|
-
}
|
|
5599
|
-
|
|
5600
5634
|
// Overridden to send `inactive` in conference
|
|
5601
5635
|
updateDirection(options , isConference = false,
|
|
5602
5636
|
audioOnly = false) {
|
|
@@ -5866,7 +5900,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
5866
5900
|
const SEND_STATS_DELAY = 5000;
|
|
5867
5901
|
|
|
5868
5902
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
5869
|
-
const logger$
|
|
5903
|
+
const logger$4 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
5870
5904
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
5871
5905
|
|
|
5872
5906
|
// events
|
|
@@ -6042,13 +6076,13 @@ class WebRTCClient extends Emitter {
|
|
|
6042
6076
|
|
|
6043
6077
|
createUserAgent(configOverrides ) {
|
|
6044
6078
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6045
|
-
logger$
|
|
6079
|
+
logger$4.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6046
6080
|
|
|
6047
6081
|
webRTCConfiguration.delegate = {
|
|
6048
6082
|
onConnect: this.onConnect.bind(this),
|
|
6049
6083
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6050
6084
|
onInvite: (invitation ) => {
|
|
6051
|
-
logger$
|
|
6085
|
+
logger$4.info('sdk webrtc on invite', {
|
|
6052
6086
|
method: 'delegate.onInvite',
|
|
6053
6087
|
id: invitation.id,
|
|
6054
6088
|
remoteURI: invitation.remoteURI,
|
|
@@ -6091,7 +6125,7 @@ class WebRTCClient extends Emitter {
|
|
|
6091
6125
|
}
|
|
6092
6126
|
|
|
6093
6127
|
onConnect() {
|
|
6094
|
-
logger$
|
|
6128
|
+
logger$4.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6095
6129
|
this.eventEmitter.emit(CONNECTED);
|
|
6096
6130
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6097
6131
|
this.registerer.waitingToggle(false);
|
|
@@ -6100,7 +6134,7 @@ class WebRTCClient extends Emitter {
|
|
|
6100
6134
|
}
|
|
6101
6135
|
|
|
6102
6136
|
async onDisconnect(error ) {
|
|
6103
|
-
logger$
|
|
6137
|
+
logger$4.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6104
6138
|
this.connectionPromise = null;
|
|
6105
6139
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6106
6140
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6125,37 +6159,37 @@ class WebRTCClient extends Emitter {
|
|
|
6125
6159
|
};
|
|
6126
6160
|
|
|
6127
6161
|
if (this.skipRegister) {
|
|
6128
|
-
logger$
|
|
6162
|
+
logger$4.info('sdk webrtc skip register...', logInfo);
|
|
6129
6163
|
return Promise.resolve();
|
|
6130
6164
|
}
|
|
6131
6165
|
|
|
6132
|
-
logger$
|
|
6166
|
+
logger$4.info('sdk webrtc registering...', logInfo);
|
|
6133
6167
|
|
|
6134
6168
|
if (!this.userAgent) {
|
|
6135
|
-
logger$
|
|
6169
|
+
logger$4.info('sdk webrtc recreating User Agent');
|
|
6136
6170
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6137
6171
|
}
|
|
6138
6172
|
if (!this.userAgent || this.isRegistered()) {
|
|
6139
|
-
logger$
|
|
6173
|
+
logger$4.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6140
6174
|
return Promise.resolve();
|
|
6141
6175
|
}
|
|
6142
6176
|
|
|
6143
6177
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6144
|
-
logger$
|
|
6178
|
+
logger$4.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6145
6179
|
return Promise.resolve();
|
|
6146
6180
|
}
|
|
6147
6181
|
|
|
6148
6182
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6149
6183
|
|
|
6150
6184
|
const onRegisterFailed = () => {
|
|
6151
|
-
logger$
|
|
6185
|
+
logger$4.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6152
6186
|
this.connectionPromise = null;
|
|
6153
6187
|
if (this.registerer && this.registerer.waiting) {
|
|
6154
6188
|
this.registerer.waitingToggle(false);
|
|
6155
6189
|
}
|
|
6156
6190
|
|
|
6157
6191
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6158
|
-
logger$
|
|
6192
|
+
logger$4.info('sdk webrtc registering, retrying...', { tries });
|
|
6159
6193
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6160
6194
|
}
|
|
6161
6195
|
};
|
|
@@ -6164,18 +6198,18 @@ class WebRTCClient extends Emitter {
|
|
|
6164
6198
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6165
6199
|
// during the resolution of the primise.
|
|
6166
6200
|
if (!this.userAgent) {
|
|
6167
|
-
logger$
|
|
6201
|
+
logger$4.info('sdk webrtc recreating User Agent after connection');
|
|
6168
6202
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6169
6203
|
}
|
|
6170
6204
|
|
|
6171
|
-
logger$
|
|
6205
|
+
logger$4.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6172
6206
|
this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
|
|
6173
6207
|
this.connectionPromise = null;
|
|
6174
6208
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6175
6209
|
|
|
6176
6210
|
// Bind registerer events
|
|
6177
6211
|
this.registerer.stateChange.addListener(newState => {
|
|
6178
|
-
logger$
|
|
6212
|
+
logger$4.info('sdk webrtc registering, state changed', { newState });
|
|
6179
6213
|
|
|
6180
6214
|
if (newState === registererState.RegistererState.Registered && this.registerer
|
|
6181
6215
|
&& this.registerer.state === registererState.RegistererState.Registered) {
|
|
@@ -6188,7 +6222,7 @@ class WebRTCClient extends Emitter {
|
|
|
6188
6222
|
const options = {
|
|
6189
6223
|
requestDelegate: {
|
|
6190
6224
|
onReject: response => {
|
|
6191
|
-
logger$
|
|
6225
|
+
logger$4.error('sdk webrtc registering, rejected', { response });
|
|
6192
6226
|
|
|
6193
6227
|
onRegisterFailed();
|
|
6194
6228
|
},
|
|
@@ -6196,13 +6230,13 @@ class WebRTCClient extends Emitter {
|
|
|
6196
6230
|
};
|
|
6197
6231
|
|
|
6198
6232
|
return this.registerer.register(options).catch((e) => {
|
|
6199
|
-
logger$
|
|
6233
|
+
logger$4.error('sdk webrtc registering, error', e);
|
|
6200
6234
|
|
|
6201
6235
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6202
6236
|
return e;
|
|
6203
6237
|
});
|
|
6204
6238
|
}).catch(error => {
|
|
6205
|
-
logger$
|
|
6239
|
+
logger$4.error('sdk webrtc registering, transport error', error);
|
|
6206
6240
|
onRegisterFailed();
|
|
6207
6241
|
});
|
|
6208
6242
|
}
|
|
@@ -6231,21 +6265,21 @@ class WebRTCClient extends Emitter {
|
|
|
6231
6265
|
}
|
|
6232
6266
|
|
|
6233
6267
|
unregister() {
|
|
6234
|
-
logger$
|
|
6268
|
+
logger$4.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6235
6269
|
if (!this.registerer) {
|
|
6236
6270
|
return Promise.resolve();
|
|
6237
6271
|
}
|
|
6238
6272
|
|
|
6239
6273
|
try {
|
|
6240
6274
|
return this.registerer.unregister().then(() => {
|
|
6241
|
-
logger$
|
|
6275
|
+
logger$4.info('sdk webrtc unregistered');
|
|
6242
6276
|
this._cleanupRegister();
|
|
6243
6277
|
}).catch(e => {
|
|
6244
|
-
logger$
|
|
6278
|
+
logger$4.error('sdk webrtc unregistering, promise error', e);
|
|
6245
6279
|
this._cleanupRegister();
|
|
6246
6280
|
});
|
|
6247
6281
|
} catch (e) {
|
|
6248
|
-
logger$
|
|
6282
|
+
logger$4.error('sdk webrtc unregistering, error', e);
|
|
6249
6283
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6250
6284
|
// error when the registerer is in a bad state
|
|
6251
6285
|
this._cleanupRegister();
|
|
@@ -6253,7 +6287,7 @@ class WebRTCClient extends Emitter {
|
|
|
6253
6287
|
}
|
|
6254
6288
|
|
|
6255
6289
|
stop() {
|
|
6256
|
-
logger$
|
|
6290
|
+
logger$4.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6257
6291
|
if (!this.userAgent) {
|
|
6258
6292
|
return Promise.resolve();
|
|
6259
6293
|
}
|
|
@@ -6261,12 +6295,12 @@ class WebRTCClient extends Emitter {
|
|
|
6261
6295
|
return this.userAgent.stop().then(() => {
|
|
6262
6296
|
return this._cleanupRegister();
|
|
6263
6297
|
}).catch(e => {
|
|
6264
|
-
logger$
|
|
6298
|
+
logger$4.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6265
6299
|
});
|
|
6266
6300
|
}
|
|
6267
6301
|
|
|
6268
6302
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6269
|
-
logger$
|
|
6303
|
+
logger$4.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6270
6304
|
const inviterOptions = {
|
|
6271
6305
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6272
6306
|
conference,
|
|
@@ -6291,11 +6325,13 @@ class WebRTCClient extends Emitter {
|
|
|
6291
6325
|
const inviteOptions = {
|
|
6292
6326
|
requestDelegate: {
|
|
6293
6327
|
onAccept: (response ) => {
|
|
6294
|
-
session.sessionDescriptionHandler.peerConnection
|
|
6328
|
+
if (session.sessionDescriptionHandler.peerConnection) {
|
|
6329
|
+
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
6330
|
+
}
|
|
6295
6331
|
this._onAccepted(session, response.session, true);
|
|
6296
6332
|
},
|
|
6297
6333
|
onReject: (response ) => {
|
|
6298
|
-
logger$
|
|
6334
|
+
logger$4.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6299
6335
|
this._stopSendingStats(session);
|
|
6300
6336
|
this.stopNetworkMonitoring(session);
|
|
6301
6337
|
|
|
@@ -6318,11 +6354,11 @@ class WebRTCClient extends Emitter {
|
|
|
6318
6354
|
}
|
|
6319
6355
|
|
|
6320
6356
|
answer(session , enableVideo ) {
|
|
6321
|
-
logger$
|
|
6357
|
+
logger$4.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
6322
6358
|
|
|
6323
6359
|
if (!session || !session.accept) {
|
|
6324
6360
|
const error = 'No session to answer, or not an invitation';
|
|
6325
|
-
logger$
|
|
6361
|
+
logger$4.warn(error);
|
|
6326
6362
|
return Promise.reject(new Error(error));
|
|
6327
6363
|
}
|
|
6328
6364
|
const options = {
|
|
@@ -6332,15 +6368,15 @@ class WebRTCClient extends Emitter {
|
|
|
6332
6368
|
return session.accept(options).then(() => {
|
|
6333
6369
|
if (session.isCanceled) {
|
|
6334
6370
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
6335
|
-
logger$
|
|
6371
|
+
logger$4.error(message, { id: session.id });
|
|
6336
6372
|
this.onCallEnded(session);
|
|
6337
6373
|
|
|
6338
6374
|
throw new CanceledCallError(message);
|
|
6339
6375
|
}
|
|
6340
|
-
logger$
|
|
6376
|
+
logger$4.info('sdk webrtc answer, accepted.');
|
|
6341
6377
|
this._onAccepted(session);
|
|
6342
6378
|
}).catch(e => {
|
|
6343
|
-
logger$
|
|
6379
|
+
logger$4.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
6344
6380
|
|
|
6345
6381
|
throw e;
|
|
6346
6382
|
});
|
|
@@ -6348,7 +6384,7 @@ class WebRTCClient extends Emitter {
|
|
|
6348
6384
|
|
|
6349
6385
|
hangup(session ) {
|
|
6350
6386
|
const { state, id } = session;
|
|
6351
|
-
logger$
|
|
6387
|
+
logger$4.info('sdk webrtc hangup call', { id, state });
|
|
6352
6388
|
|
|
6353
6389
|
try {
|
|
6354
6390
|
this._stopSendingStats(session);
|
|
@@ -6377,7 +6413,7 @@ class WebRTCClient extends Emitter {
|
|
|
6377
6413
|
|
|
6378
6414
|
return bye();
|
|
6379
6415
|
} catch (error) {
|
|
6380
|
-
logger$
|
|
6416
|
+
logger$4.warn('sdk webrtc hangup, error', error);
|
|
6381
6417
|
}
|
|
6382
6418
|
|
|
6383
6419
|
return null;
|
|
@@ -6395,7 +6431,7 @@ class WebRTCClient extends Emitter {
|
|
|
6395
6431
|
// Fetch and emit an event at `interval` with session network stats
|
|
6396
6432
|
startNetworkMonitoring(session , interval = 1000) {
|
|
6397
6433
|
const sessionId = this.getSipSessionId(session);
|
|
6398
|
-
logger$
|
|
6434
|
+
logger$4.info('starting network inspection', { id: sessionId });
|
|
6399
6435
|
|
|
6400
6436
|
this.sessionNetworkStats[sessionId] = [];
|
|
6401
6437
|
|
|
@@ -6405,7 +6441,7 @@ class WebRTCClient extends Emitter {
|
|
|
6405
6441
|
stopNetworkMonitoring(session ) {
|
|
6406
6442
|
const sessionId = this.getSipSessionId(session);
|
|
6407
6443
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
6408
|
-
logger$
|
|
6444
|
+
logger$4.info('stopping network inspection', { id: sessionId, exists });
|
|
6409
6445
|
|
|
6410
6446
|
if (exists) {
|
|
6411
6447
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -6415,17 +6451,17 @@ class WebRTCClient extends Emitter {
|
|
|
6415
6451
|
}
|
|
6416
6452
|
|
|
6417
6453
|
reject(session ) {
|
|
6418
|
-
logger$
|
|
6454
|
+
logger$4.info('sdk webrtc reject call', { id: session.id });
|
|
6419
6455
|
|
|
6420
6456
|
try {
|
|
6421
6457
|
return session.reject ? session.reject() : session.cancel();
|
|
6422
6458
|
} catch (e) {
|
|
6423
|
-
logger$
|
|
6459
|
+
logger$4.warn('Error when rejecting call', e.message, e.stack);
|
|
6424
6460
|
}
|
|
6425
6461
|
}
|
|
6426
6462
|
|
|
6427
6463
|
async close() {
|
|
6428
|
-
logger$
|
|
6464
|
+
logger$4.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
6429
6465
|
this._cleanupMedia();
|
|
6430
6466
|
this.connectionPromise = null;
|
|
6431
6467
|
|
|
@@ -6456,7 +6492,7 @@ class WebRTCClient extends Emitter {
|
|
|
6456
6492
|
// eg: "INVITE not rejectable in state Completed"
|
|
6457
6493
|
}
|
|
6458
6494
|
this.userAgent = null;
|
|
6459
|
-
logger$
|
|
6495
|
+
logger$4.info('sdk webrtc client closed');
|
|
6460
6496
|
}
|
|
6461
6497
|
|
|
6462
6498
|
getNumber(session ) {
|
|
@@ -6469,13 +6505,13 @@ class WebRTCClient extends Emitter {
|
|
|
6469
6505
|
}
|
|
6470
6506
|
|
|
6471
6507
|
mute(session ) {
|
|
6472
|
-
logger$
|
|
6508
|
+
logger$4.info('sdk webrtc mute', { id: session.id });
|
|
6473
6509
|
|
|
6474
6510
|
this._toggleAudio(session, true);
|
|
6475
6511
|
}
|
|
6476
6512
|
|
|
6477
6513
|
unmute(session ) {
|
|
6478
|
-
logger$
|
|
6514
|
+
logger$4.info('sdk webrtc unmute', { id: session.id });
|
|
6479
6515
|
|
|
6480
6516
|
this._toggleAudio(session, false);
|
|
6481
6517
|
}
|
|
@@ -6515,13 +6551,13 @@ class WebRTCClient extends Emitter {
|
|
|
6515
6551
|
}
|
|
6516
6552
|
|
|
6517
6553
|
toggleCameraOn(session ) {
|
|
6518
|
-
logger$
|
|
6554
|
+
logger$4.info('sdk webrtc toggle camera on', { id: session.id });
|
|
6519
6555
|
|
|
6520
6556
|
this._toggleVideo(session, false);
|
|
6521
6557
|
}
|
|
6522
6558
|
|
|
6523
6559
|
toggleCameraOff(session ) {
|
|
6524
|
-
logger$
|
|
6560
|
+
logger$4.info('sdk webrtc toggle camera off', { id: session.id });
|
|
6525
6561
|
|
|
6526
6562
|
this._toggleVideo(session, true);
|
|
6527
6563
|
}
|
|
@@ -6530,7 +6566,7 @@ class WebRTCClient extends Emitter {
|
|
|
6530
6566
|
const sessionId = this.getSipSessionId(session);
|
|
6531
6567
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
6532
6568
|
|
|
6533
|
-
logger$
|
|
6569
|
+
logger$4.info('sdk webrtc hold', {
|
|
6534
6570
|
sessionId,
|
|
6535
6571
|
keys: Object.keys(this.heldSessions),
|
|
6536
6572
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6579,7 +6615,7 @@ class WebRTCClient extends Emitter {
|
|
|
6579
6615
|
const sessionId = this.getSipSessionId(session);
|
|
6580
6616
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
6581
6617
|
|
|
6582
|
-
logger$
|
|
6618
|
+
logger$4.info('sdk webrtc unhold', {
|
|
6583
6619
|
sessionId,
|
|
6584
6620
|
keys: Object.keys(this.heldSessions),
|
|
6585
6621
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6727,7 +6763,7 @@ class WebRTCClient extends Emitter {
|
|
|
6727
6763
|
if (!session.sessionDescriptionHandler) {
|
|
6728
6764
|
return;
|
|
6729
6765
|
}
|
|
6730
|
-
logger$
|
|
6766
|
+
logger$4.info('Sending DTMF', {
|
|
6731
6767
|
id: this.getSipSessionId(session),
|
|
6732
6768
|
tone,
|
|
6733
6769
|
});
|
|
@@ -6743,7 +6779,7 @@ class WebRTCClient extends Emitter {
|
|
|
6743
6779
|
transfer(session , target ) {
|
|
6744
6780
|
this.hold(session);
|
|
6745
6781
|
|
|
6746
|
-
logger$
|
|
6782
|
+
logger$4.info('Transfering a session', {
|
|
6747
6783
|
id: this.getSipSessionId(session),
|
|
6748
6784
|
target,
|
|
6749
6785
|
});
|
|
@@ -6765,17 +6801,17 @@ class WebRTCClient extends Emitter {
|
|
|
6765
6801
|
atxfer(session ) {
|
|
6766
6802
|
this.hold(session);
|
|
6767
6803
|
|
|
6768
|
-
logger$
|
|
6804
|
+
logger$4.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
6769
6805
|
|
|
6770
6806
|
const result = {
|
|
6771
6807
|
newSession: null,
|
|
6772
6808
|
init: async (target ) => {
|
|
6773
|
-
logger$
|
|
6809
|
+
logger$4.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
6774
6810
|
|
|
6775
6811
|
result.newSession = await this.call(target);
|
|
6776
6812
|
},
|
|
6777
6813
|
complete: () => {
|
|
6778
|
-
logger$
|
|
6814
|
+
logger$4.info('webrtc transfer completed', {
|
|
6779
6815
|
id: this.getSipSessionId(session),
|
|
6780
6816
|
referId: this.getSipSessionId(result.newSession),
|
|
6781
6817
|
});
|
|
@@ -6796,7 +6832,7 @@ class WebRTCClient extends Emitter {
|
|
|
6796
6832
|
return;
|
|
6797
6833
|
}
|
|
6798
6834
|
|
|
6799
|
-
logger$
|
|
6835
|
+
logger$4.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
6800
6836
|
|
|
6801
6837
|
try {
|
|
6802
6838
|
sipSession.message({
|
|
@@ -6838,7 +6874,7 @@ class WebRTCClient extends Emitter {
|
|
|
6838
6874
|
}
|
|
6839
6875
|
|
|
6840
6876
|
changeAudioOutputVolume(volume ) {
|
|
6841
|
-
logger$
|
|
6877
|
+
logger$4.info('Changing audio output volume', { volume });
|
|
6842
6878
|
|
|
6843
6879
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
6844
6880
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -6850,7 +6886,7 @@ class WebRTCClient extends Emitter {
|
|
|
6850
6886
|
}
|
|
6851
6887
|
|
|
6852
6888
|
changeAudioOutputDevice(id ) {
|
|
6853
|
-
logger$
|
|
6889
|
+
logger$4.info('Changing audio output device', { id });
|
|
6854
6890
|
|
|
6855
6891
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
6856
6892
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -6867,7 +6903,7 @@ class WebRTCClient extends Emitter {
|
|
|
6867
6903
|
|
|
6868
6904
|
changeAudioInputDevice(id , session ) {
|
|
6869
6905
|
const currentId = this.getAudioDeviceId();
|
|
6870
|
-
logger$
|
|
6906
|
+
logger$4.info('setting audio input device', { id, currentId, session: !!session });
|
|
6871
6907
|
|
|
6872
6908
|
if (id === currentId) {
|
|
6873
6909
|
return null;
|
|
@@ -6913,7 +6949,7 @@ class WebRTCClient extends Emitter {
|
|
|
6913
6949
|
|
|
6914
6950
|
setVideoInputDevice(id ) {
|
|
6915
6951
|
const currentId = this.getVideoDeviceId();
|
|
6916
|
-
logger$
|
|
6952
|
+
logger$4.info('setting video input device', { id, currentId });
|
|
6917
6953
|
|
|
6918
6954
|
if (id === currentId) {
|
|
6919
6955
|
return null;
|
|
@@ -6938,7 +6974,7 @@ class WebRTCClient extends Emitter {
|
|
|
6938
6974
|
const sessionId = this.getSipSessionId(session);
|
|
6939
6975
|
const localStream = this.getLocalStream(sessionId);
|
|
6940
6976
|
|
|
6941
|
-
logger$
|
|
6977
|
+
logger$4.info('changing video input device', { id, sessionId });
|
|
6942
6978
|
|
|
6943
6979
|
// Release old video stream
|
|
6944
6980
|
if (localStream) {
|
|
@@ -7006,7 +7042,7 @@ class WebRTCClient extends Emitter {
|
|
|
7006
7042
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
7007
7043
|
const desktop = newConstraints && newConstraints.desktop;
|
|
7008
7044
|
|
|
7009
|
-
logger$
|
|
7045
|
+
logger$4.info('Sending reinvite', {
|
|
7010
7046
|
id: this.getSipSessionId(sipSession),
|
|
7011
7047
|
newConstraints,
|
|
7012
7048
|
conference,
|
|
@@ -7044,7 +7080,7 @@ class WebRTCClient extends Emitter {
|
|
|
7044
7080
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
7045
7081
|
}
|
|
7046
7082
|
|
|
7047
|
-
logger$
|
|
7083
|
+
logger$4.info('on re-INVITE accepted', {
|
|
7048
7084
|
id: this.getSipSessionId(sipSession),
|
|
7049
7085
|
wasMuted,
|
|
7050
7086
|
shouldDoScreenSharing,
|
|
@@ -7163,6 +7199,16 @@ class WebRTCClient extends Emitter {
|
|
|
7163
7199
|
return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
|
|
7164
7200
|
}
|
|
7165
7201
|
|
|
7202
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
7203
|
+
getRemoteVideoStreamFromPc(sessionId ) {
|
|
7204
|
+
const pc = this.getPeerConnection(sessionId);
|
|
7205
|
+
if (!pc) {
|
|
7206
|
+
return null;
|
|
7207
|
+
}
|
|
7208
|
+
|
|
7209
|
+
return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
|
|
7210
|
+
}
|
|
7211
|
+
|
|
7166
7212
|
hasVideo(sessionId ) {
|
|
7167
7213
|
return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
|
|
7168
7214
|
}
|
|
@@ -7209,7 +7255,7 @@ class WebRTCClient extends Emitter {
|
|
|
7209
7255
|
}
|
|
7210
7256
|
|
|
7211
7257
|
startHeartbeat() {
|
|
7212
|
-
logger$
|
|
7258
|
+
logger$4.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7213
7259
|
if (!this.userAgent) {
|
|
7214
7260
|
this.heartbeat.stop();
|
|
7215
7261
|
return;
|
|
@@ -7222,7 +7268,7 @@ class WebRTCClient extends Emitter {
|
|
|
7222
7268
|
}
|
|
7223
7269
|
|
|
7224
7270
|
stopHeartbeat() {
|
|
7225
|
-
logger$
|
|
7271
|
+
logger$4.info('sdk webrtc stop heartbeat');
|
|
7226
7272
|
this.heartbeat.stop();
|
|
7227
7273
|
}
|
|
7228
7274
|
|
|
@@ -7243,7 +7289,7 @@ class WebRTCClient extends Emitter {
|
|
|
7243
7289
|
}
|
|
7244
7290
|
|
|
7245
7291
|
attemptReconnection() {
|
|
7246
|
-
logger$
|
|
7292
|
+
logger$4.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7247
7293
|
if (!this.userAgent) {
|
|
7248
7294
|
return;
|
|
7249
7295
|
}
|
|
@@ -7268,7 +7314,7 @@ class WebRTCClient extends Emitter {
|
|
|
7268
7314
|
return;
|
|
7269
7315
|
}
|
|
7270
7316
|
|
|
7271
|
-
logger$
|
|
7317
|
+
logger$4.info('setting local media stream', {
|
|
7272
7318
|
sipSessionId,
|
|
7273
7319
|
tracks: newStream ? newStream.getTracks() : null,
|
|
7274
7320
|
});
|
|
@@ -7285,7 +7331,7 @@ class WebRTCClient extends Emitter {
|
|
|
7285
7331
|
|
|
7286
7332
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
7287
7333
|
|
|
7288
|
-
logger$
|
|
7334
|
+
logger$4.info('updating local stream', {
|
|
7289
7335
|
sipSessionId,
|
|
7290
7336
|
oldStream: !!oldStream,
|
|
7291
7337
|
tracks: newStream.getTracks(),
|
|
@@ -7305,7 +7351,7 @@ class WebRTCClient extends Emitter {
|
|
|
7305
7351
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
7306
7352
|
const pc = this.getPeerConnection(sessionId);
|
|
7307
7353
|
|
|
7308
|
-
logger$
|
|
7354
|
+
logger$4.info('Updating remote stream', {
|
|
7309
7355
|
sessionId,
|
|
7310
7356
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
7311
7357
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -7331,7 +7377,7 @@ class WebRTCClient extends Emitter {
|
|
|
7331
7377
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
7332
7378
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
7333
7379
|
|
|
7334
|
-
logger$
|
|
7380
|
+
logger$4.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
7335
7381
|
|
|
7336
7382
|
return {
|
|
7337
7383
|
constraints: {
|
|
@@ -7380,7 +7426,7 @@ class WebRTCClient extends Emitter {
|
|
|
7380
7426
|
}
|
|
7381
7427
|
|
|
7382
7428
|
_onTransportError() {
|
|
7383
|
-
logger$
|
|
7429
|
+
logger$4.error('on transport error');
|
|
7384
7430
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
7385
7431
|
this.attemptReconnection();
|
|
7386
7432
|
}
|
|
@@ -7389,7 +7435,7 @@ class WebRTCClient extends Emitter {
|
|
|
7389
7435
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
7390
7436
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
7391
7437
|
if (this.hasHeartbeat()) {
|
|
7392
|
-
logger$
|
|
7438
|
+
logger$4.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
7393
7439
|
|
|
7394
7440
|
this.heartbeat.onHeartbeat();
|
|
7395
7441
|
if (this.heartbeatCb) {
|
|
@@ -7400,7 +7446,7 @@ class WebRTCClient extends Emitter {
|
|
|
7400
7446
|
}
|
|
7401
7447
|
|
|
7402
7448
|
async _onHeartbeatTimeout() {
|
|
7403
|
-
logger$
|
|
7449
|
+
logger$4.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
7404
7450
|
|
|
7405
7451
|
if (this.heartbeatTimeoutCb) {
|
|
7406
7452
|
this.heartbeatTimeoutCb();
|
|
@@ -7412,7 +7458,7 @@ class WebRTCClient extends Emitter {
|
|
|
7412
7458
|
try {
|
|
7413
7459
|
await this.userAgent.transport.disconnect();
|
|
7414
7460
|
} catch (e) {
|
|
7415
|
-
logger$
|
|
7461
|
+
logger$4.error('Transport disconnection after heartbeat timeout, error', e);
|
|
7416
7462
|
}
|
|
7417
7463
|
}
|
|
7418
7464
|
|
|
@@ -7445,31 +7491,31 @@ class WebRTCClient extends Emitter {
|
|
|
7445
7491
|
}
|
|
7446
7492
|
|
|
7447
7493
|
_connectIfNeeded() {
|
|
7448
|
-
logger$
|
|
7494
|
+
logger$4.info('connect if needed, checking', { connected: this.isConnected() });
|
|
7449
7495
|
if (!this.userAgent) {
|
|
7450
|
-
logger$
|
|
7496
|
+
logger$4.info('need to recreate User Agent');
|
|
7451
7497
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
7452
7498
|
}
|
|
7453
7499
|
|
|
7454
7500
|
if (this.isConnected()) {
|
|
7455
|
-
logger$
|
|
7501
|
+
logger$4.info('webrtc sdk, already connected');
|
|
7456
7502
|
return Promise.resolve();
|
|
7457
7503
|
}
|
|
7458
7504
|
|
|
7459
7505
|
if (this.isConnecting()) {
|
|
7460
|
-
logger$
|
|
7506
|
+
logger$4.info('webrtc sdk, already connecting...');
|
|
7461
7507
|
|
|
7462
7508
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
7463
7509
|
return this.connectionPromise;
|
|
7464
7510
|
}
|
|
7465
7511
|
|
|
7466
7512
|
if (this.connectionPromise) {
|
|
7467
|
-
logger$
|
|
7513
|
+
logger$4.info('webrtc sdk, connection promise connecting...');
|
|
7468
7514
|
// $FlowFixMe
|
|
7469
7515
|
return this.connectionPromise;
|
|
7470
7516
|
}
|
|
7471
7517
|
|
|
7472
|
-
logger$
|
|
7518
|
+
logger$4.info('WebRTC UA needs to connect');
|
|
7473
7519
|
|
|
7474
7520
|
// Force UA to reconnect
|
|
7475
7521
|
if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
|
|
@@ -7594,7 +7640,7 @@ class WebRTCClient extends Emitter {
|
|
|
7594
7640
|
|
|
7595
7641
|
sdh.peerConnectionDelegate = {
|
|
7596
7642
|
onicecandidateerror: (error ) => {
|
|
7597
|
-
logger$
|
|
7643
|
+
logger$4.error('on icecandidate error', {
|
|
7598
7644
|
address: error.address,
|
|
7599
7645
|
port: error.port,
|
|
7600
7646
|
errorCode: error.errorCode,
|
|
@@ -7623,7 +7669,7 @@ class WebRTCClient extends Emitter {
|
|
|
7623
7669
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
7624
7670
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
7625
7671
|
}
|
|
7626
|
-
logger$
|
|
7672
|
+
logger$4.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
7627
7673
|
|
|
7628
7674
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
7629
7675
|
|
|
@@ -7644,7 +7690,7 @@ class WebRTCClient extends Emitter {
|
|
|
7644
7690
|
}
|
|
7645
7691
|
|
|
7646
7692
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
7647
|
-
logger$
|
|
7693
|
+
logger$4.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7648
7694
|
|
|
7649
7695
|
this.storeSipSession(session);
|
|
7650
7696
|
|
|
@@ -7656,7 +7702,7 @@ class WebRTCClient extends Emitter {
|
|
|
7656
7702
|
const onTrack = (event ) => {
|
|
7657
7703
|
const isAudioOnly = this._isAudioOnly(session);
|
|
7658
7704
|
const { kind, label, readyState, id, muted } = event.track;
|
|
7659
|
-
logger$
|
|
7705
|
+
logger$4.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
7660
7706
|
|
|
7661
7707
|
// Stop video track in audio only mode
|
|
7662
7708
|
if (isAudioOnly && kind === 'video') {
|
|
@@ -7673,6 +7719,7 @@ class WebRTCClient extends Emitter {
|
|
|
7673
7719
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
7674
7720
|
|
|
7675
7721
|
pc.oniceconnectionstatechange = () => {
|
|
7722
|
+
logger$4.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
7676
7723
|
if (pc.iceConnectionState === 'disconnected') {
|
|
7677
7724
|
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
7678
7725
|
}
|
|
@@ -7845,10 +7892,10 @@ class WebRTCClient extends Emitter {
|
|
|
7845
7892
|
|
|
7846
7893
|
_stopSendingStats(session ) {
|
|
7847
7894
|
const sessionId = this.getSipSessionId(session);
|
|
7848
|
-
logger$
|
|
7895
|
+
logger$4.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
7849
7896
|
|
|
7850
7897
|
if (sessionId in this.statsIntervals) {
|
|
7851
|
-
logger$
|
|
7898
|
+
logger$4.trace('Stop sending stats for call', { sessionId });
|
|
7852
7899
|
this.statsIntervals[sessionId]();
|
|
7853
7900
|
delete this.statsIntervals[sessionId];
|
|
7854
7901
|
}
|
|
@@ -7864,7 +7911,7 @@ class WebRTCClient extends Emitter {
|
|
|
7864
7911
|
try {
|
|
7865
7912
|
await this.userAgent.transport.disconnect();
|
|
7866
7913
|
} catch (e) {
|
|
7867
|
-
logger$
|
|
7914
|
+
logger$4.error('WebRTC transport disconnect, error', e);
|
|
7868
7915
|
}
|
|
7869
7916
|
}
|
|
7870
7917
|
}
|
|
@@ -7901,25 +7948,25 @@ class WebRTCClient extends Emitter {
|
|
|
7901
7948
|
|
|
7902
7949
|
stats.forEach(report => {
|
|
7903
7950
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
7904
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
7951
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
7905
7952
|
}
|
|
7906
7953
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
7907
|
-
audioBytesSent += report.bytesSent;
|
|
7954
|
+
audioBytesSent += Number(report.bytesSent);
|
|
7908
7955
|
}
|
|
7909
7956
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
7910
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
7957
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
7911
7958
|
}
|
|
7912
7959
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
7913
|
-
packetsLost += report.packetsLost;
|
|
7914
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
7915
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
7960
|
+
packetsLost += Number(report.packetsLost);
|
|
7961
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
7962
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
7916
7963
|
}
|
|
7917
7964
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
7918
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
7965
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
7919
7966
|
}
|
|
7920
7967
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
7921
7968
|
if ('framesPerSecond' in report) {
|
|
7922
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
7969
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
7923
7970
|
}
|
|
7924
7971
|
if ('framerateMean' in report) {
|
|
7925
7972
|
// framerateMean is only available in FF
|
|
@@ -7927,32 +7974,36 @@ class WebRTCClient extends Emitter {
|
|
|
7927
7974
|
}
|
|
7928
7975
|
}
|
|
7929
7976
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
7930
|
-
packetsLost += report.packetsLost;
|
|
7931
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
7932
|
-
networkStats.jitter = report.jitter;
|
|
7977
|
+
packetsLost += Number(report.packetsLost);
|
|
7978
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
7979
|
+
networkStats.jitter = Number(report.jitter);
|
|
7933
7980
|
}
|
|
7934
7981
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
7935
|
-
packetsLost += report.packetsLost;
|
|
7982
|
+
packetsLost += Number(report.packetsLost);
|
|
7936
7983
|
}
|
|
7937
7984
|
if (report.type === 'transport') {
|
|
7938
|
-
transportSent += report.bytesSent;
|
|
7939
|
-
transportReceived += report.bytesReceived;
|
|
7985
|
+
transportSent += Number(report.bytesSent);
|
|
7986
|
+
transportReceived += Number(report.bytesReceived);
|
|
7940
7987
|
}
|
|
7941
7988
|
});
|
|
7942
7989
|
|
|
7943
7990
|
networkStats.packetsLost = packetsLost;
|
|
7944
|
-
networkStats.
|
|
7991
|
+
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
7992
|
+
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
7993
|
+
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
7945
7994
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
7946
|
-
networkStats.
|
|
7947
|
-
networkStats.
|
|
7995
|
+
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
7996
|
+
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
7997
|
+
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
7998
|
+
networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
|
|
7999
|
+
networkStats.totalTransportSent = transportSent - lastTransportSent;
|
|
7948
8000
|
networkStats.transportSent = transportSent;
|
|
7949
|
-
networkStats.
|
|
7950
|
-
|
|
7951
|
-
const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
|
|
7952
|
-
+ (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
|
|
7953
|
-
+ (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
|
|
8001
|
+
networkStats.totalTransportReceived = transportReceived;
|
|
8002
|
+
networkStats.transportReceived = transportReceived - lastTransportReceived;
|
|
7954
8003
|
|
|
7955
|
-
networkStats.bandwidth =
|
|
8004
|
+
networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
|
|
8005
|
+
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
8006
|
+
+ networkStats.transportSent;
|
|
7956
8007
|
|
|
7957
8008
|
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
7958
8009
|
this.sessionNetworkStats[sessionId].push(networkStats);
|
|
@@ -8043,7 +8094,7 @@ var webrtc = {
|
|
|
8043
8094
|
}),
|
|
8044
8095
|
};
|
|
8045
8096
|
|
|
8046
|
-
const parseCandidate = line => {
|
|
8097
|
+
const parseCandidate$1 = line => {
|
|
8047
8098
|
let parts;
|
|
8048
8099
|
// Parse both variants.
|
|
8049
8100
|
if (line.indexOf('a=candidate:') === 0) {
|
|
@@ -8134,7 +8185,7 @@ var SymmetricNat = {
|
|
|
8134
8185
|
}
|
|
8135
8186
|
|
|
8136
8187
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
8137
|
-
const cand = parseCandidate(e.candidate.candidate);
|
|
8188
|
+
const cand = parseCandidate$1(e.candidate.candidate);
|
|
8138
8189
|
if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
|
|
8139
8190
|
candidates[cand.relatedPort].push(cand.port);
|
|
8140
8191
|
} else if (!e.candidate) {
|
|
@@ -8202,7 +8253,7 @@ var iceIpv4 = {
|
|
|
8202
8253
|
const rawCandidate = e.candidate.candidate;
|
|
8203
8254
|
if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
|
|
8204
8255
|
hasSrflxOrRelay = true;
|
|
8205
|
-
const candidate = parseCandidate(e.candidate.candidate);
|
|
8256
|
+
const candidate = parseCandidate$1(e.candidate.candidate);
|
|
8206
8257
|
ips.push(candidate.ip);
|
|
8207
8258
|
}
|
|
8208
8259
|
} else if (!e.candidate) {
|
|
@@ -8239,7 +8290,7 @@ var checks = [
|
|
|
8239
8290
|
|
|
8240
8291
|
//
|
|
8241
8292
|
|
|
8242
|
-
const logger = IssueReporter$1.loggerFor('engine-check');
|
|
8293
|
+
const logger$5 = IssueReporter$1.loggerFor('engine-check');
|
|
8243
8294
|
|
|
8244
8295
|
class Checker {
|
|
8245
8296
|
|
|
@@ -8257,28 +8308,28 @@ class Checker {
|
|
|
8257
8308
|
async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
|
|
8258
8309
|
await this._addEngineVersion();
|
|
8259
8310
|
|
|
8260
|
-
logger.info('Engine check starting');
|
|
8311
|
+
logger$5.info('Engine check starting');
|
|
8261
8312
|
|
|
8262
8313
|
for (let i = 0; i < this.checks.length; i++) {
|
|
8263
8314
|
const { name, check } = this.checks[i];
|
|
8264
8315
|
|
|
8265
|
-
logger.info(`Checking ${name} ...`);
|
|
8316
|
+
logger$5.info(`Checking ${name} ...`);
|
|
8266
8317
|
|
|
8267
8318
|
onCheckBegin(name);
|
|
8268
8319
|
try {
|
|
8269
8320
|
// eslint-disable-next-line no-await-in-loop
|
|
8270
8321
|
const result = await check(this.server, this.session, this.externalAppConfig);
|
|
8271
|
-
logger.info(`Checking ${name} success.`, { result });
|
|
8322
|
+
logger$5.info(`Checking ${name} success.`, { result });
|
|
8272
8323
|
|
|
8273
8324
|
onCheckResult(name, result);
|
|
8274
8325
|
} catch (e) {
|
|
8275
|
-
logger.info(`Checking ${name} failure`, { message: e.message });
|
|
8326
|
+
logger$5.info(`Checking ${name} failure`, { message: e.message });
|
|
8276
8327
|
|
|
8277
8328
|
onCheckResult(name, e);
|
|
8278
8329
|
}
|
|
8279
8330
|
}
|
|
8280
8331
|
|
|
8281
|
-
logger.info('Engine check done.');
|
|
8332
|
+
logger$5.info('Engine check done.');
|
|
8282
8333
|
}
|
|
8283
8334
|
|
|
8284
8335
|
addCheck(check ) {
|