@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
|
@@ -138,7 +138,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
138
138
|
|
|
139
139
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
140
140
|
|
|
141
|
-
const logger
|
|
141
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
142
142
|
|
|
143
143
|
// Use a function here to be able to mock it in tests
|
|
144
144
|
const realFetch = () => {
|
|
@@ -277,7 +277,7 @@ class ApiRequester {
|
|
|
277
277
|
};
|
|
278
278
|
|
|
279
279
|
if (this.refreshTokenPromise) {
|
|
280
|
-
logger
|
|
280
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
281
281
|
await this.refreshTokenPromise;
|
|
282
282
|
}
|
|
283
283
|
|
|
@@ -297,7 +297,7 @@ class ApiRequester {
|
|
|
297
297
|
return promise.then(async (err ) => {
|
|
298
298
|
// Check if the token is still valid
|
|
299
299
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
300
|
-
logger
|
|
300
|
+
logger.warn('token expired', { error: err.reason });
|
|
301
301
|
// Replay the call after refreshing the token
|
|
302
302
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
303
303
|
}
|
|
@@ -307,7 +307,7 @@ class ApiRequester {
|
|
|
307
307
|
: exceptionClass.fromResponse(err, response.status);
|
|
308
308
|
|
|
309
309
|
if (this.shouldLogErrors) {
|
|
310
|
-
logger
|
|
310
|
+
logger.error('API error', error);
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
throw error;
|
|
@@ -317,7 +317,7 @@ class ApiRequester {
|
|
|
317
317
|
return newParse(response, isJson);
|
|
318
318
|
}).catch(error => {
|
|
319
319
|
if (this.shouldLogErrors) {
|
|
320
|
-
logger
|
|
320
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
throw error;
|
|
@@ -345,13 +345,13 @@ class ApiRequester {
|
|
|
345
345
|
) {
|
|
346
346
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
347
347
|
let newPath = path;
|
|
348
|
-
logger
|
|
348
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
349
349
|
|
|
350
350
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
351
351
|
|
|
352
352
|
return this.refreshTokenPromise.then(() => {
|
|
353
353
|
this.refreshTokenPromise = null;
|
|
354
|
-
logger
|
|
354
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
355
355
|
if (isTokenNotFound) {
|
|
356
356
|
const pathParts = path.split('/');
|
|
357
357
|
pathParts.pop();
|
|
@@ -450,6 +450,7 @@ class IssueReporter {
|
|
|
450
450
|
|
|
451
451
|
|
|
452
452
|
|
|
453
|
+
|
|
453
454
|
|
|
454
455
|
constructor() {
|
|
455
456
|
addLevelsTo(this);
|
|
@@ -461,12 +462,17 @@ class IssueReporter {
|
|
|
461
462
|
this.bufferTimeout = null;
|
|
462
463
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
463
464
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
465
|
+
this._callback = null;
|
|
464
466
|
}
|
|
465
467
|
|
|
466
468
|
init() {
|
|
467
469
|
this._catchConsole();
|
|
468
470
|
}
|
|
469
471
|
|
|
472
|
+
setCallback(cb ) {
|
|
473
|
+
this._callback = cb;
|
|
474
|
+
}
|
|
475
|
+
|
|
470
476
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
471
477
|
this.remoteClientConfiguration = configuration;
|
|
472
478
|
}
|
|
@@ -502,6 +508,7 @@ class IssueReporter {
|
|
|
502
508
|
|
|
503
509
|
// Handle category label
|
|
504
510
|
let category = null;
|
|
511
|
+
let skipSendToRemote = false;
|
|
505
512
|
let extra = {};
|
|
506
513
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
507
514
|
category = args[0].split('=')[1];
|
|
@@ -517,6 +524,7 @@ class IssueReporter {
|
|
|
517
524
|
errorMessage: lastArg.message,
|
|
518
525
|
errorStack: lastArg.stack,
|
|
519
526
|
errorType: lastArg.constructor.name,
|
|
527
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
520
528
|
};
|
|
521
529
|
} else {
|
|
522
530
|
extra = lastArg;
|
|
@@ -525,6 +533,11 @@ class IssueReporter {
|
|
|
525
533
|
args.splice(1, 1);
|
|
526
534
|
}
|
|
527
535
|
|
|
536
|
+
if (extra.skipSendToRemote) {
|
|
537
|
+
skipSendToRemote = true;
|
|
538
|
+
delete extra.skipSendToRemote;
|
|
539
|
+
}
|
|
540
|
+
|
|
528
541
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
529
542
|
const message = args.join(', ');
|
|
530
543
|
let consoleMessage = message;
|
|
@@ -545,7 +558,13 @@ class IssueReporter {
|
|
|
545
558
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
546
559
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
547
560
|
|
|
548
|
-
this.
|
|
561
|
+
if (this._callback) {
|
|
562
|
+
this._callback(level, consoleMessage);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
if (!skipSendToRemote) {
|
|
566
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
567
|
+
}
|
|
549
568
|
}
|
|
550
569
|
|
|
551
570
|
logRequest(url , options , response , start ) {
|
|
@@ -690,7 +709,11 @@ class IssueReporter {
|
|
|
690
709
|
},
|
|
691
710
|
// $FlowFixMe
|
|
692
711
|
body,
|
|
693
|
-
}).catch(() => {
|
|
712
|
+
}).catch((e ) => {
|
|
713
|
+
// $FlowFixMe
|
|
714
|
+
e.skipSendToRemote = true;
|
|
715
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
716
|
+
|
|
694
717
|
setTimeout(() => {
|
|
695
718
|
if (isArray) {
|
|
696
719
|
payload = payload.map(message => {
|
|
@@ -1563,6 +1586,9 @@ class Contact {
|
|
|
1563
1586
|
}
|
|
1564
1587
|
|
|
1565
1588
|
static parseMany(response ) {
|
|
1589
|
+
if (!response || !response.results) {
|
|
1590
|
+
return [];
|
|
1591
|
+
}
|
|
1566
1592
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
1567
1593
|
}
|
|
1568
1594
|
|
|
@@ -2640,8 +2666,9 @@ class ExternalApp {
|
|
|
2640
2666
|
|
|
2641
2667
|
|
|
2642
2668
|
|
|
2643
|
-
|
|
2669
|
+
|
|
2644
2670
|
|
|
2671
|
+
|
|
2645
2672
|
|
|
2646
2673
|
|
|
2647
2674
|
class Meeting {
|
|
@@ -2652,9 +2679,10 @@ class Meeting {
|
|
|
2652
2679
|
|
|
2653
2680
|
|
|
2654
2681
|
|
|
2655
|
-
|
|
2682
|
+
|
|
2656
2683
|
|
|
2657
2684
|
|
|
2685
|
+
|
|
2658
2686
|
|
|
2659
2687
|
static parse(plain ) {
|
|
2660
2688
|
return new Meeting({
|
|
@@ -2664,24 +2692,43 @@ class Meeting {
|
|
|
2664
2692
|
ownerUuids: plain.owner_uuids,
|
|
2665
2693
|
port: plain.port,
|
|
2666
2694
|
uuid: plain.uuid,
|
|
2667
|
-
|
|
2695
|
+
extension: plain.exten,
|
|
2668
2696
|
persistent: plain.persistent,
|
|
2697
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
2669
2698
|
});
|
|
2670
2699
|
}
|
|
2671
2700
|
|
|
2701
|
+
static parseMany(items ) {
|
|
2702
|
+
if (!items) {
|
|
2703
|
+
return [];
|
|
2704
|
+
}
|
|
2705
|
+
return items.map(plain => Meeting.parse(plain));
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2672
2708
|
static newFrom(meeting ) {
|
|
2673
2709
|
return newFrom(meeting, Meeting);
|
|
2674
2710
|
}
|
|
2675
2711
|
|
|
2676
|
-
constructor({
|
|
2712
|
+
constructor({
|
|
2713
|
+
uuid,
|
|
2714
|
+
name,
|
|
2715
|
+
guestSipAuthorization,
|
|
2716
|
+
ownerUuids,
|
|
2717
|
+
port,
|
|
2718
|
+
uri,
|
|
2719
|
+
extension,
|
|
2720
|
+
persistent,
|
|
2721
|
+
creationTime,
|
|
2722
|
+
} = {}) {
|
|
2677
2723
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2678
2724
|
this.uri = uri;
|
|
2679
2725
|
this.name = name;
|
|
2680
2726
|
this.ownerUuids = ownerUuids;
|
|
2681
2727
|
this.port = port;
|
|
2682
2728
|
this.uuid = uuid;
|
|
2683
|
-
this.
|
|
2729
|
+
this.extension = extension;
|
|
2684
2730
|
this.persistent = persistent;
|
|
2731
|
+
this.creationTime = creationTime;
|
|
2685
2732
|
|
|
2686
2733
|
// Useful to compare instead of instanceof with minified code
|
|
2687
2734
|
this.type = 'Meeting';
|
|
@@ -2759,8 +2806,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2759
2806
|
}
|
|
2760
2807
|
},
|
|
2761
2808
|
|
|
2762
|
-
|
|
2763
|
-
client.
|
|
2809
|
+
getMyMeetings: () =>
|
|
2810
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
2811
|
+
|
|
2812
|
+
createMyMeeting: (name , persistent ) =>
|
|
2813
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
2764
2814
|
|
|
2765
2815
|
deleteMyMeeting: (meetingUuid ) =>
|
|
2766
2816
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -2856,6 +2906,10 @@ class ChatMessage {
|
|
|
2856
2906
|
|
|
2857
2907
|
|
|
2858
2908
|
static parseMany(plain ) {
|
|
2909
|
+
if (!plain || !plain.items) {
|
|
2910
|
+
return [];
|
|
2911
|
+
}
|
|
2912
|
+
|
|
2859
2913
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
2860
2914
|
}
|
|
2861
2915
|
|
|
@@ -2965,6 +3019,9 @@ class Voicemail {
|
|
|
2965
3019
|
}
|
|
2966
3020
|
|
|
2967
3021
|
static parseMany(plain ) {
|
|
3022
|
+
if (!plain) {
|
|
3023
|
+
return [];
|
|
3024
|
+
}
|
|
2968
3025
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
2969
3026
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
2970
3027
|
|
|
@@ -3074,6 +3131,9 @@ class Call {
|
|
|
3074
3131
|
|
|
3075
3132
|
|
|
3076
3133
|
static parseMany(plain ) {
|
|
3134
|
+
if (!plain) {
|
|
3135
|
+
return [];
|
|
3136
|
+
}
|
|
3077
3137
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
3078
3138
|
}
|
|
3079
3139
|
|
|
@@ -3591,6 +3651,9 @@ class Recording {
|
|
|
3591
3651
|
|
|
3592
3652
|
|
|
3593
3653
|
static parseMany(recordings = []) {
|
|
3654
|
+
if (!recordings) {
|
|
3655
|
+
return [];
|
|
3656
|
+
}
|
|
3594
3657
|
return recordings.map(item => Recording.parse(item));
|
|
3595
3658
|
}
|
|
3596
3659
|
|
|
@@ -3692,6 +3755,10 @@ class CallLog {
|
|
|
3692
3755
|
}
|
|
3693
3756
|
|
|
3694
3757
|
static parseMany(plain ) {
|
|
3758
|
+
if (!plain || !plain.items) {
|
|
3759
|
+
return [];
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3695
3762
|
return plain.items.map(item => CallLog.parse(item));
|
|
3696
3763
|
}
|
|
3697
3764
|
|
|
@@ -3996,7 +4063,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3996
4063
|
|
|
3997
4064
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3998
4065
|
|
|
3999
|
-
const logger$
|
|
4066
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
4000
4067
|
|
|
4001
4068
|
class CTIPhone extends Emitter {
|
|
4002
4069
|
|
|
@@ -4009,7 +4076,7 @@ class CTIPhone extends Emitter {
|
|
|
4009
4076
|
|
|
4010
4077
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
4011
4078
|
super();
|
|
4012
|
-
logger$
|
|
4079
|
+
logger$1.info('CTI Phone created');
|
|
4013
4080
|
this.session = session;
|
|
4014
4081
|
this.isMobile = isMobile;
|
|
4015
4082
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -4070,7 +4137,7 @@ class CTIPhone extends Emitter {
|
|
|
4070
4137
|
}
|
|
4071
4138
|
|
|
4072
4139
|
async makeCall(number , line ) {
|
|
4073
|
-
logger$
|
|
4140
|
+
logger$1.info('make CTI call', { number });
|
|
4074
4141
|
|
|
4075
4142
|
if (!number) {
|
|
4076
4143
|
return null;
|
|
@@ -4093,7 +4160,7 @@ class CTIPhone extends Emitter {
|
|
|
4093
4160
|
if (!callSession) {
|
|
4094
4161
|
return Promise.resolve(null);
|
|
4095
4162
|
}
|
|
4096
|
-
logger$
|
|
4163
|
+
logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4097
4164
|
|
|
4098
4165
|
if (!this.currentCall) {
|
|
4099
4166
|
this.currentCall = callSession.call;
|
|
@@ -4106,7 +4173,7 @@ class CTIPhone extends Emitter {
|
|
|
4106
4173
|
if (!callSession) {
|
|
4107
4174
|
return;
|
|
4108
4175
|
}
|
|
4109
|
-
logger$
|
|
4176
|
+
logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4110
4177
|
|
|
4111
4178
|
this.currentCall = undefined;
|
|
4112
4179
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4116,7 +4183,7 @@ class CTIPhone extends Emitter {
|
|
|
4116
4183
|
if (!callSession) {
|
|
4117
4184
|
return Promise.resolve(false);
|
|
4118
4185
|
}
|
|
4119
|
-
logger$
|
|
4186
|
+
logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4120
4187
|
|
|
4121
4188
|
try {
|
|
4122
4189
|
await CallApi.cancelCall(callSession);
|
|
@@ -4127,7 +4194,7 @@ class CTIPhone extends Emitter {
|
|
|
4127
4194
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
4128
4195
|
return true;
|
|
4129
4196
|
} catch (e) {
|
|
4130
|
-
logger$
|
|
4197
|
+
logger$1.error('hangup CTI call, error', e);
|
|
4131
4198
|
|
|
4132
4199
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
4133
4200
|
return false;
|
|
@@ -4140,7 +4207,7 @@ class CTIPhone extends Emitter {
|
|
|
4140
4207
|
if (!callSession) {
|
|
4141
4208
|
return;
|
|
4142
4209
|
}
|
|
4143
|
-
logger$
|
|
4210
|
+
logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4144
4211
|
|
|
4145
4212
|
await CallApi.cancelCall(callSession);
|
|
4146
4213
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4150,7 +4217,7 @@ class CTIPhone extends Emitter {
|
|
|
4150
4217
|
if (!callSession) {
|
|
4151
4218
|
return;
|
|
4152
4219
|
}
|
|
4153
|
-
logger$
|
|
4220
|
+
logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4154
4221
|
|
|
4155
4222
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
4156
4223
|
}
|
|
@@ -4163,19 +4230,19 @@ class CTIPhone extends Emitter {
|
|
|
4163
4230
|
if (!callSession) {
|
|
4164
4231
|
return;
|
|
4165
4232
|
}
|
|
4166
|
-
logger$
|
|
4233
|
+
logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4167
4234
|
|
|
4168
4235
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
4169
4236
|
}
|
|
4170
4237
|
|
|
4171
4238
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
4172
|
-
logger$
|
|
4239
|
+
logger$1.info('cancel CTI transfer', { transferId });
|
|
4173
4240
|
|
|
4174
4241
|
return CallApi.cancelCallTransfer(transferId);
|
|
4175
4242
|
}
|
|
4176
4243
|
|
|
4177
4244
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
4178
|
-
logger$
|
|
4245
|
+
logger$1.info('confirm CTI transfer', { transferId });
|
|
4179
4246
|
|
|
4180
4247
|
return CallApi.confirmCallTransfer(transferId);
|
|
4181
4248
|
}
|
|
@@ -4184,19 +4251,19 @@ class CTIPhone extends Emitter {
|
|
|
4184
4251
|
if (!callSession) {
|
|
4185
4252
|
return;
|
|
4186
4253
|
}
|
|
4187
|
-
logger$
|
|
4254
|
+
logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4188
4255
|
|
|
4189
4256
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4190
4257
|
}
|
|
4191
4258
|
|
|
4192
4259
|
onConnectionMade() {
|
|
4193
|
-
logger$
|
|
4260
|
+
logger$1.info('on CTI connection made');
|
|
4194
4261
|
|
|
4195
4262
|
this.eventEmitter.emit('onCallAccepted');
|
|
4196
4263
|
}
|
|
4197
4264
|
|
|
4198
4265
|
async close() {
|
|
4199
|
-
logger$
|
|
4266
|
+
logger$1.info('CTI close');
|
|
4200
4267
|
|
|
4201
4268
|
return Promise.resolve();
|
|
4202
4269
|
}
|
|
@@ -4205,7 +4272,7 @@ class CTIPhone extends Emitter {
|
|
|
4205
4272
|
if (!callSession) {
|
|
4206
4273
|
return;
|
|
4207
4274
|
}
|
|
4208
|
-
logger$
|
|
4275
|
+
logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4209
4276
|
|
|
4210
4277
|
return CallApi.hold(callSession.callId);
|
|
4211
4278
|
}
|
|
@@ -4214,7 +4281,7 @@ class CTIPhone extends Emitter {
|
|
|
4214
4281
|
if (!callSession) {
|
|
4215
4282
|
return;
|
|
4216
4283
|
}
|
|
4217
|
-
logger$
|
|
4284
|
+
logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4218
4285
|
|
|
4219
4286
|
return CallApi.resume(callSession.callId);
|
|
4220
4287
|
}
|
|
@@ -4223,7 +4290,7 @@ class CTIPhone extends Emitter {
|
|
|
4223
4290
|
if (!callSession) {
|
|
4224
4291
|
return;
|
|
4225
4292
|
}
|
|
4226
|
-
logger$
|
|
4293
|
+
logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4227
4294
|
|
|
4228
4295
|
return CallApi.mute(callSession.callId);
|
|
4229
4296
|
}
|
|
@@ -4232,7 +4299,7 @@ class CTIPhone extends Emitter {
|
|
|
4232
4299
|
if (!callSession) {
|
|
4233
4300
|
return;
|
|
4234
4301
|
}
|
|
4235
|
-
logger$
|
|
4302
|
+
logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4236
4303
|
|
|
4237
4304
|
return CallApi.unmute(callSession.callId);
|
|
4238
4305
|
}
|
|
@@ -4261,6 +4328,10 @@ class CTIPhone extends Emitter {
|
|
|
4261
4328
|
return false;
|
|
4262
4329
|
}
|
|
4263
4330
|
|
|
4331
|
+
hasAVideoTrack() {
|
|
4332
|
+
return false;
|
|
4333
|
+
}
|
|
4334
|
+
|
|
4264
4335
|
getLocalStreamForCall() {
|
|
4265
4336
|
return null;
|
|
4266
4337
|
}
|
|
@@ -4654,6 +4725,9 @@ class ChatRoom {
|
|
|
4654
4725
|
|
|
4655
4726
|
|
|
4656
4727
|
static parseMany(plain ) {
|
|
4728
|
+
if (!plain || !plain.items) {
|
|
4729
|
+
return [];
|
|
4730
|
+
}
|
|
4657
4731
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
4658
4732
|
}
|
|
4659
4733
|
|
|
@@ -5234,7 +5308,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5234
5308
|
const WEBHOOKD_VERSION = '1.0';
|
|
5235
5309
|
const AMID_VERSION = '1.0';
|
|
5236
5310
|
|
|
5237
|
-
const logger$
|
|
5311
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5238
5312
|
|
|
5239
5313
|
class ApiClient {
|
|
5240
5314
|
|
|
@@ -5286,12 +5360,12 @@ class ApiClient {
|
|
|
5286
5360
|
}
|
|
5287
5361
|
|
|
5288
5362
|
async forceRefreshToken() {
|
|
5289
|
-
logger$
|
|
5363
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
5290
5364
|
return this.refreshTokenCallback();
|
|
5291
5365
|
}
|
|
5292
5366
|
|
|
5293
5367
|
async refreshTokenCallback() {
|
|
5294
|
-
logger$
|
|
5368
|
+
logger$2.info('refresh token callback called', {
|
|
5295
5369
|
refreshToken: this.refreshToken,
|
|
5296
5370
|
refreshBackend: this.refreshBackend,
|
|
5297
5371
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5309,7 +5383,7 @@ class ApiClient {
|
|
|
5309
5383
|
this.isMobile,
|
|
5310
5384
|
);
|
|
5311
5385
|
|
|
5312
|
-
logger$
|
|
5386
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
5313
5387
|
|
|
5314
5388
|
if (this.onRefreshToken) {
|
|
5315
5389
|
this.onRefreshToken(session.token, session);
|
|
@@ -5450,7 +5524,7 @@ var getApiClient = (forServer ) => {
|
|
|
5450
5524
|
class InvalidSubscription extends Error {}
|
|
5451
5525
|
class InvalidAuthorization extends Error {}
|
|
5452
5526
|
|
|
5453
|
-
const logger$
|
|
5527
|
+
const logger$3 = IssueReporter$1.loggerFor('simple-auth');
|
|
5454
5528
|
|
|
5455
5529
|
class Auth {
|
|
5456
5530
|
|
|
@@ -5485,7 +5559,7 @@ class Auth {
|
|
|
5485
5559
|
setApiClientId(this.clientId);
|
|
5486
5560
|
setRefreshExpiration(this.expiration);
|
|
5487
5561
|
setOnRefreshToken((token , session ) => {
|
|
5488
|
-
logger$
|
|
5562
|
+
logger$3.info('on refresh token done', { token });
|
|
5489
5563
|
setApiToken(token);
|
|
5490
5564
|
Wazo.Websocket.updateToken(token);
|
|
5491
5565
|
|
|
@@ -5530,7 +5604,7 @@ class Auth {
|
|
|
5530
5604
|
const rawSession = await getApiClient().auth.authenticate(token);
|
|
5531
5605
|
return this._onAuthenticated(rawSession);
|
|
5532
5606
|
} catch (e) {
|
|
5533
|
-
logger$
|
|
5607
|
+
logger$3.error('on validate token error', e);
|
|
5534
5608
|
console.warn(e);
|
|
5535
5609
|
return false;
|
|
5536
5610
|
}
|
|
@@ -5886,7 +5960,7 @@ class AdHocAPIConference {
|
|
|
5886
5960
|
|
|
5887
5961
|
/* */
|
|
5888
5962
|
|
|
5889
|
-
const parseCandidate
|
|
5963
|
+
const parseCandidate = (candidate ) => {
|
|
5890
5964
|
if (!candidate) {
|
|
5891
5965
|
return null;
|
|
5892
5966
|
}
|
|
@@ -5899,10 +5973,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
5899
5973
|
candidates
|
|
5900
5974
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
5901
5975
|
|
|
5902
|
-
const areCandidateValid = (candidates ) =>
|
|
5903
|
-
getSrflxOrRelay(candidates)
|
|
5904
|
-
.length > 0;
|
|
5905
|
-
|
|
5906
5976
|
const getVideoDirection = (sdp ) => {
|
|
5907
5977
|
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
5908
5978
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -5955,8 +6025,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
5955
6025
|
/* global RTCSessionDescriptionInit, navigator */
|
|
5956
6026
|
|
|
5957
6027
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
5958
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
5959
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
5960
6028
|
|
|
5961
6029
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
5962
6030
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -6046,7 +6114,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6046
6114
|
this.peerConnectionDelegate.onicecandidate = event => {
|
|
6047
6115
|
wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
|
|
6048
6116
|
if (event.candidate) {
|
|
6049
|
-
this.gatheredCandidates.push(parseCandidate
|
|
6117
|
+
this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
|
|
6050
6118
|
}
|
|
6051
6119
|
};
|
|
6052
6120
|
|
|
@@ -6146,38 +6214,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6146
6214
|
this._peerConnection = undefined;
|
|
6147
6215
|
}
|
|
6148
6216
|
|
|
6149
|
-
async _waitForValidGatheredIce() {
|
|
6150
|
-
let tries = 0;
|
|
6151
|
-
|
|
6152
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
6153
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
6154
|
-
tries,
|
|
6155
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
6156
|
-
});
|
|
6157
|
-
|
|
6158
|
-
tries++;
|
|
6159
|
-
|
|
6160
|
-
// eslint-disable-next-line no-await-in-loop
|
|
6161
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
6162
|
-
}
|
|
6163
|
-
|
|
6164
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
6165
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
6166
|
-
const error = new Error(errorMsg);
|
|
6167
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
6168
|
-
|
|
6169
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
6170
|
-
this.eventEmitter.emit('error', error);
|
|
6171
|
-
|
|
6172
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
6173
|
-
}
|
|
6174
|
-
|
|
6175
|
-
// eslint-disable-next-line
|
|
6176
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
6177
|
-
|
|
6178
|
-
return this.getLocalSessionDescription();
|
|
6179
|
-
}
|
|
6180
|
-
|
|
6181
6217
|
// Overridden to send `inactive` in conference
|
|
6182
6218
|
updateDirection(options , isConference = false,
|
|
6183
6219
|
audioOnly = false) {
|
|
@@ -6542,7 +6578,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
6542
6578
|
const SEND_STATS_DELAY = 5000;
|
|
6543
6579
|
|
|
6544
6580
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
6545
|
-
const logger$
|
|
6581
|
+
const logger$4 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
6546
6582
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
6547
6583
|
|
|
6548
6584
|
// events
|
|
@@ -6556,14 +6592,14 @@ const TRANSPORT_ERROR = 'transportError';
|
|
|
6556
6592
|
const MESSAGE = 'message';
|
|
6557
6593
|
const ACCEPTED = 'accepted';
|
|
6558
6594
|
const REJECTED = 'rejected';
|
|
6559
|
-
const ON_TRACK
|
|
6560
|
-
const ON_REINVITE
|
|
6595
|
+
const ON_TRACK = 'onTrack';
|
|
6596
|
+
const ON_REINVITE = 'reinvite';
|
|
6561
6597
|
const ON_ERROR = 'onError';
|
|
6562
6598
|
const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
|
|
6563
|
-
const ON_NETWORK_STATS
|
|
6564
|
-
const ON_DISCONNECTED
|
|
6599
|
+
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
6600
|
+
const ON_DISCONNECTED = 'onDisconnected';
|
|
6565
6601
|
|
|
6566
|
-
const events
|
|
6602
|
+
const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
6567
6603
|
const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
6568
6604
|
class CanceledCallError extends Error {}
|
|
6569
6605
|
|
|
@@ -6699,12 +6735,12 @@ class WebRTCClient extends Emitter {
|
|
|
6699
6735
|
this.MESSAGE = MESSAGE;
|
|
6700
6736
|
this.ACCEPTED = ACCEPTED;
|
|
6701
6737
|
this.REJECTED = REJECTED;
|
|
6702
|
-
this.ON_TRACK = ON_TRACK
|
|
6703
|
-
this.ON_REINVITE = ON_REINVITE
|
|
6738
|
+
this.ON_TRACK = ON_TRACK;
|
|
6739
|
+
this.ON_REINVITE = ON_REINVITE;
|
|
6704
6740
|
this.ON_ERROR = ON_ERROR;
|
|
6705
6741
|
this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
|
|
6706
|
-
this.ON_NETWORK_STATS = ON_NETWORK_STATS
|
|
6707
|
-
this.ON_DISCONNECTED = ON_DISCONNECTED
|
|
6742
|
+
this.ON_NETWORK_STATS = ON_NETWORK_STATS;
|
|
6743
|
+
this.ON_DISCONNECTED = ON_DISCONNECTED;
|
|
6708
6744
|
}
|
|
6709
6745
|
|
|
6710
6746
|
configureMedia(media ) {
|
|
@@ -6721,13 +6757,13 @@ class WebRTCClient extends Emitter {
|
|
|
6721
6757
|
|
|
6722
6758
|
createUserAgent(configOverrides ) {
|
|
6723
6759
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6724
|
-
logger$
|
|
6760
|
+
logger$4.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6725
6761
|
|
|
6726
6762
|
webRTCConfiguration.delegate = {
|
|
6727
6763
|
onConnect: this.onConnect.bind(this),
|
|
6728
6764
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6729
6765
|
onInvite: (invitation ) => {
|
|
6730
|
-
logger$
|
|
6766
|
+
logger$4.info('sdk webrtc on invite', {
|
|
6731
6767
|
method: 'delegate.onInvite',
|
|
6732
6768
|
id: invitation.id,
|
|
6733
6769
|
remoteURI: invitation.remoteURI,
|
|
@@ -6770,7 +6806,7 @@ class WebRTCClient extends Emitter {
|
|
|
6770
6806
|
}
|
|
6771
6807
|
|
|
6772
6808
|
onConnect() {
|
|
6773
|
-
logger$
|
|
6809
|
+
logger$4.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6774
6810
|
this.eventEmitter.emit(CONNECTED);
|
|
6775
6811
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6776
6812
|
this.registerer.waitingToggle(false);
|
|
@@ -6779,7 +6815,7 @@ class WebRTCClient extends Emitter {
|
|
|
6779
6815
|
}
|
|
6780
6816
|
|
|
6781
6817
|
async onDisconnect(error ) {
|
|
6782
|
-
logger$
|
|
6818
|
+
logger$4.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6783
6819
|
this.connectionPromise = null;
|
|
6784
6820
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6785
6821
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6804,37 +6840,37 @@ class WebRTCClient extends Emitter {
|
|
|
6804
6840
|
};
|
|
6805
6841
|
|
|
6806
6842
|
if (this.skipRegister) {
|
|
6807
|
-
logger$
|
|
6843
|
+
logger$4.info('sdk webrtc skip register...', logInfo);
|
|
6808
6844
|
return Promise.resolve();
|
|
6809
6845
|
}
|
|
6810
6846
|
|
|
6811
|
-
logger$
|
|
6847
|
+
logger$4.info('sdk webrtc registering...', logInfo);
|
|
6812
6848
|
|
|
6813
6849
|
if (!this.userAgent) {
|
|
6814
|
-
logger$
|
|
6850
|
+
logger$4.info('sdk webrtc recreating User Agent');
|
|
6815
6851
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6816
6852
|
}
|
|
6817
6853
|
if (!this.userAgent || this.isRegistered()) {
|
|
6818
|
-
logger$
|
|
6854
|
+
logger$4.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6819
6855
|
return Promise.resolve();
|
|
6820
6856
|
}
|
|
6821
6857
|
|
|
6822
6858
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6823
|
-
logger$
|
|
6859
|
+
logger$4.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6824
6860
|
return Promise.resolve();
|
|
6825
6861
|
}
|
|
6826
6862
|
|
|
6827
6863
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6828
6864
|
|
|
6829
6865
|
const onRegisterFailed = () => {
|
|
6830
|
-
logger$
|
|
6866
|
+
logger$4.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6831
6867
|
this.connectionPromise = null;
|
|
6832
6868
|
if (this.registerer && this.registerer.waiting) {
|
|
6833
6869
|
this.registerer.waitingToggle(false);
|
|
6834
6870
|
}
|
|
6835
6871
|
|
|
6836
6872
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6837
|
-
logger$
|
|
6873
|
+
logger$4.info('sdk webrtc registering, retrying...', { tries });
|
|
6838
6874
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6839
6875
|
}
|
|
6840
6876
|
};
|
|
@@ -6843,18 +6879,18 @@ class WebRTCClient extends Emitter {
|
|
|
6843
6879
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6844
6880
|
// during the resolution of the primise.
|
|
6845
6881
|
if (!this.userAgent) {
|
|
6846
|
-
logger$
|
|
6882
|
+
logger$4.info('sdk webrtc recreating User Agent after connection');
|
|
6847
6883
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6848
6884
|
}
|
|
6849
6885
|
|
|
6850
|
-
logger$
|
|
6886
|
+
logger$4.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6851
6887
|
this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
|
|
6852
6888
|
this.connectionPromise = null;
|
|
6853
6889
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6854
6890
|
|
|
6855
6891
|
// Bind registerer events
|
|
6856
6892
|
this.registerer.stateChange.addListener(newState => {
|
|
6857
|
-
logger$
|
|
6893
|
+
logger$4.info('sdk webrtc registering, state changed', { newState });
|
|
6858
6894
|
|
|
6859
6895
|
if (newState === registererState.RegistererState.Registered && this.registerer
|
|
6860
6896
|
&& this.registerer.state === registererState.RegistererState.Registered) {
|
|
@@ -6867,7 +6903,7 @@ class WebRTCClient extends Emitter {
|
|
|
6867
6903
|
const options = {
|
|
6868
6904
|
requestDelegate: {
|
|
6869
6905
|
onReject: response => {
|
|
6870
|
-
logger$
|
|
6906
|
+
logger$4.error('sdk webrtc registering, rejected', { response });
|
|
6871
6907
|
|
|
6872
6908
|
onRegisterFailed();
|
|
6873
6909
|
},
|
|
@@ -6875,13 +6911,13 @@ class WebRTCClient extends Emitter {
|
|
|
6875
6911
|
};
|
|
6876
6912
|
|
|
6877
6913
|
return this.registerer.register(options).catch((e) => {
|
|
6878
|
-
logger$
|
|
6914
|
+
logger$4.error('sdk webrtc registering, error', e);
|
|
6879
6915
|
|
|
6880
6916
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6881
6917
|
return e;
|
|
6882
6918
|
});
|
|
6883
6919
|
}).catch(error => {
|
|
6884
|
-
logger$
|
|
6920
|
+
logger$4.error('sdk webrtc registering, transport error', error);
|
|
6885
6921
|
onRegisterFailed();
|
|
6886
6922
|
});
|
|
6887
6923
|
}
|
|
@@ -6910,21 +6946,21 @@ class WebRTCClient extends Emitter {
|
|
|
6910
6946
|
}
|
|
6911
6947
|
|
|
6912
6948
|
unregister() {
|
|
6913
|
-
logger$
|
|
6949
|
+
logger$4.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6914
6950
|
if (!this.registerer) {
|
|
6915
6951
|
return Promise.resolve();
|
|
6916
6952
|
}
|
|
6917
6953
|
|
|
6918
6954
|
try {
|
|
6919
6955
|
return this.registerer.unregister().then(() => {
|
|
6920
|
-
logger$
|
|
6956
|
+
logger$4.info('sdk webrtc unregistered');
|
|
6921
6957
|
this._cleanupRegister();
|
|
6922
6958
|
}).catch(e => {
|
|
6923
|
-
logger$
|
|
6959
|
+
logger$4.error('sdk webrtc unregistering, promise error', e);
|
|
6924
6960
|
this._cleanupRegister();
|
|
6925
6961
|
});
|
|
6926
6962
|
} catch (e) {
|
|
6927
|
-
logger$
|
|
6963
|
+
logger$4.error('sdk webrtc unregistering, error', e);
|
|
6928
6964
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6929
6965
|
// error when the registerer is in a bad state
|
|
6930
6966
|
this._cleanupRegister();
|
|
@@ -6932,7 +6968,7 @@ class WebRTCClient extends Emitter {
|
|
|
6932
6968
|
}
|
|
6933
6969
|
|
|
6934
6970
|
stop() {
|
|
6935
|
-
logger$
|
|
6971
|
+
logger$4.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6936
6972
|
if (!this.userAgent) {
|
|
6937
6973
|
return Promise.resolve();
|
|
6938
6974
|
}
|
|
@@ -6940,12 +6976,12 @@ class WebRTCClient extends Emitter {
|
|
|
6940
6976
|
return this.userAgent.stop().then(() => {
|
|
6941
6977
|
return this._cleanupRegister();
|
|
6942
6978
|
}).catch(e => {
|
|
6943
|
-
logger$
|
|
6979
|
+
logger$4.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6944
6980
|
});
|
|
6945
6981
|
}
|
|
6946
6982
|
|
|
6947
6983
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6948
|
-
logger$
|
|
6984
|
+
logger$4.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6949
6985
|
const inviterOptions = {
|
|
6950
6986
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6951
6987
|
conference,
|
|
@@ -6970,11 +7006,13 @@ class WebRTCClient extends Emitter {
|
|
|
6970
7006
|
const inviteOptions = {
|
|
6971
7007
|
requestDelegate: {
|
|
6972
7008
|
onAccept: (response ) => {
|
|
6973
|
-
session.sessionDescriptionHandler.peerConnection
|
|
7009
|
+
if (session.sessionDescriptionHandler.peerConnection) {
|
|
7010
|
+
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
7011
|
+
}
|
|
6974
7012
|
this._onAccepted(session, response.session, true);
|
|
6975
7013
|
},
|
|
6976
7014
|
onReject: (response ) => {
|
|
6977
|
-
logger$
|
|
7015
|
+
logger$4.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6978
7016
|
this._stopSendingStats(session);
|
|
6979
7017
|
this.stopNetworkMonitoring(session);
|
|
6980
7018
|
|
|
@@ -6997,11 +7035,11 @@ class WebRTCClient extends Emitter {
|
|
|
6997
7035
|
}
|
|
6998
7036
|
|
|
6999
7037
|
answer(session , enableVideo ) {
|
|
7000
|
-
logger$
|
|
7038
|
+
logger$4.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
7001
7039
|
|
|
7002
7040
|
if (!session || !session.accept) {
|
|
7003
7041
|
const error = 'No session to answer, or not an invitation';
|
|
7004
|
-
logger$
|
|
7042
|
+
logger$4.warn(error);
|
|
7005
7043
|
return Promise.reject(new Error(error));
|
|
7006
7044
|
}
|
|
7007
7045
|
const options = {
|
|
@@ -7011,15 +7049,15 @@ class WebRTCClient extends Emitter {
|
|
|
7011
7049
|
return session.accept(options).then(() => {
|
|
7012
7050
|
if (session.isCanceled) {
|
|
7013
7051
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
7014
|
-
logger$
|
|
7052
|
+
logger$4.error(message, { id: session.id });
|
|
7015
7053
|
this.onCallEnded(session);
|
|
7016
7054
|
|
|
7017
7055
|
throw new CanceledCallError(message);
|
|
7018
7056
|
}
|
|
7019
|
-
logger$
|
|
7057
|
+
logger$4.info('sdk webrtc answer, accepted.');
|
|
7020
7058
|
this._onAccepted(session);
|
|
7021
7059
|
}).catch(e => {
|
|
7022
|
-
logger$
|
|
7060
|
+
logger$4.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
7023
7061
|
|
|
7024
7062
|
throw e;
|
|
7025
7063
|
});
|
|
@@ -7027,7 +7065,7 @@ class WebRTCClient extends Emitter {
|
|
|
7027
7065
|
|
|
7028
7066
|
hangup(session ) {
|
|
7029
7067
|
const { state, id } = session;
|
|
7030
|
-
logger$
|
|
7068
|
+
logger$4.info('sdk webrtc hangup call', { id, state });
|
|
7031
7069
|
|
|
7032
7070
|
try {
|
|
7033
7071
|
this._stopSendingStats(session);
|
|
@@ -7056,7 +7094,7 @@ class WebRTCClient extends Emitter {
|
|
|
7056
7094
|
|
|
7057
7095
|
return bye();
|
|
7058
7096
|
} catch (error) {
|
|
7059
|
-
logger$
|
|
7097
|
+
logger$4.warn('sdk webrtc hangup, error', error);
|
|
7060
7098
|
}
|
|
7061
7099
|
|
|
7062
7100
|
return null;
|
|
@@ -7074,7 +7112,7 @@ class WebRTCClient extends Emitter {
|
|
|
7074
7112
|
// Fetch and emit an event at `interval` with session network stats
|
|
7075
7113
|
startNetworkMonitoring(session , interval = 1000) {
|
|
7076
7114
|
const sessionId = this.getSipSessionId(session);
|
|
7077
|
-
logger$
|
|
7115
|
+
logger$4.info('starting network inspection', { id: sessionId });
|
|
7078
7116
|
|
|
7079
7117
|
this.sessionNetworkStats[sessionId] = [];
|
|
7080
7118
|
|
|
@@ -7084,7 +7122,7 @@ class WebRTCClient extends Emitter {
|
|
|
7084
7122
|
stopNetworkMonitoring(session ) {
|
|
7085
7123
|
const sessionId = this.getSipSessionId(session);
|
|
7086
7124
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
7087
|
-
logger$
|
|
7125
|
+
logger$4.info('stopping network inspection', { id: sessionId, exists });
|
|
7088
7126
|
|
|
7089
7127
|
if (exists) {
|
|
7090
7128
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -7094,17 +7132,17 @@ class WebRTCClient extends Emitter {
|
|
|
7094
7132
|
}
|
|
7095
7133
|
|
|
7096
7134
|
reject(session ) {
|
|
7097
|
-
logger$
|
|
7135
|
+
logger$4.info('sdk webrtc reject call', { id: session.id });
|
|
7098
7136
|
|
|
7099
7137
|
try {
|
|
7100
7138
|
return session.reject ? session.reject() : session.cancel();
|
|
7101
7139
|
} catch (e) {
|
|
7102
|
-
logger$
|
|
7140
|
+
logger$4.warn('Error when rejecting call', e.message, e.stack);
|
|
7103
7141
|
}
|
|
7104
7142
|
}
|
|
7105
7143
|
|
|
7106
7144
|
async close() {
|
|
7107
|
-
logger$
|
|
7145
|
+
logger$4.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
7108
7146
|
this._cleanupMedia();
|
|
7109
7147
|
this.connectionPromise = null;
|
|
7110
7148
|
|
|
@@ -7135,7 +7173,7 @@ class WebRTCClient extends Emitter {
|
|
|
7135
7173
|
// eg: "INVITE not rejectable in state Completed"
|
|
7136
7174
|
}
|
|
7137
7175
|
this.userAgent = null;
|
|
7138
|
-
logger$
|
|
7176
|
+
logger$4.info('sdk webrtc client closed');
|
|
7139
7177
|
}
|
|
7140
7178
|
|
|
7141
7179
|
getNumber(session ) {
|
|
@@ -7148,13 +7186,13 @@ class WebRTCClient extends Emitter {
|
|
|
7148
7186
|
}
|
|
7149
7187
|
|
|
7150
7188
|
mute(session ) {
|
|
7151
|
-
logger$
|
|
7189
|
+
logger$4.info('sdk webrtc mute', { id: session.id });
|
|
7152
7190
|
|
|
7153
7191
|
this._toggleAudio(session, true);
|
|
7154
7192
|
}
|
|
7155
7193
|
|
|
7156
7194
|
unmute(session ) {
|
|
7157
|
-
logger$
|
|
7195
|
+
logger$4.info('sdk webrtc unmute', { id: session.id });
|
|
7158
7196
|
|
|
7159
7197
|
this._toggleAudio(session, false);
|
|
7160
7198
|
}
|
|
@@ -7194,13 +7232,13 @@ class WebRTCClient extends Emitter {
|
|
|
7194
7232
|
}
|
|
7195
7233
|
|
|
7196
7234
|
toggleCameraOn(session ) {
|
|
7197
|
-
logger$
|
|
7235
|
+
logger$4.info('sdk webrtc toggle camera on', { id: session.id });
|
|
7198
7236
|
|
|
7199
7237
|
this._toggleVideo(session, false);
|
|
7200
7238
|
}
|
|
7201
7239
|
|
|
7202
7240
|
toggleCameraOff(session ) {
|
|
7203
|
-
logger$
|
|
7241
|
+
logger$4.info('sdk webrtc toggle camera off', { id: session.id });
|
|
7204
7242
|
|
|
7205
7243
|
this._toggleVideo(session, true);
|
|
7206
7244
|
}
|
|
@@ -7209,7 +7247,7 @@ class WebRTCClient extends Emitter {
|
|
|
7209
7247
|
const sessionId = this.getSipSessionId(session);
|
|
7210
7248
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
7211
7249
|
|
|
7212
|
-
logger$
|
|
7250
|
+
logger$4.info('sdk webrtc hold', {
|
|
7213
7251
|
sessionId,
|
|
7214
7252
|
keys: Object.keys(this.heldSessions),
|
|
7215
7253
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7258,7 +7296,7 @@ class WebRTCClient extends Emitter {
|
|
|
7258
7296
|
const sessionId = this.getSipSessionId(session);
|
|
7259
7297
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
7260
7298
|
|
|
7261
|
-
logger$
|
|
7299
|
+
logger$4.info('sdk webrtc unhold', {
|
|
7262
7300
|
sessionId,
|
|
7263
7301
|
keys: Object.keys(this.heldSessions),
|
|
7264
7302
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7406,7 +7444,7 @@ class WebRTCClient extends Emitter {
|
|
|
7406
7444
|
if (!session.sessionDescriptionHandler) {
|
|
7407
7445
|
return;
|
|
7408
7446
|
}
|
|
7409
|
-
logger$
|
|
7447
|
+
logger$4.info('Sending DTMF', {
|
|
7410
7448
|
id: this.getSipSessionId(session),
|
|
7411
7449
|
tone,
|
|
7412
7450
|
});
|
|
@@ -7422,7 +7460,7 @@ class WebRTCClient extends Emitter {
|
|
|
7422
7460
|
transfer(session , target ) {
|
|
7423
7461
|
this.hold(session);
|
|
7424
7462
|
|
|
7425
|
-
logger$
|
|
7463
|
+
logger$4.info('Transfering a session', {
|
|
7426
7464
|
id: this.getSipSessionId(session),
|
|
7427
7465
|
target,
|
|
7428
7466
|
});
|
|
@@ -7444,17 +7482,17 @@ class WebRTCClient extends Emitter {
|
|
|
7444
7482
|
atxfer(session ) {
|
|
7445
7483
|
this.hold(session);
|
|
7446
7484
|
|
|
7447
|
-
logger$
|
|
7485
|
+
logger$4.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
7448
7486
|
|
|
7449
7487
|
const result = {
|
|
7450
7488
|
newSession: null,
|
|
7451
7489
|
init: async (target ) => {
|
|
7452
|
-
logger$
|
|
7490
|
+
logger$4.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
7453
7491
|
|
|
7454
7492
|
result.newSession = await this.call(target);
|
|
7455
7493
|
},
|
|
7456
7494
|
complete: () => {
|
|
7457
|
-
logger$
|
|
7495
|
+
logger$4.info('webrtc transfer completed', {
|
|
7458
7496
|
id: this.getSipSessionId(session),
|
|
7459
7497
|
referId: this.getSipSessionId(result.newSession),
|
|
7460
7498
|
});
|
|
@@ -7475,7 +7513,7 @@ class WebRTCClient extends Emitter {
|
|
|
7475
7513
|
return;
|
|
7476
7514
|
}
|
|
7477
7515
|
|
|
7478
|
-
logger$
|
|
7516
|
+
logger$4.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
7479
7517
|
|
|
7480
7518
|
try {
|
|
7481
7519
|
sipSession.message({
|
|
@@ -7517,7 +7555,7 @@ class WebRTCClient extends Emitter {
|
|
|
7517
7555
|
}
|
|
7518
7556
|
|
|
7519
7557
|
changeAudioOutputVolume(volume ) {
|
|
7520
|
-
logger$
|
|
7558
|
+
logger$4.info('Changing audio output volume', { volume });
|
|
7521
7559
|
|
|
7522
7560
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7523
7561
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -7529,7 +7567,7 @@ class WebRTCClient extends Emitter {
|
|
|
7529
7567
|
}
|
|
7530
7568
|
|
|
7531
7569
|
changeAudioOutputDevice(id ) {
|
|
7532
|
-
logger$
|
|
7570
|
+
logger$4.info('Changing audio output device', { id });
|
|
7533
7571
|
|
|
7534
7572
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7535
7573
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -7546,7 +7584,7 @@ class WebRTCClient extends Emitter {
|
|
|
7546
7584
|
|
|
7547
7585
|
changeAudioInputDevice(id , session ) {
|
|
7548
7586
|
const currentId = this.getAudioDeviceId();
|
|
7549
|
-
logger$
|
|
7587
|
+
logger$4.info('setting audio input device', { id, currentId, session: !!session });
|
|
7550
7588
|
|
|
7551
7589
|
if (id === currentId) {
|
|
7552
7590
|
return null;
|
|
@@ -7592,7 +7630,7 @@ class WebRTCClient extends Emitter {
|
|
|
7592
7630
|
|
|
7593
7631
|
setVideoInputDevice(id ) {
|
|
7594
7632
|
const currentId = this.getVideoDeviceId();
|
|
7595
|
-
logger$
|
|
7633
|
+
logger$4.info('setting video input device', { id, currentId });
|
|
7596
7634
|
|
|
7597
7635
|
if (id === currentId) {
|
|
7598
7636
|
return null;
|
|
@@ -7617,7 +7655,7 @@ class WebRTCClient extends Emitter {
|
|
|
7617
7655
|
const sessionId = this.getSipSessionId(session);
|
|
7618
7656
|
const localStream = this.getLocalStream(sessionId);
|
|
7619
7657
|
|
|
7620
|
-
logger$
|
|
7658
|
+
logger$4.info('changing video input device', { id, sessionId });
|
|
7621
7659
|
|
|
7622
7660
|
// Release old video stream
|
|
7623
7661
|
if (localStream) {
|
|
@@ -7685,7 +7723,7 @@ class WebRTCClient extends Emitter {
|
|
|
7685
7723
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
7686
7724
|
const desktop = newConstraints && newConstraints.desktop;
|
|
7687
7725
|
|
|
7688
|
-
logger$
|
|
7726
|
+
logger$4.info('Sending reinvite', {
|
|
7689
7727
|
id: this.getSipSessionId(sipSession),
|
|
7690
7728
|
newConstraints,
|
|
7691
7729
|
conference,
|
|
@@ -7723,7 +7761,7 @@ class WebRTCClient extends Emitter {
|
|
|
7723
7761
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
7724
7762
|
}
|
|
7725
7763
|
|
|
7726
|
-
logger$
|
|
7764
|
+
logger$4.info('on re-INVITE accepted', {
|
|
7727
7765
|
id: this.getSipSessionId(sipSession),
|
|
7728
7766
|
wasMuted,
|
|
7729
7767
|
shouldDoScreenSharing,
|
|
@@ -7741,7 +7779,7 @@ class WebRTCClient extends Emitter {
|
|
|
7741
7779
|
this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
|
|
7742
7780
|
}
|
|
7743
7781
|
|
|
7744
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
7782
|
+
return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
|
|
7745
7783
|
},
|
|
7746
7784
|
},
|
|
7747
7785
|
sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
|
|
@@ -7842,6 +7880,16 @@ class WebRTCClient extends Emitter {
|
|
|
7842
7880
|
return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
|
|
7843
7881
|
}
|
|
7844
7882
|
|
|
7883
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
7884
|
+
getRemoteVideoStreamFromPc(sessionId ) {
|
|
7885
|
+
const pc = this.getPeerConnection(sessionId);
|
|
7886
|
+
if (!pc) {
|
|
7887
|
+
return null;
|
|
7888
|
+
}
|
|
7889
|
+
|
|
7890
|
+
return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
|
|
7891
|
+
}
|
|
7892
|
+
|
|
7845
7893
|
hasVideo(sessionId ) {
|
|
7846
7894
|
return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
|
|
7847
7895
|
}
|
|
@@ -7888,7 +7936,7 @@ class WebRTCClient extends Emitter {
|
|
|
7888
7936
|
}
|
|
7889
7937
|
|
|
7890
7938
|
startHeartbeat() {
|
|
7891
|
-
logger$
|
|
7939
|
+
logger$4.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7892
7940
|
if (!this.userAgent) {
|
|
7893
7941
|
this.heartbeat.stop();
|
|
7894
7942
|
return;
|
|
@@ -7901,7 +7949,7 @@ class WebRTCClient extends Emitter {
|
|
|
7901
7949
|
}
|
|
7902
7950
|
|
|
7903
7951
|
stopHeartbeat() {
|
|
7904
|
-
logger$
|
|
7952
|
+
logger$4.info('sdk webrtc stop heartbeat');
|
|
7905
7953
|
this.heartbeat.stop();
|
|
7906
7954
|
}
|
|
7907
7955
|
|
|
@@ -7922,7 +7970,7 @@ class WebRTCClient extends Emitter {
|
|
|
7922
7970
|
}
|
|
7923
7971
|
|
|
7924
7972
|
attemptReconnection() {
|
|
7925
|
-
logger$
|
|
7973
|
+
logger$4.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7926
7974
|
if (!this.userAgent) {
|
|
7927
7975
|
return;
|
|
7928
7976
|
}
|
|
@@ -7947,7 +7995,7 @@ class WebRTCClient extends Emitter {
|
|
|
7947
7995
|
return;
|
|
7948
7996
|
}
|
|
7949
7997
|
|
|
7950
|
-
logger$
|
|
7998
|
+
logger$4.info('setting local media stream', {
|
|
7951
7999
|
sipSessionId,
|
|
7952
8000
|
tracks: newStream ? newStream.getTracks() : null,
|
|
7953
8001
|
});
|
|
@@ -7964,7 +8012,7 @@ class WebRTCClient extends Emitter {
|
|
|
7964
8012
|
|
|
7965
8013
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
7966
8014
|
|
|
7967
|
-
logger$
|
|
8015
|
+
logger$4.info('updating local stream', {
|
|
7968
8016
|
sipSessionId,
|
|
7969
8017
|
oldStream: !!oldStream,
|
|
7970
8018
|
tracks: newStream.getTracks(),
|
|
@@ -7984,7 +8032,7 @@ class WebRTCClient extends Emitter {
|
|
|
7984
8032
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
7985
8033
|
const pc = this.getPeerConnection(sessionId);
|
|
7986
8034
|
|
|
7987
|
-
logger$
|
|
8035
|
+
logger$4.info('Updating remote stream', {
|
|
7988
8036
|
sessionId,
|
|
7989
8037
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
7990
8038
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -8010,7 +8058,7 @@ class WebRTCClient extends Emitter {
|
|
|
8010
8058
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
8011
8059
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
8012
8060
|
|
|
8013
|
-
logger$
|
|
8061
|
+
logger$4.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
8014
8062
|
|
|
8015
8063
|
return {
|
|
8016
8064
|
constraints: {
|
|
@@ -8059,7 +8107,7 @@ class WebRTCClient extends Emitter {
|
|
|
8059
8107
|
}
|
|
8060
8108
|
|
|
8061
8109
|
_onTransportError() {
|
|
8062
|
-
logger$
|
|
8110
|
+
logger$4.error('on transport error');
|
|
8063
8111
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
8064
8112
|
this.attemptReconnection();
|
|
8065
8113
|
}
|
|
@@ -8068,7 +8116,7 @@ class WebRTCClient extends Emitter {
|
|
|
8068
8116
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
8069
8117
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
8070
8118
|
if (this.hasHeartbeat()) {
|
|
8071
|
-
logger$
|
|
8119
|
+
logger$4.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
8072
8120
|
|
|
8073
8121
|
this.heartbeat.onHeartbeat();
|
|
8074
8122
|
if (this.heartbeatCb) {
|
|
@@ -8079,7 +8127,7 @@ class WebRTCClient extends Emitter {
|
|
|
8079
8127
|
}
|
|
8080
8128
|
|
|
8081
8129
|
async _onHeartbeatTimeout() {
|
|
8082
|
-
logger$
|
|
8130
|
+
logger$4.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
8083
8131
|
|
|
8084
8132
|
if (this.heartbeatTimeoutCb) {
|
|
8085
8133
|
this.heartbeatTimeoutCb();
|
|
@@ -8091,7 +8139,7 @@ class WebRTCClient extends Emitter {
|
|
|
8091
8139
|
try {
|
|
8092
8140
|
await this.userAgent.transport.disconnect();
|
|
8093
8141
|
} catch (e) {
|
|
8094
|
-
logger$
|
|
8142
|
+
logger$4.error('Transport disconnection after heartbeat timeout, error', e);
|
|
8095
8143
|
}
|
|
8096
8144
|
}
|
|
8097
8145
|
|
|
@@ -8124,31 +8172,31 @@ class WebRTCClient extends Emitter {
|
|
|
8124
8172
|
}
|
|
8125
8173
|
|
|
8126
8174
|
_connectIfNeeded() {
|
|
8127
|
-
logger$
|
|
8175
|
+
logger$4.info('connect if needed, checking', { connected: this.isConnected() });
|
|
8128
8176
|
if (!this.userAgent) {
|
|
8129
|
-
logger$
|
|
8177
|
+
logger$4.info('need to recreate User Agent');
|
|
8130
8178
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
8131
8179
|
}
|
|
8132
8180
|
|
|
8133
8181
|
if (this.isConnected()) {
|
|
8134
|
-
logger$
|
|
8182
|
+
logger$4.info('webrtc sdk, already connected');
|
|
8135
8183
|
return Promise.resolve();
|
|
8136
8184
|
}
|
|
8137
8185
|
|
|
8138
8186
|
if (this.isConnecting()) {
|
|
8139
|
-
logger$
|
|
8187
|
+
logger$4.info('webrtc sdk, already connecting...');
|
|
8140
8188
|
|
|
8141
8189
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
8142
8190
|
return this.connectionPromise;
|
|
8143
8191
|
}
|
|
8144
8192
|
|
|
8145
8193
|
if (this.connectionPromise) {
|
|
8146
|
-
logger$
|
|
8194
|
+
logger$4.info('webrtc sdk, connection promise connecting...');
|
|
8147
8195
|
// $FlowFixMe
|
|
8148
8196
|
return this.connectionPromise;
|
|
8149
8197
|
}
|
|
8150
8198
|
|
|
8151
|
-
logger$
|
|
8199
|
+
logger$4.info('WebRTC UA needs to connect');
|
|
8152
8200
|
|
|
8153
8201
|
// Force UA to reconnect
|
|
8154
8202
|
if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
|
|
@@ -8273,7 +8321,7 @@ class WebRTCClient extends Emitter {
|
|
|
8273
8321
|
|
|
8274
8322
|
sdh.peerConnectionDelegate = {
|
|
8275
8323
|
onicecandidateerror: (error ) => {
|
|
8276
|
-
logger$
|
|
8324
|
+
logger$4.error('on icecandidate error', {
|
|
8277
8325
|
address: error.address,
|
|
8278
8326
|
port: error.port,
|
|
8279
8327
|
errorCode: error.errorCode,
|
|
@@ -8302,7 +8350,7 @@ class WebRTCClient extends Emitter {
|
|
|
8302
8350
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
8303
8351
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
8304
8352
|
}
|
|
8305
|
-
logger$
|
|
8353
|
+
logger$4.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
8306
8354
|
|
|
8307
8355
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
8308
8356
|
|
|
@@ -8318,12 +8366,12 @@ class WebRTCClient extends Emitter {
|
|
|
8318
8366
|
|
|
8319
8367
|
this._setupMedias(session);
|
|
8320
8368
|
|
|
8321
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
8369
|
+
return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
|
|
8322
8370
|
};
|
|
8323
8371
|
}
|
|
8324
8372
|
|
|
8325
8373
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
8326
|
-
logger$
|
|
8374
|
+
logger$4.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
8327
8375
|
|
|
8328
8376
|
this.storeSipSession(session);
|
|
8329
8377
|
|
|
@@ -8335,14 +8383,14 @@ class WebRTCClient extends Emitter {
|
|
|
8335
8383
|
const onTrack = (event ) => {
|
|
8336
8384
|
const isAudioOnly = this._isAudioOnly(session);
|
|
8337
8385
|
const { kind, label, readyState, id, muted } = event.track;
|
|
8338
|
-
logger$
|
|
8386
|
+
logger$4.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
8339
8387
|
|
|
8340
8388
|
// Stop video track in audio only mode
|
|
8341
8389
|
if (isAudioOnly && kind === 'video') {
|
|
8342
8390
|
event.track.stop();
|
|
8343
8391
|
}
|
|
8344
8392
|
|
|
8345
|
-
this.eventEmitter.emit(ON_TRACK
|
|
8393
|
+
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
8346
8394
|
};
|
|
8347
8395
|
|
|
8348
8396
|
if (session.sessionDescriptionHandler.peerConnection) {
|
|
@@ -8352,8 +8400,9 @@ class WebRTCClient extends Emitter {
|
|
|
8352
8400
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
8353
8401
|
|
|
8354
8402
|
pc.oniceconnectionstatechange = () => {
|
|
8403
|
+
logger$4.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
8355
8404
|
if (pc.iceConnectionState === 'disconnected') {
|
|
8356
|
-
this.eventEmitter.emit(ON_DISCONNECTED
|
|
8405
|
+
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
8357
8406
|
}
|
|
8358
8407
|
};
|
|
8359
8408
|
|
|
@@ -8524,10 +8573,10 @@ class WebRTCClient extends Emitter {
|
|
|
8524
8573
|
|
|
8525
8574
|
_stopSendingStats(session ) {
|
|
8526
8575
|
const sessionId = this.getSipSessionId(session);
|
|
8527
|
-
logger$
|
|
8576
|
+
logger$4.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
8528
8577
|
|
|
8529
8578
|
if (sessionId in this.statsIntervals) {
|
|
8530
|
-
logger$
|
|
8579
|
+
logger$4.trace('Stop sending stats for call', { sessionId });
|
|
8531
8580
|
this.statsIntervals[sessionId]();
|
|
8532
8581
|
delete this.statsIntervals[sessionId];
|
|
8533
8582
|
}
|
|
@@ -8543,7 +8592,7 @@ class WebRTCClient extends Emitter {
|
|
|
8543
8592
|
try {
|
|
8544
8593
|
await this.userAgent.transport.disconnect();
|
|
8545
8594
|
} catch (e) {
|
|
8546
|
-
logger$
|
|
8595
|
+
logger$4.error('WebRTC transport disconnect, error', e);
|
|
8547
8596
|
}
|
|
8548
8597
|
}
|
|
8549
8598
|
}
|
|
@@ -8580,25 +8629,25 @@ class WebRTCClient extends Emitter {
|
|
|
8580
8629
|
|
|
8581
8630
|
stats.forEach(report => {
|
|
8582
8631
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
8583
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8632
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8584
8633
|
}
|
|
8585
8634
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
8586
|
-
audioBytesSent += report.bytesSent;
|
|
8635
|
+
audioBytesSent += Number(report.bytesSent);
|
|
8587
8636
|
}
|
|
8588
8637
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8589
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8638
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8590
8639
|
}
|
|
8591
8640
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
8592
|
-
packetsLost += report.packetsLost;
|
|
8593
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
8594
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8641
|
+
packetsLost += Number(report.packetsLost);
|
|
8642
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
8643
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8595
8644
|
}
|
|
8596
8645
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
8597
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8646
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8598
8647
|
}
|
|
8599
8648
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8600
8649
|
if ('framesPerSecond' in report) {
|
|
8601
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
8650
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
8602
8651
|
}
|
|
8603
8652
|
if ('framerateMean' in report) {
|
|
8604
8653
|
// framerateMean is only available in FF
|
|
@@ -8606,34 +8655,38 @@ class WebRTCClient extends Emitter {
|
|
|
8606
8655
|
}
|
|
8607
8656
|
}
|
|
8608
8657
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
8609
|
-
packetsLost += report.packetsLost;
|
|
8610
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
8611
|
-
networkStats.jitter = report.jitter;
|
|
8658
|
+
packetsLost += Number(report.packetsLost);
|
|
8659
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
8660
|
+
networkStats.jitter = Number(report.jitter);
|
|
8612
8661
|
}
|
|
8613
8662
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
8614
|
-
packetsLost += report.packetsLost;
|
|
8663
|
+
packetsLost += Number(report.packetsLost);
|
|
8615
8664
|
}
|
|
8616
8665
|
if (report.type === 'transport') {
|
|
8617
|
-
transportSent += report.bytesSent;
|
|
8618
|
-
transportReceived += report.bytesReceived;
|
|
8666
|
+
transportSent += Number(report.bytesSent);
|
|
8667
|
+
transportReceived += Number(report.bytesReceived);
|
|
8619
8668
|
}
|
|
8620
8669
|
});
|
|
8621
8670
|
|
|
8622
8671
|
networkStats.packetsLost = packetsLost;
|
|
8623
|
-
networkStats.
|
|
8672
|
+
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
8673
|
+
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
8674
|
+
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
8624
8675
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
8625
|
-
networkStats.
|
|
8626
|
-
networkStats.
|
|
8676
|
+
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
8677
|
+
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
8678
|
+
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
8679
|
+
networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
|
|
8680
|
+
networkStats.totalTransportSent = transportSent - lastTransportSent;
|
|
8627
8681
|
networkStats.transportSent = transportSent;
|
|
8628
|
-
networkStats.
|
|
8629
|
-
|
|
8630
|
-
const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
|
|
8631
|
-
+ (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
|
|
8632
|
-
+ (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
|
|
8682
|
+
networkStats.totalTransportReceived = transportReceived;
|
|
8683
|
+
networkStats.transportReceived = transportReceived - lastTransportReceived;
|
|
8633
8684
|
|
|
8634
|
-
networkStats.bandwidth =
|
|
8685
|
+
networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
|
|
8686
|
+
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
8687
|
+
+ networkStats.transportSent;
|
|
8635
8688
|
|
|
8636
|
-
this.eventEmitter.emit(ON_NETWORK_STATS
|
|
8689
|
+
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
8637
8690
|
this.sessionNetworkStats[sessionId].push(networkStats);
|
|
8638
8691
|
}
|
|
8639
8692
|
|
|
@@ -8661,8 +8714,8 @@ const ON_CALL_FAILED = 'onCallFailed';
|
|
|
8661
8714
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
8662
8715
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
8663
8716
|
const ON_MESSAGE = 'onMessage';
|
|
8664
|
-
const ON_REINVITE = 'reinvite';
|
|
8665
|
-
const ON_TRACK = 'onTrack';
|
|
8717
|
+
const ON_REINVITE$1 = 'reinvite';
|
|
8718
|
+
const ON_TRACK$1 = 'onTrack';
|
|
8666
8719
|
const ON_AUDIO_STREAM = 'onAudioStream';
|
|
8667
8720
|
const ON_VIDEO_STREAM = 'onVideoStream';
|
|
8668
8721
|
const ON_REMOVE_STREAM = 'onRemoveStream';
|
|
@@ -8677,15 +8730,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
|
|
|
8677
8730
|
const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
|
|
8678
8731
|
const ON_CALL_ERROR = 'onCallError';
|
|
8679
8732
|
const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
|
|
8680
|
-
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
8733
|
+
const ON_NETWORK_STATS$1 = 'onNetworkStats';
|
|
8681
8734
|
const ON_CHAT = 'phone/ON_CHAT';
|
|
8682
8735
|
const ON_SIGNAL = 'phone/ON_SIGNAL';
|
|
8683
|
-
const ON_DISCONNECTED = 'onDisconnected';
|
|
8736
|
+
const ON_DISCONNECTED$1 = 'onDisconnected';
|
|
8684
8737
|
|
|
8685
8738
|
const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
8686
8739
|
const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
8687
8740
|
|
|
8688
|
-
const events = [
|
|
8741
|
+
const events$1 = [
|
|
8689
8742
|
ON_USER_AGENT,
|
|
8690
8743
|
ON_REGISTERED,
|
|
8691
8744
|
ON_UNREGISTERED,
|
|
@@ -8703,8 +8756,8 @@ const events = [
|
|
|
8703
8756
|
ON_CALL_FAILED,
|
|
8704
8757
|
ON_CALL_ENDED,
|
|
8705
8758
|
ON_MESSAGE,
|
|
8706
|
-
ON_REINVITE,
|
|
8707
|
-
ON_TRACK,
|
|
8759
|
+
ON_REINVITE$1,
|
|
8760
|
+
ON_TRACK$1,
|
|
8708
8761
|
ON_AUDIO_STREAM,
|
|
8709
8762
|
ON_VIDEO_STREAM,
|
|
8710
8763
|
ON_REMOVE_STREAM,
|
|
@@ -8719,11 +8772,11 @@ const events = [
|
|
|
8719
8772
|
ON_CALL_ERROR,
|
|
8720
8773
|
ON_CHAT,
|
|
8721
8774
|
ON_SIGNAL,
|
|
8722
|
-
ON_NETWORK_STATS,
|
|
8723
|
-
ON_DISCONNECTED,
|
|
8775
|
+
ON_NETWORK_STATS$1,
|
|
8776
|
+
ON_DISCONNECTED$1,
|
|
8724
8777
|
];
|
|
8725
8778
|
|
|
8726
|
-
const logger$
|
|
8779
|
+
const logger$5 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
8727
8780
|
|
|
8728
8781
|
class WebRTCPhone extends Emitter {
|
|
8729
8782
|
|
|
@@ -8796,7 +8849,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8796
8849
|
}).catch(error => {
|
|
8797
8850
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
8798
8851
|
console.error('register error', error, error.message, error.stack);
|
|
8799
|
-
logger$
|
|
8852
|
+
logger$5.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
8800
8853
|
});
|
|
8801
8854
|
}
|
|
8802
8855
|
|
|
@@ -8811,7 +8864,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8811
8864
|
if (!this.client) {
|
|
8812
8865
|
return;
|
|
8813
8866
|
}
|
|
8814
|
-
logger$
|
|
8867
|
+
logger$5.info('WebRTC phone stop');
|
|
8815
8868
|
this.client.stop();
|
|
8816
8869
|
}
|
|
8817
8870
|
|
|
@@ -8826,7 +8879,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8826
8879
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
8827
8880
|
audioOnly = false, iceRestart = false) {
|
|
8828
8881
|
const sipSession = this.findSipSession(callSession);
|
|
8829
|
-
logger$
|
|
8882
|
+
logger$5.info('WebRTC phone - send reinvite', {
|
|
8830
8883
|
sessionId: sipSession ? sipSession.id : null,
|
|
8831
8884
|
constraints,
|
|
8832
8885
|
audioOnly,
|
|
@@ -8863,7 +8916,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8863
8916
|
}
|
|
8864
8917
|
|
|
8865
8918
|
startHeartbeat() {
|
|
8866
|
-
logger$
|
|
8919
|
+
logger$5.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
8867
8920
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
8868
8921
|
return;
|
|
8869
8922
|
}
|
|
@@ -8872,7 +8925,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8872
8925
|
}
|
|
8873
8926
|
|
|
8874
8927
|
stopHeartbeat() {
|
|
8875
|
-
logger$
|
|
8928
|
+
logger$5.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
8876
8929
|
if (!this.client) {
|
|
8877
8930
|
return;
|
|
8878
8931
|
}
|
|
@@ -8889,7 +8942,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8889
8942
|
}
|
|
8890
8943
|
|
|
8891
8944
|
reconnect() {
|
|
8892
|
-
logger$
|
|
8945
|
+
logger$5.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
8893
8946
|
if (!this.client) {
|
|
8894
8947
|
return;
|
|
8895
8948
|
}
|
|
@@ -8930,10 +8983,15 @@ class WebRTCPhone extends Emitter {
|
|
|
8930
8983
|
return false;
|
|
8931
8984
|
}
|
|
8932
8985
|
|
|
8933
|
-
logger$
|
|
8986
|
+
logger$5.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
8934
8987
|
|
|
8935
8988
|
this.client.downgradeToAudio(sipSession);
|
|
8936
8989
|
|
|
8990
|
+
if (callSession) {
|
|
8991
|
+
callSession.cameraEnabled = false;
|
|
8992
|
+
this._updateCallSession(callSession);
|
|
8993
|
+
}
|
|
8994
|
+
|
|
8937
8995
|
if (withMessage) {
|
|
8938
8996
|
this._sendReinviteMessage(callSession, false);
|
|
8939
8997
|
}
|
|
@@ -8948,7 +9006,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8948
9006
|
return Promise.resolve(false);
|
|
8949
9007
|
}
|
|
8950
9008
|
|
|
8951
|
-
logger$
|
|
9009
|
+
logger$5.info('Upgrade to video', {
|
|
8952
9010
|
id: callSession ? callSession.getId() : null,
|
|
8953
9011
|
constraints,
|
|
8954
9012
|
isConference,
|
|
@@ -8961,6 +9019,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8961
9019
|
|
|
8962
9020
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
8963
9021
|
|
|
9022
|
+
if (callSession) {
|
|
9023
|
+
callSession.cameraEnabled = true;
|
|
9024
|
+
this._updateCallSession(callSession);
|
|
9025
|
+
}
|
|
9026
|
+
|
|
8964
9027
|
// If no stream is returned, it means we have to reinvite
|
|
8965
9028
|
if (!newStream) {
|
|
8966
9029
|
return true;
|
|
@@ -8983,7 +9046,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8983
9046
|
|
|
8984
9047
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
8985
9048
|
const sipSession = this.findSipSession(callSession);
|
|
8986
|
-
logger$
|
|
9049
|
+
logger$5.info('Sending reinvite message', {
|
|
8987
9050
|
id: callSession ? callSession.getId() : null,
|
|
8988
9051
|
isUpgrade,
|
|
8989
9052
|
});
|
|
@@ -9009,11 +9072,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9009
9072
|
// Monkey patch to know when canceled with the CANCEL message
|
|
9010
9073
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
9011
9074
|
sipSession._onCancel = (message ) => {
|
|
9012
|
-
logger$
|
|
9075
|
+
logger$5.trace('on sip session canceled', { callId: message.callId });
|
|
9013
9076
|
|
|
9014
9077
|
onCancel(message);
|
|
9015
9078
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
9016
|
-
|
|
9079
|
+
const callSession = this._createCallSession(sipSession);
|
|
9080
|
+
delete this.callSessions[callSession.getId()];
|
|
9081
|
+
|
|
9082
|
+
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
9017
9083
|
};
|
|
9018
9084
|
} else if (sipSession instanceof invitation.Invitation) {
|
|
9019
9085
|
console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
|
|
@@ -9034,17 +9100,19 @@ class WebRTCPhone extends Emitter {
|
|
|
9034
9100
|
this.audioOutputVolume,
|
|
9035
9101
|
);
|
|
9036
9102
|
case sessionState.SessionState.Terminating:
|
|
9037
|
-
logger$
|
|
9103
|
+
logger$5.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
9038
9104
|
|
|
9039
9105
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
9040
9106
|
|
|
9041
9107
|
break;
|
|
9042
9108
|
case sessionState.SessionState.Terminated: {
|
|
9043
|
-
logger$
|
|
9109
|
+
logger$5.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
9044
9110
|
|
|
9111
|
+
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
9112
|
+
const callSession = this._createCallSession(sipSession);
|
|
9045
9113
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
9046
9114
|
|
|
9047
|
-
return this.eventEmitter.emit(ON_CALL_ENDED,
|
|
9115
|
+
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
9048
9116
|
}
|
|
9049
9117
|
}
|
|
9050
9118
|
});
|
|
@@ -9060,7 +9128,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9060
9128
|
const [stream] = event.streams;
|
|
9061
9129
|
const kind = event && event.track && event.track.kind;
|
|
9062
9130
|
|
|
9063
|
-
logger$
|
|
9131
|
+
logger$5.info('on track stream called on the peer connection', {
|
|
9064
9132
|
callId: this.getSipSessionId(sipSession),
|
|
9065
9133
|
streamId: stream ? stream.id : null,
|
|
9066
9134
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -9080,7 +9148,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9080
9148
|
};
|
|
9081
9149
|
|
|
9082
9150
|
peerConnection.onremovestream = event => {
|
|
9083
|
-
logger$
|
|
9151
|
+
logger$5.info('on remove stream called on the peer connection', {
|
|
9084
9152
|
id: event.stream.id,
|
|
9085
9153
|
tracks: event.stream.getTracks(),
|
|
9086
9154
|
});
|
|
@@ -9090,7 +9158,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9090
9158
|
}
|
|
9091
9159
|
|
|
9092
9160
|
async startScreenSharing(constraints , callSession ) {
|
|
9093
|
-
logger$
|
|
9161
|
+
logger$5.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
9094
9162
|
|
|
9095
9163
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
9096
9164
|
if (!screenShareStream) {
|
|
@@ -9130,7 +9198,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9130
9198
|
return;
|
|
9131
9199
|
}
|
|
9132
9200
|
|
|
9133
|
-
logger$
|
|
9201
|
+
logger$5.info('WebRTC phone - stop screen sharing', {
|
|
9134
9202
|
restoreLocalStream,
|
|
9135
9203
|
});
|
|
9136
9204
|
|
|
@@ -9186,24 +9254,26 @@ class WebRTCPhone extends Emitter {
|
|
|
9186
9254
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
9187
9255
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
9188
9256
|
|
|
9189
|
-
logger$
|
|
9257
|
+
logger$5.info('WebRTC phone - on screensharing', {
|
|
9190
9258
|
hadVideo,
|
|
9191
9259
|
id: this.getSipSessionId(sipSession),
|
|
9192
9260
|
screenTrack,
|
|
9193
9261
|
});
|
|
9194
9262
|
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9263
|
+
if (screenTrack) {
|
|
9264
|
+
screenTrack.onended = () => {
|
|
9265
|
+
logger$5.info('WebRTC phone - on screenshare ended', {
|
|
9266
|
+
hadVideo,
|
|
9267
|
+
id: this.getSipSessionId(sipSession),
|
|
9268
|
+
screenTrack,
|
|
9269
|
+
});
|
|
9201
9270
|
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9271
|
+
this.eventEmitter.emit(
|
|
9272
|
+
ON_SHARE_SCREEN_ENDING,
|
|
9273
|
+
this._createCallSession(sipSession, callSession),
|
|
9274
|
+
);
|
|
9275
|
+
};
|
|
9276
|
+
}
|
|
9207
9277
|
|
|
9208
9278
|
this.currentScreenShare = {
|
|
9209
9279
|
stream: screenStream,
|
|
@@ -9223,7 +9293,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9223
9293
|
}
|
|
9224
9294
|
|
|
9225
9295
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
9226
|
-
logger$
|
|
9296
|
+
logger$5.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
9227
9297
|
|
|
9228
9298
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
9229
9299
|
this.currentSipSession = sipSession;
|
|
@@ -9241,7 +9311,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9241
9311
|
}
|
|
9242
9312
|
|
|
9243
9313
|
changeAudioDevice(id ) {
|
|
9244
|
-
logger$
|
|
9314
|
+
logger$5.info('WebRTC phone - change audio device', { deviceId: id });
|
|
9245
9315
|
this.audioOutputDeviceId = id;
|
|
9246
9316
|
this.client.changeAudioOutputDevice(id);
|
|
9247
9317
|
}
|
|
@@ -9251,14 +9321,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9251
9321
|
}
|
|
9252
9322
|
|
|
9253
9323
|
changeRingDevice(id ) {
|
|
9254
|
-
logger$
|
|
9324
|
+
logger$5.info('WebRTC phone - changing ring device', { id });
|
|
9255
9325
|
|
|
9256
9326
|
this.audioRingDeviceId = id;
|
|
9257
9327
|
}
|
|
9258
9328
|
|
|
9259
9329
|
// volume is a value between 0 and 1
|
|
9260
9330
|
changeAudioVolume(volume ) {
|
|
9261
|
-
logger$
|
|
9331
|
+
logger$5.info('WebRTC phone - changing audio volume', { volume });
|
|
9262
9332
|
|
|
9263
9333
|
this.audioOutputVolume = volume;
|
|
9264
9334
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -9266,31 +9336,31 @@ class WebRTCPhone extends Emitter {
|
|
|
9266
9336
|
|
|
9267
9337
|
// volume is a value between 0 and 1
|
|
9268
9338
|
changeRingVolume(volume ) {
|
|
9269
|
-
logger$
|
|
9339
|
+
logger$5.info('WebRTC phone - changing ring volume', { volume });
|
|
9270
9340
|
|
|
9271
9341
|
this.audioRingVolume = volume;
|
|
9272
9342
|
}
|
|
9273
9343
|
|
|
9274
9344
|
changeAudioInputDevice(id ) {
|
|
9275
|
-
logger$
|
|
9345
|
+
logger$5.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
9276
9346
|
|
|
9277
9347
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
9278
9348
|
}
|
|
9279
9349
|
|
|
9280
9350
|
changeVideoInputDevice(id ) {
|
|
9281
|
-
logger$
|
|
9351
|
+
logger$5.info('WebRTC phone - change video input device', { deviceId: id });
|
|
9282
9352
|
|
|
9283
9353
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
9284
9354
|
}
|
|
9285
9355
|
|
|
9286
9356
|
changeSessionVideoInputDevice(id ) {
|
|
9287
|
-
logger$
|
|
9357
|
+
logger$5.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
9288
9358
|
|
|
9289
9359
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
9290
9360
|
}
|
|
9291
9361
|
|
|
9292
9362
|
_onCallTerminated(sipSession ) {
|
|
9293
|
-
logger$
|
|
9363
|
+
logger$5.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9294
9364
|
|
|
9295
9365
|
const callSession = this._createCallSession(sipSession);
|
|
9296
9366
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -9324,7 +9394,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9324
9394
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
9325
9395
|
|
|
9326
9396
|
// Re-trigger incoming call event for remaining incoming calls
|
|
9327
|
-
logger$
|
|
9397
|
+
logger$5.info('WebRTC phone - check to re-trigger incoming call', {
|
|
9328
9398
|
sipId: sipSession.id,
|
|
9329
9399
|
shouldRetrigger,
|
|
9330
9400
|
hasIncomingCallSession,
|
|
@@ -9415,37 +9485,37 @@ class WebRTCPhone extends Emitter {
|
|
|
9415
9485
|
|
|
9416
9486
|
// Deprecated
|
|
9417
9487
|
getLocalStreamForCall(callSession ) {
|
|
9418
|
-
logger$
|
|
9488
|
+
logger$5.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9419
9489
|
|
|
9420
9490
|
return this.getLocalStream(callSession);
|
|
9421
9491
|
}
|
|
9422
9492
|
|
|
9423
9493
|
// Deprecated
|
|
9424
9494
|
getRemoteStreamForCall(callSession ) {
|
|
9425
|
-
logger$
|
|
9495
|
+
logger$5.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
9426
9496
|
|
|
9427
9497
|
return this.getRemoteVideoStream(callSession);
|
|
9428
9498
|
}
|
|
9429
9499
|
|
|
9430
9500
|
getRemoteStreamsForCall(callSession ) {
|
|
9431
|
-
logger$
|
|
9501
|
+
logger$5.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
9432
9502
|
|
|
9433
9503
|
return this.getRemoteStream(callSession);
|
|
9434
9504
|
}
|
|
9435
9505
|
|
|
9436
9506
|
accept(callSession , cameraEnabled ) {
|
|
9437
|
-
logger$
|
|
9507
|
+
logger$5.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
9438
9508
|
if (this.currentSipSession) {
|
|
9439
9509
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
9440
9510
|
}
|
|
9441
9511
|
|
|
9442
9512
|
if (!callSession) {
|
|
9443
|
-
logger$
|
|
9513
|
+
logger$5.warn('no CallSession to accept.');
|
|
9444
9514
|
return Promise.resolve(null);
|
|
9445
9515
|
}
|
|
9446
9516
|
|
|
9447
9517
|
if (callSession.getId() in this.acceptedSessions) {
|
|
9448
|
-
logger$
|
|
9518
|
+
logger$5.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9449
9519
|
return Promise.resolve(callSession.sipCallId);
|
|
9450
9520
|
}
|
|
9451
9521
|
|
|
@@ -9457,24 +9527,24 @@ class WebRTCPhone extends Emitter {
|
|
|
9457
9527
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
9458
9528
|
if (sipSession) {
|
|
9459
9529
|
if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
|
|
9460
|
-
logger$
|
|
9530
|
+
logger$5.warn('Trying to answer a terminated sipSession.');
|
|
9461
9531
|
|
|
9462
9532
|
return Promise.resolve(null);
|
|
9463
9533
|
}
|
|
9464
9534
|
|
|
9465
|
-
logger$
|
|
9535
|
+
logger$5.info('accept call, session found', { sipId: sipSession.id });
|
|
9466
9536
|
|
|
9467
9537
|
// $FlowFixMe
|
|
9468
9538
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
9469
9539
|
return callSession.sipCallId;
|
|
9470
9540
|
}).catch(e => {
|
|
9471
|
-
logger$
|
|
9541
|
+
logger$5.error(e);
|
|
9472
9542
|
this.endCurrentCall(callSession);
|
|
9473
9543
|
throw e;
|
|
9474
9544
|
});
|
|
9475
9545
|
}
|
|
9476
9546
|
|
|
9477
|
-
logger$
|
|
9547
|
+
logger$5.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9478
9548
|
|
|
9479
9549
|
return Promise.resolve(null);
|
|
9480
9550
|
}
|
|
@@ -9484,7 +9554,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9484
9554
|
}
|
|
9485
9555
|
|
|
9486
9556
|
async reject(callSession ) {
|
|
9487
|
-
logger$
|
|
9557
|
+
logger$5.info('reject WebRTC called', { id: callSession.getId() });
|
|
9488
9558
|
|
|
9489
9559
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
9490
9560
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -9496,14 +9566,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9496
9566
|
|
|
9497
9567
|
const sipSession = this.findSipSession(callSession);
|
|
9498
9568
|
if (sipSession) {
|
|
9499
|
-
logger$
|
|
9569
|
+
logger$5.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
9500
9570
|
|
|
9501
9571
|
this.client.hangup(sipSession);
|
|
9502
9572
|
}
|
|
9503
9573
|
}
|
|
9504
9574
|
|
|
9505
9575
|
async ignore(callSession ) {
|
|
9506
|
-
logger$
|
|
9576
|
+
logger$5.info('WebRTC ignore', { id: callSession.getId() });
|
|
9507
9577
|
|
|
9508
9578
|
// kill the ring
|
|
9509
9579
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -9515,14 +9585,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9515
9585
|
const sipSession = this.findSipSession(callSession);
|
|
9516
9586
|
|
|
9517
9587
|
if (sipSession) {
|
|
9518
|
-
logger$
|
|
9588
|
+
logger$5.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
9519
9589
|
|
|
9520
9590
|
return this.client.atxfer(sipSession);
|
|
9521
9591
|
}
|
|
9522
9592
|
}
|
|
9523
9593
|
|
|
9524
9594
|
hold(callSession , withEvent = true, isConference = false) {
|
|
9525
|
-
logger$
|
|
9595
|
+
logger$5.info('WebRTC hold', { id: callSession.getId() });
|
|
9526
9596
|
|
|
9527
9597
|
const sipSession = this.findSipSession(callSession);
|
|
9528
9598
|
|
|
@@ -9537,18 +9607,18 @@ class WebRTCPhone extends Emitter {
|
|
|
9537
9607
|
}
|
|
9538
9608
|
|
|
9539
9609
|
resume(callSession , isConference = false, withEvent = true) {
|
|
9540
|
-
logger$
|
|
9610
|
+
logger$5.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
9541
9611
|
|
|
9542
9612
|
const sipSession = this.findSipSession(callSession);
|
|
9543
9613
|
if (!sipSession) {
|
|
9544
9614
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
9545
9615
|
}
|
|
9546
9616
|
|
|
9547
|
-
logger$
|
|
9617
|
+
logger$5.info('WebRTC resuming', { sipId: sipSession.id });
|
|
9548
9618
|
|
|
9549
9619
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
9550
9620
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
9551
|
-
logger$
|
|
9621
|
+
logger$5.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
9552
9622
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
9553
9623
|
}
|
|
9554
9624
|
|
|
@@ -9573,7 +9643,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9573
9643
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9574
9644
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
9575
9645
|
|
|
9576
|
-
logger$
|
|
9646
|
+
logger$5.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9577
9647
|
|
|
9578
9648
|
// Stop screenshre if needed
|
|
9579
9649
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -9604,7 +9674,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9604
9674
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
9605
9675
|
}
|
|
9606
9676
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9607
|
-
logger$
|
|
9677
|
+
logger$5.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
9608
9678
|
|
|
9609
9679
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
9610
9680
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -9648,14 +9718,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9648
9718
|
}
|
|
9649
9719
|
|
|
9650
9720
|
mute(callSession , withEvent = true) {
|
|
9651
|
-
logger$
|
|
9721
|
+
logger$5.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
9652
9722
|
|
|
9653
9723
|
const sipSession = this.findSipSession(callSession);
|
|
9654
9724
|
if (!sipSession) {
|
|
9655
9725
|
return;
|
|
9656
9726
|
}
|
|
9657
9727
|
|
|
9658
|
-
logger$
|
|
9728
|
+
logger$5.info('WebRTC muting', { sipId: sipSession.id });
|
|
9659
9729
|
this.client.mute(sipSession);
|
|
9660
9730
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
9661
9731
|
|
|
@@ -9669,14 +9739,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9669
9739
|
}
|
|
9670
9740
|
|
|
9671
9741
|
unmute(callSession , withEvent = true) {
|
|
9672
|
-
logger$
|
|
9742
|
+
logger$5.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
9673
9743
|
|
|
9674
9744
|
const sipSession = this.findSipSession(callSession);
|
|
9675
9745
|
if (!sipSession) {
|
|
9676
9746
|
return;
|
|
9677
9747
|
}
|
|
9678
9748
|
|
|
9679
|
-
logger$
|
|
9749
|
+
logger$5.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
9680
9750
|
this.client.unmute(sipSession);
|
|
9681
9751
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
9682
9752
|
|
|
@@ -9703,7 +9773,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9703
9773
|
if (!sipSession) {
|
|
9704
9774
|
return;
|
|
9705
9775
|
}
|
|
9706
|
-
logger$
|
|
9776
|
+
logger$5.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
9707
9777
|
|
|
9708
9778
|
this.client.toggleCameraOn(sipSession);
|
|
9709
9779
|
|
|
@@ -9715,7 +9785,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9715
9785
|
if (!sipSession) {
|
|
9716
9786
|
return;
|
|
9717
9787
|
}
|
|
9718
|
-
logger$
|
|
9788
|
+
logger$5.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
9719
9789
|
|
|
9720
9790
|
this.client.toggleCameraOff(sipSession);
|
|
9721
9791
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -9727,7 +9797,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9727
9797
|
return;
|
|
9728
9798
|
}
|
|
9729
9799
|
|
|
9730
|
-
logger$
|
|
9800
|
+
logger$5.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
9731
9801
|
this.client.sendDTMF(sipSession, tone);
|
|
9732
9802
|
}
|
|
9733
9803
|
|
|
@@ -9735,7 +9805,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9735
9805
|
// @TODO: line is not used here
|
|
9736
9806
|
async makeCall(number , line , cameraEnabled ,
|
|
9737
9807
|
audioOnly = false, conference = false) {
|
|
9738
|
-
logger$
|
|
9808
|
+
logger$5.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
9739
9809
|
if (!number) {
|
|
9740
9810
|
return Promise.resolve(null);
|
|
9741
9811
|
}
|
|
@@ -9745,7 +9815,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9745
9815
|
}
|
|
9746
9816
|
if (this.currentSipSession) {
|
|
9747
9817
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
9748
|
-
logger$
|
|
9818
|
+
logger$5.warn('Unable to hold current session when making another call', e);
|
|
9749
9819
|
});
|
|
9750
9820
|
}
|
|
9751
9821
|
|
|
@@ -9755,7 +9825,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9755
9825
|
this._bindEvents(sipSession);
|
|
9756
9826
|
} catch (error) {
|
|
9757
9827
|
console.warn(error);
|
|
9758
|
-
logger$
|
|
9828
|
+
logger$5.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
9759
9829
|
return Promise.resolve(null);
|
|
9760
9830
|
}
|
|
9761
9831
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -9783,7 +9853,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9783
9853
|
return;
|
|
9784
9854
|
}
|
|
9785
9855
|
|
|
9786
|
-
logger$
|
|
9856
|
+
logger$5.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
9787
9857
|
|
|
9788
9858
|
this.client.transfer(sipSession, target);
|
|
9789
9859
|
}
|
|
@@ -9792,7 +9862,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9792
9862
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
9793
9863
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
9794
9864
|
|
|
9795
|
-
logger$
|
|
9865
|
+
logger$5.info('WebRTC indirect transfer', {
|
|
9796
9866
|
sipId: sipSession ? sipSession.id : null,
|
|
9797
9867
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
9798
9868
|
});
|
|
@@ -9831,7 +9901,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9831
9901
|
return false;
|
|
9832
9902
|
}
|
|
9833
9903
|
|
|
9834
|
-
logger$
|
|
9904
|
+
logger$5.info('WebRTC hangup', { sipId: sipSession.id });
|
|
9835
9905
|
|
|
9836
9906
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9837
9907
|
|
|
@@ -9877,7 +9947,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9877
9947
|
endCurrentCall(callSession ) {
|
|
9878
9948
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
9879
9949
|
|
|
9880
|
-
logger$
|
|
9950
|
+
logger$5.info('Ending current call', {
|
|
9881
9951
|
id: callSession ? callSession.getId() : null,
|
|
9882
9952
|
isCurrent,
|
|
9883
9953
|
});
|
|
@@ -9901,7 +9971,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9901
9971
|
}
|
|
9902
9972
|
|
|
9903
9973
|
async close() {
|
|
9904
|
-
logger$
|
|
9974
|
+
logger$5.info('WebRTC close');
|
|
9905
9975
|
|
|
9906
9976
|
try {
|
|
9907
9977
|
await Promise.race([
|
|
@@ -9909,7 +9979,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9909
9979
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
9910
9980
|
]);
|
|
9911
9981
|
} catch (e) {
|
|
9912
|
-
logger$
|
|
9982
|
+
logger$5.error('WebRTC close, unregister error', e);
|
|
9913
9983
|
}
|
|
9914
9984
|
|
|
9915
9985
|
this.client.close();
|
|
@@ -9927,12 +9997,12 @@ class WebRTCPhone extends Emitter {
|
|
|
9927
9997
|
}
|
|
9928
9998
|
|
|
9929
9999
|
enableRinging() {
|
|
9930
|
-
logger$
|
|
10000
|
+
logger$5.info('WebRTC enable ringing');
|
|
9931
10001
|
this.ringingEnabled = true;
|
|
9932
10002
|
}
|
|
9933
10003
|
|
|
9934
10004
|
disableRinging() {
|
|
9935
|
-
logger$
|
|
10005
|
+
logger$5.info('WebRTC disable ringing');
|
|
9936
10006
|
this.ringingEnabled = false;
|
|
9937
10007
|
}
|
|
9938
10008
|
|
|
@@ -9972,7 +10042,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9972
10042
|
|
|
9973
10043
|
// Deprecated
|
|
9974
10044
|
getLocalMediaStream(callSession ) {
|
|
9975
|
-
logger$
|
|
10045
|
+
logger$5.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9976
10046
|
return this.getLocalStream(callSession);
|
|
9977
10047
|
}
|
|
9978
10048
|
|
|
@@ -9992,6 +10062,10 @@ class WebRTCPhone extends Emitter {
|
|
|
9992
10062
|
return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
|
|
9993
10063
|
}
|
|
9994
10064
|
|
|
10065
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
10066
|
+
return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
|
|
10067
|
+
}
|
|
10068
|
+
|
|
9995
10069
|
hasRemoteVideo(callSession ) {
|
|
9996
10070
|
return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
|
|
9997
10071
|
}
|
|
@@ -10010,7 +10084,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10010
10084
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
10011
10085
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
10012
10086
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
10013
|
-
logger$
|
|
10087
|
+
logger$5.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
10014
10088
|
|
|
10015
10089
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
10016
10090
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -10033,7 +10107,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10033
10107
|
});
|
|
10034
10108
|
|
|
10035
10109
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
10036
|
-
logger$
|
|
10110
|
+
logger$5.info('WebRTC on reinvite', {
|
|
10037
10111
|
sessionId: args[0].id,
|
|
10038
10112
|
inviteId: args[1].id,
|
|
10039
10113
|
updatedCalleeName: args[2],
|
|
@@ -10053,7 +10127,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10053
10127
|
});
|
|
10054
10128
|
|
|
10055
10129
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
10056
|
-
logger$
|
|
10130
|
+
logger$5.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
10057
10131
|
|
|
10058
10132
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
10059
10133
|
|
|
@@ -10064,22 +10138,22 @@ class WebRTCPhone extends Emitter {
|
|
|
10064
10138
|
this.client.on('ended', () => {});
|
|
10065
10139
|
|
|
10066
10140
|
this.client.on(this.client.ON_ERROR, e => {
|
|
10067
|
-
logger$
|
|
10141
|
+
logger$5.error('WebRTC error', e);
|
|
10068
10142
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
10069
10143
|
});
|
|
10070
10144
|
|
|
10071
10145
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
10072
|
-
logger$
|
|
10146
|
+
logger$5.info('WebRTC unregistered');
|
|
10073
10147
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10074
10148
|
});
|
|
10075
10149
|
|
|
10076
10150
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
10077
|
-
logger$
|
|
10078
|
-
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
10151
|
+
logger$5.info('WebRTC disconnected');
|
|
10152
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
10079
10153
|
});
|
|
10080
10154
|
|
|
10081
10155
|
this.client.on(this.client.REGISTERED, () => {
|
|
10082
|
-
logger$
|
|
10156
|
+
logger$5.info('WebRTC registered', {
|
|
10083
10157
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
10084
10158
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
10085
10159
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -10092,23 +10166,27 @@ class WebRTCPhone extends Emitter {
|
|
|
10092
10166
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
10093
10167
|
&& this.currentSipSession.state === sessionState.SessionState.Established) {
|
|
10094
10168
|
this.shouldSendReinvite = false;
|
|
10169
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
10170
|
+
const isConference = pc ? pc.sfu : false;
|
|
10171
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
10172
|
+
|
|
10095
10173
|
try {
|
|
10096
10174
|
// Send reinvite with iceRestart
|
|
10097
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
10175
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
10098
10176
|
} catch (e) {
|
|
10099
|
-
logger$
|
|
10177
|
+
logger$5.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
10100
10178
|
}
|
|
10101
10179
|
}
|
|
10102
10180
|
});
|
|
10103
10181
|
|
|
10104
10182
|
this.client.on(this.client.CONNECTED, () => {
|
|
10105
|
-
logger$
|
|
10183
|
+
logger$5.info('WebRTC client connected');
|
|
10106
10184
|
|
|
10107
10185
|
this.stopHeartbeat();
|
|
10108
10186
|
});
|
|
10109
10187
|
|
|
10110
10188
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10111
|
-
logger$
|
|
10189
|
+
logger$5.info('WebRTC client disconnected');
|
|
10112
10190
|
|
|
10113
10191
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10114
10192
|
|
|
@@ -10122,7 +10200,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10122
10200
|
});
|
|
10123
10201
|
|
|
10124
10202
|
this.client.on(this.client.ON_TRACK, (session, event) => {
|
|
10125
|
-
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
10203
|
+
this.eventEmitter.emit(ON_TRACK$1, session, event);
|
|
10126
10204
|
});
|
|
10127
10205
|
|
|
10128
10206
|
this.client.on('onVideoInputChange', stream => {
|
|
@@ -10137,7 +10215,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10137
10215
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
10138
10216
|
const callSession = this.getCallSession(this.getSipSessionId(session));
|
|
10139
10217
|
|
|
10140
|
-
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
10218
|
+
this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
|
|
10141
10219
|
});
|
|
10142
10220
|
|
|
10143
10221
|
// Used when upgrading directly in screenshare mode
|
|
@@ -10146,7 +10224,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10146
10224
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
10147
10225
|
const callSession = this.callSessions[sipSessionId];
|
|
10148
10226
|
|
|
10149
|
-
logger$
|
|
10227
|
+
logger$5.info('Updrading directly in screensharing mode', {
|
|
10150
10228
|
sipSessionId,
|
|
10151
10229
|
tracks: localStream ? localStream.getTracks() : null,
|
|
10152
10230
|
});
|
|
@@ -10178,6 +10256,15 @@ class WebRTCPhone extends Emitter {
|
|
|
10178
10256
|
return this.client.getSipSessionId(sipSession);
|
|
10179
10257
|
}
|
|
10180
10258
|
|
|
10259
|
+
_updateCallSession(callSession ) {
|
|
10260
|
+
const sipSession = this.findSipSession(callSession);
|
|
10261
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
10262
|
+
|
|
10263
|
+
if (sipSessionId) {
|
|
10264
|
+
this.callSessions[sipSessionId] = callSession;
|
|
10265
|
+
}
|
|
10266
|
+
}
|
|
10267
|
+
|
|
10181
10268
|
_onMessage(message ) {
|
|
10182
10269
|
if (!message || message.method !== 'MESSAGE') {
|
|
10183
10270
|
return;
|
|
@@ -10315,8 +10402,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10315
10402
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10316
10403
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10317
10404
|
ON_MESSAGE: ON_MESSAGE,
|
|
10318
|
-
ON_REINVITE: ON_REINVITE,
|
|
10319
|
-
ON_TRACK: ON_TRACK,
|
|
10405
|
+
ON_REINVITE: ON_REINVITE$1,
|
|
10406
|
+
ON_TRACK: ON_TRACK$1,
|
|
10320
10407
|
ON_AUDIO_STREAM: ON_AUDIO_STREAM,
|
|
10321
10408
|
ON_VIDEO_STREAM: ON_VIDEO_STREAM,
|
|
10322
10409
|
ON_REMOVE_STREAM: ON_REMOVE_STREAM,
|
|
@@ -10331,13 +10418,13 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10331
10418
|
ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
|
|
10332
10419
|
ON_CALL_ERROR: ON_CALL_ERROR,
|
|
10333
10420
|
ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
|
|
10334
|
-
ON_NETWORK_STATS: ON_NETWORK_STATS,
|
|
10421
|
+
ON_NETWORK_STATS: ON_NETWORK_STATS$1,
|
|
10335
10422
|
ON_CHAT: ON_CHAT,
|
|
10336
10423
|
ON_SIGNAL: ON_SIGNAL,
|
|
10337
|
-
ON_DISCONNECTED: ON_DISCONNECTED,
|
|
10424
|
+
ON_DISCONNECTED: ON_DISCONNECTED$1,
|
|
10338
10425
|
MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
|
|
10339
10426
|
MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
|
|
10340
|
-
events: events,
|
|
10427
|
+
events: events$1,
|
|
10341
10428
|
'default': WebRTCPhone
|
|
10342
10429
|
});
|
|
10343
10430
|
|
|
@@ -10675,6 +10762,11 @@ class Phone extends Emitter {
|
|
|
10675
10762
|
return this.getRemoteVideoStream(callSession);
|
|
10676
10763
|
}
|
|
10677
10764
|
|
|
10765
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
10766
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
10767
|
+
return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
|
|
10768
|
+
}
|
|
10769
|
+
|
|
10678
10770
|
hasVideo(callSession ) {
|
|
10679
10771
|
return this.phone ? this.phone.hasVideo(callSession) : false;
|
|
10680
10772
|
}
|
|
@@ -10726,7 +10818,7 @@ class Phone extends Emitter {
|
|
|
10726
10818
|
|
|
10727
10819
|
_transferEvents() {
|
|
10728
10820
|
this.unbind();
|
|
10729
|
-
[...events
|
|
10821
|
+
[...events, ...transportEvents].forEach(event => {
|
|
10730
10822
|
this.client.on(event, (...args) =>
|
|
10731
10823
|
this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
|
|
10732
10824
|
});
|
|
@@ -10748,7 +10840,7 @@ var Phone$1 = global.wazoTelephonyInstance;
|
|
|
10748
10840
|
|
|
10749
10841
|
//
|
|
10750
10842
|
|
|
10751
|
-
const SOCKET_EVENTS
|
|
10843
|
+
const SOCKET_EVENTS = {
|
|
10752
10844
|
ON_OPEN: 'onopen',
|
|
10753
10845
|
ON_MESSAGE: 'onmessage',
|
|
10754
10846
|
ON_ERROR: 'onerror',
|
|
@@ -10834,6 +10926,7 @@ const AGENT_PAUSED = 'agent_paused';
|
|
|
10834
10926
|
const AGENT_UNPAUSED = 'agent_unpaused';
|
|
10835
10927
|
const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
|
|
10836
10928
|
const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
|
|
10929
|
+
const MEETING_USER_PROGRESS = 'meeting_user_progress';
|
|
10837
10930
|
|
|
10838
10931
|
const BLACKLIST_EVENTS = [
|
|
10839
10932
|
CHAT_MESSAGE_SENT,
|
|
@@ -10843,7 +10936,7 @@ const BLACKLIST_EVENTS = [
|
|
|
10843
10936
|
];
|
|
10844
10937
|
|
|
10845
10938
|
const HEARTBEAT_ENGINE_VERSION = '20.09';
|
|
10846
|
-
const logger$
|
|
10939
|
+
const logger$7 = IssueReporter$1.loggerFor('wazo-ws');
|
|
10847
10940
|
const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
|
|
10848
10941
|
|
|
10849
10942
|
class WebSocketClient extends Emitter {
|
|
@@ -10892,24 +10985,24 @@ class WebSocketClient extends Emitter {
|
|
|
10892
10985
|
}
|
|
10893
10986
|
|
|
10894
10987
|
connect() {
|
|
10895
|
-
logger$
|
|
10988
|
+
logger$7.info('connect method started', { host: this.host, token: this.token });
|
|
10896
10989
|
this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
|
|
10897
10990
|
if (this.options.binaryType) {
|
|
10898
10991
|
this.socket.binaryType = this.options.binaryType;
|
|
10899
10992
|
}
|
|
10900
10993
|
|
|
10901
10994
|
this.socket.onopen = () => {
|
|
10902
|
-
logger$
|
|
10903
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10995
|
+
logger$7.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
10996
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
10904
10997
|
};
|
|
10905
10998
|
|
|
10906
10999
|
this.socket.onerror = event => {
|
|
10907
|
-
logger$
|
|
10908
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11000
|
+
logger$7.error('on Wazo WS error', event.target);
|
|
11001
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
10909
11002
|
};
|
|
10910
11003
|
|
|
10911
11004
|
this.socket.onmessage = (event ) => {
|
|
10912
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11005
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
|
|
10913
11006
|
|
|
10914
11007
|
const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
|
|
10915
11008
|
let { name } = message;
|
|
@@ -10934,7 +11027,7 @@ class WebSocketClient extends Emitter {
|
|
|
10934
11027
|
|
|
10935
11028
|
this.socket.onclose = event => {
|
|
10936
11029
|
// Can't be converted to JSON (circular structure)
|
|
10937
|
-
logger$
|
|
11030
|
+
logger$7.info('on Wazo WS close', {
|
|
10938
11031
|
reason: event.reason,
|
|
10939
11032
|
code: event.code,
|
|
10940
11033
|
readyState: event.target.readyState,
|
|
@@ -10942,22 +11035,22 @@ class WebSocketClient extends Emitter {
|
|
|
10942
11035
|
token: this.token,
|
|
10943
11036
|
});
|
|
10944
11037
|
this.initialized = false;
|
|
10945
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11038
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
|
|
10946
11039
|
|
|
10947
11040
|
switch (event.code) {
|
|
10948
11041
|
case 4002:
|
|
10949
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11042
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
|
|
10950
11043
|
break;
|
|
10951
11044
|
}
|
|
10952
11045
|
};
|
|
10953
11046
|
|
|
10954
11047
|
this.socket.onerror = event => {
|
|
10955
|
-
logger$
|
|
11048
|
+
logger$7.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
10956
11049
|
};
|
|
10957
11050
|
}
|
|
10958
11051
|
|
|
10959
11052
|
close(force = false) {
|
|
10960
|
-
logger$
|
|
11053
|
+
logger$7.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
10961
11054
|
|
|
10962
11055
|
if (!this.socket) {
|
|
10963
11056
|
return;
|
|
@@ -10975,7 +11068,7 @@ class WebSocketClient extends Emitter {
|
|
|
10975
11068
|
|
|
10976
11069
|
updateToken(token ) {
|
|
10977
11070
|
this.token = token;
|
|
10978
|
-
logger$
|
|
11071
|
+
logger$7.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
10979
11072
|
|
|
10980
11073
|
if (this.socket) {
|
|
10981
11074
|
// If still connected, send the token to the WS
|
|
@@ -10993,7 +11086,7 @@ class WebSocketClient extends Emitter {
|
|
|
10993
11086
|
}
|
|
10994
11087
|
|
|
10995
11088
|
startHeartbeat() {
|
|
10996
|
-
logger$
|
|
11089
|
+
logger$7.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
10997
11090
|
|
|
10998
11091
|
if (!this.socket) {
|
|
10999
11092
|
this.heartbeat.stop();
|
|
@@ -11007,7 +11100,7 @@ class WebSocketClient extends Emitter {
|
|
|
11007
11100
|
}
|
|
11008
11101
|
|
|
11009
11102
|
stopHeartbeat() {
|
|
11010
|
-
logger$
|
|
11103
|
+
logger$7.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
11011
11104
|
|
|
11012
11105
|
this.heartbeat.stop();
|
|
11013
11106
|
}
|
|
@@ -11037,7 +11130,7 @@ class WebSocketClient extends Emitter {
|
|
|
11037
11130
|
}
|
|
11038
11131
|
|
|
11039
11132
|
reconnect(reason ) {
|
|
11040
|
-
logger$
|
|
11133
|
+
logger$7.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
11041
11134
|
if (!this.socket) {
|
|
11042
11135
|
return;
|
|
11043
11136
|
}
|
|
@@ -11062,7 +11155,7 @@ class WebSocketClient extends Emitter {
|
|
|
11062
11155
|
break;
|
|
11063
11156
|
case 'start':
|
|
11064
11157
|
this.initialized = true;
|
|
11065
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11158
|
+
this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
|
|
11066
11159
|
break;
|
|
11067
11160
|
default:
|
|
11068
11161
|
this.eventEmitter.emit('message', message);
|
|
@@ -11093,7 +11186,7 @@ class WebSocketClient extends Emitter {
|
|
|
11093
11186
|
this.close();
|
|
11094
11187
|
}
|
|
11095
11188
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
11096
|
-
logger$
|
|
11189
|
+
logger$7.log('Wazo WS url computed to reconnect', { url });
|
|
11097
11190
|
|
|
11098
11191
|
return url;
|
|
11099
11192
|
}
|
|
@@ -11101,15 +11194,15 @@ class WebSocketClient extends Emitter {
|
|
|
11101
11194
|
_onHeartbeat(message ) {
|
|
11102
11195
|
if (message.payload === 'pong') {
|
|
11103
11196
|
this.heartbeat.onHeartbeat();
|
|
11104
|
-
logger$
|
|
11197
|
+
logger$7.log('on heartbeat received from Wazo WS');
|
|
11105
11198
|
}
|
|
11106
11199
|
}
|
|
11107
11200
|
|
|
11108
11201
|
async _onHeartbeatTimeout() {
|
|
11109
|
-
logger$
|
|
11202
|
+
logger$7.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
11110
11203
|
|
|
11111
11204
|
this.close();
|
|
11112
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11205
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
11113
11206
|
|
|
11114
11207
|
if (this.onHeartBeatTimeout) {
|
|
11115
11208
|
this.onHeartBeatTimeout();
|
|
@@ -11184,11 +11277,12 @@ WebSocketClient.eventLists = [
|
|
|
11184
11277
|
AGENT_UNPAUSED,
|
|
11185
11278
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
11186
11279
|
CONFERENCE_ADHOC_DELETED,
|
|
11280
|
+
MEETING_USER_PROGRESS,
|
|
11187
11281
|
];
|
|
11188
11282
|
|
|
11189
11283
|
var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
11190
11284
|
__proto__: null,
|
|
11191
|
-
SOCKET_EVENTS: SOCKET_EVENTS
|
|
11285
|
+
SOCKET_EVENTS: SOCKET_EVENTS,
|
|
11192
11286
|
AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
|
|
11193
11287
|
FAVORITE_ADDED: FAVORITE_ADDED,
|
|
11194
11288
|
FAVORITE_DELETED: FAVORITE_DELETED,
|
|
@@ -11254,16 +11348,17 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
11254
11348
|
AGENT_UNPAUSED: AGENT_UNPAUSED,
|
|
11255
11349
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
11256
11350
|
CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
|
|
11351
|
+
MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
|
|
11257
11352
|
HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
|
|
11258
11353
|
'default': WebSocketClient
|
|
11259
11354
|
});
|
|
11260
11355
|
|
|
11261
11356
|
//
|
|
11262
11357
|
|
|
11263
|
-
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
11264
|
-
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
11358
|
+
const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
11359
|
+
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
|
|
11265
11360
|
|
|
11266
|
-
const logger$
|
|
11361
|
+
const logger$8 = IssueReporter$1.loggerFor('simple-ws-client');
|
|
11267
11362
|
|
|
11268
11363
|
class Websocket extends Emitter {
|
|
11269
11364
|
|
|
@@ -11277,9 +11372,9 @@ class Websocket extends Emitter {
|
|
|
11277
11372
|
// $FlowFixMe
|
|
11278
11373
|
this[key] = OTHER_EVENTS[key];
|
|
11279
11374
|
});
|
|
11280
|
-
Object.keys(SOCKET_EVENTS).forEach(key => {
|
|
11375
|
+
Object.keys(SOCKET_EVENTS$1).forEach(key => {
|
|
11281
11376
|
// $FlowFixMe
|
|
11282
|
-
this[key] = SOCKET_EVENTS[key];
|
|
11377
|
+
this[key] = SOCKET_EVENTS$1[key];
|
|
11283
11378
|
});
|
|
11284
11379
|
this.eventLists = WebSocketClient.eventLists;
|
|
11285
11380
|
|
|
@@ -11287,7 +11382,7 @@ class Websocket extends Emitter {
|
|
|
11287
11382
|
}
|
|
11288
11383
|
|
|
11289
11384
|
open(host , session ) {
|
|
11290
|
-
logger$
|
|
11385
|
+
logger$8.info('open simple WebSocket', { host, token: session.token });
|
|
11291
11386
|
this.ws = new WebSocketClient(
|
|
11292
11387
|
{
|
|
11293
11388
|
host,
|
|
@@ -11315,7 +11410,7 @@ class Websocket extends Emitter {
|
|
|
11315
11410
|
}
|
|
11316
11411
|
|
|
11317
11412
|
updateToken(token ) {
|
|
11318
|
-
logger$
|
|
11413
|
+
logger$8.info('update token via simple Websocket', { token, ws: !!this.ws });
|
|
11319
11414
|
|
|
11320
11415
|
if (!this.ws) {
|
|
11321
11416
|
return;
|
|
@@ -11343,12 +11438,12 @@ var Websocket$1 = global.wazoWebsocketInstance;
|
|
|
11343
11438
|
|
|
11344
11439
|
//
|
|
11345
11440
|
|
|
11346
|
-
const logger$
|
|
11441
|
+
const logger$9 = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
11347
11442
|
|
|
11348
|
-
class SipRoom extends Room {
|
|
11443
|
+
class SipRoom extends Room$1 {
|
|
11349
11444
|
|
|
11350
11445
|
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
11351
|
-
logger$
|
|
11446
|
+
logger$9.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
11352
11447
|
|
|
11353
11448
|
if (!room) {
|
|
11354
11449
|
await Wazo.Phone.connect();
|
|
@@ -11364,7 +11459,7 @@ class SipRoom extends Room {
|
|
|
11364
11459
|
room.setCallId(room.callSession.call.id);
|
|
11365
11460
|
}
|
|
11366
11461
|
|
|
11367
|
-
logger$
|
|
11462
|
+
logger$9.info('connected to room', {
|
|
11368
11463
|
extension: room.extension,
|
|
11369
11464
|
});
|
|
11370
11465
|
|
|
@@ -11372,7 +11467,7 @@ class SipRoom extends Room {
|
|
|
11372
11467
|
}
|
|
11373
11468
|
|
|
11374
11469
|
mute() {
|
|
11375
|
-
logger$
|
|
11470
|
+
logger$9.info('mute sip room');
|
|
11376
11471
|
|
|
11377
11472
|
Wazo.Phone.mute(this.callSession, false);
|
|
11378
11473
|
|
|
@@ -11380,7 +11475,7 @@ class SipRoom extends Room {
|
|
|
11380
11475
|
}
|
|
11381
11476
|
|
|
11382
11477
|
unmute() {
|
|
11383
|
-
logger$
|
|
11478
|
+
logger$9.info('unmute sip room');
|
|
11384
11479
|
|
|
11385
11480
|
Wazo.Phone.unmute(this.callSession, false);
|
|
11386
11481
|
|
|
@@ -11675,7 +11770,7 @@ class NotificationOptions {
|
|
|
11675
11770
|
|
|
11676
11771
|
|
|
11677
11772
|
// Represents a conference room, like `9000`.
|
|
11678
|
-
class Room
|
|
11773
|
+
class Room {
|
|
11679
11774
|
|
|
11680
11775
|
|
|
11681
11776
|
|
|
@@ -11696,7 +11791,7 @@ class Room$1 {
|
|
|
11696
11791
|
}
|
|
11697
11792
|
|
|
11698
11793
|
connect(callSession ) {
|
|
11699
|
-
return new Room
|
|
11794
|
+
return new Room({ ...this, connectedCallSession: callSession });
|
|
11700
11795
|
}
|
|
11701
11796
|
|
|
11702
11797
|
has(callSession ) {
|
|
@@ -11705,7 +11800,7 @@ class Room$1 {
|
|
|
11705
11800
|
|
|
11706
11801
|
addParticipant(uuid , extension , talking = null) {
|
|
11707
11802
|
if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
|
|
11708
|
-
return new Room
|
|
11803
|
+
return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
11709
11804
|
}
|
|
11710
11805
|
|
|
11711
11806
|
return this;
|
|
@@ -11724,7 +11819,7 @@ class Room$1 {
|
|
|
11724
11819
|
updatedParticipants.push(participant);
|
|
11725
11820
|
}
|
|
11726
11821
|
|
|
11727
|
-
return new Room
|
|
11822
|
+
return new Room({ ...this, participants: updatedParticipants });
|
|
11728
11823
|
}
|
|
11729
11824
|
|
|
11730
11825
|
updateParticipantByExtension(extension , participant , shouldAdd = false) {
|
|
@@ -11740,7 +11835,7 @@ class Room$1 {
|
|
|
11740
11835
|
updatedParticipants.push(participant);
|
|
11741
11836
|
}
|
|
11742
11837
|
|
|
11743
|
-
return new Room
|
|
11838
|
+
return new Room({ ...this, participants: updatedParticipants });
|
|
11744
11839
|
}
|
|
11745
11840
|
|
|
11746
11841
|
hasCallWithId(id ) {
|
|
@@ -11748,18 +11843,18 @@ class Room$1 {
|
|
|
11748
11843
|
}
|
|
11749
11844
|
|
|
11750
11845
|
disconnect() {
|
|
11751
|
-
return new Room
|
|
11846
|
+
return new Room({ ...this, connectedCallSession: null });
|
|
11752
11847
|
}
|
|
11753
11848
|
|
|
11754
11849
|
removeParticipantWithUUID(uuid ) {
|
|
11755
|
-
return new Room
|
|
11850
|
+
return new Room({
|
|
11756
11851
|
...this,
|
|
11757
11852
|
participants: this.participants.filter(participant => participant.uuid !== uuid),
|
|
11758
11853
|
});
|
|
11759
11854
|
}
|
|
11760
11855
|
|
|
11761
11856
|
removeParticipantWithExtension(extension ) {
|
|
11762
|
-
return new Room
|
|
11857
|
+
return new Room({
|
|
11763
11858
|
...this,
|
|
11764
11859
|
participants: this.participants.filter(participant => participant.extension !== extension),
|
|
11765
11860
|
});
|
|
@@ -11770,7 +11865,7 @@ class Room$1 {
|
|
|
11770
11865
|
}
|
|
11771
11866
|
|
|
11772
11867
|
static newFrom(room ) {
|
|
11773
|
-
return newFrom(room, Room
|
|
11868
|
+
return newFrom(room, Room);
|
|
11774
11869
|
}
|
|
11775
11870
|
}
|
|
11776
11871
|
|
|
@@ -12077,11 +12172,11 @@ var wazoWebsocket = {
|
|
|
12077
12172
|
resolve();
|
|
12078
12173
|
};
|
|
12079
12174
|
|
|
12080
|
-
client.on(SOCKET_EVENTS
|
|
12175
|
+
client.on(SOCKET_EVENTS.ON_ERROR, error => {
|
|
12081
12176
|
handleError(`Connection error : ${error}`);
|
|
12082
12177
|
});
|
|
12083
12178
|
|
|
12084
|
-
client.on(SOCKET_EVENTS
|
|
12179
|
+
client.on(SOCKET_EVENTS.ON_OPEN, () => {
|
|
12085
12180
|
if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
|
|
12086
12181
|
client.setOnHeartbeatTimeout(() => {
|
|
12087
12182
|
handleError('No response to heartbeat');
|
|
@@ -12182,7 +12277,7 @@ var webrtc = {
|
|
|
12182
12277
|
}),
|
|
12183
12278
|
};
|
|
12184
12279
|
|
|
12185
|
-
const parseCandidate = line => {
|
|
12280
|
+
const parseCandidate$1 = line => {
|
|
12186
12281
|
let parts;
|
|
12187
12282
|
// Parse both variants.
|
|
12188
12283
|
if (line.indexOf('a=candidate:') === 0) {
|
|
@@ -12273,7 +12368,7 @@ var SymmetricNat = {
|
|
|
12273
12368
|
}
|
|
12274
12369
|
|
|
12275
12370
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
12276
|
-
const cand = parseCandidate(e.candidate.candidate);
|
|
12371
|
+
const cand = parseCandidate$1(e.candidate.candidate);
|
|
12277
12372
|
if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
|
|
12278
12373
|
candidates[cand.relatedPort].push(cand.port);
|
|
12279
12374
|
} else if (!e.candidate) {
|
|
@@ -12341,7 +12436,7 @@ var iceIpv4 = {
|
|
|
12341
12436
|
const rawCandidate = e.candidate.candidate;
|
|
12342
12437
|
if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
|
|
12343
12438
|
hasSrflxOrRelay = true;
|
|
12344
|
-
const candidate = parseCandidate(e.candidate.candidate);
|
|
12439
|
+
const candidate = parseCandidate$1(e.candidate.candidate);
|
|
12345
12440
|
ips.push(candidate.ip);
|
|
12346
12441
|
}
|
|
12347
12442
|
} else if (!e.candidate) {
|
|
@@ -12378,7 +12473,7 @@ var checks = [
|
|
|
12378
12473
|
|
|
12379
12474
|
//
|
|
12380
12475
|
|
|
12381
|
-
const logger$
|
|
12476
|
+
const logger$a = IssueReporter$1.loggerFor('engine-check');
|
|
12382
12477
|
|
|
12383
12478
|
class Checker {
|
|
12384
12479
|
|
|
@@ -12396,28 +12491,28 @@ class Checker {
|
|
|
12396
12491
|
async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
|
|
12397
12492
|
await this._addEngineVersion();
|
|
12398
12493
|
|
|
12399
|
-
logger$
|
|
12494
|
+
logger$a.info('Engine check starting');
|
|
12400
12495
|
|
|
12401
12496
|
for (let i = 0; i < this.checks.length; i++) {
|
|
12402
12497
|
const { name, check } = this.checks[i];
|
|
12403
12498
|
|
|
12404
|
-
logger$
|
|
12499
|
+
logger$a.info(`Checking ${name} ...`);
|
|
12405
12500
|
|
|
12406
12501
|
onCheckBegin(name);
|
|
12407
12502
|
try {
|
|
12408
12503
|
// eslint-disable-next-line no-await-in-loop
|
|
12409
12504
|
const result = await check(this.server, this.session, this.externalAppConfig);
|
|
12410
|
-
logger$
|
|
12505
|
+
logger$a.info(`Checking ${name} success.`, { result });
|
|
12411
12506
|
|
|
12412
12507
|
onCheckResult(name, result);
|
|
12413
12508
|
} catch (e) {
|
|
12414
|
-
logger$
|
|
12509
|
+
logger$a.info(`Checking ${name} failure`, { message: e.message });
|
|
12415
12510
|
|
|
12416
12511
|
onCheckResult(name, e);
|
|
12417
12512
|
}
|
|
12418
12513
|
}
|
|
12419
12514
|
|
|
12420
|
-
logger$
|
|
12515
|
+
logger$a.info('Engine check done.');
|
|
12421
12516
|
}
|
|
12422
12517
|
|
|
12423
12518
|
addCheck(check ) {
|
|
@@ -12441,7 +12536,7 @@ const Wazo = {
|
|
|
12441
12536
|
Auth: Auth$1,
|
|
12442
12537
|
Phone: Phone$1,
|
|
12443
12538
|
Websocket: Websocket$1,
|
|
12444
|
-
Room,
|
|
12539
|
+
Room: Room$1,
|
|
12445
12540
|
SipRoom,
|
|
12446
12541
|
RemoteParticipant,
|
|
12447
12542
|
LocalParticipant,
|
|
@@ -12474,7 +12569,7 @@ const Wazo = {
|
|
|
12474
12569
|
Session,
|
|
12475
12570
|
Voicemail,
|
|
12476
12571
|
Relocation,
|
|
12477
|
-
ConferenceRoom: Room
|
|
12572
|
+
ConferenceRoom: Room,
|
|
12478
12573
|
CallSession,
|
|
12479
12574
|
IndirectTransfer,
|
|
12480
12575
|
SwitchboardCall,
|
|
@@ -12513,9 +12608,9 @@ if (global) {
|
|
|
12513
12608
|
const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
12514
12609
|
const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
12515
12610
|
|
|
12516
|
-
const logger$
|
|
12611
|
+
const logger$b = IssueReporter$1.loggerFor('sdk-room');
|
|
12517
12612
|
|
|
12518
|
-
class Room extends Emitter {
|
|
12613
|
+
class Room$1 extends Emitter {
|
|
12519
12614
|
|
|
12520
12615
|
|
|
12521
12616
|
|
|
@@ -12573,7 +12668,7 @@ class Room extends Emitter {
|
|
|
12573
12668
|
extra = {},
|
|
12574
12669
|
) {
|
|
12575
12670
|
super();
|
|
12576
|
-
logger$
|
|
12671
|
+
logger$b.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
12577
12672
|
|
|
12578
12673
|
// Represents the room callSession
|
|
12579
12674
|
this.callSession = callSession;
|
|
@@ -12639,7 +12734,7 @@ class Room extends Emitter {
|
|
|
12639
12734
|
* @returns {Promise<Room>}
|
|
12640
12735
|
*/
|
|
12641
12736
|
static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
|
|
12642
|
-
logger$
|
|
12737
|
+
logger$b.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
12643
12738
|
|
|
12644
12739
|
if (!room) {
|
|
12645
12740
|
await Wazo.Phone.connect();
|
|
@@ -12652,7 +12747,7 @@ class Room extends Emitter {
|
|
|
12652
12747
|
|
|
12653
12748
|
// Call_created is triggered before call_accepted, so we have to listen for it here.
|
|
12654
12749
|
Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
|
|
12655
|
-
logger$
|
|
12750
|
+
logger$b.info('room call received via WS', { callId: data.call_id });
|
|
12656
12751
|
if (room) {
|
|
12657
12752
|
room.setCallId(data.call_id);
|
|
12658
12753
|
}
|
|
@@ -12660,7 +12755,7 @@ class Room extends Emitter {
|
|
|
12660
12755
|
|
|
12661
12756
|
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
12662
12757
|
// eslint-disable-next-line no-param-reassign
|
|
12663
|
-
room = new Room(callSession, extension, null, null, extra);
|
|
12758
|
+
room = new Room$1(callSession, extension, null, null, extra);
|
|
12664
12759
|
|
|
12665
12760
|
// Wait for the call to be accepted
|
|
12666
12761
|
await new Promise((resolve, reject) => {
|
|
@@ -12681,7 +12776,7 @@ class Room extends Emitter {
|
|
|
12681
12776
|
// Retrieve conference
|
|
12682
12777
|
const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
|
|
12683
12778
|
|
|
12684
|
-
logger$
|
|
12779
|
+
logger$b.info('connected to room', {
|
|
12685
12780
|
sourceId: conference ? conference.sourceId : null,
|
|
12686
12781
|
name: conference ? conference.name : null,
|
|
12687
12782
|
});
|
|
@@ -12691,7 +12786,7 @@ class Room extends Emitter {
|
|
|
12691
12786
|
room.setName(conference.name);
|
|
12692
12787
|
}
|
|
12693
12788
|
} else if (meeting) {
|
|
12694
|
-
logger$
|
|
12789
|
+
logger$b.info('Already connected to meeting', {
|
|
12695
12790
|
uuid: meeting.uuid,
|
|
12696
12791
|
name: meeting.name,
|
|
12697
12792
|
});
|
|
@@ -12704,13 +12799,13 @@ class Room extends Emitter {
|
|
|
12704
12799
|
}
|
|
12705
12800
|
|
|
12706
12801
|
static disconnect() {
|
|
12707
|
-
logger$
|
|
12802
|
+
logger$b.info('static disconnection to room');
|
|
12708
12803
|
|
|
12709
12804
|
Wazo.Phone.disconnect();
|
|
12710
12805
|
}
|
|
12711
12806
|
|
|
12712
12807
|
async disconnect() {
|
|
12713
|
-
logger$
|
|
12808
|
+
logger$b.info('disconnection to room called');
|
|
12714
12809
|
|
|
12715
12810
|
await Wazo.Phone.hangup(this.callSession);
|
|
12716
12811
|
this.callSession = null;
|
|
@@ -12730,19 +12825,19 @@ class Room extends Emitter {
|
|
|
12730
12825
|
}
|
|
12731
12826
|
|
|
12732
12827
|
setSourceId(sourceId ) {
|
|
12733
|
-
logger$
|
|
12828
|
+
logger$b.info('set room source id', { sourceId });
|
|
12734
12829
|
|
|
12735
12830
|
this.sourceId = sourceId;
|
|
12736
12831
|
}
|
|
12737
12832
|
|
|
12738
12833
|
setMeetingUuid(meetingUuid ) {
|
|
12739
|
-
logger$
|
|
12834
|
+
logger$b.info('set meeting uuid', { meetingUuid });
|
|
12740
12835
|
|
|
12741
12836
|
this.meetingUuid = meetingUuid;
|
|
12742
12837
|
}
|
|
12743
12838
|
|
|
12744
12839
|
setCallId(callId ) {
|
|
12745
|
-
logger$
|
|
12840
|
+
logger$b.info('set room call id', { callId });
|
|
12746
12841
|
|
|
12747
12842
|
if (callId) {
|
|
12748
12843
|
this.callId = callId;
|
|
@@ -12750,7 +12845,7 @@ class Room extends Emitter {
|
|
|
12750
12845
|
}
|
|
12751
12846
|
|
|
12752
12847
|
setName(name ) {
|
|
12753
|
-
logger$
|
|
12848
|
+
logger$b.info('set room name', { name });
|
|
12754
12849
|
|
|
12755
12850
|
this.name = name;
|
|
12756
12851
|
}
|
|
@@ -12769,7 +12864,7 @@ class Room extends Emitter {
|
|
|
12769
12864
|
}
|
|
12770
12865
|
|
|
12771
12866
|
async startScreenSharing(constraints ) {
|
|
12772
|
-
logger$
|
|
12867
|
+
logger$b.info('start room screen sharing', { constraints });
|
|
12773
12868
|
|
|
12774
12869
|
const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
|
|
12775
12870
|
if (!screensharingStream) {
|
|
@@ -12783,7 +12878,7 @@ class Room extends Emitter {
|
|
|
12783
12878
|
}
|
|
12784
12879
|
|
|
12785
12880
|
async stopScreenSharing(restoreLocalStream = true) {
|
|
12786
|
-
logger$
|
|
12881
|
+
logger$b.info('stop room screen sharing');
|
|
12787
12882
|
|
|
12788
12883
|
await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
12789
12884
|
|
|
@@ -12795,7 +12890,7 @@ class Room extends Emitter {
|
|
|
12795
12890
|
}
|
|
12796
12891
|
|
|
12797
12892
|
turnCameraOff() {
|
|
12798
|
-
logger$
|
|
12893
|
+
logger$b.info('turn room camera off');
|
|
12799
12894
|
|
|
12800
12895
|
Wazo.Phone.turnCameraOff(this.callSession);
|
|
12801
12896
|
|
|
@@ -12805,7 +12900,7 @@ class Room extends Emitter {
|
|
|
12805
12900
|
}
|
|
12806
12901
|
|
|
12807
12902
|
turnCameraOn() {
|
|
12808
|
-
logger$
|
|
12903
|
+
logger$b.info('turn room camera on');
|
|
12809
12904
|
|
|
12810
12905
|
Wazo.Phone.turnCameraOn(this.callSession);
|
|
12811
12906
|
|
|
@@ -12815,7 +12910,7 @@ class Room extends Emitter {
|
|
|
12815
12910
|
}
|
|
12816
12911
|
|
|
12817
12912
|
mute() {
|
|
12818
|
-
logger$
|
|
12913
|
+
logger$b.info('mute room');
|
|
12819
12914
|
|
|
12820
12915
|
Wazo.Phone.mute(this.callSession);
|
|
12821
12916
|
|
|
@@ -12823,7 +12918,7 @@ class Room extends Emitter {
|
|
|
12823
12918
|
}
|
|
12824
12919
|
|
|
12825
12920
|
unmute() {
|
|
12826
|
-
logger$
|
|
12921
|
+
logger$b.info('unmute room');
|
|
12827
12922
|
|
|
12828
12923
|
Wazo.Phone.unmute(this.callSession);
|
|
12829
12924
|
|
|
@@ -12843,7 +12938,7 @@ class Room extends Emitter {
|
|
|
12843
12938
|
}
|
|
12844
12939
|
|
|
12845
12940
|
hold() {
|
|
12846
|
-
logger$
|
|
12941
|
+
logger$b.info('hold room');
|
|
12847
12942
|
|
|
12848
12943
|
Wazo.Phone.hold(this.callSession, true);
|
|
12849
12944
|
|
|
@@ -12853,7 +12948,7 @@ class Room extends Emitter {
|
|
|
12853
12948
|
}
|
|
12854
12949
|
|
|
12855
12950
|
async resume() {
|
|
12856
|
-
logger$
|
|
12951
|
+
logger$b.info('resume room');
|
|
12857
12952
|
|
|
12858
12953
|
const newStream = await Wazo.Phone.resume(this.callSession, true);
|
|
12859
12954
|
|
|
@@ -12881,13 +12976,13 @@ class Room extends Emitter {
|
|
|
12881
12976
|
}
|
|
12882
12977
|
|
|
12883
12978
|
sendDTMF(tone ) {
|
|
12884
|
-
logger$
|
|
12979
|
+
logger$b.info('send room DTMF', { tone });
|
|
12885
12980
|
|
|
12886
12981
|
Wazo.Phone.sendDTMF(tone, this.callSession);
|
|
12887
12982
|
}
|
|
12888
12983
|
|
|
12889
12984
|
async sendReinvite(newConstraints = null) {
|
|
12890
|
-
logger$
|
|
12985
|
+
logger$b.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
12891
12986
|
const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
|
|
12892
12987
|
|
|
12893
12988
|
Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
|
|
@@ -12946,7 +13041,7 @@ class Room extends Emitter {
|
|
|
12946
13041
|
Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
12947
13042
|
|
|
12948
13043
|
this.on(this.ON_AUDIO_STREAM, stream => {
|
|
12949
|
-
logger$
|
|
13044
|
+
logger$b.info('on room audio stream');
|
|
12950
13045
|
|
|
12951
13046
|
this.audioStream = stream;
|
|
12952
13047
|
if (!this.roomAudioElement) {
|
|
@@ -12959,7 +13054,7 @@ class Room extends Emitter {
|
|
|
12959
13054
|
});
|
|
12960
13055
|
|
|
12961
13056
|
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
12962
|
-
logger$
|
|
13057
|
+
logger$b.info('on room video stream', { streamId });
|
|
12963
13058
|
|
|
12964
13059
|
this._mapMsid(sipSession.body.body);
|
|
12965
13060
|
|
|
@@ -12974,7 +13069,7 @@ class Room extends Emitter {
|
|
|
12974
13069
|
});
|
|
12975
13070
|
|
|
12976
13071
|
this.on(this.ON_REMOVE_STREAM, stream => {
|
|
12977
|
-
logger$
|
|
13072
|
+
logger$b.info('on room remove stream');
|
|
12978
13073
|
|
|
12979
13074
|
const participant = this.participants.find(someParticipant =>
|
|
12980
13075
|
someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
|
|
@@ -13106,7 +13201,7 @@ class Room extends Emitter {
|
|
|
13106
13201
|
const requester = this._getParticipantFromCallId(origin.callId);
|
|
13107
13202
|
if (requester) {
|
|
13108
13203
|
// @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
|
|
13109
|
-
logger$
|
|
13204
|
+
logger$b.info('trigger room requester status', { origin });
|
|
13110
13205
|
requester.triggerUpdate('REQUESTER_UPDATE');
|
|
13111
13206
|
}
|
|
13112
13207
|
break;
|
|
@@ -13137,24 +13232,24 @@ class Room extends Emitter {
|
|
|
13137
13232
|
|
|
13138
13233
|
// When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
|
|
13139
13234
|
if (participant.user_uuid === session.uuid) {
|
|
13140
|
-
logger$
|
|
13235
|
+
logger$b.info('room current user joined');
|
|
13141
13236
|
|
|
13142
13237
|
// Retrieve participants via an API calls
|
|
13143
13238
|
const conferenceId = this.sourceId || payload.data.conference_id;
|
|
13144
13239
|
let response;
|
|
13145
13240
|
try {
|
|
13146
13241
|
if (this.meetingUuid) {
|
|
13147
|
-
logger$
|
|
13242
|
+
logger$b.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
13148
13243
|
response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
|
|
13149
13244
|
} else {
|
|
13150
|
-
logger$
|
|
13245
|
+
logger$b.info('fetching conference participants', { conferenceId });
|
|
13151
13246
|
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
13152
13247
|
}
|
|
13153
13248
|
} catch (e) {
|
|
13154
|
-
logger$
|
|
13249
|
+
logger$b.error('room participants fetching, error', e);
|
|
13155
13250
|
}
|
|
13156
13251
|
if (response) {
|
|
13157
|
-
logger$
|
|
13252
|
+
logger$b.info('conference participants fetched', { nb: response.items.length });
|
|
13158
13253
|
participants = response.items.map(item => {
|
|
13159
13254
|
const isMe = item.call_id === this.callId;
|
|
13160
13255
|
|
|
@@ -13181,7 +13276,7 @@ class Room extends Emitter {
|
|
|
13181
13276
|
? new Wazo.RemoteParticipant(this, participant)
|
|
13182
13277
|
: null;
|
|
13183
13278
|
|
|
13184
|
-
logger$
|
|
13279
|
+
logger$b.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
13185
13280
|
|
|
13186
13281
|
if (remoteParticipant) {
|
|
13187
13282
|
this.participants.push(remoteParticipant);
|
|
@@ -13346,7 +13441,7 @@ class Room extends Emitter {
|
|
|
13346
13441
|
|
|
13347
13442
|
//
|
|
13348
13443
|
|
|
13349
|
-
const logger = IssueReporter$1.loggerFor('room');
|
|
13444
|
+
const logger$c = IssueReporter$1.loggerFor('room');
|
|
13350
13445
|
|
|
13351
13446
|
class Participant extends Emitter {
|
|
13352
13447
|
|
|
@@ -13468,7 +13563,7 @@ class Participant extends Emitter {
|
|
|
13468
13563
|
}
|
|
13469
13564
|
|
|
13470
13565
|
onTalking(isTalking ) {
|
|
13471
|
-
logger.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
|
|
13566
|
+
logger$c.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
|
|
13472
13567
|
this.isTalking = isTalking;
|
|
13473
13568
|
// you may notice we're not broadcasting: since all participants are getting this info
|
|
13474
13569
|
// directly from asterisk, there's no need to do so
|
|
@@ -13571,7 +13666,7 @@ class Participant extends Emitter {
|
|
|
13571
13666
|
}
|
|
13572
13667
|
|
|
13573
13668
|
updateStatus(status , broadcast = true) {
|
|
13574
|
-
logger.info('updating participant status', { name: this.name, status });
|
|
13669
|
+
logger$c.info('updating participant status', { name: this.name, status });
|
|
13575
13670
|
|
|
13576
13671
|
if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
|
|
13577
13672
|
if (status.audioMuted) {
|
|
@@ -13619,7 +13714,7 @@ class Participant extends Emitter {
|
|
|
13619
13714
|
|
|
13620
13715
|
broadcastStatus(inboundStatus = null) {
|
|
13621
13716
|
const status = inboundStatus || this.getStatus();
|
|
13622
|
-
logger.info('broadcasting participant status', { callId: this.callId, status });
|
|
13717
|
+
logger$c.info('broadcasting participant status', { callId: this.callId, status });
|
|
13623
13718
|
|
|
13624
13719
|
this.room.sendSignal({
|
|
13625
13720
|
type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
|