@wazo/sdk 0.37.20 → 0.37.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/api-client.test.js +91 -21
- package/esm/__tests__/web-rtc-client.test.js +214 -165
- package/esm/api/agentd.js +25 -2
- package/esm/api/amid.js +26 -3
- package/esm/api/application.js +25 -2
- package/esm/api/auth.js +25 -2
- package/esm/api/call-logd.js +34 -4
- package/esm/api/calld.js +35 -2
- package/esm/api/chatd.js +32 -2
- package/esm/api/confd.js +56 -9
- package/esm/api/ctid-ng.js +38 -5
- package/esm/api/dird.js +29 -3
- package/esm/api/webhookd.js +26 -3
- package/esm/api-client.js +91 -21
- package/esm/checker/Checker.js +241 -190
- package/esm/checker/checks/aor.js +91 -21
- package/esm/checker/checks/api.js +91 -21
- package/esm/checker/checks/index.js +231 -180
- package/esm/checker/checks/wazo-websocket.js +42 -17
- package/esm/checker/checks/webrtc-transport.js +214 -165
- package/esm/checker/checks/webrtc.js +214 -165
- package/esm/domain/AdHocAPIConference.js +91 -21
- package/esm/domain/Call.js +3 -0
- package/esm/domain/CallLog.js +8 -1
- package/esm/domain/ChatMessage.js +4 -0
- package/esm/domain/ChatRoom.js +3 -0
- package/esm/domain/Contact.js +4 -1
- package/esm/domain/Features.js +91 -21
- package/esm/domain/Meeting.js +28 -5
- package/esm/domain/Phone/CTIPhone.js +109 -35
- package/esm/domain/Phone/WebRTCPhone.js +159 -102
- package/esm/domain/Recording.js +3 -0
- package/esm/domain/Voicemail.js +3 -0
- package/esm/domain/__tests__/Call.test.js +3 -0
- package/esm/domain/__tests__/CallLog.test.js +8 -1
- package/esm/domain/__tests__/Contact.test.js +4 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +509 -414
- package/esm/lib/WazoSessionDescriptionHandler.js +26 -41
- package/esm/service/CallApi.js +91 -21
- package/esm/service/IssueReporter.js +26 -3
- package/esm/service/__tests__/IssueReporter.test.js +26 -3
- package/esm/service/getApiClient.js +91 -21
- package/esm/simple/Auth.js +499 -404
- package/esm/simple/Configuration.js +499 -404
- package/esm/simple/Directory.js +91 -21
- package/esm/simple/Phone.js +499 -404
- package/esm/simple/Websocket.js +45 -19
- package/esm/simple/index.js +503 -408
- package/esm/simple/room/LocalParticipant.js +503 -408
- package/esm/simple/room/Participant.js +503 -408
- package/esm/simple/room/RemoteParticipant.js +503 -408
- package/esm/simple/room/Room.js +504 -409
- package/esm/simple/room/SipRoom.js +503 -408
- package/esm/simple/room/Stream.js +503 -408
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/esm/simple/utils.js +503 -408
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/utils/__tests__/api-requester.test.js +25 -2
- package/esm/utils/api-requester.js +25 -2
- package/esm/web-rtc-client.js +214 -165
- package/esm/websocket-client.js +43 -18
- package/lib/__tests__/api-client.test.js +91 -21
- package/lib/__tests__/web-rtc-client.test.js +214 -165
- package/lib/api/agentd.js +25 -2
- package/lib/api/amid.js +26 -3
- package/lib/api/application.js +25 -2
- package/lib/api/auth.js +25 -2
- package/lib/api/call-logd.js +34 -4
- package/lib/api/calld.js +35 -2
- package/lib/api/chatd.js +32 -2
- package/lib/api/confd.js +56 -9
- package/lib/api/ctid-ng.js +38 -5
- package/lib/api/dird.js +29 -3
- package/lib/api/webhookd.js +26 -3
- package/lib/api-client.js +91 -21
- package/lib/checker/Checker.js +241 -190
- package/lib/checker/checks/aor.js +91 -21
- package/lib/checker/checks/api.js +91 -21
- package/lib/checker/checks/index.js +231 -180
- package/lib/checker/checks/wazo-websocket.js +42 -17
- package/lib/checker/checks/webrtc-transport.js +214 -165
- package/lib/checker/checks/webrtc.js +214 -165
- package/lib/domain/AdHocAPIConference.js +91 -21
- package/lib/domain/Call.js +3 -0
- package/lib/domain/CallLog.js +8 -1
- package/lib/domain/ChatMessage.js +4 -0
- package/lib/domain/ChatRoom.js +3 -0
- package/lib/domain/Contact.js +4 -1
- package/lib/domain/Features.js +91 -21
- package/lib/domain/Meeting.js +32 -5
- package/lib/domain/Phone/CTIPhone.js +109 -35
- package/lib/domain/Phone/WebRTCPhone.js +159 -102
- package/lib/domain/Recording.js +3 -0
- package/lib/domain/Voicemail.js +3 -0
- package/lib/domain/__tests__/Call.test.js +3 -0
- package/lib/domain/__tests__/CallLog.test.js +8 -1
- package/lib/domain/__tests__/Contact.test.js +4 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +509 -414
- package/lib/lib/WazoSessionDescriptionHandler.js +26 -41
- package/lib/service/CallApi.js +91 -21
- package/lib/service/IssueReporter.js +26 -3
- package/lib/service/__tests__/IssueReporter.test.js +26 -3
- package/lib/service/getApiClient.js +91 -21
- package/lib/simple/Auth.js +499 -404
- package/lib/simple/Configuration.js +499 -404
- package/lib/simple/Directory.js +91 -21
- package/lib/simple/Phone.js +499 -404
- package/lib/simple/Websocket.js +45 -19
- package/lib/simple/index.js +503 -408
- package/lib/simple/room/LocalParticipant.js +503 -408
- package/lib/simple/room/Participant.js +503 -408
- package/lib/simple/room/RemoteParticipant.js +503 -408
- package/lib/simple/room/Room.js +504 -409
- package/lib/simple/room/SipRoom.js +503 -408
- package/lib/simple/room/Stream.js +503 -408
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/lib/simple/utils.js +503 -408
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/utils/__tests__/api-requester.test.js +25 -2
- package/lib/utils/api-requester.js +25 -2
- package/lib/web-rtc-client.js +214 -165
- package/lib/websocket-client.js +43 -17
- package/package.json +1 -1
- package/src/api/confd.js +5 -2
- package/src/domain/Call.js +3 -0
- package/src/domain/CallLog.js +4 -0
- package/src/domain/ChatMessage.js +4 -0
- package/src/domain/ChatRoom.js +3 -0
- package/src/domain/Contact.js +3 -0
- package/src/domain/Meeting.js +28 -5
- package/src/domain/Phone/CTIPhone.js +4 -0
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +49 -15
- package/src/domain/Recording.js +3 -0
- package/src/domain/Voicemail.js +3 -0
- package/src/domain/__tests__/Meeting.test.js +50 -0
- package/src/lib/WazoSessionDescriptionHandler.js +1 -35
- package/src/service/IssueReporter.js +25 -2
- package/src/simple/Phone.js +5 -0
- package/src/types/WebSocketMessage.js +5 -1
- package/src/web-rtc-client.js +41 -24
- package/src/websocket-client.js +2 -0
package/esm/simple/room/Room.js
CHANGED
|
@@ -149,6 +149,7 @@ class IssueReporter {
|
|
|
149
149
|
|
|
150
150
|
|
|
151
151
|
|
|
152
|
+
|
|
152
153
|
|
|
153
154
|
constructor() {
|
|
154
155
|
addLevelsTo(this);
|
|
@@ -160,12 +161,17 @@ class IssueReporter {
|
|
|
160
161
|
this.bufferTimeout = null;
|
|
161
162
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
162
163
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
164
|
+
this._callback = null;
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
init() {
|
|
166
168
|
this._catchConsole();
|
|
167
169
|
}
|
|
168
170
|
|
|
171
|
+
setCallback(cb ) {
|
|
172
|
+
this._callback = cb;
|
|
173
|
+
}
|
|
174
|
+
|
|
169
175
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
170
176
|
this.remoteClientConfiguration = configuration;
|
|
171
177
|
}
|
|
@@ -201,6 +207,7 @@ class IssueReporter {
|
|
|
201
207
|
|
|
202
208
|
// Handle category label
|
|
203
209
|
let category = null;
|
|
210
|
+
let skipSendToRemote = false;
|
|
204
211
|
let extra = {};
|
|
205
212
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
206
213
|
category = args[0].split('=')[1];
|
|
@@ -216,6 +223,7 @@ class IssueReporter {
|
|
|
216
223
|
errorMessage: lastArg.message,
|
|
217
224
|
errorStack: lastArg.stack,
|
|
218
225
|
errorType: lastArg.constructor.name,
|
|
226
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
219
227
|
};
|
|
220
228
|
} else {
|
|
221
229
|
extra = lastArg;
|
|
@@ -224,6 +232,11 @@ class IssueReporter {
|
|
|
224
232
|
args.splice(1, 1);
|
|
225
233
|
}
|
|
226
234
|
|
|
235
|
+
if (extra.skipSendToRemote) {
|
|
236
|
+
skipSendToRemote = true;
|
|
237
|
+
delete extra.skipSendToRemote;
|
|
238
|
+
}
|
|
239
|
+
|
|
227
240
|
const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
228
241
|
const message = args.join(', ');
|
|
229
242
|
let consoleMessage = message;
|
|
@@ -244,7 +257,13 @@ class IssueReporter {
|
|
|
244
257
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
245
258
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
246
259
|
|
|
247
|
-
this.
|
|
260
|
+
if (this._callback) {
|
|
261
|
+
this._callback(level, consoleMessage);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (!skipSendToRemote) {
|
|
265
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
266
|
+
}
|
|
248
267
|
}
|
|
249
268
|
|
|
250
269
|
logRequest(url , options , response , start ) {
|
|
@@ -389,7 +408,11 @@ class IssueReporter {
|
|
|
389
408
|
},
|
|
390
409
|
// $FlowFixMe
|
|
391
410
|
body,
|
|
392
|
-
}).catch(() => {
|
|
411
|
+
}).catch((e ) => {
|
|
412
|
+
// $FlowFixMe
|
|
413
|
+
e.skipSendToRemote = true;
|
|
414
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
415
|
+
|
|
393
416
|
setTimeout(() => {
|
|
394
417
|
if (isArray) {
|
|
395
418
|
payload = payload.map(message => {
|
|
@@ -436,7 +459,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
436
459
|
|
|
437
460
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
438
461
|
|
|
439
|
-
const logger
|
|
462
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
440
463
|
|
|
441
464
|
// Use a function here to be able to mock it in tests
|
|
442
465
|
const realFetch = () => {
|
|
@@ -575,7 +598,7 @@ class ApiRequester {
|
|
|
575
598
|
};
|
|
576
599
|
|
|
577
600
|
if (this.refreshTokenPromise) {
|
|
578
|
-
logger
|
|
601
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
579
602
|
await this.refreshTokenPromise;
|
|
580
603
|
}
|
|
581
604
|
|
|
@@ -595,7 +618,7 @@ class ApiRequester {
|
|
|
595
618
|
return promise.then(async (err ) => {
|
|
596
619
|
// Check if the token is still valid
|
|
597
620
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
598
|
-
logger
|
|
621
|
+
logger.warn('token expired', { error: err.reason });
|
|
599
622
|
// Replay the call after refreshing the token
|
|
600
623
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
601
624
|
}
|
|
@@ -605,7 +628,7 @@ class ApiRequester {
|
|
|
605
628
|
: exceptionClass.fromResponse(err, response.status);
|
|
606
629
|
|
|
607
630
|
if (this.shouldLogErrors) {
|
|
608
|
-
logger
|
|
631
|
+
logger.error('API error', error);
|
|
609
632
|
}
|
|
610
633
|
|
|
611
634
|
throw error;
|
|
@@ -615,7 +638,7 @@ class ApiRequester {
|
|
|
615
638
|
return newParse(response, isJson);
|
|
616
639
|
}).catch(error => {
|
|
617
640
|
if (this.shouldLogErrors) {
|
|
618
|
-
logger
|
|
641
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
619
642
|
}
|
|
620
643
|
|
|
621
644
|
throw error;
|
|
@@ -643,13 +666,13 @@ class ApiRequester {
|
|
|
643
666
|
) {
|
|
644
667
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
645
668
|
let newPath = path;
|
|
646
|
-
logger
|
|
669
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
647
670
|
|
|
648
671
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
649
672
|
|
|
650
673
|
return this.refreshTokenPromise.then(() => {
|
|
651
674
|
this.refreshTokenPromise = null;
|
|
652
|
-
logger
|
|
675
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
653
676
|
if (isTokenNotFound) {
|
|
654
677
|
const pathParts = path.split('/');
|
|
655
678
|
pathParts.pop();
|
|
@@ -1527,6 +1550,9 @@ class Contact {
|
|
|
1527
1550
|
}
|
|
1528
1551
|
|
|
1529
1552
|
static parseMany(response ) {
|
|
1553
|
+
if (!response || !response.results) {
|
|
1554
|
+
return [];
|
|
1555
|
+
}
|
|
1530
1556
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
1531
1557
|
}
|
|
1532
1558
|
|
|
@@ -2604,8 +2630,9 @@ class ExternalApp {
|
|
|
2604
2630
|
|
|
2605
2631
|
|
|
2606
2632
|
|
|
2607
|
-
|
|
2633
|
+
|
|
2608
2634
|
|
|
2635
|
+
|
|
2609
2636
|
|
|
2610
2637
|
|
|
2611
2638
|
class Meeting {
|
|
@@ -2616,9 +2643,10 @@ class Meeting {
|
|
|
2616
2643
|
|
|
2617
2644
|
|
|
2618
2645
|
|
|
2619
|
-
|
|
2646
|
+
|
|
2620
2647
|
|
|
2621
2648
|
|
|
2649
|
+
|
|
2622
2650
|
|
|
2623
2651
|
static parse(plain ) {
|
|
2624
2652
|
return new Meeting({
|
|
@@ -2628,24 +2656,43 @@ class Meeting {
|
|
|
2628
2656
|
ownerUuids: plain.owner_uuids,
|
|
2629
2657
|
port: plain.port,
|
|
2630
2658
|
uuid: plain.uuid,
|
|
2631
|
-
|
|
2659
|
+
extension: plain.exten,
|
|
2632
2660
|
persistent: plain.persistent,
|
|
2661
|
+
creationTime: moment(plain.creation_time).toDate(),
|
|
2633
2662
|
});
|
|
2634
2663
|
}
|
|
2635
2664
|
|
|
2665
|
+
static parseMany(items ) {
|
|
2666
|
+
if (!items) {
|
|
2667
|
+
return [];
|
|
2668
|
+
}
|
|
2669
|
+
return items.map(plain => Meeting.parse(plain));
|
|
2670
|
+
}
|
|
2671
|
+
|
|
2636
2672
|
static newFrom(meeting ) {
|
|
2637
2673
|
return newFrom(meeting, Meeting);
|
|
2638
2674
|
}
|
|
2639
2675
|
|
|
2640
|
-
constructor({
|
|
2676
|
+
constructor({
|
|
2677
|
+
uuid,
|
|
2678
|
+
name,
|
|
2679
|
+
guestSipAuthorization,
|
|
2680
|
+
ownerUuids,
|
|
2681
|
+
port,
|
|
2682
|
+
uri,
|
|
2683
|
+
extension,
|
|
2684
|
+
persistent,
|
|
2685
|
+
creationTime,
|
|
2686
|
+
} = {}) {
|
|
2641
2687
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2642
2688
|
this.uri = uri;
|
|
2643
2689
|
this.name = name;
|
|
2644
2690
|
this.ownerUuids = ownerUuids;
|
|
2645
2691
|
this.port = port;
|
|
2646
2692
|
this.uuid = uuid;
|
|
2647
|
-
this.
|
|
2693
|
+
this.extension = extension;
|
|
2648
2694
|
this.persistent = persistent;
|
|
2695
|
+
this.creationTime = creationTime;
|
|
2649
2696
|
|
|
2650
2697
|
// Useful to compare instead of instanceof with minified code
|
|
2651
2698
|
this.type = 'Meeting';
|
|
@@ -2723,8 +2770,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2723
2770
|
}
|
|
2724
2771
|
},
|
|
2725
2772
|
|
|
2726
|
-
|
|
2727
|
-
client.
|
|
2773
|
+
getMyMeetings: () =>
|
|
2774
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
2775
|
+
|
|
2776
|
+
createMyMeeting: (name , persistent ) =>
|
|
2777
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
2728
2778
|
|
|
2729
2779
|
deleteMyMeeting: (meetingUuid ) =>
|
|
2730
2780
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -2820,6 +2870,10 @@ class ChatMessage {
|
|
|
2820
2870
|
|
|
2821
2871
|
|
|
2822
2872
|
static parseMany(plain ) {
|
|
2873
|
+
if (!plain || !plain.items) {
|
|
2874
|
+
return [];
|
|
2875
|
+
}
|
|
2876
|
+
|
|
2823
2877
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
2824
2878
|
}
|
|
2825
2879
|
|
|
@@ -2929,6 +2983,9 @@ class Voicemail {
|
|
|
2929
2983
|
}
|
|
2930
2984
|
|
|
2931
2985
|
static parseMany(plain ) {
|
|
2986
|
+
if (!plain) {
|
|
2987
|
+
return [];
|
|
2988
|
+
}
|
|
2932
2989
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
2933
2990
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
2934
2991
|
|
|
@@ -3038,6 +3095,9 @@ class Call {
|
|
|
3038
3095
|
|
|
3039
3096
|
|
|
3040
3097
|
static parseMany(plain ) {
|
|
3098
|
+
if (!plain) {
|
|
3099
|
+
return [];
|
|
3100
|
+
}
|
|
3041
3101
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
3042
3102
|
}
|
|
3043
3103
|
|
|
@@ -3581,6 +3641,9 @@ class Recording {
|
|
|
3581
3641
|
|
|
3582
3642
|
|
|
3583
3643
|
static parseMany(recordings = []) {
|
|
3644
|
+
if (!recordings) {
|
|
3645
|
+
return [];
|
|
3646
|
+
}
|
|
3584
3647
|
return recordings.map(item => Recording.parse(item));
|
|
3585
3648
|
}
|
|
3586
3649
|
|
|
@@ -3682,6 +3745,10 @@ class CallLog {
|
|
|
3682
3745
|
}
|
|
3683
3746
|
|
|
3684
3747
|
static parseMany(plain ) {
|
|
3748
|
+
if (!plain || !plain.items) {
|
|
3749
|
+
return [];
|
|
3750
|
+
}
|
|
3751
|
+
|
|
3685
3752
|
return plain.items.map(item => CallLog.parse(item));
|
|
3686
3753
|
}
|
|
3687
3754
|
|
|
@@ -3986,7 +4053,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3986
4053
|
|
|
3987
4054
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3988
4055
|
|
|
3989
|
-
const logger$
|
|
4056
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3990
4057
|
|
|
3991
4058
|
class CTIPhone extends Emitter {
|
|
3992
4059
|
|
|
@@ -3999,7 +4066,7 @@ class CTIPhone extends Emitter {
|
|
|
3999
4066
|
|
|
4000
4067
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
4001
4068
|
super();
|
|
4002
|
-
logger$
|
|
4069
|
+
logger$1.info('CTI Phone created');
|
|
4003
4070
|
this.session = session;
|
|
4004
4071
|
this.isMobile = isMobile;
|
|
4005
4072
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -4060,7 +4127,7 @@ class CTIPhone extends Emitter {
|
|
|
4060
4127
|
}
|
|
4061
4128
|
|
|
4062
4129
|
async makeCall(number , line ) {
|
|
4063
|
-
logger$
|
|
4130
|
+
logger$1.info('make CTI call', { number });
|
|
4064
4131
|
|
|
4065
4132
|
if (!number) {
|
|
4066
4133
|
return null;
|
|
@@ -4083,7 +4150,7 @@ class CTIPhone extends Emitter {
|
|
|
4083
4150
|
if (!callSession) {
|
|
4084
4151
|
return Promise.resolve(null);
|
|
4085
4152
|
}
|
|
4086
|
-
logger$
|
|
4153
|
+
logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4087
4154
|
|
|
4088
4155
|
if (!this.currentCall) {
|
|
4089
4156
|
this.currentCall = callSession.call;
|
|
@@ -4096,7 +4163,7 @@ class CTIPhone extends Emitter {
|
|
|
4096
4163
|
if (!callSession) {
|
|
4097
4164
|
return;
|
|
4098
4165
|
}
|
|
4099
|
-
logger$
|
|
4166
|
+
logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4100
4167
|
|
|
4101
4168
|
this.currentCall = undefined;
|
|
4102
4169
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4106,7 +4173,7 @@ class CTIPhone extends Emitter {
|
|
|
4106
4173
|
if (!callSession) {
|
|
4107
4174
|
return Promise.resolve(false);
|
|
4108
4175
|
}
|
|
4109
|
-
logger$
|
|
4176
|
+
logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4110
4177
|
|
|
4111
4178
|
try {
|
|
4112
4179
|
await CallApi.cancelCall(callSession);
|
|
@@ -4117,7 +4184,7 @@ class CTIPhone extends Emitter {
|
|
|
4117
4184
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
4118
4185
|
return true;
|
|
4119
4186
|
} catch (e) {
|
|
4120
|
-
logger$
|
|
4187
|
+
logger$1.error('hangup CTI call, error', e);
|
|
4121
4188
|
|
|
4122
4189
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
4123
4190
|
return false;
|
|
@@ -4130,7 +4197,7 @@ class CTIPhone extends Emitter {
|
|
|
4130
4197
|
if (!callSession) {
|
|
4131
4198
|
return;
|
|
4132
4199
|
}
|
|
4133
|
-
logger$
|
|
4200
|
+
logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4134
4201
|
|
|
4135
4202
|
await CallApi.cancelCall(callSession);
|
|
4136
4203
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4140,7 +4207,7 @@ class CTIPhone extends Emitter {
|
|
|
4140
4207
|
if (!callSession) {
|
|
4141
4208
|
return;
|
|
4142
4209
|
}
|
|
4143
|
-
logger$
|
|
4210
|
+
logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4144
4211
|
|
|
4145
4212
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
4146
4213
|
}
|
|
@@ -4153,19 +4220,19 @@ class CTIPhone extends Emitter {
|
|
|
4153
4220
|
if (!callSession) {
|
|
4154
4221
|
return;
|
|
4155
4222
|
}
|
|
4156
|
-
logger$
|
|
4223
|
+
logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4157
4224
|
|
|
4158
4225
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
4159
4226
|
}
|
|
4160
4227
|
|
|
4161
4228
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
4162
|
-
logger$
|
|
4229
|
+
logger$1.info('cancel CTI transfer', { transferId });
|
|
4163
4230
|
|
|
4164
4231
|
return CallApi.cancelCallTransfer(transferId);
|
|
4165
4232
|
}
|
|
4166
4233
|
|
|
4167
4234
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
4168
|
-
logger$
|
|
4235
|
+
logger$1.info('confirm CTI transfer', { transferId });
|
|
4169
4236
|
|
|
4170
4237
|
return CallApi.confirmCallTransfer(transferId);
|
|
4171
4238
|
}
|
|
@@ -4174,19 +4241,19 @@ class CTIPhone extends Emitter {
|
|
|
4174
4241
|
if (!callSession) {
|
|
4175
4242
|
return;
|
|
4176
4243
|
}
|
|
4177
|
-
logger$
|
|
4244
|
+
logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4178
4245
|
|
|
4179
4246
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4180
4247
|
}
|
|
4181
4248
|
|
|
4182
4249
|
onConnectionMade() {
|
|
4183
|
-
logger$
|
|
4250
|
+
logger$1.info('on CTI connection made');
|
|
4184
4251
|
|
|
4185
4252
|
this.eventEmitter.emit('onCallAccepted');
|
|
4186
4253
|
}
|
|
4187
4254
|
|
|
4188
4255
|
async close() {
|
|
4189
|
-
logger$
|
|
4256
|
+
logger$1.info('CTI close');
|
|
4190
4257
|
|
|
4191
4258
|
return Promise.resolve();
|
|
4192
4259
|
}
|
|
@@ -4195,7 +4262,7 @@ class CTIPhone extends Emitter {
|
|
|
4195
4262
|
if (!callSession) {
|
|
4196
4263
|
return;
|
|
4197
4264
|
}
|
|
4198
|
-
logger$
|
|
4265
|
+
logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4199
4266
|
|
|
4200
4267
|
return CallApi.hold(callSession.callId);
|
|
4201
4268
|
}
|
|
@@ -4204,7 +4271,7 @@ class CTIPhone extends Emitter {
|
|
|
4204
4271
|
if (!callSession) {
|
|
4205
4272
|
return;
|
|
4206
4273
|
}
|
|
4207
|
-
logger$
|
|
4274
|
+
logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4208
4275
|
|
|
4209
4276
|
return CallApi.resume(callSession.callId);
|
|
4210
4277
|
}
|
|
@@ -4213,7 +4280,7 @@ class CTIPhone extends Emitter {
|
|
|
4213
4280
|
if (!callSession) {
|
|
4214
4281
|
return;
|
|
4215
4282
|
}
|
|
4216
|
-
logger$
|
|
4283
|
+
logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4217
4284
|
|
|
4218
4285
|
return CallApi.mute(callSession.callId);
|
|
4219
4286
|
}
|
|
@@ -4222,7 +4289,7 @@ class CTIPhone extends Emitter {
|
|
|
4222
4289
|
if (!callSession) {
|
|
4223
4290
|
return;
|
|
4224
4291
|
}
|
|
4225
|
-
logger$
|
|
4292
|
+
logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4226
4293
|
|
|
4227
4294
|
return CallApi.unmute(callSession.callId);
|
|
4228
4295
|
}
|
|
@@ -4251,6 +4318,10 @@ class CTIPhone extends Emitter {
|
|
|
4251
4318
|
return false;
|
|
4252
4319
|
}
|
|
4253
4320
|
|
|
4321
|
+
hasAVideoTrack() {
|
|
4322
|
+
return false;
|
|
4323
|
+
}
|
|
4324
|
+
|
|
4254
4325
|
getLocalStreamForCall() {
|
|
4255
4326
|
return null;
|
|
4256
4327
|
}
|
|
@@ -4644,6 +4715,9 @@ class ChatRoom {
|
|
|
4644
4715
|
|
|
4645
4716
|
|
|
4646
4717
|
static parseMany(plain ) {
|
|
4718
|
+
if (!plain || !plain.items) {
|
|
4719
|
+
return [];
|
|
4720
|
+
}
|
|
4647
4721
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
4648
4722
|
}
|
|
4649
4723
|
|
|
@@ -5224,7 +5298,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5224
5298
|
const WEBHOOKD_VERSION = '1.0';
|
|
5225
5299
|
const AMID_VERSION = '1.0';
|
|
5226
5300
|
|
|
5227
|
-
const logger$
|
|
5301
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5228
5302
|
|
|
5229
5303
|
class ApiClient {
|
|
5230
5304
|
|
|
@@ -5276,12 +5350,12 @@ class ApiClient {
|
|
|
5276
5350
|
}
|
|
5277
5351
|
|
|
5278
5352
|
async forceRefreshToken() {
|
|
5279
|
-
logger$
|
|
5353
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
5280
5354
|
return this.refreshTokenCallback();
|
|
5281
5355
|
}
|
|
5282
5356
|
|
|
5283
5357
|
async refreshTokenCallback() {
|
|
5284
|
-
logger$
|
|
5358
|
+
logger$2.info('refresh token callback called', {
|
|
5285
5359
|
refreshToken: this.refreshToken,
|
|
5286
5360
|
refreshBackend: this.refreshBackend,
|
|
5287
5361
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5299,7 +5373,7 @@ class ApiClient {
|
|
|
5299
5373
|
this.isMobile,
|
|
5300
5374
|
);
|
|
5301
5375
|
|
|
5302
|
-
logger$
|
|
5376
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
5303
5377
|
|
|
5304
5378
|
if (this.onRefreshToken) {
|
|
5305
5379
|
this.onRefreshToken(session.token, session);
|
|
@@ -5440,7 +5514,7 @@ var getApiClient = (forServer ) => {
|
|
|
5440
5514
|
class InvalidSubscription extends Error {}
|
|
5441
5515
|
class InvalidAuthorization extends Error {}
|
|
5442
5516
|
|
|
5443
|
-
const logger$
|
|
5517
|
+
const logger$3 = IssueReporter$1.loggerFor('simple-auth');
|
|
5444
5518
|
|
|
5445
5519
|
class Auth {
|
|
5446
5520
|
|
|
@@ -5475,7 +5549,7 @@ class Auth {
|
|
|
5475
5549
|
setApiClientId(this.clientId);
|
|
5476
5550
|
setRefreshExpiration(this.expiration);
|
|
5477
5551
|
setOnRefreshToken((token , session ) => {
|
|
5478
|
-
logger$
|
|
5552
|
+
logger$3.info('on refresh token done', { token });
|
|
5479
5553
|
setApiToken(token);
|
|
5480
5554
|
Wazo.Websocket.updateToken(token);
|
|
5481
5555
|
|
|
@@ -5520,7 +5594,7 @@ class Auth {
|
|
|
5520
5594
|
const rawSession = await getApiClient().auth.authenticate(token);
|
|
5521
5595
|
return this._onAuthenticated(rawSession);
|
|
5522
5596
|
} catch (e) {
|
|
5523
|
-
logger$
|
|
5597
|
+
logger$3.error('on validate token error', e);
|
|
5524
5598
|
console.warn(e);
|
|
5525
5599
|
return false;
|
|
5526
5600
|
}
|
|
@@ -5876,7 +5950,7 @@ class AdHocAPIConference {
|
|
|
5876
5950
|
|
|
5877
5951
|
/* */
|
|
5878
5952
|
|
|
5879
|
-
const parseCandidate
|
|
5953
|
+
const parseCandidate = (candidate ) => {
|
|
5880
5954
|
if (!candidate) {
|
|
5881
5955
|
return null;
|
|
5882
5956
|
}
|
|
@@ -5889,10 +5963,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
5889
5963
|
candidates
|
|
5890
5964
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
5891
5965
|
|
|
5892
|
-
const areCandidateValid = (candidates ) =>
|
|
5893
|
-
getSrflxOrRelay(candidates)
|
|
5894
|
-
.length > 0;
|
|
5895
|
-
|
|
5896
5966
|
const getVideoDirection = (sdp ) => {
|
|
5897
5967
|
const parsedSdp = sdpParser.parse(sdp);
|
|
5898
5968
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -5945,8 +6015,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
5945
6015
|
/* global RTCSessionDescriptionInit, navigator */
|
|
5946
6016
|
|
|
5947
6017
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
5948
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
5949
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
5950
6018
|
|
|
5951
6019
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
5952
6020
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -6036,7 +6104,7 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
6036
6104
|
this.peerConnectionDelegate.onicecandidate = event => {
|
|
6037
6105
|
wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
|
|
6038
6106
|
if (event.candidate) {
|
|
6039
|
-
this.gatheredCandidates.push(parseCandidate
|
|
6107
|
+
this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
|
|
6040
6108
|
}
|
|
6041
6109
|
};
|
|
6042
6110
|
|
|
@@ -6136,38 +6204,6 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
6136
6204
|
this._peerConnection = undefined;
|
|
6137
6205
|
}
|
|
6138
6206
|
|
|
6139
|
-
async _waitForValidGatheredIce() {
|
|
6140
|
-
let tries = 0;
|
|
6141
|
-
|
|
6142
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
6143
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
6144
|
-
tries,
|
|
6145
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
6146
|
-
});
|
|
6147
|
-
|
|
6148
|
-
tries++;
|
|
6149
|
-
|
|
6150
|
-
// eslint-disable-next-line no-await-in-loop
|
|
6151
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
6152
|
-
}
|
|
6153
|
-
|
|
6154
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
6155
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
6156
|
-
const error = new Error(errorMsg);
|
|
6157
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
6158
|
-
|
|
6159
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
6160
|
-
this.eventEmitter.emit('error', error);
|
|
6161
|
-
|
|
6162
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
6163
|
-
}
|
|
6164
|
-
|
|
6165
|
-
// eslint-disable-next-line
|
|
6166
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
6167
|
-
|
|
6168
|
-
return this.getLocalSessionDescription();
|
|
6169
|
-
}
|
|
6170
|
-
|
|
6171
6207
|
// Overridden to send `inactive` in conference
|
|
6172
6208
|
updateDirection(options , isConference = false,
|
|
6173
6209
|
audioOnly = false) {
|
|
@@ -6532,7 +6568,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
6532
6568
|
const SEND_STATS_DELAY = 5000;
|
|
6533
6569
|
|
|
6534
6570
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
6535
|
-
const logger$
|
|
6571
|
+
const logger$4 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
6536
6572
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
6537
6573
|
|
|
6538
6574
|
// events
|
|
@@ -6546,14 +6582,14 @@ const TRANSPORT_ERROR = 'transportError';
|
|
|
6546
6582
|
const MESSAGE = 'message';
|
|
6547
6583
|
const ACCEPTED = 'accepted';
|
|
6548
6584
|
const REJECTED = 'rejected';
|
|
6549
|
-
const ON_TRACK
|
|
6550
|
-
const ON_REINVITE
|
|
6585
|
+
const ON_TRACK = 'onTrack';
|
|
6586
|
+
const ON_REINVITE = 'reinvite';
|
|
6551
6587
|
const ON_ERROR = 'onError';
|
|
6552
6588
|
const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
|
|
6553
|
-
const ON_NETWORK_STATS
|
|
6554
|
-
const ON_DISCONNECTED
|
|
6589
|
+
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
6590
|
+
const ON_DISCONNECTED = 'onDisconnected';
|
|
6555
6591
|
|
|
6556
|
-
const events
|
|
6592
|
+
const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
6557
6593
|
const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
6558
6594
|
class CanceledCallError extends Error {}
|
|
6559
6595
|
|
|
@@ -6689,12 +6725,12 @@ class WebRTCClient extends Emitter {
|
|
|
6689
6725
|
this.MESSAGE = MESSAGE;
|
|
6690
6726
|
this.ACCEPTED = ACCEPTED;
|
|
6691
6727
|
this.REJECTED = REJECTED;
|
|
6692
|
-
this.ON_TRACK = ON_TRACK
|
|
6693
|
-
this.ON_REINVITE = ON_REINVITE
|
|
6728
|
+
this.ON_TRACK = ON_TRACK;
|
|
6729
|
+
this.ON_REINVITE = ON_REINVITE;
|
|
6694
6730
|
this.ON_ERROR = ON_ERROR;
|
|
6695
6731
|
this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
|
|
6696
|
-
this.ON_NETWORK_STATS = ON_NETWORK_STATS
|
|
6697
|
-
this.ON_DISCONNECTED = ON_DISCONNECTED
|
|
6732
|
+
this.ON_NETWORK_STATS = ON_NETWORK_STATS;
|
|
6733
|
+
this.ON_DISCONNECTED = ON_DISCONNECTED;
|
|
6698
6734
|
}
|
|
6699
6735
|
|
|
6700
6736
|
configureMedia(media ) {
|
|
@@ -6711,13 +6747,13 @@ class WebRTCClient extends Emitter {
|
|
|
6711
6747
|
|
|
6712
6748
|
createUserAgent(configOverrides ) {
|
|
6713
6749
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6714
|
-
logger$
|
|
6750
|
+
logger$4.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6715
6751
|
|
|
6716
6752
|
webRTCConfiguration.delegate = {
|
|
6717
6753
|
onConnect: this.onConnect.bind(this),
|
|
6718
6754
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6719
6755
|
onInvite: (invitation ) => {
|
|
6720
|
-
logger$
|
|
6756
|
+
logger$4.info('sdk webrtc on invite', {
|
|
6721
6757
|
method: 'delegate.onInvite',
|
|
6722
6758
|
id: invitation.id,
|
|
6723
6759
|
remoteURI: invitation.remoteURI,
|
|
@@ -6760,7 +6796,7 @@ class WebRTCClient extends Emitter {
|
|
|
6760
6796
|
}
|
|
6761
6797
|
|
|
6762
6798
|
onConnect() {
|
|
6763
|
-
logger$
|
|
6799
|
+
logger$4.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6764
6800
|
this.eventEmitter.emit(CONNECTED);
|
|
6765
6801
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6766
6802
|
this.registerer.waitingToggle(false);
|
|
@@ -6769,7 +6805,7 @@ class WebRTCClient extends Emitter {
|
|
|
6769
6805
|
}
|
|
6770
6806
|
|
|
6771
6807
|
async onDisconnect(error ) {
|
|
6772
|
-
logger$
|
|
6808
|
+
logger$4.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6773
6809
|
this.connectionPromise = null;
|
|
6774
6810
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6775
6811
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6794,37 +6830,37 @@ class WebRTCClient extends Emitter {
|
|
|
6794
6830
|
};
|
|
6795
6831
|
|
|
6796
6832
|
if (this.skipRegister) {
|
|
6797
|
-
logger$
|
|
6833
|
+
logger$4.info('sdk webrtc skip register...', logInfo);
|
|
6798
6834
|
return Promise.resolve();
|
|
6799
6835
|
}
|
|
6800
6836
|
|
|
6801
|
-
logger$
|
|
6837
|
+
logger$4.info('sdk webrtc registering...', logInfo);
|
|
6802
6838
|
|
|
6803
6839
|
if (!this.userAgent) {
|
|
6804
|
-
logger$
|
|
6840
|
+
logger$4.info('sdk webrtc recreating User Agent');
|
|
6805
6841
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6806
6842
|
}
|
|
6807
6843
|
if (!this.userAgent || this.isRegistered()) {
|
|
6808
|
-
logger$
|
|
6844
|
+
logger$4.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6809
6845
|
return Promise.resolve();
|
|
6810
6846
|
}
|
|
6811
6847
|
|
|
6812
6848
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6813
|
-
logger$
|
|
6849
|
+
logger$4.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6814
6850
|
return Promise.resolve();
|
|
6815
6851
|
}
|
|
6816
6852
|
|
|
6817
6853
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6818
6854
|
|
|
6819
6855
|
const onRegisterFailed = () => {
|
|
6820
|
-
logger$
|
|
6856
|
+
logger$4.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6821
6857
|
this.connectionPromise = null;
|
|
6822
6858
|
if (this.registerer && this.registerer.waiting) {
|
|
6823
6859
|
this.registerer.waitingToggle(false);
|
|
6824
6860
|
}
|
|
6825
6861
|
|
|
6826
6862
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6827
|
-
logger$
|
|
6863
|
+
logger$4.info('sdk webrtc registering, retrying...', { tries });
|
|
6828
6864
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6829
6865
|
}
|
|
6830
6866
|
};
|
|
@@ -6833,18 +6869,18 @@ class WebRTCClient extends Emitter {
|
|
|
6833
6869
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6834
6870
|
// during the resolution of the primise.
|
|
6835
6871
|
if (!this.userAgent) {
|
|
6836
|
-
logger$
|
|
6872
|
+
logger$4.info('sdk webrtc recreating User Agent after connection');
|
|
6837
6873
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6838
6874
|
}
|
|
6839
6875
|
|
|
6840
|
-
logger$
|
|
6876
|
+
logger$4.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6841
6877
|
this.registerer = new Registerer(this.userAgent, registerOptions);
|
|
6842
6878
|
this.connectionPromise = null;
|
|
6843
6879
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6844
6880
|
|
|
6845
6881
|
// Bind registerer events
|
|
6846
6882
|
this.registerer.stateChange.addListener(newState => {
|
|
6847
|
-
logger$
|
|
6883
|
+
logger$4.info('sdk webrtc registering, state changed', { newState });
|
|
6848
6884
|
|
|
6849
6885
|
if (newState === RegistererState.Registered && this.registerer
|
|
6850
6886
|
&& this.registerer.state === RegistererState.Registered) {
|
|
@@ -6857,7 +6893,7 @@ class WebRTCClient extends Emitter {
|
|
|
6857
6893
|
const options = {
|
|
6858
6894
|
requestDelegate: {
|
|
6859
6895
|
onReject: response => {
|
|
6860
|
-
logger$
|
|
6896
|
+
logger$4.error('sdk webrtc registering, rejected', { response });
|
|
6861
6897
|
|
|
6862
6898
|
onRegisterFailed();
|
|
6863
6899
|
},
|
|
@@ -6865,13 +6901,13 @@ class WebRTCClient extends Emitter {
|
|
|
6865
6901
|
};
|
|
6866
6902
|
|
|
6867
6903
|
return this.registerer.register(options).catch((e) => {
|
|
6868
|
-
logger$
|
|
6904
|
+
logger$4.error('sdk webrtc registering, error', e);
|
|
6869
6905
|
|
|
6870
6906
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6871
6907
|
return e;
|
|
6872
6908
|
});
|
|
6873
6909
|
}).catch(error => {
|
|
6874
|
-
logger$
|
|
6910
|
+
logger$4.error('sdk webrtc registering, transport error', error);
|
|
6875
6911
|
onRegisterFailed();
|
|
6876
6912
|
});
|
|
6877
6913
|
}
|
|
@@ -6900,21 +6936,21 @@ class WebRTCClient extends Emitter {
|
|
|
6900
6936
|
}
|
|
6901
6937
|
|
|
6902
6938
|
unregister() {
|
|
6903
|
-
logger$
|
|
6939
|
+
logger$4.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6904
6940
|
if (!this.registerer) {
|
|
6905
6941
|
return Promise.resolve();
|
|
6906
6942
|
}
|
|
6907
6943
|
|
|
6908
6944
|
try {
|
|
6909
6945
|
return this.registerer.unregister().then(() => {
|
|
6910
|
-
logger$
|
|
6946
|
+
logger$4.info('sdk webrtc unregistered');
|
|
6911
6947
|
this._cleanupRegister();
|
|
6912
6948
|
}).catch(e => {
|
|
6913
|
-
logger$
|
|
6949
|
+
logger$4.error('sdk webrtc unregistering, promise error', e);
|
|
6914
6950
|
this._cleanupRegister();
|
|
6915
6951
|
});
|
|
6916
6952
|
} catch (e) {
|
|
6917
|
-
logger$
|
|
6953
|
+
logger$4.error('sdk webrtc unregistering, error', e);
|
|
6918
6954
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6919
6955
|
// error when the registerer is in a bad state
|
|
6920
6956
|
this._cleanupRegister();
|
|
@@ -6922,7 +6958,7 @@ class WebRTCClient extends Emitter {
|
|
|
6922
6958
|
}
|
|
6923
6959
|
|
|
6924
6960
|
stop() {
|
|
6925
|
-
logger$
|
|
6961
|
+
logger$4.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6926
6962
|
if (!this.userAgent) {
|
|
6927
6963
|
return Promise.resolve();
|
|
6928
6964
|
}
|
|
@@ -6930,12 +6966,12 @@ class WebRTCClient extends Emitter {
|
|
|
6930
6966
|
return this.userAgent.stop().then(() => {
|
|
6931
6967
|
return this._cleanupRegister();
|
|
6932
6968
|
}).catch(e => {
|
|
6933
|
-
logger$
|
|
6969
|
+
logger$4.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6934
6970
|
});
|
|
6935
6971
|
}
|
|
6936
6972
|
|
|
6937
6973
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6938
|
-
logger$
|
|
6974
|
+
logger$4.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6939
6975
|
const inviterOptions = {
|
|
6940
6976
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6941
6977
|
conference,
|
|
@@ -6960,11 +6996,13 @@ class WebRTCClient extends Emitter {
|
|
|
6960
6996
|
const inviteOptions = {
|
|
6961
6997
|
requestDelegate: {
|
|
6962
6998
|
onAccept: (response ) => {
|
|
6963
|
-
session.sessionDescriptionHandler.peerConnection
|
|
6999
|
+
if (session.sessionDescriptionHandler.peerConnection) {
|
|
7000
|
+
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
7001
|
+
}
|
|
6964
7002
|
this._onAccepted(session, response.session, true);
|
|
6965
7003
|
},
|
|
6966
7004
|
onReject: (response ) => {
|
|
6967
|
-
logger$
|
|
7005
|
+
logger$4.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6968
7006
|
this._stopSendingStats(session);
|
|
6969
7007
|
this.stopNetworkMonitoring(session);
|
|
6970
7008
|
|
|
@@ -6987,11 +7025,11 @@ class WebRTCClient extends Emitter {
|
|
|
6987
7025
|
}
|
|
6988
7026
|
|
|
6989
7027
|
answer(session , enableVideo ) {
|
|
6990
|
-
logger$
|
|
7028
|
+
logger$4.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
6991
7029
|
|
|
6992
7030
|
if (!session || !session.accept) {
|
|
6993
7031
|
const error = 'No session to answer, or not an invitation';
|
|
6994
|
-
logger$
|
|
7032
|
+
logger$4.warn(error);
|
|
6995
7033
|
return Promise.reject(new Error(error));
|
|
6996
7034
|
}
|
|
6997
7035
|
const options = {
|
|
@@ -7001,15 +7039,15 @@ class WebRTCClient extends Emitter {
|
|
|
7001
7039
|
return session.accept(options).then(() => {
|
|
7002
7040
|
if (session.isCanceled) {
|
|
7003
7041
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
7004
|
-
logger$
|
|
7042
|
+
logger$4.error(message, { id: session.id });
|
|
7005
7043
|
this.onCallEnded(session);
|
|
7006
7044
|
|
|
7007
7045
|
throw new CanceledCallError(message);
|
|
7008
7046
|
}
|
|
7009
|
-
logger$
|
|
7047
|
+
logger$4.info('sdk webrtc answer, accepted.');
|
|
7010
7048
|
this._onAccepted(session);
|
|
7011
7049
|
}).catch(e => {
|
|
7012
|
-
logger$
|
|
7050
|
+
logger$4.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
7013
7051
|
|
|
7014
7052
|
throw e;
|
|
7015
7053
|
});
|
|
@@ -7017,7 +7055,7 @@ class WebRTCClient extends Emitter {
|
|
|
7017
7055
|
|
|
7018
7056
|
hangup(session ) {
|
|
7019
7057
|
const { state, id } = session;
|
|
7020
|
-
logger$
|
|
7058
|
+
logger$4.info('sdk webrtc hangup call', { id, state });
|
|
7021
7059
|
|
|
7022
7060
|
try {
|
|
7023
7061
|
this._stopSendingStats(session);
|
|
@@ -7046,7 +7084,7 @@ class WebRTCClient extends Emitter {
|
|
|
7046
7084
|
|
|
7047
7085
|
return bye();
|
|
7048
7086
|
} catch (error) {
|
|
7049
|
-
logger$
|
|
7087
|
+
logger$4.warn('sdk webrtc hangup, error', error);
|
|
7050
7088
|
}
|
|
7051
7089
|
|
|
7052
7090
|
return null;
|
|
@@ -7064,7 +7102,7 @@ class WebRTCClient extends Emitter {
|
|
|
7064
7102
|
// Fetch and emit an event at `interval` with session network stats
|
|
7065
7103
|
startNetworkMonitoring(session , interval = 1000) {
|
|
7066
7104
|
const sessionId = this.getSipSessionId(session);
|
|
7067
|
-
logger$
|
|
7105
|
+
logger$4.info('starting network inspection', { id: sessionId });
|
|
7068
7106
|
|
|
7069
7107
|
this.sessionNetworkStats[sessionId] = [];
|
|
7070
7108
|
|
|
@@ -7074,7 +7112,7 @@ class WebRTCClient extends Emitter {
|
|
|
7074
7112
|
stopNetworkMonitoring(session ) {
|
|
7075
7113
|
const sessionId = this.getSipSessionId(session);
|
|
7076
7114
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
7077
|
-
logger$
|
|
7115
|
+
logger$4.info('stopping network inspection', { id: sessionId, exists });
|
|
7078
7116
|
|
|
7079
7117
|
if (exists) {
|
|
7080
7118
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -7084,17 +7122,17 @@ class WebRTCClient extends Emitter {
|
|
|
7084
7122
|
}
|
|
7085
7123
|
|
|
7086
7124
|
reject(session ) {
|
|
7087
|
-
logger$
|
|
7125
|
+
logger$4.info('sdk webrtc reject call', { id: session.id });
|
|
7088
7126
|
|
|
7089
7127
|
try {
|
|
7090
7128
|
return session.reject ? session.reject() : session.cancel();
|
|
7091
7129
|
} catch (e) {
|
|
7092
|
-
logger$
|
|
7130
|
+
logger$4.warn('Error when rejecting call', e.message, e.stack);
|
|
7093
7131
|
}
|
|
7094
7132
|
}
|
|
7095
7133
|
|
|
7096
7134
|
async close() {
|
|
7097
|
-
logger$
|
|
7135
|
+
logger$4.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
7098
7136
|
this._cleanupMedia();
|
|
7099
7137
|
this.connectionPromise = null;
|
|
7100
7138
|
|
|
@@ -7125,7 +7163,7 @@ class WebRTCClient extends Emitter {
|
|
|
7125
7163
|
// eg: "INVITE not rejectable in state Completed"
|
|
7126
7164
|
}
|
|
7127
7165
|
this.userAgent = null;
|
|
7128
|
-
logger$
|
|
7166
|
+
logger$4.info('sdk webrtc client closed');
|
|
7129
7167
|
}
|
|
7130
7168
|
|
|
7131
7169
|
getNumber(session ) {
|
|
@@ -7138,13 +7176,13 @@ class WebRTCClient extends Emitter {
|
|
|
7138
7176
|
}
|
|
7139
7177
|
|
|
7140
7178
|
mute(session ) {
|
|
7141
|
-
logger$
|
|
7179
|
+
logger$4.info('sdk webrtc mute', { id: session.id });
|
|
7142
7180
|
|
|
7143
7181
|
this._toggleAudio(session, true);
|
|
7144
7182
|
}
|
|
7145
7183
|
|
|
7146
7184
|
unmute(session ) {
|
|
7147
|
-
logger$
|
|
7185
|
+
logger$4.info('sdk webrtc unmute', { id: session.id });
|
|
7148
7186
|
|
|
7149
7187
|
this._toggleAudio(session, false);
|
|
7150
7188
|
}
|
|
@@ -7184,13 +7222,13 @@ class WebRTCClient extends Emitter {
|
|
|
7184
7222
|
}
|
|
7185
7223
|
|
|
7186
7224
|
toggleCameraOn(session ) {
|
|
7187
|
-
logger$
|
|
7225
|
+
logger$4.info('sdk webrtc toggle camera on', { id: session.id });
|
|
7188
7226
|
|
|
7189
7227
|
this._toggleVideo(session, false);
|
|
7190
7228
|
}
|
|
7191
7229
|
|
|
7192
7230
|
toggleCameraOff(session ) {
|
|
7193
|
-
logger$
|
|
7231
|
+
logger$4.info('sdk webrtc toggle camera off', { id: session.id });
|
|
7194
7232
|
|
|
7195
7233
|
this._toggleVideo(session, true);
|
|
7196
7234
|
}
|
|
@@ -7199,7 +7237,7 @@ class WebRTCClient extends Emitter {
|
|
|
7199
7237
|
const sessionId = this.getSipSessionId(session);
|
|
7200
7238
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
7201
7239
|
|
|
7202
|
-
logger$
|
|
7240
|
+
logger$4.info('sdk webrtc hold', {
|
|
7203
7241
|
sessionId,
|
|
7204
7242
|
keys: Object.keys(this.heldSessions),
|
|
7205
7243
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7248,7 +7286,7 @@ class WebRTCClient extends Emitter {
|
|
|
7248
7286
|
const sessionId = this.getSipSessionId(session);
|
|
7249
7287
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
7250
7288
|
|
|
7251
|
-
logger$
|
|
7289
|
+
logger$4.info('sdk webrtc unhold', {
|
|
7252
7290
|
sessionId,
|
|
7253
7291
|
keys: Object.keys(this.heldSessions),
|
|
7254
7292
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7396,7 +7434,7 @@ class WebRTCClient extends Emitter {
|
|
|
7396
7434
|
if (!session.sessionDescriptionHandler) {
|
|
7397
7435
|
return;
|
|
7398
7436
|
}
|
|
7399
|
-
logger$
|
|
7437
|
+
logger$4.info('Sending DTMF', {
|
|
7400
7438
|
id: this.getSipSessionId(session),
|
|
7401
7439
|
tone,
|
|
7402
7440
|
});
|
|
@@ -7412,7 +7450,7 @@ class WebRTCClient extends Emitter {
|
|
|
7412
7450
|
transfer(session , target ) {
|
|
7413
7451
|
this.hold(session);
|
|
7414
7452
|
|
|
7415
|
-
logger$
|
|
7453
|
+
logger$4.info('Transfering a session', {
|
|
7416
7454
|
id: this.getSipSessionId(session),
|
|
7417
7455
|
target,
|
|
7418
7456
|
});
|
|
@@ -7434,17 +7472,17 @@ class WebRTCClient extends Emitter {
|
|
|
7434
7472
|
atxfer(session ) {
|
|
7435
7473
|
this.hold(session);
|
|
7436
7474
|
|
|
7437
|
-
logger$
|
|
7475
|
+
logger$4.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
7438
7476
|
|
|
7439
7477
|
const result = {
|
|
7440
7478
|
newSession: null,
|
|
7441
7479
|
init: async (target ) => {
|
|
7442
|
-
logger$
|
|
7480
|
+
logger$4.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
7443
7481
|
|
|
7444
7482
|
result.newSession = await this.call(target);
|
|
7445
7483
|
},
|
|
7446
7484
|
complete: () => {
|
|
7447
|
-
logger$
|
|
7485
|
+
logger$4.info('webrtc transfer completed', {
|
|
7448
7486
|
id: this.getSipSessionId(session),
|
|
7449
7487
|
referId: this.getSipSessionId(result.newSession),
|
|
7450
7488
|
});
|
|
@@ -7465,7 +7503,7 @@ class WebRTCClient extends Emitter {
|
|
|
7465
7503
|
return;
|
|
7466
7504
|
}
|
|
7467
7505
|
|
|
7468
|
-
logger$
|
|
7506
|
+
logger$4.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
7469
7507
|
|
|
7470
7508
|
try {
|
|
7471
7509
|
sipSession.message({
|
|
@@ -7507,7 +7545,7 @@ class WebRTCClient extends Emitter {
|
|
|
7507
7545
|
}
|
|
7508
7546
|
|
|
7509
7547
|
changeAudioOutputVolume(volume ) {
|
|
7510
|
-
logger$
|
|
7548
|
+
logger$4.info('Changing audio output volume', { volume });
|
|
7511
7549
|
|
|
7512
7550
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7513
7551
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -7519,7 +7557,7 @@ class WebRTCClient extends Emitter {
|
|
|
7519
7557
|
}
|
|
7520
7558
|
|
|
7521
7559
|
changeAudioOutputDevice(id ) {
|
|
7522
|
-
logger$
|
|
7560
|
+
logger$4.info('Changing audio output device', { id });
|
|
7523
7561
|
|
|
7524
7562
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7525
7563
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -7536,7 +7574,7 @@ class WebRTCClient extends Emitter {
|
|
|
7536
7574
|
|
|
7537
7575
|
changeAudioInputDevice(id , session ) {
|
|
7538
7576
|
const currentId = this.getAudioDeviceId();
|
|
7539
|
-
logger$
|
|
7577
|
+
logger$4.info('setting audio input device', { id, currentId, session: !!session });
|
|
7540
7578
|
|
|
7541
7579
|
if (id === currentId) {
|
|
7542
7580
|
return null;
|
|
@@ -7582,7 +7620,7 @@ class WebRTCClient extends Emitter {
|
|
|
7582
7620
|
|
|
7583
7621
|
setVideoInputDevice(id ) {
|
|
7584
7622
|
const currentId = this.getVideoDeviceId();
|
|
7585
|
-
logger$
|
|
7623
|
+
logger$4.info('setting video input device', { id, currentId });
|
|
7586
7624
|
|
|
7587
7625
|
if (id === currentId) {
|
|
7588
7626
|
return null;
|
|
@@ -7607,7 +7645,7 @@ class WebRTCClient extends Emitter {
|
|
|
7607
7645
|
const sessionId = this.getSipSessionId(session);
|
|
7608
7646
|
const localStream = this.getLocalStream(sessionId);
|
|
7609
7647
|
|
|
7610
|
-
logger$
|
|
7648
|
+
logger$4.info('changing video input device', { id, sessionId });
|
|
7611
7649
|
|
|
7612
7650
|
// Release old video stream
|
|
7613
7651
|
if (localStream) {
|
|
@@ -7675,7 +7713,7 @@ class WebRTCClient extends Emitter {
|
|
|
7675
7713
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
7676
7714
|
const desktop = newConstraints && newConstraints.desktop;
|
|
7677
7715
|
|
|
7678
|
-
logger$
|
|
7716
|
+
logger$4.info('Sending reinvite', {
|
|
7679
7717
|
id: this.getSipSessionId(sipSession),
|
|
7680
7718
|
newConstraints,
|
|
7681
7719
|
conference,
|
|
@@ -7713,7 +7751,7 @@ class WebRTCClient extends Emitter {
|
|
|
7713
7751
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
7714
7752
|
}
|
|
7715
7753
|
|
|
7716
|
-
logger$
|
|
7754
|
+
logger$4.info('on re-INVITE accepted', {
|
|
7717
7755
|
id: this.getSipSessionId(sipSession),
|
|
7718
7756
|
wasMuted,
|
|
7719
7757
|
shouldDoScreenSharing,
|
|
@@ -7731,7 +7769,7 @@ class WebRTCClient extends Emitter {
|
|
|
7731
7769
|
this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
|
|
7732
7770
|
}
|
|
7733
7771
|
|
|
7734
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
7772
|
+
return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
|
|
7735
7773
|
},
|
|
7736
7774
|
},
|
|
7737
7775
|
sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
|
|
@@ -7832,6 +7870,16 @@ class WebRTCClient extends Emitter {
|
|
|
7832
7870
|
return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
|
|
7833
7871
|
}
|
|
7834
7872
|
|
|
7873
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
7874
|
+
getRemoteVideoStreamFromPc(sessionId ) {
|
|
7875
|
+
const pc = this.getPeerConnection(sessionId);
|
|
7876
|
+
if (!pc) {
|
|
7877
|
+
return null;
|
|
7878
|
+
}
|
|
7879
|
+
|
|
7880
|
+
return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
|
|
7881
|
+
}
|
|
7882
|
+
|
|
7835
7883
|
hasVideo(sessionId ) {
|
|
7836
7884
|
return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
|
|
7837
7885
|
}
|
|
@@ -7878,7 +7926,7 @@ class WebRTCClient extends Emitter {
|
|
|
7878
7926
|
}
|
|
7879
7927
|
|
|
7880
7928
|
startHeartbeat() {
|
|
7881
|
-
logger$
|
|
7929
|
+
logger$4.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7882
7930
|
if (!this.userAgent) {
|
|
7883
7931
|
this.heartbeat.stop();
|
|
7884
7932
|
return;
|
|
@@ -7891,7 +7939,7 @@ class WebRTCClient extends Emitter {
|
|
|
7891
7939
|
}
|
|
7892
7940
|
|
|
7893
7941
|
stopHeartbeat() {
|
|
7894
|
-
logger$
|
|
7942
|
+
logger$4.info('sdk webrtc stop heartbeat');
|
|
7895
7943
|
this.heartbeat.stop();
|
|
7896
7944
|
}
|
|
7897
7945
|
|
|
@@ -7912,7 +7960,7 @@ class WebRTCClient extends Emitter {
|
|
|
7912
7960
|
}
|
|
7913
7961
|
|
|
7914
7962
|
attemptReconnection() {
|
|
7915
|
-
logger$
|
|
7963
|
+
logger$4.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7916
7964
|
if (!this.userAgent) {
|
|
7917
7965
|
return;
|
|
7918
7966
|
}
|
|
@@ -7937,7 +7985,7 @@ class WebRTCClient extends Emitter {
|
|
|
7937
7985
|
return;
|
|
7938
7986
|
}
|
|
7939
7987
|
|
|
7940
|
-
logger$
|
|
7988
|
+
logger$4.info('setting local media stream', {
|
|
7941
7989
|
sipSessionId,
|
|
7942
7990
|
tracks: newStream ? newStream.getTracks() : null,
|
|
7943
7991
|
});
|
|
@@ -7954,7 +8002,7 @@ class WebRTCClient extends Emitter {
|
|
|
7954
8002
|
|
|
7955
8003
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
7956
8004
|
|
|
7957
|
-
logger$
|
|
8005
|
+
logger$4.info('updating local stream', {
|
|
7958
8006
|
sipSessionId,
|
|
7959
8007
|
oldStream: !!oldStream,
|
|
7960
8008
|
tracks: newStream.getTracks(),
|
|
@@ -7974,7 +8022,7 @@ class WebRTCClient extends Emitter {
|
|
|
7974
8022
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
7975
8023
|
const pc = this.getPeerConnection(sessionId);
|
|
7976
8024
|
|
|
7977
|
-
logger$
|
|
8025
|
+
logger$4.info('Updating remote stream', {
|
|
7978
8026
|
sessionId,
|
|
7979
8027
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
7980
8028
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -8000,7 +8048,7 @@ class WebRTCClient extends Emitter {
|
|
|
8000
8048
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
8001
8049
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
8002
8050
|
|
|
8003
|
-
logger$
|
|
8051
|
+
logger$4.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
8004
8052
|
|
|
8005
8053
|
return {
|
|
8006
8054
|
constraints: {
|
|
@@ -8049,7 +8097,7 @@ class WebRTCClient extends Emitter {
|
|
|
8049
8097
|
}
|
|
8050
8098
|
|
|
8051
8099
|
_onTransportError() {
|
|
8052
|
-
logger$
|
|
8100
|
+
logger$4.error('on transport error');
|
|
8053
8101
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
8054
8102
|
this.attemptReconnection();
|
|
8055
8103
|
}
|
|
@@ -8058,7 +8106,7 @@ class WebRTCClient extends Emitter {
|
|
|
8058
8106
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
8059
8107
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
8060
8108
|
if (this.hasHeartbeat()) {
|
|
8061
|
-
logger$
|
|
8109
|
+
logger$4.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
8062
8110
|
|
|
8063
8111
|
this.heartbeat.onHeartbeat();
|
|
8064
8112
|
if (this.heartbeatCb) {
|
|
@@ -8069,7 +8117,7 @@ class WebRTCClient extends Emitter {
|
|
|
8069
8117
|
}
|
|
8070
8118
|
|
|
8071
8119
|
async _onHeartbeatTimeout() {
|
|
8072
|
-
logger$
|
|
8120
|
+
logger$4.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
8073
8121
|
|
|
8074
8122
|
if (this.heartbeatTimeoutCb) {
|
|
8075
8123
|
this.heartbeatTimeoutCb();
|
|
@@ -8081,7 +8129,7 @@ class WebRTCClient extends Emitter {
|
|
|
8081
8129
|
try {
|
|
8082
8130
|
await this.userAgent.transport.disconnect();
|
|
8083
8131
|
} catch (e) {
|
|
8084
|
-
logger$
|
|
8132
|
+
logger$4.error('Transport disconnection after heartbeat timeout, error', e);
|
|
8085
8133
|
}
|
|
8086
8134
|
}
|
|
8087
8135
|
|
|
@@ -8114,31 +8162,31 @@ class WebRTCClient extends Emitter {
|
|
|
8114
8162
|
}
|
|
8115
8163
|
|
|
8116
8164
|
_connectIfNeeded() {
|
|
8117
|
-
logger$
|
|
8165
|
+
logger$4.info('connect if needed, checking', { connected: this.isConnected() });
|
|
8118
8166
|
if (!this.userAgent) {
|
|
8119
|
-
logger$
|
|
8167
|
+
logger$4.info('need to recreate User Agent');
|
|
8120
8168
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
8121
8169
|
}
|
|
8122
8170
|
|
|
8123
8171
|
if (this.isConnected()) {
|
|
8124
|
-
logger$
|
|
8172
|
+
logger$4.info('webrtc sdk, already connected');
|
|
8125
8173
|
return Promise.resolve();
|
|
8126
8174
|
}
|
|
8127
8175
|
|
|
8128
8176
|
if (this.isConnecting()) {
|
|
8129
|
-
logger$
|
|
8177
|
+
logger$4.info('webrtc sdk, already connecting...');
|
|
8130
8178
|
|
|
8131
8179
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
8132
8180
|
return this.connectionPromise;
|
|
8133
8181
|
}
|
|
8134
8182
|
|
|
8135
8183
|
if (this.connectionPromise) {
|
|
8136
|
-
logger$
|
|
8184
|
+
logger$4.info('webrtc sdk, connection promise connecting...');
|
|
8137
8185
|
// $FlowFixMe
|
|
8138
8186
|
return this.connectionPromise;
|
|
8139
8187
|
}
|
|
8140
8188
|
|
|
8141
|
-
logger$
|
|
8189
|
+
logger$4.info('WebRTC UA needs to connect');
|
|
8142
8190
|
|
|
8143
8191
|
// Force UA to reconnect
|
|
8144
8192
|
if (this.userAgent && this.userAgent.state !== UserAgentState.Stopped) {
|
|
@@ -8263,7 +8311,7 @@ class WebRTCClient extends Emitter {
|
|
|
8263
8311
|
|
|
8264
8312
|
sdh.peerConnectionDelegate = {
|
|
8265
8313
|
onicecandidateerror: (error ) => {
|
|
8266
|
-
logger$
|
|
8314
|
+
logger$4.error('on icecandidate error', {
|
|
8267
8315
|
address: error.address,
|
|
8268
8316
|
port: error.port,
|
|
8269
8317
|
errorCode: error.errorCode,
|
|
@@ -8292,7 +8340,7 @@ class WebRTCClient extends Emitter {
|
|
|
8292
8340
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
8293
8341
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
8294
8342
|
}
|
|
8295
|
-
logger$
|
|
8343
|
+
logger$4.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
8296
8344
|
|
|
8297
8345
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
8298
8346
|
|
|
@@ -8308,12 +8356,12 @@ class WebRTCClient extends Emitter {
|
|
|
8308
8356
|
|
|
8309
8357
|
this._setupMedias(session);
|
|
8310
8358
|
|
|
8311
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
8359
|
+
return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
|
|
8312
8360
|
};
|
|
8313
8361
|
}
|
|
8314
8362
|
|
|
8315
8363
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
8316
|
-
logger$
|
|
8364
|
+
logger$4.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
8317
8365
|
|
|
8318
8366
|
this.storeSipSession(session);
|
|
8319
8367
|
|
|
@@ -8325,14 +8373,14 @@ class WebRTCClient extends Emitter {
|
|
|
8325
8373
|
const onTrack = (event ) => {
|
|
8326
8374
|
const isAudioOnly = this._isAudioOnly(session);
|
|
8327
8375
|
const { kind, label, readyState, id, muted } = event.track;
|
|
8328
|
-
logger$
|
|
8376
|
+
logger$4.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
8329
8377
|
|
|
8330
8378
|
// Stop video track in audio only mode
|
|
8331
8379
|
if (isAudioOnly && kind === 'video') {
|
|
8332
8380
|
event.track.stop();
|
|
8333
8381
|
}
|
|
8334
8382
|
|
|
8335
|
-
this.eventEmitter.emit(ON_TRACK
|
|
8383
|
+
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
8336
8384
|
};
|
|
8337
8385
|
|
|
8338
8386
|
if (session.sessionDescriptionHandler.peerConnection) {
|
|
@@ -8342,8 +8390,9 @@ class WebRTCClient extends Emitter {
|
|
|
8342
8390
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
8343
8391
|
|
|
8344
8392
|
pc.oniceconnectionstatechange = () => {
|
|
8393
|
+
logger$4.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
8345
8394
|
if (pc.iceConnectionState === 'disconnected') {
|
|
8346
|
-
this.eventEmitter.emit(ON_DISCONNECTED
|
|
8395
|
+
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
8347
8396
|
}
|
|
8348
8397
|
};
|
|
8349
8398
|
|
|
@@ -8514,10 +8563,10 @@ class WebRTCClient extends Emitter {
|
|
|
8514
8563
|
|
|
8515
8564
|
_stopSendingStats(session ) {
|
|
8516
8565
|
const sessionId = this.getSipSessionId(session);
|
|
8517
|
-
logger$
|
|
8566
|
+
logger$4.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
8518
8567
|
|
|
8519
8568
|
if (sessionId in this.statsIntervals) {
|
|
8520
|
-
logger$
|
|
8569
|
+
logger$4.trace('Stop sending stats for call', { sessionId });
|
|
8521
8570
|
this.statsIntervals[sessionId]();
|
|
8522
8571
|
delete this.statsIntervals[sessionId];
|
|
8523
8572
|
}
|
|
@@ -8533,7 +8582,7 @@ class WebRTCClient extends Emitter {
|
|
|
8533
8582
|
try {
|
|
8534
8583
|
await this.userAgent.transport.disconnect();
|
|
8535
8584
|
} catch (e) {
|
|
8536
|
-
logger$
|
|
8585
|
+
logger$4.error('WebRTC transport disconnect, error', e);
|
|
8537
8586
|
}
|
|
8538
8587
|
}
|
|
8539
8588
|
}
|
|
@@ -8570,25 +8619,25 @@ class WebRTCClient extends Emitter {
|
|
|
8570
8619
|
|
|
8571
8620
|
stats.forEach(report => {
|
|
8572
8621
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
8573
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8622
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8574
8623
|
}
|
|
8575
8624
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
8576
|
-
audioBytesSent += report.bytesSent;
|
|
8625
|
+
audioBytesSent += Number(report.bytesSent);
|
|
8577
8626
|
}
|
|
8578
8627
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8579
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8628
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8580
8629
|
}
|
|
8581
8630
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
8582
|
-
packetsLost += report.packetsLost;
|
|
8583
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
8584
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8631
|
+
packetsLost += Number(report.packetsLost);
|
|
8632
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
8633
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8585
8634
|
}
|
|
8586
8635
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
8587
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8636
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8588
8637
|
}
|
|
8589
8638
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8590
8639
|
if ('framesPerSecond' in report) {
|
|
8591
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
8640
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
8592
8641
|
}
|
|
8593
8642
|
if ('framerateMean' in report) {
|
|
8594
8643
|
// framerateMean is only available in FF
|
|
@@ -8596,34 +8645,38 @@ class WebRTCClient extends Emitter {
|
|
|
8596
8645
|
}
|
|
8597
8646
|
}
|
|
8598
8647
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
8599
|
-
packetsLost += report.packetsLost;
|
|
8600
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
8601
|
-
networkStats.jitter = report.jitter;
|
|
8648
|
+
packetsLost += Number(report.packetsLost);
|
|
8649
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
8650
|
+
networkStats.jitter = Number(report.jitter);
|
|
8602
8651
|
}
|
|
8603
8652
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
8604
|
-
packetsLost += report.packetsLost;
|
|
8653
|
+
packetsLost += Number(report.packetsLost);
|
|
8605
8654
|
}
|
|
8606
8655
|
if (report.type === 'transport') {
|
|
8607
|
-
transportSent += report.bytesSent;
|
|
8608
|
-
transportReceived += report.bytesReceived;
|
|
8656
|
+
transportSent += Number(report.bytesSent);
|
|
8657
|
+
transportReceived += Number(report.bytesReceived);
|
|
8609
8658
|
}
|
|
8610
8659
|
});
|
|
8611
8660
|
|
|
8612
8661
|
networkStats.packetsLost = packetsLost;
|
|
8613
|
-
networkStats.
|
|
8662
|
+
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
8663
|
+
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
8664
|
+
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
8614
8665
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
8615
|
-
networkStats.
|
|
8616
|
-
networkStats.
|
|
8666
|
+
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
8667
|
+
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
8668
|
+
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
8669
|
+
networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
|
|
8670
|
+
networkStats.totalTransportSent = transportSent - lastTransportSent;
|
|
8617
8671
|
networkStats.transportSent = transportSent;
|
|
8618
|
-
networkStats.
|
|
8619
|
-
|
|
8620
|
-
const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
|
|
8621
|
-
+ (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
|
|
8622
|
-
+ (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
|
|
8672
|
+
networkStats.totalTransportReceived = transportReceived;
|
|
8673
|
+
networkStats.transportReceived = transportReceived - lastTransportReceived;
|
|
8623
8674
|
|
|
8624
|
-
networkStats.bandwidth =
|
|
8675
|
+
networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
|
|
8676
|
+
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
8677
|
+
+ networkStats.transportSent;
|
|
8625
8678
|
|
|
8626
|
-
this.eventEmitter.emit(ON_NETWORK_STATS
|
|
8679
|
+
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
8627
8680
|
this.sessionNetworkStats[sessionId].push(networkStats);
|
|
8628
8681
|
}
|
|
8629
8682
|
|
|
@@ -8651,8 +8704,8 @@ const ON_CALL_FAILED = 'onCallFailed';
|
|
|
8651
8704
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
8652
8705
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
8653
8706
|
const ON_MESSAGE = 'onMessage';
|
|
8654
|
-
const ON_REINVITE = 'reinvite';
|
|
8655
|
-
const ON_TRACK = 'onTrack';
|
|
8707
|
+
const ON_REINVITE$1 = 'reinvite';
|
|
8708
|
+
const ON_TRACK$1 = 'onTrack';
|
|
8656
8709
|
const ON_AUDIO_STREAM = 'onAudioStream';
|
|
8657
8710
|
const ON_VIDEO_STREAM = 'onVideoStream';
|
|
8658
8711
|
const ON_REMOVE_STREAM = 'onRemoveStream';
|
|
@@ -8667,15 +8720,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
|
|
|
8667
8720
|
const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
|
|
8668
8721
|
const ON_CALL_ERROR = 'onCallError';
|
|
8669
8722
|
const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
|
|
8670
|
-
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
8723
|
+
const ON_NETWORK_STATS$1 = 'onNetworkStats';
|
|
8671
8724
|
const ON_CHAT = 'phone/ON_CHAT';
|
|
8672
8725
|
const ON_SIGNAL = 'phone/ON_SIGNAL';
|
|
8673
|
-
const ON_DISCONNECTED = 'onDisconnected';
|
|
8726
|
+
const ON_DISCONNECTED$1 = 'onDisconnected';
|
|
8674
8727
|
|
|
8675
8728
|
const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
8676
8729
|
const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
8677
8730
|
|
|
8678
|
-
const events = [
|
|
8731
|
+
const events$1 = [
|
|
8679
8732
|
ON_USER_AGENT,
|
|
8680
8733
|
ON_REGISTERED,
|
|
8681
8734
|
ON_UNREGISTERED,
|
|
@@ -8693,8 +8746,8 @@ const events = [
|
|
|
8693
8746
|
ON_CALL_FAILED,
|
|
8694
8747
|
ON_CALL_ENDED,
|
|
8695
8748
|
ON_MESSAGE,
|
|
8696
|
-
ON_REINVITE,
|
|
8697
|
-
ON_TRACK,
|
|
8749
|
+
ON_REINVITE$1,
|
|
8750
|
+
ON_TRACK$1,
|
|
8698
8751
|
ON_AUDIO_STREAM,
|
|
8699
8752
|
ON_VIDEO_STREAM,
|
|
8700
8753
|
ON_REMOVE_STREAM,
|
|
@@ -8709,11 +8762,11 @@ const events = [
|
|
|
8709
8762
|
ON_CALL_ERROR,
|
|
8710
8763
|
ON_CHAT,
|
|
8711
8764
|
ON_SIGNAL,
|
|
8712
|
-
ON_NETWORK_STATS,
|
|
8713
|
-
ON_DISCONNECTED,
|
|
8765
|
+
ON_NETWORK_STATS$1,
|
|
8766
|
+
ON_DISCONNECTED$1,
|
|
8714
8767
|
];
|
|
8715
8768
|
|
|
8716
|
-
const logger$
|
|
8769
|
+
const logger$5 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
8717
8770
|
|
|
8718
8771
|
class WebRTCPhone extends Emitter {
|
|
8719
8772
|
|
|
@@ -8786,7 +8839,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8786
8839
|
}).catch(error => {
|
|
8787
8840
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
8788
8841
|
console.error('register error', error, error.message, error.stack);
|
|
8789
|
-
logger$
|
|
8842
|
+
logger$5.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
8790
8843
|
});
|
|
8791
8844
|
}
|
|
8792
8845
|
|
|
@@ -8801,7 +8854,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8801
8854
|
if (!this.client) {
|
|
8802
8855
|
return;
|
|
8803
8856
|
}
|
|
8804
|
-
logger$
|
|
8857
|
+
logger$5.info('WebRTC phone stop');
|
|
8805
8858
|
this.client.stop();
|
|
8806
8859
|
}
|
|
8807
8860
|
|
|
@@ -8816,7 +8869,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8816
8869
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
8817
8870
|
audioOnly = false, iceRestart = false) {
|
|
8818
8871
|
const sipSession = this.findSipSession(callSession);
|
|
8819
|
-
logger$
|
|
8872
|
+
logger$5.info('WebRTC phone - send reinvite', {
|
|
8820
8873
|
sessionId: sipSession ? sipSession.id : null,
|
|
8821
8874
|
constraints,
|
|
8822
8875
|
audioOnly,
|
|
@@ -8853,7 +8906,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8853
8906
|
}
|
|
8854
8907
|
|
|
8855
8908
|
startHeartbeat() {
|
|
8856
|
-
logger$
|
|
8909
|
+
logger$5.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
8857
8910
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
8858
8911
|
return;
|
|
8859
8912
|
}
|
|
@@ -8862,7 +8915,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8862
8915
|
}
|
|
8863
8916
|
|
|
8864
8917
|
stopHeartbeat() {
|
|
8865
|
-
logger$
|
|
8918
|
+
logger$5.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
8866
8919
|
if (!this.client) {
|
|
8867
8920
|
return;
|
|
8868
8921
|
}
|
|
@@ -8879,7 +8932,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8879
8932
|
}
|
|
8880
8933
|
|
|
8881
8934
|
reconnect() {
|
|
8882
|
-
logger$
|
|
8935
|
+
logger$5.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
8883
8936
|
if (!this.client) {
|
|
8884
8937
|
return;
|
|
8885
8938
|
}
|
|
@@ -8920,10 +8973,15 @@ class WebRTCPhone extends Emitter {
|
|
|
8920
8973
|
return false;
|
|
8921
8974
|
}
|
|
8922
8975
|
|
|
8923
|
-
logger$
|
|
8976
|
+
logger$5.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
8924
8977
|
|
|
8925
8978
|
this.client.downgradeToAudio(sipSession);
|
|
8926
8979
|
|
|
8980
|
+
if (callSession) {
|
|
8981
|
+
callSession.cameraEnabled = false;
|
|
8982
|
+
this._updateCallSession(callSession);
|
|
8983
|
+
}
|
|
8984
|
+
|
|
8927
8985
|
if (withMessage) {
|
|
8928
8986
|
this._sendReinviteMessage(callSession, false);
|
|
8929
8987
|
}
|
|
@@ -8938,7 +8996,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8938
8996
|
return Promise.resolve(false);
|
|
8939
8997
|
}
|
|
8940
8998
|
|
|
8941
|
-
logger$
|
|
8999
|
+
logger$5.info('Upgrade to video', {
|
|
8942
9000
|
id: callSession ? callSession.getId() : null,
|
|
8943
9001
|
constraints,
|
|
8944
9002
|
isConference,
|
|
@@ -8951,6 +9009,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8951
9009
|
|
|
8952
9010
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
8953
9011
|
|
|
9012
|
+
if (callSession) {
|
|
9013
|
+
callSession.cameraEnabled = true;
|
|
9014
|
+
this._updateCallSession(callSession);
|
|
9015
|
+
}
|
|
9016
|
+
|
|
8954
9017
|
// If no stream is returned, it means we have to reinvite
|
|
8955
9018
|
if (!newStream) {
|
|
8956
9019
|
return true;
|
|
@@ -8973,7 +9036,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8973
9036
|
|
|
8974
9037
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
8975
9038
|
const sipSession = this.findSipSession(callSession);
|
|
8976
|
-
logger$
|
|
9039
|
+
logger$5.info('Sending reinvite message', {
|
|
8977
9040
|
id: callSession ? callSession.getId() : null,
|
|
8978
9041
|
isUpgrade,
|
|
8979
9042
|
});
|
|
@@ -8999,11 +9062,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8999
9062
|
// Monkey patch to know when canceled with the CANCEL message
|
|
9000
9063
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
9001
9064
|
sipSession._onCancel = (message ) => {
|
|
9002
|
-
logger$
|
|
9065
|
+
logger$5.trace('on sip session canceled', { callId: message.callId });
|
|
9003
9066
|
|
|
9004
9067
|
onCancel(message);
|
|
9005
9068
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
9006
|
-
|
|
9069
|
+
const callSession = this._createCallSession(sipSession);
|
|
9070
|
+
delete this.callSessions[callSession.getId()];
|
|
9071
|
+
|
|
9072
|
+
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
9007
9073
|
};
|
|
9008
9074
|
} else if (sipSession instanceof Invitation) {
|
|
9009
9075
|
console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
|
|
@@ -9024,17 +9090,19 @@ class WebRTCPhone extends Emitter {
|
|
|
9024
9090
|
this.audioOutputVolume,
|
|
9025
9091
|
);
|
|
9026
9092
|
case SessionState.Terminating:
|
|
9027
|
-
logger$
|
|
9093
|
+
logger$5.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
9028
9094
|
|
|
9029
9095
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
9030
9096
|
|
|
9031
9097
|
break;
|
|
9032
9098
|
case SessionState.Terminated: {
|
|
9033
|
-
logger$
|
|
9099
|
+
logger$5.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
9034
9100
|
|
|
9101
|
+
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
9102
|
+
const callSession = this._createCallSession(sipSession);
|
|
9035
9103
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
9036
9104
|
|
|
9037
|
-
return this.eventEmitter.emit(ON_CALL_ENDED,
|
|
9105
|
+
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
9038
9106
|
}
|
|
9039
9107
|
}
|
|
9040
9108
|
});
|
|
@@ -9050,7 +9118,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9050
9118
|
const [stream] = event.streams;
|
|
9051
9119
|
const kind = event && event.track && event.track.kind;
|
|
9052
9120
|
|
|
9053
|
-
logger$
|
|
9121
|
+
logger$5.info('on track stream called on the peer connection', {
|
|
9054
9122
|
callId: this.getSipSessionId(sipSession),
|
|
9055
9123
|
streamId: stream ? stream.id : null,
|
|
9056
9124
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -9070,7 +9138,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9070
9138
|
};
|
|
9071
9139
|
|
|
9072
9140
|
peerConnection.onremovestream = event => {
|
|
9073
|
-
logger$
|
|
9141
|
+
logger$5.info('on remove stream called on the peer connection', {
|
|
9074
9142
|
id: event.stream.id,
|
|
9075
9143
|
tracks: event.stream.getTracks(),
|
|
9076
9144
|
});
|
|
@@ -9080,7 +9148,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9080
9148
|
}
|
|
9081
9149
|
|
|
9082
9150
|
async startScreenSharing(constraints , callSession ) {
|
|
9083
|
-
logger$
|
|
9151
|
+
logger$5.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
9084
9152
|
|
|
9085
9153
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
9086
9154
|
if (!screenShareStream) {
|
|
@@ -9120,7 +9188,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9120
9188
|
return;
|
|
9121
9189
|
}
|
|
9122
9190
|
|
|
9123
|
-
logger$
|
|
9191
|
+
logger$5.info('WebRTC phone - stop screen sharing', {
|
|
9124
9192
|
restoreLocalStream,
|
|
9125
9193
|
});
|
|
9126
9194
|
|
|
@@ -9176,24 +9244,26 @@ class WebRTCPhone extends Emitter {
|
|
|
9176
9244
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
9177
9245
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
9178
9246
|
|
|
9179
|
-
logger$
|
|
9247
|
+
logger$5.info('WebRTC phone - on screensharing', {
|
|
9180
9248
|
hadVideo,
|
|
9181
9249
|
id: this.getSipSessionId(sipSession),
|
|
9182
9250
|
screenTrack,
|
|
9183
9251
|
});
|
|
9184
9252
|
|
|
9185
|
-
|
|
9186
|
-
|
|
9187
|
-
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
|
|
9253
|
+
if (screenTrack) {
|
|
9254
|
+
screenTrack.onended = () => {
|
|
9255
|
+
logger$5.info('WebRTC phone - on screenshare ended', {
|
|
9256
|
+
hadVideo,
|
|
9257
|
+
id: this.getSipSessionId(sipSession),
|
|
9258
|
+
screenTrack,
|
|
9259
|
+
});
|
|
9191
9260
|
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
|
|
9261
|
+
this.eventEmitter.emit(
|
|
9262
|
+
ON_SHARE_SCREEN_ENDING,
|
|
9263
|
+
this._createCallSession(sipSession, callSession),
|
|
9264
|
+
);
|
|
9265
|
+
};
|
|
9266
|
+
}
|
|
9197
9267
|
|
|
9198
9268
|
this.currentScreenShare = {
|
|
9199
9269
|
stream: screenStream,
|
|
@@ -9213,7 +9283,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9213
9283
|
}
|
|
9214
9284
|
|
|
9215
9285
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
9216
|
-
logger$
|
|
9286
|
+
logger$5.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
9217
9287
|
|
|
9218
9288
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
9219
9289
|
this.currentSipSession = sipSession;
|
|
@@ -9231,7 +9301,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9231
9301
|
}
|
|
9232
9302
|
|
|
9233
9303
|
changeAudioDevice(id ) {
|
|
9234
|
-
logger$
|
|
9304
|
+
logger$5.info('WebRTC phone - change audio device', { deviceId: id });
|
|
9235
9305
|
this.audioOutputDeviceId = id;
|
|
9236
9306
|
this.client.changeAudioOutputDevice(id);
|
|
9237
9307
|
}
|
|
@@ -9241,14 +9311,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9241
9311
|
}
|
|
9242
9312
|
|
|
9243
9313
|
changeRingDevice(id ) {
|
|
9244
|
-
logger$
|
|
9314
|
+
logger$5.info('WebRTC phone - changing ring device', { id });
|
|
9245
9315
|
|
|
9246
9316
|
this.audioRingDeviceId = id;
|
|
9247
9317
|
}
|
|
9248
9318
|
|
|
9249
9319
|
// volume is a value between 0 and 1
|
|
9250
9320
|
changeAudioVolume(volume ) {
|
|
9251
|
-
logger$
|
|
9321
|
+
logger$5.info('WebRTC phone - changing audio volume', { volume });
|
|
9252
9322
|
|
|
9253
9323
|
this.audioOutputVolume = volume;
|
|
9254
9324
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -9256,31 +9326,31 @@ class WebRTCPhone extends Emitter {
|
|
|
9256
9326
|
|
|
9257
9327
|
// volume is a value between 0 and 1
|
|
9258
9328
|
changeRingVolume(volume ) {
|
|
9259
|
-
logger$
|
|
9329
|
+
logger$5.info('WebRTC phone - changing ring volume', { volume });
|
|
9260
9330
|
|
|
9261
9331
|
this.audioRingVolume = volume;
|
|
9262
9332
|
}
|
|
9263
9333
|
|
|
9264
9334
|
changeAudioInputDevice(id ) {
|
|
9265
|
-
logger$
|
|
9335
|
+
logger$5.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
9266
9336
|
|
|
9267
9337
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
9268
9338
|
}
|
|
9269
9339
|
|
|
9270
9340
|
changeVideoInputDevice(id ) {
|
|
9271
|
-
logger$
|
|
9341
|
+
logger$5.info('WebRTC phone - change video input device', { deviceId: id });
|
|
9272
9342
|
|
|
9273
9343
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
9274
9344
|
}
|
|
9275
9345
|
|
|
9276
9346
|
changeSessionVideoInputDevice(id ) {
|
|
9277
|
-
logger$
|
|
9347
|
+
logger$5.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
9278
9348
|
|
|
9279
9349
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
9280
9350
|
}
|
|
9281
9351
|
|
|
9282
9352
|
_onCallTerminated(sipSession ) {
|
|
9283
|
-
logger$
|
|
9353
|
+
logger$5.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9284
9354
|
|
|
9285
9355
|
const callSession = this._createCallSession(sipSession);
|
|
9286
9356
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -9314,7 +9384,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9314
9384
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
9315
9385
|
|
|
9316
9386
|
// Re-trigger incoming call event for remaining incoming calls
|
|
9317
|
-
logger$
|
|
9387
|
+
logger$5.info('WebRTC phone - check to re-trigger incoming call', {
|
|
9318
9388
|
sipId: sipSession.id,
|
|
9319
9389
|
shouldRetrigger,
|
|
9320
9390
|
hasIncomingCallSession,
|
|
@@ -9405,37 +9475,37 @@ class WebRTCPhone extends Emitter {
|
|
|
9405
9475
|
|
|
9406
9476
|
// Deprecated
|
|
9407
9477
|
getLocalStreamForCall(callSession ) {
|
|
9408
|
-
logger$
|
|
9478
|
+
logger$5.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9409
9479
|
|
|
9410
9480
|
return this.getLocalStream(callSession);
|
|
9411
9481
|
}
|
|
9412
9482
|
|
|
9413
9483
|
// Deprecated
|
|
9414
9484
|
getRemoteStreamForCall(callSession ) {
|
|
9415
|
-
logger$
|
|
9485
|
+
logger$5.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
9416
9486
|
|
|
9417
9487
|
return this.getRemoteVideoStream(callSession);
|
|
9418
9488
|
}
|
|
9419
9489
|
|
|
9420
9490
|
getRemoteStreamsForCall(callSession ) {
|
|
9421
|
-
logger$
|
|
9491
|
+
logger$5.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
9422
9492
|
|
|
9423
9493
|
return this.getRemoteStream(callSession);
|
|
9424
9494
|
}
|
|
9425
9495
|
|
|
9426
9496
|
accept(callSession , cameraEnabled ) {
|
|
9427
|
-
logger$
|
|
9497
|
+
logger$5.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
9428
9498
|
if (this.currentSipSession) {
|
|
9429
9499
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
9430
9500
|
}
|
|
9431
9501
|
|
|
9432
9502
|
if (!callSession) {
|
|
9433
|
-
logger$
|
|
9503
|
+
logger$5.warn('no CallSession to accept.');
|
|
9434
9504
|
return Promise.resolve(null);
|
|
9435
9505
|
}
|
|
9436
9506
|
|
|
9437
9507
|
if (callSession.getId() in this.acceptedSessions) {
|
|
9438
|
-
logger$
|
|
9508
|
+
logger$5.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9439
9509
|
return Promise.resolve(callSession.sipCallId);
|
|
9440
9510
|
}
|
|
9441
9511
|
|
|
@@ -9447,24 +9517,24 @@ class WebRTCPhone extends Emitter {
|
|
|
9447
9517
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
9448
9518
|
if (sipSession) {
|
|
9449
9519
|
if (sipSession.state === SessionState.Terminated || sipSession.state === SessionState.Terminating) {
|
|
9450
|
-
logger$
|
|
9520
|
+
logger$5.warn('Trying to answer a terminated sipSession.');
|
|
9451
9521
|
|
|
9452
9522
|
return Promise.resolve(null);
|
|
9453
9523
|
}
|
|
9454
9524
|
|
|
9455
|
-
logger$
|
|
9525
|
+
logger$5.info('accept call, session found', { sipId: sipSession.id });
|
|
9456
9526
|
|
|
9457
9527
|
// $FlowFixMe
|
|
9458
9528
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
9459
9529
|
return callSession.sipCallId;
|
|
9460
9530
|
}).catch(e => {
|
|
9461
|
-
logger$
|
|
9531
|
+
logger$5.error(e);
|
|
9462
9532
|
this.endCurrentCall(callSession);
|
|
9463
9533
|
throw e;
|
|
9464
9534
|
});
|
|
9465
9535
|
}
|
|
9466
9536
|
|
|
9467
|
-
logger$
|
|
9537
|
+
logger$5.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9468
9538
|
|
|
9469
9539
|
return Promise.resolve(null);
|
|
9470
9540
|
}
|
|
@@ -9474,7 +9544,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9474
9544
|
}
|
|
9475
9545
|
|
|
9476
9546
|
async reject(callSession ) {
|
|
9477
|
-
logger$
|
|
9547
|
+
logger$5.info('reject WebRTC called', { id: callSession.getId() });
|
|
9478
9548
|
|
|
9479
9549
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
9480
9550
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -9486,14 +9556,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9486
9556
|
|
|
9487
9557
|
const sipSession = this.findSipSession(callSession);
|
|
9488
9558
|
if (sipSession) {
|
|
9489
|
-
logger$
|
|
9559
|
+
logger$5.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
9490
9560
|
|
|
9491
9561
|
this.client.hangup(sipSession);
|
|
9492
9562
|
}
|
|
9493
9563
|
}
|
|
9494
9564
|
|
|
9495
9565
|
async ignore(callSession ) {
|
|
9496
|
-
logger$
|
|
9566
|
+
logger$5.info('WebRTC ignore', { id: callSession.getId() });
|
|
9497
9567
|
|
|
9498
9568
|
// kill the ring
|
|
9499
9569
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -9505,14 +9575,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9505
9575
|
const sipSession = this.findSipSession(callSession);
|
|
9506
9576
|
|
|
9507
9577
|
if (sipSession) {
|
|
9508
|
-
logger$
|
|
9578
|
+
logger$5.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
9509
9579
|
|
|
9510
9580
|
return this.client.atxfer(sipSession);
|
|
9511
9581
|
}
|
|
9512
9582
|
}
|
|
9513
9583
|
|
|
9514
9584
|
hold(callSession , withEvent = true, isConference = false) {
|
|
9515
|
-
logger$
|
|
9585
|
+
logger$5.info('WebRTC hold', { id: callSession.getId() });
|
|
9516
9586
|
|
|
9517
9587
|
const sipSession = this.findSipSession(callSession);
|
|
9518
9588
|
|
|
@@ -9527,18 +9597,18 @@ class WebRTCPhone extends Emitter {
|
|
|
9527
9597
|
}
|
|
9528
9598
|
|
|
9529
9599
|
resume(callSession , isConference = false, withEvent = true) {
|
|
9530
|
-
logger$
|
|
9600
|
+
logger$5.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
9531
9601
|
|
|
9532
9602
|
const sipSession = this.findSipSession(callSession);
|
|
9533
9603
|
if (!sipSession) {
|
|
9534
9604
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
9535
9605
|
}
|
|
9536
9606
|
|
|
9537
|
-
logger$
|
|
9607
|
+
logger$5.info('WebRTC resuming', { sipId: sipSession.id });
|
|
9538
9608
|
|
|
9539
9609
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
9540
9610
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
9541
|
-
logger$
|
|
9611
|
+
logger$5.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
9542
9612
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
9543
9613
|
}
|
|
9544
9614
|
|
|
@@ -9563,7 +9633,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9563
9633
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9564
9634
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
9565
9635
|
|
|
9566
|
-
logger$
|
|
9636
|
+
logger$5.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9567
9637
|
|
|
9568
9638
|
// Stop screenshre if needed
|
|
9569
9639
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -9594,7 +9664,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9594
9664
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
9595
9665
|
}
|
|
9596
9666
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9597
|
-
logger$
|
|
9667
|
+
logger$5.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
9598
9668
|
|
|
9599
9669
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
9600
9670
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -9638,14 +9708,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9638
9708
|
}
|
|
9639
9709
|
|
|
9640
9710
|
mute(callSession , withEvent = true) {
|
|
9641
|
-
logger$
|
|
9711
|
+
logger$5.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
9642
9712
|
|
|
9643
9713
|
const sipSession = this.findSipSession(callSession);
|
|
9644
9714
|
if (!sipSession) {
|
|
9645
9715
|
return;
|
|
9646
9716
|
}
|
|
9647
9717
|
|
|
9648
|
-
logger$
|
|
9718
|
+
logger$5.info('WebRTC muting', { sipId: sipSession.id });
|
|
9649
9719
|
this.client.mute(sipSession);
|
|
9650
9720
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
9651
9721
|
|
|
@@ -9659,14 +9729,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9659
9729
|
}
|
|
9660
9730
|
|
|
9661
9731
|
unmute(callSession , withEvent = true) {
|
|
9662
|
-
logger$
|
|
9732
|
+
logger$5.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
9663
9733
|
|
|
9664
9734
|
const sipSession = this.findSipSession(callSession);
|
|
9665
9735
|
if (!sipSession) {
|
|
9666
9736
|
return;
|
|
9667
9737
|
}
|
|
9668
9738
|
|
|
9669
|
-
logger$
|
|
9739
|
+
logger$5.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
9670
9740
|
this.client.unmute(sipSession);
|
|
9671
9741
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
9672
9742
|
|
|
@@ -9693,7 +9763,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9693
9763
|
if (!sipSession) {
|
|
9694
9764
|
return;
|
|
9695
9765
|
}
|
|
9696
|
-
logger$
|
|
9766
|
+
logger$5.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
9697
9767
|
|
|
9698
9768
|
this.client.toggleCameraOn(sipSession);
|
|
9699
9769
|
|
|
@@ -9705,7 +9775,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9705
9775
|
if (!sipSession) {
|
|
9706
9776
|
return;
|
|
9707
9777
|
}
|
|
9708
|
-
logger$
|
|
9778
|
+
logger$5.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
9709
9779
|
|
|
9710
9780
|
this.client.toggleCameraOff(sipSession);
|
|
9711
9781
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -9717,7 +9787,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9717
9787
|
return;
|
|
9718
9788
|
}
|
|
9719
9789
|
|
|
9720
|
-
logger$
|
|
9790
|
+
logger$5.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
9721
9791
|
this.client.sendDTMF(sipSession, tone);
|
|
9722
9792
|
}
|
|
9723
9793
|
|
|
@@ -9725,7 +9795,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9725
9795
|
// @TODO: line is not used here
|
|
9726
9796
|
async makeCall(number , line , cameraEnabled ,
|
|
9727
9797
|
audioOnly = false, conference = false) {
|
|
9728
|
-
logger$
|
|
9798
|
+
logger$5.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
9729
9799
|
if (!number) {
|
|
9730
9800
|
return Promise.resolve(null);
|
|
9731
9801
|
}
|
|
@@ -9735,7 +9805,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9735
9805
|
}
|
|
9736
9806
|
if (this.currentSipSession) {
|
|
9737
9807
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
9738
|
-
logger$
|
|
9808
|
+
logger$5.warn('Unable to hold current session when making another call', e);
|
|
9739
9809
|
});
|
|
9740
9810
|
}
|
|
9741
9811
|
|
|
@@ -9745,7 +9815,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9745
9815
|
this._bindEvents(sipSession);
|
|
9746
9816
|
} catch (error) {
|
|
9747
9817
|
console.warn(error);
|
|
9748
|
-
logger$
|
|
9818
|
+
logger$5.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
9749
9819
|
return Promise.resolve(null);
|
|
9750
9820
|
}
|
|
9751
9821
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -9773,7 +9843,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9773
9843
|
return;
|
|
9774
9844
|
}
|
|
9775
9845
|
|
|
9776
|
-
logger$
|
|
9846
|
+
logger$5.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
9777
9847
|
|
|
9778
9848
|
this.client.transfer(sipSession, target);
|
|
9779
9849
|
}
|
|
@@ -9782,7 +9852,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9782
9852
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
9783
9853
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
9784
9854
|
|
|
9785
|
-
logger$
|
|
9855
|
+
logger$5.info('WebRTC indirect transfer', {
|
|
9786
9856
|
sipId: sipSession ? sipSession.id : null,
|
|
9787
9857
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
9788
9858
|
});
|
|
@@ -9821,7 +9891,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9821
9891
|
return false;
|
|
9822
9892
|
}
|
|
9823
9893
|
|
|
9824
|
-
logger$
|
|
9894
|
+
logger$5.info('WebRTC hangup', { sipId: sipSession.id });
|
|
9825
9895
|
|
|
9826
9896
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9827
9897
|
|
|
@@ -9867,7 +9937,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9867
9937
|
endCurrentCall(callSession ) {
|
|
9868
9938
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
9869
9939
|
|
|
9870
|
-
logger$
|
|
9940
|
+
logger$5.info('Ending current call', {
|
|
9871
9941
|
id: callSession ? callSession.getId() : null,
|
|
9872
9942
|
isCurrent,
|
|
9873
9943
|
});
|
|
@@ -9891,7 +9961,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9891
9961
|
}
|
|
9892
9962
|
|
|
9893
9963
|
async close() {
|
|
9894
|
-
logger$
|
|
9964
|
+
logger$5.info('WebRTC close');
|
|
9895
9965
|
|
|
9896
9966
|
try {
|
|
9897
9967
|
await Promise.race([
|
|
@@ -9899,7 +9969,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9899
9969
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
9900
9970
|
]);
|
|
9901
9971
|
} catch (e) {
|
|
9902
|
-
logger$
|
|
9972
|
+
logger$5.error('WebRTC close, unregister error', e);
|
|
9903
9973
|
}
|
|
9904
9974
|
|
|
9905
9975
|
this.client.close();
|
|
@@ -9917,12 +9987,12 @@ class WebRTCPhone extends Emitter {
|
|
|
9917
9987
|
}
|
|
9918
9988
|
|
|
9919
9989
|
enableRinging() {
|
|
9920
|
-
logger$
|
|
9990
|
+
logger$5.info('WebRTC enable ringing');
|
|
9921
9991
|
this.ringingEnabled = true;
|
|
9922
9992
|
}
|
|
9923
9993
|
|
|
9924
9994
|
disableRinging() {
|
|
9925
|
-
logger$
|
|
9995
|
+
logger$5.info('WebRTC disable ringing');
|
|
9926
9996
|
this.ringingEnabled = false;
|
|
9927
9997
|
}
|
|
9928
9998
|
|
|
@@ -9962,7 +10032,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9962
10032
|
|
|
9963
10033
|
// Deprecated
|
|
9964
10034
|
getLocalMediaStream(callSession ) {
|
|
9965
|
-
logger$
|
|
10035
|
+
logger$5.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9966
10036
|
return this.getLocalStream(callSession);
|
|
9967
10037
|
}
|
|
9968
10038
|
|
|
@@ -9982,6 +10052,10 @@ class WebRTCPhone extends Emitter {
|
|
|
9982
10052
|
return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
|
|
9983
10053
|
}
|
|
9984
10054
|
|
|
10055
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
10056
|
+
return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
|
|
10057
|
+
}
|
|
10058
|
+
|
|
9985
10059
|
hasRemoteVideo(callSession ) {
|
|
9986
10060
|
return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
|
|
9987
10061
|
}
|
|
@@ -10000,7 +10074,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10000
10074
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
10001
10075
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
10002
10076
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
10003
|
-
logger$
|
|
10077
|
+
logger$5.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
10004
10078
|
|
|
10005
10079
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
10006
10080
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -10023,7 +10097,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10023
10097
|
});
|
|
10024
10098
|
|
|
10025
10099
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
10026
|
-
logger$
|
|
10100
|
+
logger$5.info('WebRTC on reinvite', {
|
|
10027
10101
|
sessionId: args[0].id,
|
|
10028
10102
|
inviteId: args[1].id,
|
|
10029
10103
|
updatedCalleeName: args[2],
|
|
@@ -10043,7 +10117,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10043
10117
|
});
|
|
10044
10118
|
|
|
10045
10119
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
10046
|
-
logger$
|
|
10120
|
+
logger$5.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
10047
10121
|
|
|
10048
10122
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
10049
10123
|
|
|
@@ -10054,22 +10128,22 @@ class WebRTCPhone extends Emitter {
|
|
|
10054
10128
|
this.client.on('ended', () => {});
|
|
10055
10129
|
|
|
10056
10130
|
this.client.on(this.client.ON_ERROR, e => {
|
|
10057
|
-
logger$
|
|
10131
|
+
logger$5.error('WebRTC error', e);
|
|
10058
10132
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
10059
10133
|
});
|
|
10060
10134
|
|
|
10061
10135
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
10062
|
-
logger$
|
|
10136
|
+
logger$5.info('WebRTC unregistered');
|
|
10063
10137
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10064
10138
|
});
|
|
10065
10139
|
|
|
10066
10140
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
10067
|
-
logger$
|
|
10068
|
-
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
10141
|
+
logger$5.info('WebRTC disconnected');
|
|
10142
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
10069
10143
|
});
|
|
10070
10144
|
|
|
10071
10145
|
this.client.on(this.client.REGISTERED, () => {
|
|
10072
|
-
logger$
|
|
10146
|
+
logger$5.info('WebRTC registered', {
|
|
10073
10147
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
10074
10148
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
10075
10149
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -10082,23 +10156,27 @@ class WebRTCPhone extends Emitter {
|
|
|
10082
10156
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
10083
10157
|
&& this.currentSipSession.state === SessionState.Established) {
|
|
10084
10158
|
this.shouldSendReinvite = false;
|
|
10159
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
10160
|
+
const isConference = pc ? pc.sfu : false;
|
|
10161
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
10162
|
+
|
|
10085
10163
|
try {
|
|
10086
10164
|
// Send reinvite with iceRestart
|
|
10087
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
10165
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
10088
10166
|
} catch (e) {
|
|
10089
|
-
logger$
|
|
10167
|
+
logger$5.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
10090
10168
|
}
|
|
10091
10169
|
}
|
|
10092
10170
|
});
|
|
10093
10171
|
|
|
10094
10172
|
this.client.on(this.client.CONNECTED, () => {
|
|
10095
|
-
logger$
|
|
10173
|
+
logger$5.info('WebRTC client connected');
|
|
10096
10174
|
|
|
10097
10175
|
this.stopHeartbeat();
|
|
10098
10176
|
});
|
|
10099
10177
|
|
|
10100
10178
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10101
|
-
logger$
|
|
10179
|
+
logger$5.info('WebRTC client disconnected');
|
|
10102
10180
|
|
|
10103
10181
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10104
10182
|
|
|
@@ -10112,7 +10190,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10112
10190
|
});
|
|
10113
10191
|
|
|
10114
10192
|
this.client.on(this.client.ON_TRACK, (session, event) => {
|
|
10115
|
-
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
10193
|
+
this.eventEmitter.emit(ON_TRACK$1, session, event);
|
|
10116
10194
|
});
|
|
10117
10195
|
|
|
10118
10196
|
this.client.on('onVideoInputChange', stream => {
|
|
@@ -10127,7 +10205,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10127
10205
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
10128
10206
|
const callSession = this.getCallSession(this.getSipSessionId(session));
|
|
10129
10207
|
|
|
10130
|
-
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
10208
|
+
this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
|
|
10131
10209
|
});
|
|
10132
10210
|
|
|
10133
10211
|
// Used when upgrading directly in screenshare mode
|
|
@@ -10136,7 +10214,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10136
10214
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
10137
10215
|
const callSession = this.callSessions[sipSessionId];
|
|
10138
10216
|
|
|
10139
|
-
logger$
|
|
10217
|
+
logger$5.info('Updrading directly in screensharing mode', {
|
|
10140
10218
|
sipSessionId,
|
|
10141
10219
|
tracks: localStream ? localStream.getTracks() : null,
|
|
10142
10220
|
});
|
|
@@ -10168,6 +10246,15 @@ class WebRTCPhone extends Emitter {
|
|
|
10168
10246
|
return this.client.getSipSessionId(sipSession);
|
|
10169
10247
|
}
|
|
10170
10248
|
|
|
10249
|
+
_updateCallSession(callSession ) {
|
|
10250
|
+
const sipSession = this.findSipSession(callSession);
|
|
10251
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
10252
|
+
|
|
10253
|
+
if (sipSessionId) {
|
|
10254
|
+
this.callSessions[sipSessionId] = callSession;
|
|
10255
|
+
}
|
|
10256
|
+
}
|
|
10257
|
+
|
|
10171
10258
|
_onMessage(message ) {
|
|
10172
10259
|
if (!message || message.method !== 'MESSAGE') {
|
|
10173
10260
|
return;
|
|
@@ -10305,8 +10392,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10305
10392
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10306
10393
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10307
10394
|
ON_MESSAGE: ON_MESSAGE,
|
|
10308
|
-
ON_REINVITE: ON_REINVITE,
|
|
10309
|
-
ON_TRACK: ON_TRACK,
|
|
10395
|
+
ON_REINVITE: ON_REINVITE$1,
|
|
10396
|
+
ON_TRACK: ON_TRACK$1,
|
|
10310
10397
|
ON_AUDIO_STREAM: ON_AUDIO_STREAM,
|
|
10311
10398
|
ON_VIDEO_STREAM: ON_VIDEO_STREAM,
|
|
10312
10399
|
ON_REMOVE_STREAM: ON_REMOVE_STREAM,
|
|
@@ -10321,13 +10408,13 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10321
10408
|
ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
|
|
10322
10409
|
ON_CALL_ERROR: ON_CALL_ERROR,
|
|
10323
10410
|
ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
|
|
10324
|
-
ON_NETWORK_STATS: ON_NETWORK_STATS,
|
|
10411
|
+
ON_NETWORK_STATS: ON_NETWORK_STATS$1,
|
|
10325
10412
|
ON_CHAT: ON_CHAT,
|
|
10326
10413
|
ON_SIGNAL: ON_SIGNAL,
|
|
10327
|
-
ON_DISCONNECTED: ON_DISCONNECTED,
|
|
10414
|
+
ON_DISCONNECTED: ON_DISCONNECTED$1,
|
|
10328
10415
|
MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
|
|
10329
10416
|
MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
|
|
10330
|
-
events: events,
|
|
10417
|
+
events: events$1,
|
|
10331
10418
|
'default': WebRTCPhone
|
|
10332
10419
|
});
|
|
10333
10420
|
|
|
@@ -10665,6 +10752,11 @@ class Phone extends Emitter {
|
|
|
10665
10752
|
return this.getRemoteVideoStream(callSession);
|
|
10666
10753
|
}
|
|
10667
10754
|
|
|
10755
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
10756
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
10757
|
+
return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
|
|
10758
|
+
}
|
|
10759
|
+
|
|
10668
10760
|
hasVideo(callSession ) {
|
|
10669
10761
|
return this.phone ? this.phone.hasVideo(callSession) : false;
|
|
10670
10762
|
}
|
|
@@ -10716,7 +10808,7 @@ class Phone extends Emitter {
|
|
|
10716
10808
|
|
|
10717
10809
|
_transferEvents() {
|
|
10718
10810
|
this.unbind();
|
|
10719
|
-
[...events
|
|
10811
|
+
[...events, ...transportEvents].forEach(event => {
|
|
10720
10812
|
this.client.on(event, (...args) =>
|
|
10721
10813
|
this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
|
|
10722
10814
|
});
|
|
@@ -10738,7 +10830,7 @@ var Phone$1 = global.wazoTelephonyInstance;
|
|
|
10738
10830
|
|
|
10739
10831
|
//
|
|
10740
10832
|
|
|
10741
|
-
const SOCKET_EVENTS
|
|
10833
|
+
const SOCKET_EVENTS = {
|
|
10742
10834
|
ON_OPEN: 'onopen',
|
|
10743
10835
|
ON_MESSAGE: 'onmessage',
|
|
10744
10836
|
ON_ERROR: 'onerror',
|
|
@@ -10824,6 +10916,7 @@ const AGENT_PAUSED = 'agent_paused';
|
|
|
10824
10916
|
const AGENT_UNPAUSED = 'agent_unpaused';
|
|
10825
10917
|
const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
|
|
10826
10918
|
const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
|
|
10919
|
+
const MEETING_USER_PROGRESS = 'meeting_user_progress';
|
|
10827
10920
|
|
|
10828
10921
|
const BLACKLIST_EVENTS = [
|
|
10829
10922
|
CHAT_MESSAGE_SENT,
|
|
@@ -10833,7 +10926,7 @@ const BLACKLIST_EVENTS = [
|
|
|
10833
10926
|
];
|
|
10834
10927
|
|
|
10835
10928
|
const HEARTBEAT_ENGINE_VERSION = '20.09';
|
|
10836
|
-
const logger$
|
|
10929
|
+
const logger$7 = IssueReporter$1.loggerFor('wazo-ws');
|
|
10837
10930
|
const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
|
|
10838
10931
|
|
|
10839
10932
|
class WebSocketClient extends Emitter {
|
|
@@ -10882,24 +10975,24 @@ class WebSocketClient extends Emitter {
|
|
|
10882
10975
|
}
|
|
10883
10976
|
|
|
10884
10977
|
connect() {
|
|
10885
|
-
logger$
|
|
10978
|
+
logger$7.info('connect method started', { host: this.host, token: this.token });
|
|
10886
10979
|
this.socket = new ReconnectingWebSocket(this._getUrl.bind(this), [], this.options);
|
|
10887
10980
|
if (this.options.binaryType) {
|
|
10888
10981
|
this.socket.binaryType = this.options.binaryType;
|
|
10889
10982
|
}
|
|
10890
10983
|
|
|
10891
10984
|
this.socket.onopen = () => {
|
|
10892
|
-
logger$
|
|
10893
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10985
|
+
logger$7.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
10986
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
10894
10987
|
};
|
|
10895
10988
|
|
|
10896
10989
|
this.socket.onerror = event => {
|
|
10897
|
-
logger$
|
|
10898
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10990
|
+
logger$7.error('on Wazo WS error', event.target);
|
|
10991
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
10899
10992
|
};
|
|
10900
10993
|
|
|
10901
10994
|
this.socket.onmessage = (event ) => {
|
|
10902
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10995
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
|
|
10903
10996
|
|
|
10904
10997
|
const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
|
|
10905
10998
|
let { name } = message;
|
|
@@ -10924,7 +11017,7 @@ class WebSocketClient extends Emitter {
|
|
|
10924
11017
|
|
|
10925
11018
|
this.socket.onclose = event => {
|
|
10926
11019
|
// Can't be converted to JSON (circular structure)
|
|
10927
|
-
logger$
|
|
11020
|
+
logger$7.info('on Wazo WS close', {
|
|
10928
11021
|
reason: event.reason,
|
|
10929
11022
|
code: event.code,
|
|
10930
11023
|
readyState: event.target.readyState,
|
|
@@ -10932,22 +11025,22 @@ class WebSocketClient extends Emitter {
|
|
|
10932
11025
|
token: this.token,
|
|
10933
11026
|
});
|
|
10934
11027
|
this.initialized = false;
|
|
10935
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11028
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
|
|
10936
11029
|
|
|
10937
11030
|
switch (event.code) {
|
|
10938
11031
|
case 4002:
|
|
10939
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11032
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
|
|
10940
11033
|
break;
|
|
10941
11034
|
}
|
|
10942
11035
|
};
|
|
10943
11036
|
|
|
10944
11037
|
this.socket.onerror = event => {
|
|
10945
|
-
logger$
|
|
11038
|
+
logger$7.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
10946
11039
|
};
|
|
10947
11040
|
}
|
|
10948
11041
|
|
|
10949
11042
|
close(force = false) {
|
|
10950
|
-
logger$
|
|
11043
|
+
logger$7.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
10951
11044
|
|
|
10952
11045
|
if (!this.socket) {
|
|
10953
11046
|
return;
|
|
@@ -10965,7 +11058,7 @@ class WebSocketClient extends Emitter {
|
|
|
10965
11058
|
|
|
10966
11059
|
updateToken(token ) {
|
|
10967
11060
|
this.token = token;
|
|
10968
|
-
logger$
|
|
11061
|
+
logger$7.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
10969
11062
|
|
|
10970
11063
|
if (this.socket) {
|
|
10971
11064
|
// If still connected, send the token to the WS
|
|
@@ -10983,7 +11076,7 @@ class WebSocketClient extends Emitter {
|
|
|
10983
11076
|
}
|
|
10984
11077
|
|
|
10985
11078
|
startHeartbeat() {
|
|
10986
|
-
logger$
|
|
11079
|
+
logger$7.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
10987
11080
|
|
|
10988
11081
|
if (!this.socket) {
|
|
10989
11082
|
this.heartbeat.stop();
|
|
@@ -10997,7 +11090,7 @@ class WebSocketClient extends Emitter {
|
|
|
10997
11090
|
}
|
|
10998
11091
|
|
|
10999
11092
|
stopHeartbeat() {
|
|
11000
|
-
logger$
|
|
11093
|
+
logger$7.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
11001
11094
|
|
|
11002
11095
|
this.heartbeat.stop();
|
|
11003
11096
|
}
|
|
@@ -11027,7 +11120,7 @@ class WebSocketClient extends Emitter {
|
|
|
11027
11120
|
}
|
|
11028
11121
|
|
|
11029
11122
|
reconnect(reason ) {
|
|
11030
|
-
logger$
|
|
11123
|
+
logger$7.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
11031
11124
|
if (!this.socket) {
|
|
11032
11125
|
return;
|
|
11033
11126
|
}
|
|
@@ -11052,7 +11145,7 @@ class WebSocketClient extends Emitter {
|
|
|
11052
11145
|
break;
|
|
11053
11146
|
case 'start':
|
|
11054
11147
|
this.initialized = true;
|
|
11055
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11148
|
+
this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
|
|
11056
11149
|
break;
|
|
11057
11150
|
default:
|
|
11058
11151
|
this.eventEmitter.emit('message', message);
|
|
@@ -11083,7 +11176,7 @@ class WebSocketClient extends Emitter {
|
|
|
11083
11176
|
this.close();
|
|
11084
11177
|
}
|
|
11085
11178
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
11086
|
-
logger$
|
|
11179
|
+
logger$7.log('Wazo WS url computed to reconnect', { url });
|
|
11087
11180
|
|
|
11088
11181
|
return url;
|
|
11089
11182
|
}
|
|
@@ -11091,15 +11184,15 @@ class WebSocketClient extends Emitter {
|
|
|
11091
11184
|
_onHeartbeat(message ) {
|
|
11092
11185
|
if (message.payload === 'pong') {
|
|
11093
11186
|
this.heartbeat.onHeartbeat();
|
|
11094
|
-
logger$
|
|
11187
|
+
logger$7.log('on heartbeat received from Wazo WS');
|
|
11095
11188
|
}
|
|
11096
11189
|
}
|
|
11097
11190
|
|
|
11098
11191
|
async _onHeartbeatTimeout() {
|
|
11099
|
-
logger$
|
|
11192
|
+
logger$7.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
11100
11193
|
|
|
11101
11194
|
this.close();
|
|
11102
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11195
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
11103
11196
|
|
|
11104
11197
|
if (this.onHeartBeatTimeout) {
|
|
11105
11198
|
this.onHeartBeatTimeout();
|
|
@@ -11174,11 +11267,12 @@ WebSocketClient.eventLists = [
|
|
|
11174
11267
|
AGENT_UNPAUSED,
|
|
11175
11268
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
11176
11269
|
CONFERENCE_ADHOC_DELETED,
|
|
11270
|
+
MEETING_USER_PROGRESS,
|
|
11177
11271
|
];
|
|
11178
11272
|
|
|
11179
11273
|
var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
11180
11274
|
__proto__: null,
|
|
11181
|
-
SOCKET_EVENTS: SOCKET_EVENTS
|
|
11275
|
+
SOCKET_EVENTS: SOCKET_EVENTS,
|
|
11182
11276
|
AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
|
|
11183
11277
|
FAVORITE_ADDED: FAVORITE_ADDED,
|
|
11184
11278
|
FAVORITE_DELETED: FAVORITE_DELETED,
|
|
@@ -11244,16 +11338,17 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
11244
11338
|
AGENT_UNPAUSED: AGENT_UNPAUSED,
|
|
11245
11339
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
11246
11340
|
CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
|
|
11341
|
+
MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
|
|
11247
11342
|
HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
|
|
11248
11343
|
'default': WebSocketClient
|
|
11249
11344
|
});
|
|
11250
11345
|
|
|
11251
11346
|
//
|
|
11252
11347
|
|
|
11253
|
-
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
11254
|
-
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
11348
|
+
const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
11349
|
+
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
|
|
11255
11350
|
|
|
11256
|
-
const logger$
|
|
11351
|
+
const logger$8 = IssueReporter$1.loggerFor('simple-ws-client');
|
|
11257
11352
|
|
|
11258
11353
|
class Websocket extends Emitter {
|
|
11259
11354
|
|
|
@@ -11267,9 +11362,9 @@ class Websocket extends Emitter {
|
|
|
11267
11362
|
// $FlowFixMe
|
|
11268
11363
|
this[key] = OTHER_EVENTS[key];
|
|
11269
11364
|
});
|
|
11270
|
-
Object.keys(SOCKET_EVENTS).forEach(key => {
|
|
11365
|
+
Object.keys(SOCKET_EVENTS$1).forEach(key => {
|
|
11271
11366
|
// $FlowFixMe
|
|
11272
|
-
this[key] = SOCKET_EVENTS[key];
|
|
11367
|
+
this[key] = SOCKET_EVENTS$1[key];
|
|
11273
11368
|
});
|
|
11274
11369
|
this.eventLists = WebSocketClient.eventLists;
|
|
11275
11370
|
|
|
@@ -11277,7 +11372,7 @@ class Websocket extends Emitter {
|
|
|
11277
11372
|
}
|
|
11278
11373
|
|
|
11279
11374
|
open(host , session ) {
|
|
11280
|
-
logger$
|
|
11375
|
+
logger$8.info('open simple WebSocket', { host, token: session.token });
|
|
11281
11376
|
this.ws = new WebSocketClient(
|
|
11282
11377
|
{
|
|
11283
11378
|
host,
|
|
@@ -11305,7 +11400,7 @@ class Websocket extends Emitter {
|
|
|
11305
11400
|
}
|
|
11306
11401
|
|
|
11307
11402
|
updateToken(token ) {
|
|
11308
|
-
logger$
|
|
11403
|
+
logger$8.info('update token via simple Websocket', { token, ws: !!this.ws });
|
|
11309
11404
|
|
|
11310
11405
|
if (!this.ws) {
|
|
11311
11406
|
return;
|
|
@@ -11333,12 +11428,12 @@ var Websocket$1 = global.wazoWebsocketInstance;
|
|
|
11333
11428
|
|
|
11334
11429
|
//
|
|
11335
11430
|
|
|
11336
|
-
const logger$
|
|
11431
|
+
const logger$9 = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
11337
11432
|
|
|
11338
|
-
class SipRoom extends Room {
|
|
11433
|
+
class SipRoom extends Room$1 {
|
|
11339
11434
|
|
|
11340
11435
|
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
11341
|
-
logger$
|
|
11436
|
+
logger$9.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
11342
11437
|
|
|
11343
11438
|
if (!room) {
|
|
11344
11439
|
await Wazo.Phone.connect();
|
|
@@ -11354,7 +11449,7 @@ class SipRoom extends Room {
|
|
|
11354
11449
|
room.setCallId(room.callSession.call.id);
|
|
11355
11450
|
}
|
|
11356
11451
|
|
|
11357
|
-
logger$
|
|
11452
|
+
logger$9.info('connected to room', {
|
|
11358
11453
|
extension: room.extension,
|
|
11359
11454
|
});
|
|
11360
11455
|
|
|
@@ -11362,7 +11457,7 @@ class SipRoom extends Room {
|
|
|
11362
11457
|
}
|
|
11363
11458
|
|
|
11364
11459
|
mute() {
|
|
11365
|
-
logger$
|
|
11460
|
+
logger$9.info('mute sip room');
|
|
11366
11461
|
|
|
11367
11462
|
Wazo.Phone.mute(this.callSession, false);
|
|
11368
11463
|
|
|
@@ -11370,7 +11465,7 @@ class SipRoom extends Room {
|
|
|
11370
11465
|
}
|
|
11371
11466
|
|
|
11372
11467
|
unmute() {
|
|
11373
|
-
logger$
|
|
11468
|
+
logger$9.info('unmute sip room');
|
|
11374
11469
|
|
|
11375
11470
|
Wazo.Phone.unmute(this.callSession, false);
|
|
11376
11471
|
|
|
@@ -11472,7 +11567,7 @@ class SipRoom extends Room {
|
|
|
11472
11567
|
|
|
11473
11568
|
//
|
|
11474
11569
|
|
|
11475
|
-
const logger$
|
|
11570
|
+
const logger$a = IssueReporter$1.loggerFor('room');
|
|
11476
11571
|
|
|
11477
11572
|
class Participant extends Emitter {
|
|
11478
11573
|
|
|
@@ -11594,7 +11689,7 @@ class Participant extends Emitter {
|
|
|
11594
11689
|
}
|
|
11595
11690
|
|
|
11596
11691
|
onTalking(isTalking ) {
|
|
11597
|
-
logger$
|
|
11692
|
+
logger$a.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
|
|
11598
11693
|
this.isTalking = isTalking;
|
|
11599
11694
|
// you may notice we're not broadcasting: since all participants are getting this info
|
|
11600
11695
|
// directly from asterisk, there's no need to do so
|
|
@@ -11697,7 +11792,7 @@ class Participant extends Emitter {
|
|
|
11697
11792
|
}
|
|
11698
11793
|
|
|
11699
11794
|
updateStatus(status , broadcast = true) {
|
|
11700
|
-
logger$
|
|
11795
|
+
logger$a.info('updating participant status', { name: this.name, status });
|
|
11701
11796
|
|
|
11702
11797
|
if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
|
|
11703
11798
|
if (status.audioMuted) {
|
|
@@ -11745,7 +11840,7 @@ class Participant extends Emitter {
|
|
|
11745
11840
|
|
|
11746
11841
|
broadcastStatus(inboundStatus = null) {
|
|
11747
11842
|
const status = inboundStatus || this.getStatus();
|
|
11748
|
-
logger$
|
|
11843
|
+
logger$a.info('broadcasting participant status', { callId: this.callId, status });
|
|
11749
11844
|
|
|
11750
11845
|
this.room.sendSignal({
|
|
11751
11846
|
type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
|
|
@@ -11960,7 +12055,7 @@ class NotificationOptions {
|
|
|
11960
12055
|
|
|
11961
12056
|
|
|
11962
12057
|
// Represents a conference room, like `9000`.
|
|
11963
|
-
class Room
|
|
12058
|
+
class Room {
|
|
11964
12059
|
|
|
11965
12060
|
|
|
11966
12061
|
|
|
@@ -11981,7 +12076,7 @@ class Room$1 {
|
|
|
11981
12076
|
}
|
|
11982
12077
|
|
|
11983
12078
|
connect(callSession ) {
|
|
11984
|
-
return new Room
|
|
12079
|
+
return new Room({ ...this, connectedCallSession: callSession });
|
|
11985
12080
|
}
|
|
11986
12081
|
|
|
11987
12082
|
has(callSession ) {
|
|
@@ -11990,7 +12085,7 @@ class Room$1 {
|
|
|
11990
12085
|
|
|
11991
12086
|
addParticipant(uuid , extension , talking = null) {
|
|
11992
12087
|
if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
|
|
11993
|
-
return new Room
|
|
12088
|
+
return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
11994
12089
|
}
|
|
11995
12090
|
|
|
11996
12091
|
return this;
|
|
@@ -12009,7 +12104,7 @@ class Room$1 {
|
|
|
12009
12104
|
updatedParticipants.push(participant);
|
|
12010
12105
|
}
|
|
12011
12106
|
|
|
12012
|
-
return new Room
|
|
12107
|
+
return new Room({ ...this, participants: updatedParticipants });
|
|
12013
12108
|
}
|
|
12014
12109
|
|
|
12015
12110
|
updateParticipantByExtension(extension , participant , shouldAdd = false) {
|
|
@@ -12025,7 +12120,7 @@ class Room$1 {
|
|
|
12025
12120
|
updatedParticipants.push(participant);
|
|
12026
12121
|
}
|
|
12027
12122
|
|
|
12028
|
-
return new Room
|
|
12123
|
+
return new Room({ ...this, participants: updatedParticipants });
|
|
12029
12124
|
}
|
|
12030
12125
|
|
|
12031
12126
|
hasCallWithId(id ) {
|
|
@@ -12033,18 +12128,18 @@ class Room$1 {
|
|
|
12033
12128
|
}
|
|
12034
12129
|
|
|
12035
12130
|
disconnect() {
|
|
12036
|
-
return new Room
|
|
12131
|
+
return new Room({ ...this, connectedCallSession: null });
|
|
12037
12132
|
}
|
|
12038
12133
|
|
|
12039
12134
|
removeParticipantWithUUID(uuid ) {
|
|
12040
|
-
return new Room
|
|
12135
|
+
return new Room({
|
|
12041
12136
|
...this,
|
|
12042
12137
|
participants: this.participants.filter(participant => participant.uuid !== uuid),
|
|
12043
12138
|
});
|
|
12044
12139
|
}
|
|
12045
12140
|
|
|
12046
12141
|
removeParticipantWithExtension(extension ) {
|
|
12047
|
-
return new Room
|
|
12142
|
+
return new Room({
|
|
12048
12143
|
...this,
|
|
12049
12144
|
participants: this.participants.filter(participant => participant.extension !== extension),
|
|
12050
12145
|
});
|
|
@@ -12055,7 +12150,7 @@ class Room$1 {
|
|
|
12055
12150
|
}
|
|
12056
12151
|
|
|
12057
12152
|
static newFrom(room ) {
|
|
12058
|
-
return newFrom(room, Room
|
|
12153
|
+
return newFrom(room, Room);
|
|
12059
12154
|
}
|
|
12060
12155
|
}
|
|
12061
12156
|
|
|
@@ -12362,11 +12457,11 @@ var wazoWebsocket = {
|
|
|
12362
12457
|
resolve();
|
|
12363
12458
|
};
|
|
12364
12459
|
|
|
12365
|
-
client.on(SOCKET_EVENTS
|
|
12460
|
+
client.on(SOCKET_EVENTS.ON_ERROR, error => {
|
|
12366
12461
|
handleError(`Connection error : ${error}`);
|
|
12367
12462
|
});
|
|
12368
12463
|
|
|
12369
|
-
client.on(SOCKET_EVENTS
|
|
12464
|
+
client.on(SOCKET_EVENTS.ON_OPEN, () => {
|
|
12370
12465
|
if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
|
|
12371
12466
|
client.setOnHeartbeatTimeout(() => {
|
|
12372
12467
|
handleError('No response to heartbeat');
|
|
@@ -12467,7 +12562,7 @@ var webrtc = {
|
|
|
12467
12562
|
}),
|
|
12468
12563
|
};
|
|
12469
12564
|
|
|
12470
|
-
const parseCandidate = line => {
|
|
12565
|
+
const parseCandidate$1 = line => {
|
|
12471
12566
|
let parts;
|
|
12472
12567
|
// Parse both variants.
|
|
12473
12568
|
if (line.indexOf('a=candidate:') === 0) {
|
|
@@ -12558,7 +12653,7 @@ var SymmetricNat = {
|
|
|
12558
12653
|
}
|
|
12559
12654
|
|
|
12560
12655
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
12561
|
-
const cand = parseCandidate(e.candidate.candidate);
|
|
12656
|
+
const cand = parseCandidate$1(e.candidate.candidate);
|
|
12562
12657
|
if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
|
|
12563
12658
|
candidates[cand.relatedPort].push(cand.port);
|
|
12564
12659
|
} else if (!e.candidate) {
|
|
@@ -12626,7 +12721,7 @@ var iceIpv4 = {
|
|
|
12626
12721
|
const rawCandidate = e.candidate.candidate;
|
|
12627
12722
|
if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
|
|
12628
12723
|
hasSrflxOrRelay = true;
|
|
12629
|
-
const candidate = parseCandidate(e.candidate.candidate);
|
|
12724
|
+
const candidate = parseCandidate$1(e.candidate.candidate);
|
|
12630
12725
|
ips.push(candidate.ip);
|
|
12631
12726
|
}
|
|
12632
12727
|
} else if (!e.candidate) {
|
|
@@ -12663,7 +12758,7 @@ var checks = [
|
|
|
12663
12758
|
|
|
12664
12759
|
//
|
|
12665
12760
|
|
|
12666
|
-
const logger$
|
|
12761
|
+
const logger$b = IssueReporter$1.loggerFor('engine-check');
|
|
12667
12762
|
|
|
12668
12763
|
class Checker {
|
|
12669
12764
|
|
|
@@ -12681,28 +12776,28 @@ class Checker {
|
|
|
12681
12776
|
async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
|
|
12682
12777
|
await this._addEngineVersion();
|
|
12683
12778
|
|
|
12684
|
-
logger$
|
|
12779
|
+
logger$b.info('Engine check starting');
|
|
12685
12780
|
|
|
12686
12781
|
for (let i = 0; i < this.checks.length; i++) {
|
|
12687
12782
|
const { name, check } = this.checks[i];
|
|
12688
12783
|
|
|
12689
|
-
logger$
|
|
12784
|
+
logger$b.info(`Checking ${name} ...`);
|
|
12690
12785
|
|
|
12691
12786
|
onCheckBegin(name);
|
|
12692
12787
|
try {
|
|
12693
12788
|
// eslint-disable-next-line no-await-in-loop
|
|
12694
12789
|
const result = await check(this.server, this.session, this.externalAppConfig);
|
|
12695
|
-
logger$
|
|
12790
|
+
logger$b.info(`Checking ${name} success.`, { result });
|
|
12696
12791
|
|
|
12697
12792
|
onCheckResult(name, result);
|
|
12698
12793
|
} catch (e) {
|
|
12699
|
-
logger$
|
|
12794
|
+
logger$b.info(`Checking ${name} failure`, { message: e.message });
|
|
12700
12795
|
|
|
12701
12796
|
onCheckResult(name, e);
|
|
12702
12797
|
}
|
|
12703
12798
|
}
|
|
12704
12799
|
|
|
12705
|
-
logger$
|
|
12800
|
+
logger$b.info('Engine check done.');
|
|
12706
12801
|
}
|
|
12707
12802
|
|
|
12708
12803
|
addCheck(check ) {
|
|
@@ -12726,7 +12821,7 @@ const Wazo = {
|
|
|
12726
12821
|
Auth: Auth$1,
|
|
12727
12822
|
Phone: Phone$1,
|
|
12728
12823
|
Websocket: Websocket$1,
|
|
12729
|
-
Room,
|
|
12824
|
+
Room: Room$1,
|
|
12730
12825
|
SipRoom,
|
|
12731
12826
|
RemoteParticipant,
|
|
12732
12827
|
LocalParticipant,
|
|
@@ -12759,7 +12854,7 @@ const Wazo = {
|
|
|
12759
12854
|
Session,
|
|
12760
12855
|
Voicemail,
|
|
12761
12856
|
Relocation,
|
|
12762
|
-
ConferenceRoom: Room
|
|
12857
|
+
ConferenceRoom: Room,
|
|
12763
12858
|
CallSession,
|
|
12764
12859
|
IndirectTransfer,
|
|
12765
12860
|
SwitchboardCall,
|
|
@@ -12798,9 +12893,9 @@ if (global) {
|
|
|
12798
12893
|
const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
12799
12894
|
const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
12800
12895
|
|
|
12801
|
-
const logger = IssueReporter$1.loggerFor('sdk-room');
|
|
12896
|
+
const logger$c = IssueReporter$1.loggerFor('sdk-room');
|
|
12802
12897
|
|
|
12803
|
-
class Room extends Emitter {
|
|
12898
|
+
class Room$1 extends Emitter {
|
|
12804
12899
|
|
|
12805
12900
|
|
|
12806
12901
|
|
|
@@ -12858,7 +12953,7 @@ class Room extends Emitter {
|
|
|
12858
12953
|
extra = {},
|
|
12859
12954
|
) {
|
|
12860
12955
|
super();
|
|
12861
|
-
logger.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
12956
|
+
logger$c.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
12862
12957
|
|
|
12863
12958
|
// Represents the room callSession
|
|
12864
12959
|
this.callSession = callSession;
|
|
@@ -12924,7 +13019,7 @@ class Room extends Emitter {
|
|
|
12924
13019
|
* @returns {Promise<Room>}
|
|
12925
13020
|
*/
|
|
12926
13021
|
static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
|
|
12927
|
-
logger.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
13022
|
+
logger$c.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
12928
13023
|
|
|
12929
13024
|
if (!room) {
|
|
12930
13025
|
await Wazo.Phone.connect();
|
|
@@ -12937,7 +13032,7 @@ class Room extends Emitter {
|
|
|
12937
13032
|
|
|
12938
13033
|
// Call_created is triggered before call_accepted, so we have to listen for it here.
|
|
12939
13034
|
Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
|
|
12940
|
-
logger.info('room call received via WS', { callId: data.call_id });
|
|
13035
|
+
logger$c.info('room call received via WS', { callId: data.call_id });
|
|
12941
13036
|
if (room) {
|
|
12942
13037
|
room.setCallId(data.call_id);
|
|
12943
13038
|
}
|
|
@@ -12945,7 +13040,7 @@ class Room extends Emitter {
|
|
|
12945
13040
|
|
|
12946
13041
|
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
12947
13042
|
// eslint-disable-next-line no-param-reassign
|
|
12948
|
-
room = new Room(callSession, extension, null, null, extra);
|
|
13043
|
+
room = new Room$1(callSession, extension, null, null, extra);
|
|
12949
13044
|
|
|
12950
13045
|
// Wait for the call to be accepted
|
|
12951
13046
|
await new Promise((resolve, reject) => {
|
|
@@ -12966,7 +13061,7 @@ class Room extends Emitter {
|
|
|
12966
13061
|
// Retrieve conference
|
|
12967
13062
|
const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
|
|
12968
13063
|
|
|
12969
|
-
logger.info('connected to room', {
|
|
13064
|
+
logger$c.info('connected to room', {
|
|
12970
13065
|
sourceId: conference ? conference.sourceId : null,
|
|
12971
13066
|
name: conference ? conference.name : null,
|
|
12972
13067
|
});
|
|
@@ -12976,7 +13071,7 @@ class Room extends Emitter {
|
|
|
12976
13071
|
room.setName(conference.name);
|
|
12977
13072
|
}
|
|
12978
13073
|
} else if (meeting) {
|
|
12979
|
-
logger.info('Already connected to meeting', {
|
|
13074
|
+
logger$c.info('Already connected to meeting', {
|
|
12980
13075
|
uuid: meeting.uuid,
|
|
12981
13076
|
name: meeting.name,
|
|
12982
13077
|
});
|
|
@@ -12989,13 +13084,13 @@ class Room extends Emitter {
|
|
|
12989
13084
|
}
|
|
12990
13085
|
|
|
12991
13086
|
static disconnect() {
|
|
12992
|
-
logger.info('static disconnection to room');
|
|
13087
|
+
logger$c.info('static disconnection to room');
|
|
12993
13088
|
|
|
12994
13089
|
Wazo.Phone.disconnect();
|
|
12995
13090
|
}
|
|
12996
13091
|
|
|
12997
13092
|
async disconnect() {
|
|
12998
|
-
logger.info('disconnection to room called');
|
|
13093
|
+
logger$c.info('disconnection to room called');
|
|
12999
13094
|
|
|
13000
13095
|
await Wazo.Phone.hangup(this.callSession);
|
|
13001
13096
|
this.callSession = null;
|
|
@@ -13015,19 +13110,19 @@ class Room extends Emitter {
|
|
|
13015
13110
|
}
|
|
13016
13111
|
|
|
13017
13112
|
setSourceId(sourceId ) {
|
|
13018
|
-
logger.info('set room source id', { sourceId });
|
|
13113
|
+
logger$c.info('set room source id', { sourceId });
|
|
13019
13114
|
|
|
13020
13115
|
this.sourceId = sourceId;
|
|
13021
13116
|
}
|
|
13022
13117
|
|
|
13023
13118
|
setMeetingUuid(meetingUuid ) {
|
|
13024
|
-
logger.info('set meeting uuid', { meetingUuid });
|
|
13119
|
+
logger$c.info('set meeting uuid', { meetingUuid });
|
|
13025
13120
|
|
|
13026
13121
|
this.meetingUuid = meetingUuid;
|
|
13027
13122
|
}
|
|
13028
13123
|
|
|
13029
13124
|
setCallId(callId ) {
|
|
13030
|
-
logger.info('set room call id', { callId });
|
|
13125
|
+
logger$c.info('set room call id', { callId });
|
|
13031
13126
|
|
|
13032
13127
|
if (callId) {
|
|
13033
13128
|
this.callId = callId;
|
|
@@ -13035,7 +13130,7 @@ class Room extends Emitter {
|
|
|
13035
13130
|
}
|
|
13036
13131
|
|
|
13037
13132
|
setName(name ) {
|
|
13038
|
-
logger.info('set room name', { name });
|
|
13133
|
+
logger$c.info('set room name', { name });
|
|
13039
13134
|
|
|
13040
13135
|
this.name = name;
|
|
13041
13136
|
}
|
|
@@ -13054,7 +13149,7 @@ class Room extends Emitter {
|
|
|
13054
13149
|
}
|
|
13055
13150
|
|
|
13056
13151
|
async startScreenSharing(constraints ) {
|
|
13057
|
-
logger.info('start room screen sharing', { constraints });
|
|
13152
|
+
logger$c.info('start room screen sharing', { constraints });
|
|
13058
13153
|
|
|
13059
13154
|
const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
|
|
13060
13155
|
if (!screensharingStream) {
|
|
@@ -13068,7 +13163,7 @@ class Room extends Emitter {
|
|
|
13068
13163
|
}
|
|
13069
13164
|
|
|
13070
13165
|
async stopScreenSharing(restoreLocalStream = true) {
|
|
13071
|
-
logger.info('stop room screen sharing');
|
|
13166
|
+
logger$c.info('stop room screen sharing');
|
|
13072
13167
|
|
|
13073
13168
|
await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
13074
13169
|
|
|
@@ -13080,7 +13175,7 @@ class Room extends Emitter {
|
|
|
13080
13175
|
}
|
|
13081
13176
|
|
|
13082
13177
|
turnCameraOff() {
|
|
13083
|
-
logger.info('turn room camera off');
|
|
13178
|
+
logger$c.info('turn room camera off');
|
|
13084
13179
|
|
|
13085
13180
|
Wazo.Phone.turnCameraOff(this.callSession);
|
|
13086
13181
|
|
|
@@ -13090,7 +13185,7 @@ class Room extends Emitter {
|
|
|
13090
13185
|
}
|
|
13091
13186
|
|
|
13092
13187
|
turnCameraOn() {
|
|
13093
|
-
logger.info('turn room camera on');
|
|
13188
|
+
logger$c.info('turn room camera on');
|
|
13094
13189
|
|
|
13095
13190
|
Wazo.Phone.turnCameraOn(this.callSession);
|
|
13096
13191
|
|
|
@@ -13100,7 +13195,7 @@ class Room extends Emitter {
|
|
|
13100
13195
|
}
|
|
13101
13196
|
|
|
13102
13197
|
mute() {
|
|
13103
|
-
logger.info('mute room');
|
|
13198
|
+
logger$c.info('mute room');
|
|
13104
13199
|
|
|
13105
13200
|
Wazo.Phone.mute(this.callSession);
|
|
13106
13201
|
|
|
@@ -13108,7 +13203,7 @@ class Room extends Emitter {
|
|
|
13108
13203
|
}
|
|
13109
13204
|
|
|
13110
13205
|
unmute() {
|
|
13111
|
-
logger.info('unmute room');
|
|
13206
|
+
logger$c.info('unmute room');
|
|
13112
13207
|
|
|
13113
13208
|
Wazo.Phone.unmute(this.callSession);
|
|
13114
13209
|
|
|
@@ -13128,7 +13223,7 @@ class Room extends Emitter {
|
|
|
13128
13223
|
}
|
|
13129
13224
|
|
|
13130
13225
|
hold() {
|
|
13131
|
-
logger.info('hold room');
|
|
13226
|
+
logger$c.info('hold room');
|
|
13132
13227
|
|
|
13133
13228
|
Wazo.Phone.hold(this.callSession, true);
|
|
13134
13229
|
|
|
@@ -13138,7 +13233,7 @@ class Room extends Emitter {
|
|
|
13138
13233
|
}
|
|
13139
13234
|
|
|
13140
13235
|
async resume() {
|
|
13141
|
-
logger.info('resume room');
|
|
13236
|
+
logger$c.info('resume room');
|
|
13142
13237
|
|
|
13143
13238
|
const newStream = await Wazo.Phone.resume(this.callSession, true);
|
|
13144
13239
|
|
|
@@ -13166,13 +13261,13 @@ class Room extends Emitter {
|
|
|
13166
13261
|
}
|
|
13167
13262
|
|
|
13168
13263
|
sendDTMF(tone ) {
|
|
13169
|
-
logger.info('send room DTMF', { tone });
|
|
13264
|
+
logger$c.info('send room DTMF', { tone });
|
|
13170
13265
|
|
|
13171
13266
|
Wazo.Phone.sendDTMF(tone, this.callSession);
|
|
13172
13267
|
}
|
|
13173
13268
|
|
|
13174
13269
|
async sendReinvite(newConstraints = null) {
|
|
13175
|
-
logger.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
13270
|
+
logger$c.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
13176
13271
|
const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
|
|
13177
13272
|
|
|
13178
13273
|
Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
|
|
@@ -13231,7 +13326,7 @@ class Room extends Emitter {
|
|
|
13231
13326
|
Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
13232
13327
|
|
|
13233
13328
|
this.on(this.ON_AUDIO_STREAM, stream => {
|
|
13234
|
-
logger.info('on room audio stream');
|
|
13329
|
+
logger$c.info('on room audio stream');
|
|
13235
13330
|
|
|
13236
13331
|
this.audioStream = stream;
|
|
13237
13332
|
if (!this.roomAudioElement) {
|
|
@@ -13244,7 +13339,7 @@ class Room extends Emitter {
|
|
|
13244
13339
|
});
|
|
13245
13340
|
|
|
13246
13341
|
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
13247
|
-
logger.info('on room video stream', { streamId });
|
|
13342
|
+
logger$c.info('on room video stream', { streamId });
|
|
13248
13343
|
|
|
13249
13344
|
this._mapMsid(sipSession.body.body);
|
|
13250
13345
|
|
|
@@ -13259,7 +13354,7 @@ class Room extends Emitter {
|
|
|
13259
13354
|
});
|
|
13260
13355
|
|
|
13261
13356
|
this.on(this.ON_REMOVE_STREAM, stream => {
|
|
13262
|
-
logger.info('on room remove stream');
|
|
13357
|
+
logger$c.info('on room remove stream');
|
|
13263
13358
|
|
|
13264
13359
|
const participant = this.participants.find(someParticipant =>
|
|
13265
13360
|
someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
|
|
@@ -13391,7 +13486,7 @@ class Room extends Emitter {
|
|
|
13391
13486
|
const requester = this._getParticipantFromCallId(origin.callId);
|
|
13392
13487
|
if (requester) {
|
|
13393
13488
|
// @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
|
|
13394
|
-
logger.info('trigger room requester status', { origin });
|
|
13489
|
+
logger$c.info('trigger room requester status', { origin });
|
|
13395
13490
|
requester.triggerUpdate('REQUESTER_UPDATE');
|
|
13396
13491
|
}
|
|
13397
13492
|
break;
|
|
@@ -13422,24 +13517,24 @@ class Room extends Emitter {
|
|
|
13422
13517
|
|
|
13423
13518
|
// When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
|
|
13424
13519
|
if (participant.user_uuid === session.uuid) {
|
|
13425
|
-
logger.info('room current user joined');
|
|
13520
|
+
logger$c.info('room current user joined');
|
|
13426
13521
|
|
|
13427
13522
|
// Retrieve participants via an API calls
|
|
13428
13523
|
const conferenceId = this.sourceId || payload.data.conference_id;
|
|
13429
13524
|
let response;
|
|
13430
13525
|
try {
|
|
13431
13526
|
if (this.meetingUuid) {
|
|
13432
|
-
logger.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
13527
|
+
logger$c.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
13433
13528
|
response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
|
|
13434
13529
|
} else {
|
|
13435
|
-
logger.info('fetching conference participants', { conferenceId });
|
|
13530
|
+
logger$c.info('fetching conference participants', { conferenceId });
|
|
13436
13531
|
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
13437
13532
|
}
|
|
13438
13533
|
} catch (e) {
|
|
13439
|
-
logger.error('room participants fetching, error', e);
|
|
13534
|
+
logger$c.error('room participants fetching, error', e);
|
|
13440
13535
|
}
|
|
13441
13536
|
if (response) {
|
|
13442
|
-
logger.info('conference participants fetched', { nb: response.items.length });
|
|
13537
|
+
logger$c.info('conference participants fetched', { nb: response.items.length });
|
|
13443
13538
|
participants = response.items.map(item => {
|
|
13444
13539
|
const isMe = item.call_id === this.callId;
|
|
13445
13540
|
|
|
@@ -13466,7 +13561,7 @@ class Room extends Emitter {
|
|
|
13466
13561
|
? new Wazo.RemoteParticipant(this, participant)
|
|
13467
13562
|
: null;
|
|
13468
13563
|
|
|
13469
|
-
logger.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
13564
|
+
logger$c.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
13470
13565
|
|
|
13471
13566
|
if (remoteParticipant) {
|
|
13472
13567
|
this.participants.push(remoteParticipant);
|
|
@@ -13629,5 +13724,5 @@ class Room extends Emitter {
|
|
|
13629
13724
|
}
|
|
13630
13725
|
}
|
|
13631
13726
|
|
|
13632
|
-
export default Room;
|
|
13727
|
+
export default Room$1;
|
|
13633
13728
|
export { SIGNAL_TYPE_PARTICIPANT_REQUEST, SIGNAL_TYPE_PARTICIPANT_UPDATE };
|