@wazo/sdk 0.37.20 → 0.37.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/api-client.test.js +91 -21
- package/esm/__tests__/web-rtc-client.test.js +214 -165
- package/esm/api/agentd.js +25 -2
- package/esm/api/amid.js +26 -3
- package/esm/api/application.js +25 -2
- package/esm/api/auth.js +25 -2
- package/esm/api/call-logd.js +34 -4
- package/esm/api/calld.js +35 -2
- package/esm/api/chatd.js +32 -2
- package/esm/api/confd.js +56 -9
- package/esm/api/ctid-ng.js +38 -5
- package/esm/api/dird.js +29 -3
- package/esm/api/webhookd.js +26 -3
- package/esm/api-client.js +91 -21
- package/esm/checker/Checker.js +241 -190
- package/esm/checker/checks/aor.js +91 -21
- package/esm/checker/checks/api.js +91 -21
- package/esm/checker/checks/index.js +231 -180
- package/esm/checker/checks/wazo-websocket.js +42 -17
- package/esm/checker/checks/webrtc-transport.js +214 -165
- package/esm/checker/checks/webrtc.js +214 -165
- package/esm/domain/AdHocAPIConference.js +91 -21
- package/esm/domain/Call.js +3 -0
- package/esm/domain/CallLog.js +8 -1
- package/esm/domain/ChatMessage.js +4 -0
- package/esm/domain/ChatRoom.js +3 -0
- package/esm/domain/Contact.js +4 -1
- package/esm/domain/Features.js +91 -21
- package/esm/domain/Meeting.js +28 -5
- package/esm/domain/Phone/CTIPhone.js +109 -35
- package/esm/domain/Phone/WebRTCPhone.js +159 -102
- package/esm/domain/Recording.js +3 -0
- package/esm/domain/Voicemail.js +3 -0
- package/esm/domain/__tests__/Call.test.js +3 -0
- package/esm/domain/__tests__/CallLog.test.js +8 -1
- package/esm/domain/__tests__/Contact.test.js +4 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +509 -414
- package/esm/lib/WazoSessionDescriptionHandler.js +26 -41
- package/esm/service/CallApi.js +91 -21
- package/esm/service/IssueReporter.js +26 -3
- package/esm/service/__tests__/IssueReporter.test.js +26 -3
- package/esm/service/getApiClient.js +91 -21
- package/esm/simple/Auth.js +499 -404
- package/esm/simple/Configuration.js +499 -404
- package/esm/simple/Directory.js +91 -21
- package/esm/simple/Phone.js +499 -404
- package/esm/simple/Websocket.js +45 -19
- package/esm/simple/index.js +503 -408
- package/esm/simple/room/LocalParticipant.js +503 -408
- package/esm/simple/room/Participant.js +503 -408
- package/esm/simple/room/RemoteParticipant.js +503 -408
- package/esm/simple/room/Room.js +504 -409
- package/esm/simple/room/SipRoom.js +503 -408
- package/esm/simple/room/Stream.js +503 -408
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/esm/simple/utils.js +503 -408
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/utils/__tests__/api-requester.test.js +25 -2
- package/esm/utils/api-requester.js +25 -2
- package/esm/web-rtc-client.js +214 -165
- package/esm/websocket-client.js +43 -18
- package/lib/__tests__/api-client.test.js +91 -21
- package/lib/__tests__/web-rtc-client.test.js +214 -165
- package/lib/api/agentd.js +25 -2
- package/lib/api/amid.js +26 -3
- package/lib/api/application.js +25 -2
- package/lib/api/auth.js +25 -2
- package/lib/api/call-logd.js +34 -4
- package/lib/api/calld.js +35 -2
- package/lib/api/chatd.js +32 -2
- package/lib/api/confd.js +56 -9
- package/lib/api/ctid-ng.js +38 -5
- package/lib/api/dird.js +29 -3
- package/lib/api/webhookd.js +26 -3
- package/lib/api-client.js +91 -21
- package/lib/checker/Checker.js +241 -190
- package/lib/checker/checks/aor.js +91 -21
- package/lib/checker/checks/api.js +91 -21
- package/lib/checker/checks/index.js +231 -180
- package/lib/checker/checks/wazo-websocket.js +42 -17
- package/lib/checker/checks/webrtc-transport.js +214 -165
- package/lib/checker/checks/webrtc.js +214 -165
- package/lib/domain/AdHocAPIConference.js +91 -21
- package/lib/domain/Call.js +3 -0
- package/lib/domain/CallLog.js +8 -1
- package/lib/domain/ChatMessage.js +4 -0
- package/lib/domain/ChatRoom.js +3 -0
- package/lib/domain/Contact.js +4 -1
- package/lib/domain/Features.js +91 -21
- package/lib/domain/Meeting.js +32 -5
- package/lib/domain/Phone/CTIPhone.js +109 -35
- package/lib/domain/Phone/WebRTCPhone.js +159 -102
- package/lib/domain/Recording.js +3 -0
- package/lib/domain/Voicemail.js +3 -0
- package/lib/domain/__tests__/Call.test.js +3 -0
- package/lib/domain/__tests__/CallLog.test.js +8 -1
- package/lib/domain/__tests__/Contact.test.js +4 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +509 -414
- package/lib/lib/WazoSessionDescriptionHandler.js +26 -41
- package/lib/service/CallApi.js +91 -21
- package/lib/service/IssueReporter.js +26 -3
- package/lib/service/__tests__/IssueReporter.test.js +26 -3
- package/lib/service/getApiClient.js +91 -21
- package/lib/simple/Auth.js +499 -404
- package/lib/simple/Configuration.js +499 -404
- package/lib/simple/Directory.js +91 -21
- package/lib/simple/Phone.js +499 -404
- package/lib/simple/Websocket.js +45 -19
- package/lib/simple/index.js +503 -408
- package/lib/simple/room/LocalParticipant.js +503 -408
- package/lib/simple/room/Participant.js +503 -408
- package/lib/simple/room/RemoteParticipant.js +503 -408
- package/lib/simple/room/Room.js +504 -409
- package/lib/simple/room/SipRoom.js +503 -408
- package/lib/simple/room/Stream.js +503 -408
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/lib/simple/utils.js +503 -408
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/utils/__tests__/api-requester.test.js +25 -2
- package/lib/utils/api-requester.js +25 -2
- package/lib/web-rtc-client.js +214 -165
- package/lib/websocket-client.js +43 -17
- package/package.json +1 -1
- package/src/api/confd.js +5 -2
- package/src/domain/Call.js +3 -0
- package/src/domain/CallLog.js +4 -0
- package/src/domain/ChatMessage.js +4 -0
- package/src/domain/ChatRoom.js +3 -0
- package/src/domain/Contact.js +3 -0
- package/src/domain/Meeting.js +28 -5
- package/src/domain/Phone/CTIPhone.js +4 -0
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +49 -15
- package/src/domain/Recording.js +3 -0
- package/src/domain/Voicemail.js +3 -0
- package/src/domain/__tests__/Meeting.test.js +50 -0
- package/src/lib/WazoSessionDescriptionHandler.js +1 -35
- package/src/service/IssueReporter.js +25 -2
- package/src/simple/Phone.js +5 -0
- package/src/types/WebSocketMessage.js +5 -1
- package/src/web-rtc-client.js +41 -24
- package/src/websocket-client.js +2 -0
package/lib/index.js
CHANGED
|
@@ -161,6 +161,7 @@ class IssueReporter {
|
|
|
161
161
|
|
|
162
162
|
|
|
163
163
|
|
|
164
|
+
|
|
164
165
|
|
|
165
166
|
constructor() {
|
|
166
167
|
addLevelsTo(this);
|
|
@@ -172,12 +173,17 @@ class IssueReporter {
|
|
|
172
173
|
this.bufferTimeout = null;
|
|
173
174
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
174
175
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
176
|
+
this._callback = null;
|
|
175
177
|
}
|
|
176
178
|
|
|
177
179
|
init() {
|
|
178
180
|
this._catchConsole();
|
|
179
181
|
}
|
|
180
182
|
|
|
183
|
+
setCallback(cb ) {
|
|
184
|
+
this._callback = cb;
|
|
185
|
+
}
|
|
186
|
+
|
|
181
187
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
182
188
|
this.remoteClientConfiguration = configuration;
|
|
183
189
|
}
|
|
@@ -213,6 +219,7 @@ class IssueReporter {
|
|
|
213
219
|
|
|
214
220
|
// Handle category label
|
|
215
221
|
let category = null;
|
|
222
|
+
let skipSendToRemote = false;
|
|
216
223
|
let extra = {};
|
|
217
224
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
218
225
|
category = args[0].split('=')[1];
|
|
@@ -228,6 +235,7 @@ class IssueReporter {
|
|
|
228
235
|
errorMessage: lastArg.message,
|
|
229
236
|
errorStack: lastArg.stack,
|
|
230
237
|
errorType: lastArg.constructor.name,
|
|
238
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
231
239
|
};
|
|
232
240
|
} else {
|
|
233
241
|
extra = lastArg;
|
|
@@ -236,6 +244,11 @@ class IssueReporter {
|
|
|
236
244
|
args.splice(1, 1);
|
|
237
245
|
}
|
|
238
246
|
|
|
247
|
+
if (extra.skipSendToRemote) {
|
|
248
|
+
skipSendToRemote = true;
|
|
249
|
+
delete extra.skipSendToRemote;
|
|
250
|
+
}
|
|
251
|
+
|
|
239
252
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
240
253
|
const message = args.join(', ');
|
|
241
254
|
let consoleMessage = message;
|
|
@@ -256,7 +269,13 @@ class IssueReporter {
|
|
|
256
269
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
257
270
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
258
271
|
|
|
259
|
-
this.
|
|
272
|
+
if (this._callback) {
|
|
273
|
+
this._callback(level, consoleMessage);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (!skipSendToRemote) {
|
|
277
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
278
|
+
}
|
|
260
279
|
}
|
|
261
280
|
|
|
262
281
|
logRequest(url , options , response , start ) {
|
|
@@ -401,7 +420,11 @@ class IssueReporter {
|
|
|
401
420
|
},
|
|
402
421
|
// $FlowFixMe
|
|
403
422
|
body,
|
|
404
|
-
}).catch(() => {
|
|
423
|
+
}).catch((e ) => {
|
|
424
|
+
// $FlowFixMe
|
|
425
|
+
e.skipSendToRemote = true;
|
|
426
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
427
|
+
|
|
405
428
|
setTimeout(() => {
|
|
406
429
|
if (isArray) {
|
|
407
430
|
payload = payload.map(message => {
|
|
@@ -448,7 +471,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
448
471
|
|
|
449
472
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
450
473
|
|
|
451
|
-
const logger
|
|
474
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
452
475
|
|
|
453
476
|
// Use a function here to be able to mock it in tests
|
|
454
477
|
const realFetch = () => {
|
|
@@ -587,7 +610,7 @@ class ApiRequester {
|
|
|
587
610
|
};
|
|
588
611
|
|
|
589
612
|
if (this.refreshTokenPromise) {
|
|
590
|
-
logger
|
|
613
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
591
614
|
await this.refreshTokenPromise;
|
|
592
615
|
}
|
|
593
616
|
|
|
@@ -607,7 +630,7 @@ class ApiRequester {
|
|
|
607
630
|
return promise.then(async (err ) => {
|
|
608
631
|
// Check if the token is still valid
|
|
609
632
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
610
|
-
logger
|
|
633
|
+
logger.warn('token expired', { error: err.reason });
|
|
611
634
|
// Replay the call after refreshing the token
|
|
612
635
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
613
636
|
}
|
|
@@ -617,7 +640,7 @@ class ApiRequester {
|
|
|
617
640
|
: exceptionClass.fromResponse(err, response.status);
|
|
618
641
|
|
|
619
642
|
if (this.shouldLogErrors) {
|
|
620
|
-
logger
|
|
643
|
+
logger.error('API error', error);
|
|
621
644
|
}
|
|
622
645
|
|
|
623
646
|
throw error;
|
|
@@ -627,7 +650,7 @@ class ApiRequester {
|
|
|
627
650
|
return newParse(response, isJson);
|
|
628
651
|
}).catch(error => {
|
|
629
652
|
if (this.shouldLogErrors) {
|
|
630
|
-
logger
|
|
653
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
631
654
|
}
|
|
632
655
|
|
|
633
656
|
throw error;
|
|
@@ -655,13 +678,13 @@ class ApiRequester {
|
|
|
655
678
|
) {
|
|
656
679
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
657
680
|
let newPath = path;
|
|
658
|
-
logger
|
|
681
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
659
682
|
|
|
660
683
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
661
684
|
|
|
662
685
|
return this.refreshTokenPromise.then(() => {
|
|
663
686
|
this.refreshTokenPromise = null;
|
|
664
|
-
logger
|
|
687
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
665
688
|
if (isTokenNotFound) {
|
|
666
689
|
const pathParts = path.split('/');
|
|
667
690
|
pathParts.pop();
|
|
@@ -1539,6 +1562,9 @@ class Contact {
|
|
|
1539
1562
|
}
|
|
1540
1563
|
|
|
1541
1564
|
static parseMany(response ) {
|
|
1565
|
+
if (!response || !response.results) {
|
|
1566
|
+
return [];
|
|
1567
|
+
}
|
|
1542
1568
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
1543
1569
|
}
|
|
1544
1570
|
|
|
@@ -2616,8 +2642,9 @@ class ExternalApp {
|
|
|
2616
2642
|
|
|
2617
2643
|
|
|
2618
2644
|
|
|
2619
|
-
|
|
2645
|
+
|
|
2620
2646
|
|
|
2647
|
+
|
|
2621
2648
|
|
|
2622
2649
|
|
|
2623
2650
|
class Meeting {
|
|
@@ -2628,9 +2655,10 @@ class Meeting {
|
|
|
2628
2655
|
|
|
2629
2656
|
|
|
2630
2657
|
|
|
2631
|
-
|
|
2658
|
+
|
|
2632
2659
|
|
|
2633
2660
|
|
|
2661
|
+
|
|
2634
2662
|
|
|
2635
2663
|
static parse(plain ) {
|
|
2636
2664
|
return new Meeting({
|
|
@@ -2640,24 +2668,43 @@ class Meeting {
|
|
|
2640
2668
|
ownerUuids: plain.owner_uuids,
|
|
2641
2669
|
port: plain.port,
|
|
2642
2670
|
uuid: plain.uuid,
|
|
2643
|
-
|
|
2671
|
+
extension: plain.exten,
|
|
2644
2672
|
persistent: plain.persistent,
|
|
2673
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
2645
2674
|
});
|
|
2646
2675
|
}
|
|
2647
2676
|
|
|
2677
|
+
static parseMany(items ) {
|
|
2678
|
+
if (!items) {
|
|
2679
|
+
return [];
|
|
2680
|
+
}
|
|
2681
|
+
return items.map(plain => Meeting.parse(plain));
|
|
2682
|
+
}
|
|
2683
|
+
|
|
2648
2684
|
static newFrom(meeting ) {
|
|
2649
2685
|
return newFrom(meeting, Meeting);
|
|
2650
2686
|
}
|
|
2651
2687
|
|
|
2652
|
-
constructor({
|
|
2688
|
+
constructor({
|
|
2689
|
+
uuid,
|
|
2690
|
+
name,
|
|
2691
|
+
guestSipAuthorization,
|
|
2692
|
+
ownerUuids,
|
|
2693
|
+
port,
|
|
2694
|
+
uri,
|
|
2695
|
+
extension,
|
|
2696
|
+
persistent,
|
|
2697
|
+
creationTime,
|
|
2698
|
+
} = {}) {
|
|
2653
2699
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2654
2700
|
this.uri = uri;
|
|
2655
2701
|
this.name = name;
|
|
2656
2702
|
this.ownerUuids = ownerUuids;
|
|
2657
2703
|
this.port = port;
|
|
2658
2704
|
this.uuid = uuid;
|
|
2659
|
-
this.
|
|
2705
|
+
this.extension = extension;
|
|
2660
2706
|
this.persistent = persistent;
|
|
2707
|
+
this.creationTime = creationTime;
|
|
2661
2708
|
|
|
2662
2709
|
// Useful to compare instead of instanceof with minified code
|
|
2663
2710
|
this.type = 'Meeting';
|
|
@@ -2735,8 +2782,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2735
2782
|
}
|
|
2736
2783
|
},
|
|
2737
2784
|
|
|
2738
|
-
|
|
2739
|
-
client.
|
|
2785
|
+
getMyMeetings: () =>
|
|
2786
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
2787
|
+
|
|
2788
|
+
createMyMeeting: (name , persistent ) =>
|
|
2789
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
2740
2790
|
|
|
2741
2791
|
deleteMyMeeting: (meetingUuid ) =>
|
|
2742
2792
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -2832,6 +2882,10 @@ class ChatMessage {
|
|
|
2832
2882
|
|
|
2833
2883
|
|
|
2834
2884
|
static parseMany(plain ) {
|
|
2885
|
+
if (!plain || !plain.items) {
|
|
2886
|
+
return [];
|
|
2887
|
+
}
|
|
2888
|
+
|
|
2835
2889
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
2836
2890
|
}
|
|
2837
2891
|
|
|
@@ -2941,6 +2995,9 @@ class Voicemail {
|
|
|
2941
2995
|
}
|
|
2942
2996
|
|
|
2943
2997
|
static parseMany(plain ) {
|
|
2998
|
+
if (!plain) {
|
|
2999
|
+
return [];
|
|
3000
|
+
}
|
|
2944
3001
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
2945
3002
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
2946
3003
|
|
|
@@ -3050,6 +3107,9 @@ class Call {
|
|
|
3050
3107
|
|
|
3051
3108
|
|
|
3052
3109
|
static parseMany(plain ) {
|
|
3110
|
+
if (!plain) {
|
|
3111
|
+
return [];
|
|
3112
|
+
}
|
|
3053
3113
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
3054
3114
|
}
|
|
3055
3115
|
|
|
@@ -3593,6 +3653,9 @@ class Recording {
|
|
|
3593
3653
|
|
|
3594
3654
|
|
|
3595
3655
|
static parseMany(recordings = []) {
|
|
3656
|
+
if (!recordings) {
|
|
3657
|
+
return [];
|
|
3658
|
+
}
|
|
3596
3659
|
return recordings.map(item => Recording.parse(item));
|
|
3597
3660
|
}
|
|
3598
3661
|
|
|
@@ -3694,6 +3757,10 @@ class CallLog {
|
|
|
3694
3757
|
}
|
|
3695
3758
|
|
|
3696
3759
|
static parseMany(plain ) {
|
|
3760
|
+
if (!plain || !plain.items) {
|
|
3761
|
+
return [];
|
|
3762
|
+
}
|
|
3763
|
+
|
|
3697
3764
|
return plain.items.map(item => CallLog.parse(item));
|
|
3698
3765
|
}
|
|
3699
3766
|
|
|
@@ -4081,7 +4148,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
4081
4148
|
|
|
4082
4149
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
4083
4150
|
|
|
4084
|
-
const logger$
|
|
4151
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
4085
4152
|
|
|
4086
4153
|
class CTIPhone extends Emitter {
|
|
4087
4154
|
|
|
@@ -4094,7 +4161,7 @@ class CTIPhone extends Emitter {
|
|
|
4094
4161
|
|
|
4095
4162
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
4096
4163
|
super();
|
|
4097
|
-
logger$
|
|
4164
|
+
logger$1.info('CTI Phone created');
|
|
4098
4165
|
this.session = session;
|
|
4099
4166
|
this.isMobile = isMobile;
|
|
4100
4167
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -4155,7 +4222,7 @@ class CTIPhone extends Emitter {
|
|
|
4155
4222
|
}
|
|
4156
4223
|
|
|
4157
4224
|
async makeCall(number , line ) {
|
|
4158
|
-
logger$
|
|
4225
|
+
logger$1.info('make CTI call', { number });
|
|
4159
4226
|
|
|
4160
4227
|
if (!number) {
|
|
4161
4228
|
return null;
|
|
@@ -4178,7 +4245,7 @@ class CTIPhone extends Emitter {
|
|
|
4178
4245
|
if (!callSession) {
|
|
4179
4246
|
return Promise.resolve(null);
|
|
4180
4247
|
}
|
|
4181
|
-
logger$
|
|
4248
|
+
logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4182
4249
|
|
|
4183
4250
|
if (!this.currentCall) {
|
|
4184
4251
|
this.currentCall = callSession.call;
|
|
@@ -4191,7 +4258,7 @@ class CTIPhone extends Emitter {
|
|
|
4191
4258
|
if (!callSession) {
|
|
4192
4259
|
return;
|
|
4193
4260
|
}
|
|
4194
|
-
logger$
|
|
4261
|
+
logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4195
4262
|
|
|
4196
4263
|
this.currentCall = undefined;
|
|
4197
4264
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4201,7 +4268,7 @@ class CTIPhone extends Emitter {
|
|
|
4201
4268
|
if (!callSession) {
|
|
4202
4269
|
return Promise.resolve(false);
|
|
4203
4270
|
}
|
|
4204
|
-
logger$
|
|
4271
|
+
logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4205
4272
|
|
|
4206
4273
|
try {
|
|
4207
4274
|
await CallApi.cancelCall(callSession);
|
|
@@ -4212,7 +4279,7 @@ class CTIPhone extends Emitter {
|
|
|
4212
4279
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
4213
4280
|
return true;
|
|
4214
4281
|
} catch (e) {
|
|
4215
|
-
logger$
|
|
4282
|
+
logger$1.error('hangup CTI call, error', e);
|
|
4216
4283
|
|
|
4217
4284
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
4218
4285
|
return false;
|
|
@@ -4225,7 +4292,7 @@ class CTIPhone extends Emitter {
|
|
|
4225
4292
|
if (!callSession) {
|
|
4226
4293
|
return;
|
|
4227
4294
|
}
|
|
4228
|
-
logger$
|
|
4295
|
+
logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4229
4296
|
|
|
4230
4297
|
await CallApi.cancelCall(callSession);
|
|
4231
4298
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4235,7 +4302,7 @@ class CTIPhone extends Emitter {
|
|
|
4235
4302
|
if (!callSession) {
|
|
4236
4303
|
return;
|
|
4237
4304
|
}
|
|
4238
|
-
logger$
|
|
4305
|
+
logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4239
4306
|
|
|
4240
4307
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
4241
4308
|
}
|
|
@@ -4248,19 +4315,19 @@ class CTIPhone extends Emitter {
|
|
|
4248
4315
|
if (!callSession) {
|
|
4249
4316
|
return;
|
|
4250
4317
|
}
|
|
4251
|
-
logger$
|
|
4318
|
+
logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4252
4319
|
|
|
4253
4320
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
4254
4321
|
}
|
|
4255
4322
|
|
|
4256
4323
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
4257
|
-
logger$
|
|
4324
|
+
logger$1.info('cancel CTI transfer', { transferId });
|
|
4258
4325
|
|
|
4259
4326
|
return CallApi.cancelCallTransfer(transferId);
|
|
4260
4327
|
}
|
|
4261
4328
|
|
|
4262
4329
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
4263
|
-
logger$
|
|
4330
|
+
logger$1.info('confirm CTI transfer', { transferId });
|
|
4264
4331
|
|
|
4265
4332
|
return CallApi.confirmCallTransfer(transferId);
|
|
4266
4333
|
}
|
|
@@ -4269,19 +4336,19 @@ class CTIPhone extends Emitter {
|
|
|
4269
4336
|
if (!callSession) {
|
|
4270
4337
|
return;
|
|
4271
4338
|
}
|
|
4272
|
-
logger$
|
|
4339
|
+
logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4273
4340
|
|
|
4274
4341
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4275
4342
|
}
|
|
4276
4343
|
|
|
4277
4344
|
onConnectionMade() {
|
|
4278
|
-
logger$
|
|
4345
|
+
logger$1.info('on CTI connection made');
|
|
4279
4346
|
|
|
4280
4347
|
this.eventEmitter.emit('onCallAccepted');
|
|
4281
4348
|
}
|
|
4282
4349
|
|
|
4283
4350
|
async close() {
|
|
4284
|
-
logger$
|
|
4351
|
+
logger$1.info('CTI close');
|
|
4285
4352
|
|
|
4286
4353
|
return Promise.resolve();
|
|
4287
4354
|
}
|
|
@@ -4290,7 +4357,7 @@ class CTIPhone extends Emitter {
|
|
|
4290
4357
|
if (!callSession) {
|
|
4291
4358
|
return;
|
|
4292
4359
|
}
|
|
4293
|
-
logger$
|
|
4360
|
+
logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4294
4361
|
|
|
4295
4362
|
return CallApi.hold(callSession.callId);
|
|
4296
4363
|
}
|
|
@@ -4299,7 +4366,7 @@ class CTIPhone extends Emitter {
|
|
|
4299
4366
|
if (!callSession) {
|
|
4300
4367
|
return;
|
|
4301
4368
|
}
|
|
4302
|
-
logger$
|
|
4369
|
+
logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4303
4370
|
|
|
4304
4371
|
return CallApi.resume(callSession.callId);
|
|
4305
4372
|
}
|
|
@@ -4308,7 +4375,7 @@ class CTIPhone extends Emitter {
|
|
|
4308
4375
|
if (!callSession) {
|
|
4309
4376
|
return;
|
|
4310
4377
|
}
|
|
4311
|
-
logger$
|
|
4378
|
+
logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4312
4379
|
|
|
4313
4380
|
return CallApi.mute(callSession.callId);
|
|
4314
4381
|
}
|
|
@@ -4317,7 +4384,7 @@ class CTIPhone extends Emitter {
|
|
|
4317
4384
|
if (!callSession) {
|
|
4318
4385
|
return;
|
|
4319
4386
|
}
|
|
4320
|
-
logger$
|
|
4387
|
+
logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4321
4388
|
|
|
4322
4389
|
return CallApi.unmute(callSession.callId);
|
|
4323
4390
|
}
|
|
@@ -4346,6 +4413,10 @@ class CTIPhone extends Emitter {
|
|
|
4346
4413
|
return false;
|
|
4347
4414
|
}
|
|
4348
4415
|
|
|
4416
|
+
hasAVideoTrack() {
|
|
4417
|
+
return false;
|
|
4418
|
+
}
|
|
4419
|
+
|
|
4349
4420
|
getLocalStreamForCall() {
|
|
4350
4421
|
return null;
|
|
4351
4422
|
}
|
|
@@ -4739,6 +4810,9 @@ class ChatRoom {
|
|
|
4739
4810
|
|
|
4740
4811
|
|
|
4741
4812
|
static parseMany(plain ) {
|
|
4813
|
+
if (!plain || !plain.items) {
|
|
4814
|
+
return [];
|
|
4815
|
+
}
|
|
4742
4816
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
4743
4817
|
}
|
|
4744
4818
|
|
|
@@ -5319,7 +5393,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5319
5393
|
const WEBHOOKD_VERSION = '1.0';
|
|
5320
5394
|
const AMID_VERSION = '1.0';
|
|
5321
5395
|
|
|
5322
|
-
const logger$
|
|
5396
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5323
5397
|
|
|
5324
5398
|
class ApiClient {
|
|
5325
5399
|
|
|
@@ -5371,12 +5445,12 @@ class ApiClient {
|
|
|
5371
5445
|
}
|
|
5372
5446
|
|
|
5373
5447
|
async forceRefreshToken() {
|
|
5374
|
-
logger$
|
|
5448
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
5375
5449
|
return this.refreshTokenCallback();
|
|
5376
5450
|
}
|
|
5377
5451
|
|
|
5378
5452
|
async refreshTokenCallback() {
|
|
5379
|
-
logger$
|
|
5453
|
+
logger$2.info('refresh token callback called', {
|
|
5380
5454
|
refreshToken: this.refreshToken,
|
|
5381
5455
|
refreshBackend: this.refreshBackend,
|
|
5382
5456
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5394,7 +5468,7 @@ class ApiClient {
|
|
|
5394
5468
|
this.isMobile,
|
|
5395
5469
|
);
|
|
5396
5470
|
|
|
5397
|
-
logger$
|
|
5471
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
5398
5472
|
|
|
5399
5473
|
if (this.onRefreshToken) {
|
|
5400
5474
|
this.onRefreshToken(session.token, session);
|
|
@@ -5449,7 +5523,7 @@ class ApiClient {
|
|
|
5449
5523
|
|
|
5450
5524
|
/* */
|
|
5451
5525
|
|
|
5452
|
-
const parseCandidate
|
|
5526
|
+
const parseCandidate = (candidate ) => {
|
|
5453
5527
|
if (!candidate) {
|
|
5454
5528
|
return null;
|
|
5455
5529
|
}
|
|
@@ -5462,10 +5536,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
5462
5536
|
candidates
|
|
5463
5537
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
5464
5538
|
|
|
5465
|
-
const areCandidateValid = (candidates ) =>
|
|
5466
|
-
getSrflxOrRelay(candidates)
|
|
5467
|
-
.length > 0;
|
|
5468
|
-
|
|
5469
5539
|
const getVideoDirection = (sdp ) => {
|
|
5470
5540
|
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
5471
5541
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -5518,8 +5588,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
5518
5588
|
/* global RTCSessionDescriptionInit, navigator */
|
|
5519
5589
|
|
|
5520
5590
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
5521
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
5522
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
5523
5591
|
|
|
5524
5592
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
5525
5593
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -5609,7 +5677,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5609
5677
|
this.peerConnectionDelegate.onicecandidate = event => {
|
|
5610
5678
|
wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
|
|
5611
5679
|
if (event.candidate) {
|
|
5612
|
-
this.gatheredCandidates.push(parseCandidate
|
|
5680
|
+
this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
|
|
5613
5681
|
}
|
|
5614
5682
|
};
|
|
5615
5683
|
|
|
@@ -5709,38 +5777,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5709
5777
|
this._peerConnection = undefined;
|
|
5710
5778
|
}
|
|
5711
5779
|
|
|
5712
|
-
async _waitForValidGatheredIce() {
|
|
5713
|
-
let tries = 0;
|
|
5714
|
-
|
|
5715
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
5716
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
5717
|
-
tries,
|
|
5718
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
5719
|
-
});
|
|
5720
|
-
|
|
5721
|
-
tries++;
|
|
5722
|
-
|
|
5723
|
-
// eslint-disable-next-line no-await-in-loop
|
|
5724
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
5725
|
-
}
|
|
5726
|
-
|
|
5727
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
5728
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
5729
|
-
const error = new Error(errorMsg);
|
|
5730
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
5731
|
-
|
|
5732
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
5733
|
-
this.eventEmitter.emit('error', error);
|
|
5734
|
-
|
|
5735
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5736
|
-
}
|
|
5737
|
-
|
|
5738
|
-
// eslint-disable-next-line
|
|
5739
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5740
|
-
|
|
5741
|
-
return this.getLocalSessionDescription();
|
|
5742
|
-
}
|
|
5743
|
-
|
|
5744
5780
|
// Overridden to send `inactive` in conference
|
|
5745
5781
|
updateDirection(options , isConference = false,
|
|
5746
5782
|
audioOnly = false) {
|
|
@@ -6105,7 +6141,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
6105
6141
|
const SEND_STATS_DELAY = 5000;
|
|
6106
6142
|
|
|
6107
6143
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
6108
|
-
const logger$
|
|
6144
|
+
const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
6109
6145
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
6110
6146
|
|
|
6111
6147
|
// events
|
|
@@ -6119,14 +6155,14 @@ const TRANSPORT_ERROR = 'transportError';
|
|
|
6119
6155
|
const MESSAGE = 'message';
|
|
6120
6156
|
const ACCEPTED = 'accepted';
|
|
6121
6157
|
const REJECTED = 'rejected';
|
|
6122
|
-
const ON_TRACK
|
|
6123
|
-
const ON_REINVITE
|
|
6158
|
+
const ON_TRACK = 'onTrack';
|
|
6159
|
+
const ON_REINVITE = 'reinvite';
|
|
6124
6160
|
const ON_ERROR = 'onError';
|
|
6125
6161
|
const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
|
|
6126
|
-
const ON_NETWORK_STATS
|
|
6127
|
-
const ON_DISCONNECTED
|
|
6162
|
+
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
6163
|
+
const ON_DISCONNECTED = 'onDisconnected';
|
|
6128
6164
|
|
|
6129
|
-
const events
|
|
6165
|
+
const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
6130
6166
|
const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
6131
6167
|
class CanceledCallError extends Error {}
|
|
6132
6168
|
|
|
@@ -6262,12 +6298,12 @@ class WebRTCClient extends Emitter {
|
|
|
6262
6298
|
this.MESSAGE = MESSAGE;
|
|
6263
6299
|
this.ACCEPTED = ACCEPTED;
|
|
6264
6300
|
this.REJECTED = REJECTED;
|
|
6265
|
-
this.ON_TRACK = ON_TRACK
|
|
6266
|
-
this.ON_REINVITE = ON_REINVITE
|
|
6301
|
+
this.ON_TRACK = ON_TRACK;
|
|
6302
|
+
this.ON_REINVITE = ON_REINVITE;
|
|
6267
6303
|
this.ON_ERROR = ON_ERROR;
|
|
6268
6304
|
this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
|
|
6269
|
-
this.ON_NETWORK_STATS = ON_NETWORK_STATS
|
|
6270
|
-
this.ON_DISCONNECTED = ON_DISCONNECTED
|
|
6305
|
+
this.ON_NETWORK_STATS = ON_NETWORK_STATS;
|
|
6306
|
+
this.ON_DISCONNECTED = ON_DISCONNECTED;
|
|
6271
6307
|
}
|
|
6272
6308
|
|
|
6273
6309
|
configureMedia(media ) {
|
|
@@ -6284,13 +6320,13 @@ class WebRTCClient extends Emitter {
|
|
|
6284
6320
|
|
|
6285
6321
|
createUserAgent(configOverrides ) {
|
|
6286
6322
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6287
|
-
logger$
|
|
6323
|
+
logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6288
6324
|
|
|
6289
6325
|
webRTCConfiguration.delegate = {
|
|
6290
6326
|
onConnect: this.onConnect.bind(this),
|
|
6291
6327
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6292
6328
|
onInvite: (invitation ) => {
|
|
6293
|
-
logger$
|
|
6329
|
+
logger$3.info('sdk webrtc on invite', {
|
|
6294
6330
|
method: 'delegate.onInvite',
|
|
6295
6331
|
id: invitation.id,
|
|
6296
6332
|
remoteURI: invitation.remoteURI,
|
|
@@ -6333,7 +6369,7 @@ class WebRTCClient extends Emitter {
|
|
|
6333
6369
|
}
|
|
6334
6370
|
|
|
6335
6371
|
onConnect() {
|
|
6336
|
-
logger$
|
|
6372
|
+
logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6337
6373
|
this.eventEmitter.emit(CONNECTED);
|
|
6338
6374
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6339
6375
|
this.registerer.waitingToggle(false);
|
|
@@ -6342,7 +6378,7 @@ class WebRTCClient extends Emitter {
|
|
|
6342
6378
|
}
|
|
6343
6379
|
|
|
6344
6380
|
async onDisconnect(error ) {
|
|
6345
|
-
logger$
|
|
6381
|
+
logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6346
6382
|
this.connectionPromise = null;
|
|
6347
6383
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6348
6384
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6367,37 +6403,37 @@ class WebRTCClient extends Emitter {
|
|
|
6367
6403
|
};
|
|
6368
6404
|
|
|
6369
6405
|
if (this.skipRegister) {
|
|
6370
|
-
logger$
|
|
6406
|
+
logger$3.info('sdk webrtc skip register...', logInfo);
|
|
6371
6407
|
return Promise.resolve();
|
|
6372
6408
|
}
|
|
6373
6409
|
|
|
6374
|
-
logger$
|
|
6410
|
+
logger$3.info('sdk webrtc registering...', logInfo);
|
|
6375
6411
|
|
|
6376
6412
|
if (!this.userAgent) {
|
|
6377
|
-
logger$
|
|
6413
|
+
logger$3.info('sdk webrtc recreating User Agent');
|
|
6378
6414
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6379
6415
|
}
|
|
6380
6416
|
if (!this.userAgent || this.isRegistered()) {
|
|
6381
|
-
logger$
|
|
6417
|
+
logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6382
6418
|
return Promise.resolve();
|
|
6383
6419
|
}
|
|
6384
6420
|
|
|
6385
6421
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6386
|
-
logger$
|
|
6422
|
+
logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6387
6423
|
return Promise.resolve();
|
|
6388
6424
|
}
|
|
6389
6425
|
|
|
6390
6426
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6391
6427
|
|
|
6392
6428
|
const onRegisterFailed = () => {
|
|
6393
|
-
logger$
|
|
6429
|
+
logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6394
6430
|
this.connectionPromise = null;
|
|
6395
6431
|
if (this.registerer && this.registerer.waiting) {
|
|
6396
6432
|
this.registerer.waitingToggle(false);
|
|
6397
6433
|
}
|
|
6398
6434
|
|
|
6399
6435
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6400
|
-
logger$
|
|
6436
|
+
logger$3.info('sdk webrtc registering, retrying...', { tries });
|
|
6401
6437
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6402
6438
|
}
|
|
6403
6439
|
};
|
|
@@ -6406,18 +6442,18 @@ class WebRTCClient extends Emitter {
|
|
|
6406
6442
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6407
6443
|
// during the resolution of the primise.
|
|
6408
6444
|
if (!this.userAgent) {
|
|
6409
|
-
logger$
|
|
6445
|
+
logger$3.info('sdk webrtc recreating User Agent after connection');
|
|
6410
6446
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6411
6447
|
}
|
|
6412
6448
|
|
|
6413
|
-
logger$
|
|
6449
|
+
logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6414
6450
|
this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
|
|
6415
6451
|
this.connectionPromise = null;
|
|
6416
6452
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6417
6453
|
|
|
6418
6454
|
// Bind registerer events
|
|
6419
6455
|
this.registerer.stateChange.addListener(newState => {
|
|
6420
|
-
logger$
|
|
6456
|
+
logger$3.info('sdk webrtc registering, state changed', { newState });
|
|
6421
6457
|
|
|
6422
6458
|
if (newState === registererState.RegistererState.Registered && this.registerer
|
|
6423
6459
|
&& this.registerer.state === registererState.RegistererState.Registered) {
|
|
@@ -6430,7 +6466,7 @@ class WebRTCClient extends Emitter {
|
|
|
6430
6466
|
const options = {
|
|
6431
6467
|
requestDelegate: {
|
|
6432
6468
|
onReject: response => {
|
|
6433
|
-
logger$
|
|
6469
|
+
logger$3.error('sdk webrtc registering, rejected', { response });
|
|
6434
6470
|
|
|
6435
6471
|
onRegisterFailed();
|
|
6436
6472
|
},
|
|
@@ -6438,13 +6474,13 @@ class WebRTCClient extends Emitter {
|
|
|
6438
6474
|
};
|
|
6439
6475
|
|
|
6440
6476
|
return this.registerer.register(options).catch((e) => {
|
|
6441
|
-
logger$
|
|
6477
|
+
logger$3.error('sdk webrtc registering, error', e);
|
|
6442
6478
|
|
|
6443
6479
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6444
6480
|
return e;
|
|
6445
6481
|
});
|
|
6446
6482
|
}).catch(error => {
|
|
6447
|
-
logger$
|
|
6483
|
+
logger$3.error('sdk webrtc registering, transport error', error);
|
|
6448
6484
|
onRegisterFailed();
|
|
6449
6485
|
});
|
|
6450
6486
|
}
|
|
@@ -6473,21 +6509,21 @@ class WebRTCClient extends Emitter {
|
|
|
6473
6509
|
}
|
|
6474
6510
|
|
|
6475
6511
|
unregister() {
|
|
6476
|
-
logger$
|
|
6512
|
+
logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6477
6513
|
if (!this.registerer) {
|
|
6478
6514
|
return Promise.resolve();
|
|
6479
6515
|
}
|
|
6480
6516
|
|
|
6481
6517
|
try {
|
|
6482
6518
|
return this.registerer.unregister().then(() => {
|
|
6483
|
-
logger$
|
|
6519
|
+
logger$3.info('sdk webrtc unregistered');
|
|
6484
6520
|
this._cleanupRegister();
|
|
6485
6521
|
}).catch(e => {
|
|
6486
|
-
logger$
|
|
6522
|
+
logger$3.error('sdk webrtc unregistering, promise error', e);
|
|
6487
6523
|
this._cleanupRegister();
|
|
6488
6524
|
});
|
|
6489
6525
|
} catch (e) {
|
|
6490
|
-
logger$
|
|
6526
|
+
logger$3.error('sdk webrtc unregistering, error', e);
|
|
6491
6527
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6492
6528
|
// error when the registerer is in a bad state
|
|
6493
6529
|
this._cleanupRegister();
|
|
@@ -6495,7 +6531,7 @@ class WebRTCClient extends Emitter {
|
|
|
6495
6531
|
}
|
|
6496
6532
|
|
|
6497
6533
|
stop() {
|
|
6498
|
-
logger$
|
|
6534
|
+
logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6499
6535
|
if (!this.userAgent) {
|
|
6500
6536
|
return Promise.resolve();
|
|
6501
6537
|
}
|
|
@@ -6503,12 +6539,12 @@ class WebRTCClient extends Emitter {
|
|
|
6503
6539
|
return this.userAgent.stop().then(() => {
|
|
6504
6540
|
return this._cleanupRegister();
|
|
6505
6541
|
}).catch(e => {
|
|
6506
|
-
logger$
|
|
6542
|
+
logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6507
6543
|
});
|
|
6508
6544
|
}
|
|
6509
6545
|
|
|
6510
6546
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6511
|
-
logger$
|
|
6547
|
+
logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6512
6548
|
const inviterOptions = {
|
|
6513
6549
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6514
6550
|
conference,
|
|
@@ -6533,11 +6569,13 @@ class WebRTCClient extends Emitter {
|
|
|
6533
6569
|
const inviteOptions = {
|
|
6534
6570
|
requestDelegate: {
|
|
6535
6571
|
onAccept: (response ) => {
|
|
6536
|
-
session.sessionDescriptionHandler.peerConnection
|
|
6572
|
+
if (session.sessionDescriptionHandler.peerConnection) {
|
|
6573
|
+
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
6574
|
+
}
|
|
6537
6575
|
this._onAccepted(session, response.session, true);
|
|
6538
6576
|
},
|
|
6539
6577
|
onReject: (response ) => {
|
|
6540
|
-
logger$
|
|
6578
|
+
logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6541
6579
|
this._stopSendingStats(session);
|
|
6542
6580
|
this.stopNetworkMonitoring(session);
|
|
6543
6581
|
|
|
@@ -6560,11 +6598,11 @@ class WebRTCClient extends Emitter {
|
|
|
6560
6598
|
}
|
|
6561
6599
|
|
|
6562
6600
|
answer(session , enableVideo ) {
|
|
6563
|
-
logger$
|
|
6601
|
+
logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
6564
6602
|
|
|
6565
6603
|
if (!session || !session.accept) {
|
|
6566
6604
|
const error = 'No session to answer, or not an invitation';
|
|
6567
|
-
logger$
|
|
6605
|
+
logger$3.warn(error);
|
|
6568
6606
|
return Promise.reject(new Error(error));
|
|
6569
6607
|
}
|
|
6570
6608
|
const options = {
|
|
@@ -6574,15 +6612,15 @@ class WebRTCClient extends Emitter {
|
|
|
6574
6612
|
return session.accept(options).then(() => {
|
|
6575
6613
|
if (session.isCanceled) {
|
|
6576
6614
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
6577
|
-
logger$
|
|
6615
|
+
logger$3.error(message, { id: session.id });
|
|
6578
6616
|
this.onCallEnded(session);
|
|
6579
6617
|
|
|
6580
6618
|
throw new CanceledCallError(message);
|
|
6581
6619
|
}
|
|
6582
|
-
logger$
|
|
6620
|
+
logger$3.info('sdk webrtc answer, accepted.');
|
|
6583
6621
|
this._onAccepted(session);
|
|
6584
6622
|
}).catch(e => {
|
|
6585
|
-
logger$
|
|
6623
|
+
logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
6586
6624
|
|
|
6587
6625
|
throw e;
|
|
6588
6626
|
});
|
|
@@ -6590,7 +6628,7 @@ class WebRTCClient extends Emitter {
|
|
|
6590
6628
|
|
|
6591
6629
|
hangup(session ) {
|
|
6592
6630
|
const { state, id } = session;
|
|
6593
|
-
logger$
|
|
6631
|
+
logger$3.info('sdk webrtc hangup call', { id, state });
|
|
6594
6632
|
|
|
6595
6633
|
try {
|
|
6596
6634
|
this._stopSendingStats(session);
|
|
@@ -6619,7 +6657,7 @@ class WebRTCClient extends Emitter {
|
|
|
6619
6657
|
|
|
6620
6658
|
return bye();
|
|
6621
6659
|
} catch (error) {
|
|
6622
|
-
logger$
|
|
6660
|
+
logger$3.warn('sdk webrtc hangup, error', error);
|
|
6623
6661
|
}
|
|
6624
6662
|
|
|
6625
6663
|
return null;
|
|
@@ -6637,7 +6675,7 @@ class WebRTCClient extends Emitter {
|
|
|
6637
6675
|
// Fetch and emit an event at `interval` with session network stats
|
|
6638
6676
|
startNetworkMonitoring(session , interval = 1000) {
|
|
6639
6677
|
const sessionId = this.getSipSessionId(session);
|
|
6640
|
-
logger$
|
|
6678
|
+
logger$3.info('starting network inspection', { id: sessionId });
|
|
6641
6679
|
|
|
6642
6680
|
this.sessionNetworkStats[sessionId] = [];
|
|
6643
6681
|
|
|
@@ -6647,7 +6685,7 @@ class WebRTCClient extends Emitter {
|
|
|
6647
6685
|
stopNetworkMonitoring(session ) {
|
|
6648
6686
|
const sessionId = this.getSipSessionId(session);
|
|
6649
6687
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
6650
|
-
logger$
|
|
6688
|
+
logger$3.info('stopping network inspection', { id: sessionId, exists });
|
|
6651
6689
|
|
|
6652
6690
|
if (exists) {
|
|
6653
6691
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -6657,17 +6695,17 @@ class WebRTCClient extends Emitter {
|
|
|
6657
6695
|
}
|
|
6658
6696
|
|
|
6659
6697
|
reject(session ) {
|
|
6660
|
-
logger$
|
|
6698
|
+
logger$3.info('sdk webrtc reject call', { id: session.id });
|
|
6661
6699
|
|
|
6662
6700
|
try {
|
|
6663
6701
|
return session.reject ? session.reject() : session.cancel();
|
|
6664
6702
|
} catch (e) {
|
|
6665
|
-
logger$
|
|
6703
|
+
logger$3.warn('Error when rejecting call', e.message, e.stack);
|
|
6666
6704
|
}
|
|
6667
6705
|
}
|
|
6668
6706
|
|
|
6669
6707
|
async close() {
|
|
6670
|
-
logger$
|
|
6708
|
+
logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
6671
6709
|
this._cleanupMedia();
|
|
6672
6710
|
this.connectionPromise = null;
|
|
6673
6711
|
|
|
@@ -6698,7 +6736,7 @@ class WebRTCClient extends Emitter {
|
|
|
6698
6736
|
// eg: "INVITE not rejectable in state Completed"
|
|
6699
6737
|
}
|
|
6700
6738
|
this.userAgent = null;
|
|
6701
|
-
logger$
|
|
6739
|
+
logger$3.info('sdk webrtc client closed');
|
|
6702
6740
|
}
|
|
6703
6741
|
|
|
6704
6742
|
getNumber(session ) {
|
|
@@ -6711,13 +6749,13 @@ class WebRTCClient extends Emitter {
|
|
|
6711
6749
|
}
|
|
6712
6750
|
|
|
6713
6751
|
mute(session ) {
|
|
6714
|
-
logger$
|
|
6752
|
+
logger$3.info('sdk webrtc mute', { id: session.id });
|
|
6715
6753
|
|
|
6716
6754
|
this._toggleAudio(session, true);
|
|
6717
6755
|
}
|
|
6718
6756
|
|
|
6719
6757
|
unmute(session ) {
|
|
6720
|
-
logger$
|
|
6758
|
+
logger$3.info('sdk webrtc unmute', { id: session.id });
|
|
6721
6759
|
|
|
6722
6760
|
this._toggleAudio(session, false);
|
|
6723
6761
|
}
|
|
@@ -6757,13 +6795,13 @@ class WebRTCClient extends Emitter {
|
|
|
6757
6795
|
}
|
|
6758
6796
|
|
|
6759
6797
|
toggleCameraOn(session ) {
|
|
6760
|
-
logger$
|
|
6798
|
+
logger$3.info('sdk webrtc toggle camera on', { id: session.id });
|
|
6761
6799
|
|
|
6762
6800
|
this._toggleVideo(session, false);
|
|
6763
6801
|
}
|
|
6764
6802
|
|
|
6765
6803
|
toggleCameraOff(session ) {
|
|
6766
|
-
logger$
|
|
6804
|
+
logger$3.info('sdk webrtc toggle camera off', { id: session.id });
|
|
6767
6805
|
|
|
6768
6806
|
this._toggleVideo(session, true);
|
|
6769
6807
|
}
|
|
@@ -6772,7 +6810,7 @@ class WebRTCClient extends Emitter {
|
|
|
6772
6810
|
const sessionId = this.getSipSessionId(session);
|
|
6773
6811
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
6774
6812
|
|
|
6775
|
-
logger$
|
|
6813
|
+
logger$3.info('sdk webrtc hold', {
|
|
6776
6814
|
sessionId,
|
|
6777
6815
|
keys: Object.keys(this.heldSessions),
|
|
6778
6816
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6821,7 +6859,7 @@ class WebRTCClient extends Emitter {
|
|
|
6821
6859
|
const sessionId = this.getSipSessionId(session);
|
|
6822
6860
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
6823
6861
|
|
|
6824
|
-
logger$
|
|
6862
|
+
logger$3.info('sdk webrtc unhold', {
|
|
6825
6863
|
sessionId,
|
|
6826
6864
|
keys: Object.keys(this.heldSessions),
|
|
6827
6865
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6969,7 +7007,7 @@ class WebRTCClient extends Emitter {
|
|
|
6969
7007
|
if (!session.sessionDescriptionHandler) {
|
|
6970
7008
|
return;
|
|
6971
7009
|
}
|
|
6972
|
-
logger$
|
|
7010
|
+
logger$3.info('Sending DTMF', {
|
|
6973
7011
|
id: this.getSipSessionId(session),
|
|
6974
7012
|
tone,
|
|
6975
7013
|
});
|
|
@@ -6985,7 +7023,7 @@ class WebRTCClient extends Emitter {
|
|
|
6985
7023
|
transfer(session , target ) {
|
|
6986
7024
|
this.hold(session);
|
|
6987
7025
|
|
|
6988
|
-
logger$
|
|
7026
|
+
logger$3.info('Transfering a session', {
|
|
6989
7027
|
id: this.getSipSessionId(session),
|
|
6990
7028
|
target,
|
|
6991
7029
|
});
|
|
@@ -7007,17 +7045,17 @@ class WebRTCClient extends Emitter {
|
|
|
7007
7045
|
atxfer(session ) {
|
|
7008
7046
|
this.hold(session);
|
|
7009
7047
|
|
|
7010
|
-
logger$
|
|
7048
|
+
logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
7011
7049
|
|
|
7012
7050
|
const result = {
|
|
7013
7051
|
newSession: null,
|
|
7014
7052
|
init: async (target ) => {
|
|
7015
|
-
logger$
|
|
7053
|
+
logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
7016
7054
|
|
|
7017
7055
|
result.newSession = await this.call(target);
|
|
7018
7056
|
},
|
|
7019
7057
|
complete: () => {
|
|
7020
|
-
logger$
|
|
7058
|
+
logger$3.info('webrtc transfer completed', {
|
|
7021
7059
|
id: this.getSipSessionId(session),
|
|
7022
7060
|
referId: this.getSipSessionId(result.newSession),
|
|
7023
7061
|
});
|
|
@@ -7038,7 +7076,7 @@ class WebRTCClient extends Emitter {
|
|
|
7038
7076
|
return;
|
|
7039
7077
|
}
|
|
7040
7078
|
|
|
7041
|
-
logger$
|
|
7079
|
+
logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
7042
7080
|
|
|
7043
7081
|
try {
|
|
7044
7082
|
sipSession.message({
|
|
@@ -7080,7 +7118,7 @@ class WebRTCClient extends Emitter {
|
|
|
7080
7118
|
}
|
|
7081
7119
|
|
|
7082
7120
|
changeAudioOutputVolume(volume ) {
|
|
7083
|
-
logger$
|
|
7121
|
+
logger$3.info('Changing audio output volume', { volume });
|
|
7084
7122
|
|
|
7085
7123
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7086
7124
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -7092,7 +7130,7 @@ class WebRTCClient extends Emitter {
|
|
|
7092
7130
|
}
|
|
7093
7131
|
|
|
7094
7132
|
changeAudioOutputDevice(id ) {
|
|
7095
|
-
logger$
|
|
7133
|
+
logger$3.info('Changing audio output device', { id });
|
|
7096
7134
|
|
|
7097
7135
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7098
7136
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -7109,7 +7147,7 @@ class WebRTCClient extends Emitter {
|
|
|
7109
7147
|
|
|
7110
7148
|
changeAudioInputDevice(id , session ) {
|
|
7111
7149
|
const currentId = this.getAudioDeviceId();
|
|
7112
|
-
logger$
|
|
7150
|
+
logger$3.info('setting audio input device', { id, currentId, session: !!session });
|
|
7113
7151
|
|
|
7114
7152
|
if (id === currentId) {
|
|
7115
7153
|
return null;
|
|
@@ -7155,7 +7193,7 @@ class WebRTCClient extends Emitter {
|
|
|
7155
7193
|
|
|
7156
7194
|
setVideoInputDevice(id ) {
|
|
7157
7195
|
const currentId = this.getVideoDeviceId();
|
|
7158
|
-
logger$
|
|
7196
|
+
logger$3.info('setting video input device', { id, currentId });
|
|
7159
7197
|
|
|
7160
7198
|
if (id === currentId) {
|
|
7161
7199
|
return null;
|
|
@@ -7180,7 +7218,7 @@ class WebRTCClient extends Emitter {
|
|
|
7180
7218
|
const sessionId = this.getSipSessionId(session);
|
|
7181
7219
|
const localStream = this.getLocalStream(sessionId);
|
|
7182
7220
|
|
|
7183
|
-
logger$
|
|
7221
|
+
logger$3.info('changing video input device', { id, sessionId });
|
|
7184
7222
|
|
|
7185
7223
|
// Release old video stream
|
|
7186
7224
|
if (localStream) {
|
|
@@ -7248,7 +7286,7 @@ class WebRTCClient extends Emitter {
|
|
|
7248
7286
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
7249
7287
|
const desktop = newConstraints && newConstraints.desktop;
|
|
7250
7288
|
|
|
7251
|
-
logger$
|
|
7289
|
+
logger$3.info('Sending reinvite', {
|
|
7252
7290
|
id: this.getSipSessionId(sipSession),
|
|
7253
7291
|
newConstraints,
|
|
7254
7292
|
conference,
|
|
@@ -7286,7 +7324,7 @@ class WebRTCClient extends Emitter {
|
|
|
7286
7324
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
7287
7325
|
}
|
|
7288
7326
|
|
|
7289
|
-
logger$
|
|
7327
|
+
logger$3.info('on re-INVITE accepted', {
|
|
7290
7328
|
id: this.getSipSessionId(sipSession),
|
|
7291
7329
|
wasMuted,
|
|
7292
7330
|
shouldDoScreenSharing,
|
|
@@ -7304,7 +7342,7 @@ class WebRTCClient extends Emitter {
|
|
|
7304
7342
|
this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
|
|
7305
7343
|
}
|
|
7306
7344
|
|
|
7307
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
7345
|
+
return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
|
|
7308
7346
|
},
|
|
7309
7347
|
},
|
|
7310
7348
|
sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
|
|
@@ -7405,6 +7443,16 @@ class WebRTCClient extends Emitter {
|
|
|
7405
7443
|
return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
|
|
7406
7444
|
}
|
|
7407
7445
|
|
|
7446
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
7447
|
+
getRemoteVideoStreamFromPc(sessionId ) {
|
|
7448
|
+
const pc = this.getPeerConnection(sessionId);
|
|
7449
|
+
if (!pc) {
|
|
7450
|
+
return null;
|
|
7451
|
+
}
|
|
7452
|
+
|
|
7453
|
+
return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
|
|
7454
|
+
}
|
|
7455
|
+
|
|
7408
7456
|
hasVideo(sessionId ) {
|
|
7409
7457
|
return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
|
|
7410
7458
|
}
|
|
@@ -7451,7 +7499,7 @@ class WebRTCClient extends Emitter {
|
|
|
7451
7499
|
}
|
|
7452
7500
|
|
|
7453
7501
|
startHeartbeat() {
|
|
7454
|
-
logger$
|
|
7502
|
+
logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7455
7503
|
if (!this.userAgent) {
|
|
7456
7504
|
this.heartbeat.stop();
|
|
7457
7505
|
return;
|
|
@@ -7464,7 +7512,7 @@ class WebRTCClient extends Emitter {
|
|
|
7464
7512
|
}
|
|
7465
7513
|
|
|
7466
7514
|
stopHeartbeat() {
|
|
7467
|
-
logger$
|
|
7515
|
+
logger$3.info('sdk webrtc stop heartbeat');
|
|
7468
7516
|
this.heartbeat.stop();
|
|
7469
7517
|
}
|
|
7470
7518
|
|
|
@@ -7485,7 +7533,7 @@ class WebRTCClient extends Emitter {
|
|
|
7485
7533
|
}
|
|
7486
7534
|
|
|
7487
7535
|
attemptReconnection() {
|
|
7488
|
-
logger$
|
|
7536
|
+
logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7489
7537
|
if (!this.userAgent) {
|
|
7490
7538
|
return;
|
|
7491
7539
|
}
|
|
@@ -7510,7 +7558,7 @@ class WebRTCClient extends Emitter {
|
|
|
7510
7558
|
return;
|
|
7511
7559
|
}
|
|
7512
7560
|
|
|
7513
|
-
logger$
|
|
7561
|
+
logger$3.info('setting local media stream', {
|
|
7514
7562
|
sipSessionId,
|
|
7515
7563
|
tracks: newStream ? newStream.getTracks() : null,
|
|
7516
7564
|
});
|
|
@@ -7527,7 +7575,7 @@ class WebRTCClient extends Emitter {
|
|
|
7527
7575
|
|
|
7528
7576
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
7529
7577
|
|
|
7530
|
-
logger$
|
|
7578
|
+
logger$3.info('updating local stream', {
|
|
7531
7579
|
sipSessionId,
|
|
7532
7580
|
oldStream: !!oldStream,
|
|
7533
7581
|
tracks: newStream.getTracks(),
|
|
@@ -7547,7 +7595,7 @@ class WebRTCClient extends Emitter {
|
|
|
7547
7595
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
7548
7596
|
const pc = this.getPeerConnection(sessionId);
|
|
7549
7597
|
|
|
7550
|
-
logger$
|
|
7598
|
+
logger$3.info('Updating remote stream', {
|
|
7551
7599
|
sessionId,
|
|
7552
7600
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
7553
7601
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -7573,7 +7621,7 @@ class WebRTCClient extends Emitter {
|
|
|
7573
7621
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
7574
7622
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
7575
7623
|
|
|
7576
|
-
logger$
|
|
7624
|
+
logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
7577
7625
|
|
|
7578
7626
|
return {
|
|
7579
7627
|
constraints: {
|
|
@@ -7622,7 +7670,7 @@ class WebRTCClient extends Emitter {
|
|
|
7622
7670
|
}
|
|
7623
7671
|
|
|
7624
7672
|
_onTransportError() {
|
|
7625
|
-
logger$
|
|
7673
|
+
logger$3.error('on transport error');
|
|
7626
7674
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
7627
7675
|
this.attemptReconnection();
|
|
7628
7676
|
}
|
|
@@ -7631,7 +7679,7 @@ class WebRTCClient extends Emitter {
|
|
|
7631
7679
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
7632
7680
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
7633
7681
|
if (this.hasHeartbeat()) {
|
|
7634
|
-
logger$
|
|
7682
|
+
logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
7635
7683
|
|
|
7636
7684
|
this.heartbeat.onHeartbeat();
|
|
7637
7685
|
if (this.heartbeatCb) {
|
|
@@ -7642,7 +7690,7 @@ class WebRTCClient extends Emitter {
|
|
|
7642
7690
|
}
|
|
7643
7691
|
|
|
7644
7692
|
async _onHeartbeatTimeout() {
|
|
7645
|
-
logger$
|
|
7693
|
+
logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
7646
7694
|
|
|
7647
7695
|
if (this.heartbeatTimeoutCb) {
|
|
7648
7696
|
this.heartbeatTimeoutCb();
|
|
@@ -7654,7 +7702,7 @@ class WebRTCClient extends Emitter {
|
|
|
7654
7702
|
try {
|
|
7655
7703
|
await this.userAgent.transport.disconnect();
|
|
7656
7704
|
} catch (e) {
|
|
7657
|
-
logger$
|
|
7705
|
+
logger$3.error('Transport disconnection after heartbeat timeout, error', e);
|
|
7658
7706
|
}
|
|
7659
7707
|
}
|
|
7660
7708
|
|
|
@@ -7687,31 +7735,31 @@ class WebRTCClient extends Emitter {
|
|
|
7687
7735
|
}
|
|
7688
7736
|
|
|
7689
7737
|
_connectIfNeeded() {
|
|
7690
|
-
logger$
|
|
7738
|
+
logger$3.info('connect if needed, checking', { connected: this.isConnected() });
|
|
7691
7739
|
if (!this.userAgent) {
|
|
7692
|
-
logger$
|
|
7740
|
+
logger$3.info('need to recreate User Agent');
|
|
7693
7741
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
7694
7742
|
}
|
|
7695
7743
|
|
|
7696
7744
|
if (this.isConnected()) {
|
|
7697
|
-
logger$
|
|
7745
|
+
logger$3.info('webrtc sdk, already connected');
|
|
7698
7746
|
return Promise.resolve();
|
|
7699
7747
|
}
|
|
7700
7748
|
|
|
7701
7749
|
if (this.isConnecting()) {
|
|
7702
|
-
logger$
|
|
7750
|
+
logger$3.info('webrtc sdk, already connecting...');
|
|
7703
7751
|
|
|
7704
7752
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
7705
7753
|
return this.connectionPromise;
|
|
7706
7754
|
}
|
|
7707
7755
|
|
|
7708
7756
|
if (this.connectionPromise) {
|
|
7709
|
-
logger$
|
|
7757
|
+
logger$3.info('webrtc sdk, connection promise connecting...');
|
|
7710
7758
|
// $FlowFixMe
|
|
7711
7759
|
return this.connectionPromise;
|
|
7712
7760
|
}
|
|
7713
7761
|
|
|
7714
|
-
logger$
|
|
7762
|
+
logger$3.info('WebRTC UA needs to connect');
|
|
7715
7763
|
|
|
7716
7764
|
// Force UA to reconnect
|
|
7717
7765
|
if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
|
|
@@ -7836,7 +7884,7 @@ class WebRTCClient extends Emitter {
|
|
|
7836
7884
|
|
|
7837
7885
|
sdh.peerConnectionDelegate = {
|
|
7838
7886
|
onicecandidateerror: (error ) => {
|
|
7839
|
-
logger$
|
|
7887
|
+
logger$3.error('on icecandidate error', {
|
|
7840
7888
|
address: error.address,
|
|
7841
7889
|
port: error.port,
|
|
7842
7890
|
errorCode: error.errorCode,
|
|
@@ -7865,7 +7913,7 @@ class WebRTCClient extends Emitter {
|
|
|
7865
7913
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
7866
7914
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
7867
7915
|
}
|
|
7868
|
-
logger$
|
|
7916
|
+
logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
7869
7917
|
|
|
7870
7918
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
7871
7919
|
|
|
@@ -7881,12 +7929,12 @@ class WebRTCClient extends Emitter {
|
|
|
7881
7929
|
|
|
7882
7930
|
this._setupMedias(session);
|
|
7883
7931
|
|
|
7884
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
7932
|
+
return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
|
|
7885
7933
|
};
|
|
7886
7934
|
}
|
|
7887
7935
|
|
|
7888
7936
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
7889
|
-
logger$
|
|
7937
|
+
logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7890
7938
|
|
|
7891
7939
|
this.storeSipSession(session);
|
|
7892
7940
|
|
|
@@ -7898,14 +7946,14 @@ class WebRTCClient extends Emitter {
|
|
|
7898
7946
|
const onTrack = (event ) => {
|
|
7899
7947
|
const isAudioOnly = this._isAudioOnly(session);
|
|
7900
7948
|
const { kind, label, readyState, id, muted } = event.track;
|
|
7901
|
-
logger$
|
|
7949
|
+
logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
7902
7950
|
|
|
7903
7951
|
// Stop video track in audio only mode
|
|
7904
7952
|
if (isAudioOnly && kind === 'video') {
|
|
7905
7953
|
event.track.stop();
|
|
7906
7954
|
}
|
|
7907
7955
|
|
|
7908
|
-
this.eventEmitter.emit(ON_TRACK
|
|
7956
|
+
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
7909
7957
|
};
|
|
7910
7958
|
|
|
7911
7959
|
if (session.sessionDescriptionHandler.peerConnection) {
|
|
@@ -7915,8 +7963,9 @@ class WebRTCClient extends Emitter {
|
|
|
7915
7963
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
7916
7964
|
|
|
7917
7965
|
pc.oniceconnectionstatechange = () => {
|
|
7966
|
+
logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
7918
7967
|
if (pc.iceConnectionState === 'disconnected') {
|
|
7919
|
-
this.eventEmitter.emit(ON_DISCONNECTED
|
|
7968
|
+
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
7920
7969
|
}
|
|
7921
7970
|
};
|
|
7922
7971
|
|
|
@@ -8087,10 +8136,10 @@ class WebRTCClient extends Emitter {
|
|
|
8087
8136
|
|
|
8088
8137
|
_stopSendingStats(session ) {
|
|
8089
8138
|
const sessionId = this.getSipSessionId(session);
|
|
8090
|
-
logger$
|
|
8139
|
+
logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
8091
8140
|
|
|
8092
8141
|
if (sessionId in this.statsIntervals) {
|
|
8093
|
-
logger$
|
|
8142
|
+
logger$3.trace('Stop sending stats for call', { sessionId });
|
|
8094
8143
|
this.statsIntervals[sessionId]();
|
|
8095
8144
|
delete this.statsIntervals[sessionId];
|
|
8096
8145
|
}
|
|
@@ -8106,7 +8155,7 @@ class WebRTCClient extends Emitter {
|
|
|
8106
8155
|
try {
|
|
8107
8156
|
await this.userAgent.transport.disconnect();
|
|
8108
8157
|
} catch (e) {
|
|
8109
|
-
logger$
|
|
8158
|
+
logger$3.error('WebRTC transport disconnect, error', e);
|
|
8110
8159
|
}
|
|
8111
8160
|
}
|
|
8112
8161
|
}
|
|
@@ -8143,25 +8192,25 @@ class WebRTCClient extends Emitter {
|
|
|
8143
8192
|
|
|
8144
8193
|
stats.forEach(report => {
|
|
8145
8194
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
8146
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8195
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8147
8196
|
}
|
|
8148
8197
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
8149
|
-
audioBytesSent += report.bytesSent;
|
|
8198
|
+
audioBytesSent += Number(report.bytesSent);
|
|
8150
8199
|
}
|
|
8151
8200
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8152
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8201
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8153
8202
|
}
|
|
8154
8203
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
8155
|
-
packetsLost += report.packetsLost;
|
|
8156
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
8157
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8204
|
+
packetsLost += Number(report.packetsLost);
|
|
8205
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
8206
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8158
8207
|
}
|
|
8159
8208
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
8160
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8209
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8161
8210
|
}
|
|
8162
8211
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8163
8212
|
if ('framesPerSecond' in report) {
|
|
8164
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
8213
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
8165
8214
|
}
|
|
8166
8215
|
if ('framerateMean' in report) {
|
|
8167
8216
|
// framerateMean is only available in FF
|
|
@@ -8169,34 +8218,38 @@ class WebRTCClient extends Emitter {
|
|
|
8169
8218
|
}
|
|
8170
8219
|
}
|
|
8171
8220
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
8172
|
-
packetsLost += report.packetsLost;
|
|
8173
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
8174
|
-
networkStats.jitter = report.jitter;
|
|
8221
|
+
packetsLost += Number(report.packetsLost);
|
|
8222
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
8223
|
+
networkStats.jitter = Number(report.jitter);
|
|
8175
8224
|
}
|
|
8176
8225
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
8177
|
-
packetsLost += report.packetsLost;
|
|
8226
|
+
packetsLost += Number(report.packetsLost);
|
|
8178
8227
|
}
|
|
8179
8228
|
if (report.type === 'transport') {
|
|
8180
|
-
transportSent += report.bytesSent;
|
|
8181
|
-
transportReceived += report.bytesReceived;
|
|
8229
|
+
transportSent += Number(report.bytesSent);
|
|
8230
|
+
transportReceived += Number(report.bytesReceived);
|
|
8182
8231
|
}
|
|
8183
8232
|
});
|
|
8184
8233
|
|
|
8185
8234
|
networkStats.packetsLost = packetsLost;
|
|
8186
|
-
networkStats.
|
|
8235
|
+
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
8236
|
+
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
8237
|
+
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
8187
8238
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
8188
|
-
networkStats.
|
|
8189
|
-
networkStats.
|
|
8239
|
+
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
8240
|
+
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
8241
|
+
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
8242
|
+
networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
|
|
8243
|
+
networkStats.totalTransportSent = transportSent - lastTransportSent;
|
|
8190
8244
|
networkStats.transportSent = transportSent;
|
|
8191
|
-
networkStats.
|
|
8245
|
+
networkStats.totalTransportReceived = transportReceived;
|
|
8246
|
+
networkStats.transportReceived = transportReceived - lastTransportReceived;
|
|
8192
8247
|
|
|
8193
|
-
|
|
8194
|
-
+
|
|
8195
|
-
+
|
|
8248
|
+
networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
|
|
8249
|
+
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
8250
|
+
+ networkStats.transportSent;
|
|
8196
8251
|
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
8252
|
+
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
8200
8253
|
this.sessionNetworkStats[sessionId].push(networkStats);
|
|
8201
8254
|
}
|
|
8202
8255
|
|
|
@@ -8204,7 +8257,7 @@ class WebRTCClient extends Emitter {
|
|
|
8204
8257
|
|
|
8205
8258
|
//
|
|
8206
8259
|
|
|
8207
|
-
const SOCKET_EVENTS
|
|
8260
|
+
const SOCKET_EVENTS = {
|
|
8208
8261
|
ON_OPEN: 'onopen',
|
|
8209
8262
|
ON_MESSAGE: 'onmessage',
|
|
8210
8263
|
ON_ERROR: 'onerror',
|
|
@@ -8290,6 +8343,7 @@ const AGENT_PAUSED = 'agent_paused';
|
|
|
8290
8343
|
const AGENT_UNPAUSED = 'agent_unpaused';
|
|
8291
8344
|
const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
|
|
8292
8345
|
const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
|
|
8346
|
+
const MEETING_USER_PROGRESS = 'meeting_user_progress';
|
|
8293
8347
|
|
|
8294
8348
|
const BLACKLIST_EVENTS = [
|
|
8295
8349
|
CHAT_MESSAGE_SENT,
|
|
@@ -8299,7 +8353,7 @@ const BLACKLIST_EVENTS = [
|
|
|
8299
8353
|
];
|
|
8300
8354
|
|
|
8301
8355
|
const HEARTBEAT_ENGINE_VERSION = '20.09';
|
|
8302
|
-
const logger$
|
|
8356
|
+
const logger$4 = IssueReporter$1.loggerFor('wazo-ws');
|
|
8303
8357
|
const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
|
|
8304
8358
|
|
|
8305
8359
|
class WebSocketClient extends Emitter {
|
|
@@ -8348,24 +8402,24 @@ class WebSocketClient extends Emitter {
|
|
|
8348
8402
|
}
|
|
8349
8403
|
|
|
8350
8404
|
connect() {
|
|
8351
|
-
logger$
|
|
8405
|
+
logger$4.info('connect method started', { host: this.host, token: this.token });
|
|
8352
8406
|
this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
|
|
8353
8407
|
if (this.options.binaryType) {
|
|
8354
8408
|
this.socket.binaryType = this.options.binaryType;
|
|
8355
8409
|
}
|
|
8356
8410
|
|
|
8357
8411
|
this.socket.onopen = () => {
|
|
8358
|
-
logger$
|
|
8359
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
8412
|
+
logger$4.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
8413
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
8360
8414
|
};
|
|
8361
8415
|
|
|
8362
8416
|
this.socket.onerror = event => {
|
|
8363
|
-
logger$
|
|
8364
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
8417
|
+
logger$4.error('on Wazo WS error', event.target);
|
|
8418
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
8365
8419
|
};
|
|
8366
8420
|
|
|
8367
8421
|
this.socket.onmessage = (event ) => {
|
|
8368
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
8422
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
|
|
8369
8423
|
|
|
8370
8424
|
const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
|
|
8371
8425
|
let { name } = message;
|
|
@@ -8390,7 +8444,7 @@ class WebSocketClient extends Emitter {
|
|
|
8390
8444
|
|
|
8391
8445
|
this.socket.onclose = event => {
|
|
8392
8446
|
// Can't be converted to JSON (circular structure)
|
|
8393
|
-
logger$
|
|
8447
|
+
logger$4.info('on Wazo WS close', {
|
|
8394
8448
|
reason: event.reason,
|
|
8395
8449
|
code: event.code,
|
|
8396
8450
|
readyState: event.target.readyState,
|
|
@@ -8398,22 +8452,22 @@ class WebSocketClient extends Emitter {
|
|
|
8398
8452
|
token: this.token,
|
|
8399
8453
|
});
|
|
8400
8454
|
this.initialized = false;
|
|
8401
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
8455
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
|
|
8402
8456
|
|
|
8403
8457
|
switch (event.code) {
|
|
8404
8458
|
case 4002:
|
|
8405
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
8459
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
|
|
8406
8460
|
break;
|
|
8407
8461
|
}
|
|
8408
8462
|
};
|
|
8409
8463
|
|
|
8410
8464
|
this.socket.onerror = event => {
|
|
8411
|
-
logger$
|
|
8465
|
+
logger$4.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
8412
8466
|
};
|
|
8413
8467
|
}
|
|
8414
8468
|
|
|
8415
8469
|
close(force = false) {
|
|
8416
|
-
logger$
|
|
8470
|
+
logger$4.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
8417
8471
|
|
|
8418
8472
|
if (!this.socket) {
|
|
8419
8473
|
return;
|
|
@@ -8431,7 +8485,7 @@ class WebSocketClient extends Emitter {
|
|
|
8431
8485
|
|
|
8432
8486
|
updateToken(token ) {
|
|
8433
8487
|
this.token = token;
|
|
8434
|
-
logger$
|
|
8488
|
+
logger$4.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
8435
8489
|
|
|
8436
8490
|
if (this.socket) {
|
|
8437
8491
|
// If still connected, send the token to the WS
|
|
@@ -8449,7 +8503,7 @@ class WebSocketClient extends Emitter {
|
|
|
8449
8503
|
}
|
|
8450
8504
|
|
|
8451
8505
|
startHeartbeat() {
|
|
8452
|
-
logger$
|
|
8506
|
+
logger$4.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
8453
8507
|
|
|
8454
8508
|
if (!this.socket) {
|
|
8455
8509
|
this.heartbeat.stop();
|
|
@@ -8463,7 +8517,7 @@ class WebSocketClient extends Emitter {
|
|
|
8463
8517
|
}
|
|
8464
8518
|
|
|
8465
8519
|
stopHeartbeat() {
|
|
8466
|
-
logger$
|
|
8520
|
+
logger$4.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
8467
8521
|
|
|
8468
8522
|
this.heartbeat.stop();
|
|
8469
8523
|
}
|
|
@@ -8493,7 +8547,7 @@ class WebSocketClient extends Emitter {
|
|
|
8493
8547
|
}
|
|
8494
8548
|
|
|
8495
8549
|
reconnect(reason ) {
|
|
8496
|
-
logger$
|
|
8550
|
+
logger$4.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
8497
8551
|
if (!this.socket) {
|
|
8498
8552
|
return;
|
|
8499
8553
|
}
|
|
@@ -8518,7 +8572,7 @@ class WebSocketClient extends Emitter {
|
|
|
8518
8572
|
break;
|
|
8519
8573
|
case 'start':
|
|
8520
8574
|
this.initialized = true;
|
|
8521
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
8575
|
+
this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
|
|
8522
8576
|
break;
|
|
8523
8577
|
default:
|
|
8524
8578
|
this.eventEmitter.emit('message', message);
|
|
@@ -8549,7 +8603,7 @@ class WebSocketClient extends Emitter {
|
|
|
8549
8603
|
this.close();
|
|
8550
8604
|
}
|
|
8551
8605
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
8552
|
-
logger$
|
|
8606
|
+
logger$4.log('Wazo WS url computed to reconnect', { url });
|
|
8553
8607
|
|
|
8554
8608
|
return url;
|
|
8555
8609
|
}
|
|
@@ -8557,15 +8611,15 @@ class WebSocketClient extends Emitter {
|
|
|
8557
8611
|
_onHeartbeat(message ) {
|
|
8558
8612
|
if (message.payload === 'pong') {
|
|
8559
8613
|
this.heartbeat.onHeartbeat();
|
|
8560
|
-
logger$
|
|
8614
|
+
logger$4.log('on heartbeat received from Wazo WS');
|
|
8561
8615
|
}
|
|
8562
8616
|
}
|
|
8563
8617
|
|
|
8564
8618
|
async _onHeartbeatTimeout() {
|
|
8565
|
-
logger$
|
|
8619
|
+
logger$4.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
8566
8620
|
|
|
8567
8621
|
this.close();
|
|
8568
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
8622
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
8569
8623
|
|
|
8570
8624
|
if (this.onHeartBeatTimeout) {
|
|
8571
8625
|
this.onHeartBeatTimeout();
|
|
@@ -8640,11 +8694,12 @@ WebSocketClient.eventLists = [
|
|
|
8640
8694
|
AGENT_UNPAUSED,
|
|
8641
8695
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
8642
8696
|
CONFERENCE_ADHOC_DELETED,
|
|
8697
|
+
MEETING_USER_PROGRESS,
|
|
8643
8698
|
];
|
|
8644
8699
|
|
|
8645
8700
|
var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
8646
8701
|
__proto__: null,
|
|
8647
|
-
SOCKET_EVENTS: SOCKET_EVENTS
|
|
8702
|
+
SOCKET_EVENTS: SOCKET_EVENTS,
|
|
8648
8703
|
AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
|
|
8649
8704
|
FAVORITE_ADDED: FAVORITE_ADDED,
|
|
8650
8705
|
FAVORITE_DELETED: FAVORITE_DELETED,
|
|
@@ -8710,6 +8765,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
8710
8765
|
AGENT_UNPAUSED: AGENT_UNPAUSED,
|
|
8711
8766
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
8712
8767
|
CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
|
|
8768
|
+
MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
|
|
8713
8769
|
HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
|
|
8714
8770
|
'default': WebSocketClient
|
|
8715
8771
|
});
|
|
@@ -8876,7 +8932,7 @@ class NotificationOptions {
|
|
|
8876
8932
|
|
|
8877
8933
|
|
|
8878
8934
|
// Represents a conference room, like `9000`.
|
|
8879
|
-
class Room
|
|
8935
|
+
class Room {
|
|
8880
8936
|
|
|
8881
8937
|
|
|
8882
8938
|
|
|
@@ -8897,7 +8953,7 @@ class Room$1 {
|
|
|
8897
8953
|
}
|
|
8898
8954
|
|
|
8899
8955
|
connect(callSession ) {
|
|
8900
|
-
return new Room
|
|
8956
|
+
return new Room({ ...this, connectedCallSession: callSession });
|
|
8901
8957
|
}
|
|
8902
8958
|
|
|
8903
8959
|
has(callSession ) {
|
|
@@ -8906,7 +8962,7 @@ class Room$1 {
|
|
|
8906
8962
|
|
|
8907
8963
|
addParticipant(uuid , extension , talking = null) {
|
|
8908
8964
|
if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
|
|
8909
|
-
return new Room
|
|
8965
|
+
return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
8910
8966
|
}
|
|
8911
8967
|
|
|
8912
8968
|
return this;
|
|
@@ -8925,7 +8981,7 @@ class Room$1 {
|
|
|
8925
8981
|
updatedParticipants.push(participant);
|
|
8926
8982
|
}
|
|
8927
8983
|
|
|
8928
|
-
return new Room
|
|
8984
|
+
return new Room({ ...this, participants: updatedParticipants });
|
|
8929
8985
|
}
|
|
8930
8986
|
|
|
8931
8987
|
updateParticipantByExtension(extension , participant , shouldAdd = false) {
|
|
@@ -8941,7 +8997,7 @@ class Room$1 {
|
|
|
8941
8997
|
updatedParticipants.push(participant);
|
|
8942
8998
|
}
|
|
8943
8999
|
|
|
8944
|
-
return new Room
|
|
9000
|
+
return new Room({ ...this, participants: updatedParticipants });
|
|
8945
9001
|
}
|
|
8946
9002
|
|
|
8947
9003
|
hasCallWithId(id ) {
|
|
@@ -8949,18 +9005,18 @@ class Room$1 {
|
|
|
8949
9005
|
}
|
|
8950
9006
|
|
|
8951
9007
|
disconnect() {
|
|
8952
|
-
return new Room
|
|
9008
|
+
return new Room({ ...this, connectedCallSession: null });
|
|
8953
9009
|
}
|
|
8954
9010
|
|
|
8955
9011
|
removeParticipantWithUUID(uuid ) {
|
|
8956
|
-
return new Room
|
|
9012
|
+
return new Room({
|
|
8957
9013
|
...this,
|
|
8958
9014
|
participants: this.participants.filter(participant => participant.uuid !== uuid),
|
|
8959
9015
|
});
|
|
8960
9016
|
}
|
|
8961
9017
|
|
|
8962
9018
|
removeParticipantWithExtension(extension ) {
|
|
8963
|
-
return new Room
|
|
9019
|
+
return new Room({
|
|
8964
9020
|
...this,
|
|
8965
9021
|
participants: this.participants.filter(participant => participant.extension !== extension),
|
|
8966
9022
|
});
|
|
@@ -8971,7 +9027,7 @@ class Room$1 {
|
|
|
8971
9027
|
}
|
|
8972
9028
|
|
|
8973
9029
|
static newFrom(room ) {
|
|
8974
|
-
return newFrom(room, Room
|
|
9030
|
+
return newFrom(room, Room);
|
|
8975
9031
|
}
|
|
8976
9032
|
}
|
|
8977
9033
|
|
|
@@ -9114,8 +9170,8 @@ const ON_CALL_FAILED = 'onCallFailed';
|
|
|
9114
9170
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
9115
9171
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
9116
9172
|
const ON_MESSAGE = 'onMessage';
|
|
9117
|
-
const ON_REINVITE = 'reinvite';
|
|
9118
|
-
const ON_TRACK = 'onTrack';
|
|
9173
|
+
const ON_REINVITE$1 = 'reinvite';
|
|
9174
|
+
const ON_TRACK$1 = 'onTrack';
|
|
9119
9175
|
const ON_AUDIO_STREAM = 'onAudioStream';
|
|
9120
9176
|
const ON_VIDEO_STREAM = 'onVideoStream';
|
|
9121
9177
|
const ON_REMOVE_STREAM = 'onRemoveStream';
|
|
@@ -9130,15 +9186,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
|
|
|
9130
9186
|
const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
|
|
9131
9187
|
const ON_CALL_ERROR = 'onCallError';
|
|
9132
9188
|
const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
|
|
9133
|
-
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
9189
|
+
const ON_NETWORK_STATS$1 = 'onNetworkStats';
|
|
9134
9190
|
const ON_CHAT = 'phone/ON_CHAT';
|
|
9135
9191
|
const ON_SIGNAL = 'phone/ON_SIGNAL';
|
|
9136
|
-
const ON_DISCONNECTED = 'onDisconnected';
|
|
9192
|
+
const ON_DISCONNECTED$1 = 'onDisconnected';
|
|
9137
9193
|
|
|
9138
9194
|
const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
9139
9195
|
const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
9140
9196
|
|
|
9141
|
-
const events = [
|
|
9197
|
+
const events$1 = [
|
|
9142
9198
|
ON_USER_AGENT,
|
|
9143
9199
|
ON_REGISTERED,
|
|
9144
9200
|
ON_UNREGISTERED,
|
|
@@ -9156,8 +9212,8 @@ const events = [
|
|
|
9156
9212
|
ON_CALL_FAILED,
|
|
9157
9213
|
ON_CALL_ENDED,
|
|
9158
9214
|
ON_MESSAGE,
|
|
9159
|
-
ON_REINVITE,
|
|
9160
|
-
ON_TRACK,
|
|
9215
|
+
ON_REINVITE$1,
|
|
9216
|
+
ON_TRACK$1,
|
|
9161
9217
|
ON_AUDIO_STREAM,
|
|
9162
9218
|
ON_VIDEO_STREAM,
|
|
9163
9219
|
ON_REMOVE_STREAM,
|
|
@@ -9172,11 +9228,11 @@ const events = [
|
|
|
9172
9228
|
ON_CALL_ERROR,
|
|
9173
9229
|
ON_CHAT,
|
|
9174
9230
|
ON_SIGNAL,
|
|
9175
|
-
ON_NETWORK_STATS,
|
|
9176
|
-
ON_DISCONNECTED,
|
|
9231
|
+
ON_NETWORK_STATS$1,
|
|
9232
|
+
ON_DISCONNECTED$1,
|
|
9177
9233
|
];
|
|
9178
9234
|
|
|
9179
|
-
const logger$
|
|
9235
|
+
const logger$5 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
9180
9236
|
|
|
9181
9237
|
class WebRTCPhone extends Emitter {
|
|
9182
9238
|
|
|
@@ -9249,7 +9305,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9249
9305
|
}).catch(error => {
|
|
9250
9306
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
9251
9307
|
console.error('register error', error, error.message, error.stack);
|
|
9252
|
-
logger$
|
|
9308
|
+
logger$5.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
9253
9309
|
});
|
|
9254
9310
|
}
|
|
9255
9311
|
|
|
@@ -9264,7 +9320,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9264
9320
|
if (!this.client) {
|
|
9265
9321
|
return;
|
|
9266
9322
|
}
|
|
9267
|
-
logger$
|
|
9323
|
+
logger$5.info('WebRTC phone stop');
|
|
9268
9324
|
this.client.stop();
|
|
9269
9325
|
}
|
|
9270
9326
|
|
|
@@ -9279,7 +9335,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9279
9335
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
9280
9336
|
audioOnly = false, iceRestart = false) {
|
|
9281
9337
|
const sipSession = this.findSipSession(callSession);
|
|
9282
|
-
logger$
|
|
9338
|
+
logger$5.info('WebRTC phone - send reinvite', {
|
|
9283
9339
|
sessionId: sipSession ? sipSession.id : null,
|
|
9284
9340
|
constraints,
|
|
9285
9341
|
audioOnly,
|
|
@@ -9316,7 +9372,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9316
9372
|
}
|
|
9317
9373
|
|
|
9318
9374
|
startHeartbeat() {
|
|
9319
|
-
logger$
|
|
9375
|
+
logger$5.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
9320
9376
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
9321
9377
|
return;
|
|
9322
9378
|
}
|
|
@@ -9325,7 +9381,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9325
9381
|
}
|
|
9326
9382
|
|
|
9327
9383
|
stopHeartbeat() {
|
|
9328
|
-
logger$
|
|
9384
|
+
logger$5.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
9329
9385
|
if (!this.client) {
|
|
9330
9386
|
return;
|
|
9331
9387
|
}
|
|
@@ -9342,7 +9398,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9342
9398
|
}
|
|
9343
9399
|
|
|
9344
9400
|
reconnect() {
|
|
9345
|
-
logger$
|
|
9401
|
+
logger$5.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
9346
9402
|
if (!this.client) {
|
|
9347
9403
|
return;
|
|
9348
9404
|
}
|
|
@@ -9383,10 +9439,15 @@ class WebRTCPhone extends Emitter {
|
|
|
9383
9439
|
return false;
|
|
9384
9440
|
}
|
|
9385
9441
|
|
|
9386
|
-
logger$
|
|
9442
|
+
logger$5.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
9387
9443
|
|
|
9388
9444
|
this.client.downgradeToAudio(sipSession);
|
|
9389
9445
|
|
|
9446
|
+
if (callSession) {
|
|
9447
|
+
callSession.cameraEnabled = false;
|
|
9448
|
+
this._updateCallSession(callSession);
|
|
9449
|
+
}
|
|
9450
|
+
|
|
9390
9451
|
if (withMessage) {
|
|
9391
9452
|
this._sendReinviteMessage(callSession, false);
|
|
9392
9453
|
}
|
|
@@ -9401,7 +9462,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9401
9462
|
return Promise.resolve(false);
|
|
9402
9463
|
}
|
|
9403
9464
|
|
|
9404
|
-
logger$
|
|
9465
|
+
logger$5.info('Upgrade to video', {
|
|
9405
9466
|
id: callSession ? callSession.getId() : null,
|
|
9406
9467
|
constraints,
|
|
9407
9468
|
isConference,
|
|
@@ -9414,6 +9475,11 @@ class WebRTCPhone extends Emitter {
|
|
|
9414
9475
|
|
|
9415
9476
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
9416
9477
|
|
|
9478
|
+
if (callSession) {
|
|
9479
|
+
callSession.cameraEnabled = true;
|
|
9480
|
+
this._updateCallSession(callSession);
|
|
9481
|
+
}
|
|
9482
|
+
|
|
9417
9483
|
// If no stream is returned, it means we have to reinvite
|
|
9418
9484
|
if (!newStream) {
|
|
9419
9485
|
return true;
|
|
@@ -9436,7 +9502,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9436
9502
|
|
|
9437
9503
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
9438
9504
|
const sipSession = this.findSipSession(callSession);
|
|
9439
|
-
logger$
|
|
9505
|
+
logger$5.info('Sending reinvite message', {
|
|
9440
9506
|
id: callSession ? callSession.getId() : null,
|
|
9441
9507
|
isUpgrade,
|
|
9442
9508
|
});
|
|
@@ -9462,11 +9528,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9462
9528
|
// Monkey patch to know when canceled with the CANCEL message
|
|
9463
9529
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
9464
9530
|
sipSession._onCancel = (message ) => {
|
|
9465
|
-
logger$
|
|
9531
|
+
logger$5.trace('on sip session canceled', { callId: message.callId });
|
|
9466
9532
|
|
|
9467
9533
|
onCancel(message);
|
|
9468
9534
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
9469
|
-
|
|
9535
|
+
const callSession = this._createCallSession(sipSession);
|
|
9536
|
+
delete this.callSessions[callSession.getId()];
|
|
9537
|
+
|
|
9538
|
+
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
9470
9539
|
};
|
|
9471
9540
|
} else if (sipSession instanceof invitation.Invitation) {
|
|
9472
9541
|
console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
|
|
@@ -9487,17 +9556,19 @@ class WebRTCPhone extends Emitter {
|
|
|
9487
9556
|
this.audioOutputVolume,
|
|
9488
9557
|
);
|
|
9489
9558
|
case sessionState.SessionState.Terminating:
|
|
9490
|
-
logger$
|
|
9559
|
+
logger$5.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
9491
9560
|
|
|
9492
9561
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
9493
9562
|
|
|
9494
9563
|
break;
|
|
9495
9564
|
case sessionState.SessionState.Terminated: {
|
|
9496
|
-
logger$
|
|
9565
|
+
logger$5.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
9497
9566
|
|
|
9567
|
+
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
9568
|
+
const callSession = this._createCallSession(sipSession);
|
|
9498
9569
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
9499
9570
|
|
|
9500
|
-
return this.eventEmitter.emit(ON_CALL_ENDED,
|
|
9571
|
+
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
9501
9572
|
}
|
|
9502
9573
|
}
|
|
9503
9574
|
});
|
|
@@ -9513,7 +9584,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9513
9584
|
const [stream] = event.streams;
|
|
9514
9585
|
const kind = event && event.track && event.track.kind;
|
|
9515
9586
|
|
|
9516
|
-
logger$
|
|
9587
|
+
logger$5.info('on track stream called on the peer connection', {
|
|
9517
9588
|
callId: this.getSipSessionId(sipSession),
|
|
9518
9589
|
streamId: stream ? stream.id : null,
|
|
9519
9590
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -9533,7 +9604,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9533
9604
|
};
|
|
9534
9605
|
|
|
9535
9606
|
peerConnection.onremovestream = event => {
|
|
9536
|
-
logger$
|
|
9607
|
+
logger$5.info('on remove stream called on the peer connection', {
|
|
9537
9608
|
id: event.stream.id,
|
|
9538
9609
|
tracks: event.stream.getTracks(),
|
|
9539
9610
|
});
|
|
@@ -9543,7 +9614,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9543
9614
|
}
|
|
9544
9615
|
|
|
9545
9616
|
async startScreenSharing(constraints , callSession ) {
|
|
9546
|
-
logger$
|
|
9617
|
+
logger$5.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
9547
9618
|
|
|
9548
9619
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
9549
9620
|
if (!screenShareStream) {
|
|
@@ -9583,7 +9654,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9583
9654
|
return;
|
|
9584
9655
|
}
|
|
9585
9656
|
|
|
9586
|
-
logger$
|
|
9657
|
+
logger$5.info('WebRTC phone - stop screen sharing', {
|
|
9587
9658
|
restoreLocalStream,
|
|
9588
9659
|
});
|
|
9589
9660
|
|
|
@@ -9639,24 +9710,26 @@ class WebRTCPhone extends Emitter {
|
|
|
9639
9710
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
9640
9711
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
9641
9712
|
|
|
9642
|
-
logger$
|
|
9713
|
+
logger$5.info('WebRTC phone - on screensharing', {
|
|
9643
9714
|
hadVideo,
|
|
9644
9715
|
id: this.getSipSessionId(sipSession),
|
|
9645
9716
|
screenTrack,
|
|
9646
9717
|
});
|
|
9647
9718
|
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9719
|
+
if (screenTrack) {
|
|
9720
|
+
screenTrack.onended = () => {
|
|
9721
|
+
logger$5.info('WebRTC phone - on screenshare ended', {
|
|
9722
|
+
hadVideo,
|
|
9723
|
+
id: this.getSipSessionId(sipSession),
|
|
9724
|
+
screenTrack,
|
|
9725
|
+
});
|
|
9654
9726
|
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
|
|
9727
|
+
this.eventEmitter.emit(
|
|
9728
|
+
ON_SHARE_SCREEN_ENDING,
|
|
9729
|
+
this._createCallSession(sipSession, callSession),
|
|
9730
|
+
);
|
|
9731
|
+
};
|
|
9732
|
+
}
|
|
9660
9733
|
|
|
9661
9734
|
this.currentScreenShare = {
|
|
9662
9735
|
stream: screenStream,
|
|
@@ -9676,7 +9749,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9676
9749
|
}
|
|
9677
9750
|
|
|
9678
9751
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
9679
|
-
logger$
|
|
9752
|
+
logger$5.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
9680
9753
|
|
|
9681
9754
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
9682
9755
|
this.currentSipSession = sipSession;
|
|
@@ -9694,7 +9767,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9694
9767
|
}
|
|
9695
9768
|
|
|
9696
9769
|
changeAudioDevice(id ) {
|
|
9697
|
-
logger$
|
|
9770
|
+
logger$5.info('WebRTC phone - change audio device', { deviceId: id });
|
|
9698
9771
|
this.audioOutputDeviceId = id;
|
|
9699
9772
|
this.client.changeAudioOutputDevice(id);
|
|
9700
9773
|
}
|
|
@@ -9704,14 +9777,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9704
9777
|
}
|
|
9705
9778
|
|
|
9706
9779
|
changeRingDevice(id ) {
|
|
9707
|
-
logger$
|
|
9780
|
+
logger$5.info('WebRTC phone - changing ring device', { id });
|
|
9708
9781
|
|
|
9709
9782
|
this.audioRingDeviceId = id;
|
|
9710
9783
|
}
|
|
9711
9784
|
|
|
9712
9785
|
// volume is a value between 0 and 1
|
|
9713
9786
|
changeAudioVolume(volume ) {
|
|
9714
|
-
logger$
|
|
9787
|
+
logger$5.info('WebRTC phone - changing audio volume', { volume });
|
|
9715
9788
|
|
|
9716
9789
|
this.audioOutputVolume = volume;
|
|
9717
9790
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -9719,31 +9792,31 @@ class WebRTCPhone extends Emitter {
|
|
|
9719
9792
|
|
|
9720
9793
|
// volume is a value between 0 and 1
|
|
9721
9794
|
changeRingVolume(volume ) {
|
|
9722
|
-
logger$
|
|
9795
|
+
logger$5.info('WebRTC phone - changing ring volume', { volume });
|
|
9723
9796
|
|
|
9724
9797
|
this.audioRingVolume = volume;
|
|
9725
9798
|
}
|
|
9726
9799
|
|
|
9727
9800
|
changeAudioInputDevice(id ) {
|
|
9728
|
-
logger$
|
|
9801
|
+
logger$5.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
9729
9802
|
|
|
9730
9803
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
9731
9804
|
}
|
|
9732
9805
|
|
|
9733
9806
|
changeVideoInputDevice(id ) {
|
|
9734
|
-
logger$
|
|
9807
|
+
logger$5.info('WebRTC phone - change video input device', { deviceId: id });
|
|
9735
9808
|
|
|
9736
9809
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
9737
9810
|
}
|
|
9738
9811
|
|
|
9739
9812
|
changeSessionVideoInputDevice(id ) {
|
|
9740
|
-
logger$
|
|
9813
|
+
logger$5.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
9741
9814
|
|
|
9742
9815
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
9743
9816
|
}
|
|
9744
9817
|
|
|
9745
9818
|
_onCallTerminated(sipSession ) {
|
|
9746
|
-
logger$
|
|
9819
|
+
logger$5.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9747
9820
|
|
|
9748
9821
|
const callSession = this._createCallSession(sipSession);
|
|
9749
9822
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -9777,7 +9850,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9777
9850
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
9778
9851
|
|
|
9779
9852
|
// Re-trigger incoming call event for remaining incoming calls
|
|
9780
|
-
logger$
|
|
9853
|
+
logger$5.info('WebRTC phone - check to re-trigger incoming call', {
|
|
9781
9854
|
sipId: sipSession.id,
|
|
9782
9855
|
shouldRetrigger,
|
|
9783
9856
|
hasIncomingCallSession,
|
|
@@ -9868,37 +9941,37 @@ class WebRTCPhone extends Emitter {
|
|
|
9868
9941
|
|
|
9869
9942
|
// Deprecated
|
|
9870
9943
|
getLocalStreamForCall(callSession ) {
|
|
9871
|
-
logger$
|
|
9944
|
+
logger$5.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9872
9945
|
|
|
9873
9946
|
return this.getLocalStream(callSession);
|
|
9874
9947
|
}
|
|
9875
9948
|
|
|
9876
9949
|
// Deprecated
|
|
9877
9950
|
getRemoteStreamForCall(callSession ) {
|
|
9878
|
-
logger$
|
|
9951
|
+
logger$5.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
9879
9952
|
|
|
9880
9953
|
return this.getRemoteVideoStream(callSession);
|
|
9881
9954
|
}
|
|
9882
9955
|
|
|
9883
9956
|
getRemoteStreamsForCall(callSession ) {
|
|
9884
|
-
logger$
|
|
9957
|
+
logger$5.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
9885
9958
|
|
|
9886
9959
|
return this.getRemoteStream(callSession);
|
|
9887
9960
|
}
|
|
9888
9961
|
|
|
9889
9962
|
accept(callSession , cameraEnabled ) {
|
|
9890
|
-
logger$
|
|
9963
|
+
logger$5.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
9891
9964
|
if (this.currentSipSession) {
|
|
9892
9965
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
9893
9966
|
}
|
|
9894
9967
|
|
|
9895
9968
|
if (!callSession) {
|
|
9896
|
-
logger$
|
|
9969
|
+
logger$5.warn('no CallSession to accept.');
|
|
9897
9970
|
return Promise.resolve(null);
|
|
9898
9971
|
}
|
|
9899
9972
|
|
|
9900
9973
|
if (callSession.getId() in this.acceptedSessions) {
|
|
9901
|
-
logger$
|
|
9974
|
+
logger$5.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9902
9975
|
return Promise.resolve(callSession.sipCallId);
|
|
9903
9976
|
}
|
|
9904
9977
|
|
|
@@ -9910,24 +9983,24 @@ class WebRTCPhone extends Emitter {
|
|
|
9910
9983
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
9911
9984
|
if (sipSession) {
|
|
9912
9985
|
if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
|
|
9913
|
-
logger$
|
|
9986
|
+
logger$5.warn('Trying to answer a terminated sipSession.');
|
|
9914
9987
|
|
|
9915
9988
|
return Promise.resolve(null);
|
|
9916
9989
|
}
|
|
9917
9990
|
|
|
9918
|
-
logger$
|
|
9991
|
+
logger$5.info('accept call, session found', { sipId: sipSession.id });
|
|
9919
9992
|
|
|
9920
9993
|
// $FlowFixMe
|
|
9921
9994
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
9922
9995
|
return callSession.sipCallId;
|
|
9923
9996
|
}).catch(e => {
|
|
9924
|
-
logger$
|
|
9997
|
+
logger$5.error(e);
|
|
9925
9998
|
this.endCurrentCall(callSession);
|
|
9926
9999
|
throw e;
|
|
9927
10000
|
});
|
|
9928
10001
|
}
|
|
9929
10002
|
|
|
9930
|
-
logger$
|
|
10003
|
+
logger$5.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9931
10004
|
|
|
9932
10005
|
return Promise.resolve(null);
|
|
9933
10006
|
}
|
|
@@ -9937,7 +10010,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9937
10010
|
}
|
|
9938
10011
|
|
|
9939
10012
|
async reject(callSession ) {
|
|
9940
|
-
logger$
|
|
10013
|
+
logger$5.info('reject WebRTC called', { id: callSession.getId() });
|
|
9941
10014
|
|
|
9942
10015
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
9943
10016
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -9949,14 +10022,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9949
10022
|
|
|
9950
10023
|
const sipSession = this.findSipSession(callSession);
|
|
9951
10024
|
if (sipSession) {
|
|
9952
|
-
logger$
|
|
10025
|
+
logger$5.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
9953
10026
|
|
|
9954
10027
|
this.client.hangup(sipSession);
|
|
9955
10028
|
}
|
|
9956
10029
|
}
|
|
9957
10030
|
|
|
9958
10031
|
async ignore(callSession ) {
|
|
9959
|
-
logger$
|
|
10032
|
+
logger$5.info('WebRTC ignore', { id: callSession.getId() });
|
|
9960
10033
|
|
|
9961
10034
|
// kill the ring
|
|
9962
10035
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -9968,14 +10041,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9968
10041
|
const sipSession = this.findSipSession(callSession);
|
|
9969
10042
|
|
|
9970
10043
|
if (sipSession) {
|
|
9971
|
-
logger$
|
|
10044
|
+
logger$5.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
9972
10045
|
|
|
9973
10046
|
return this.client.atxfer(sipSession);
|
|
9974
10047
|
}
|
|
9975
10048
|
}
|
|
9976
10049
|
|
|
9977
10050
|
hold(callSession , withEvent = true, isConference = false) {
|
|
9978
|
-
logger$
|
|
10051
|
+
logger$5.info('WebRTC hold', { id: callSession.getId() });
|
|
9979
10052
|
|
|
9980
10053
|
const sipSession = this.findSipSession(callSession);
|
|
9981
10054
|
|
|
@@ -9990,18 +10063,18 @@ class WebRTCPhone extends Emitter {
|
|
|
9990
10063
|
}
|
|
9991
10064
|
|
|
9992
10065
|
resume(callSession , isConference = false, withEvent = true) {
|
|
9993
|
-
logger$
|
|
10066
|
+
logger$5.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
9994
10067
|
|
|
9995
10068
|
const sipSession = this.findSipSession(callSession);
|
|
9996
10069
|
if (!sipSession) {
|
|
9997
10070
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
9998
10071
|
}
|
|
9999
10072
|
|
|
10000
|
-
logger$
|
|
10073
|
+
logger$5.info('WebRTC resuming', { sipId: sipSession.id });
|
|
10001
10074
|
|
|
10002
10075
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
10003
10076
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
10004
|
-
logger$
|
|
10077
|
+
logger$5.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
10005
10078
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
10006
10079
|
}
|
|
10007
10080
|
|
|
@@ -10026,7 +10099,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10026
10099
|
const sessionId = this.getSipSessionId(sipSession);
|
|
10027
10100
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
10028
10101
|
|
|
10029
|
-
logger$
|
|
10102
|
+
logger$5.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
10030
10103
|
|
|
10031
10104
|
// Stop screenshre if needed
|
|
10032
10105
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -10057,7 +10130,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10057
10130
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
10058
10131
|
}
|
|
10059
10132
|
const sessionId = this.getSipSessionId(sipSession);
|
|
10060
|
-
logger$
|
|
10133
|
+
logger$5.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
10061
10134
|
|
|
10062
10135
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
10063
10136
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -10101,14 +10174,14 @@ class WebRTCPhone extends Emitter {
|
|
|
10101
10174
|
}
|
|
10102
10175
|
|
|
10103
10176
|
mute(callSession , withEvent = true) {
|
|
10104
|
-
logger$
|
|
10177
|
+
logger$5.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
10105
10178
|
|
|
10106
10179
|
const sipSession = this.findSipSession(callSession);
|
|
10107
10180
|
if (!sipSession) {
|
|
10108
10181
|
return;
|
|
10109
10182
|
}
|
|
10110
10183
|
|
|
10111
|
-
logger$
|
|
10184
|
+
logger$5.info('WebRTC muting', { sipId: sipSession.id });
|
|
10112
10185
|
this.client.mute(sipSession);
|
|
10113
10186
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
10114
10187
|
|
|
@@ -10122,14 +10195,14 @@ class WebRTCPhone extends Emitter {
|
|
|
10122
10195
|
}
|
|
10123
10196
|
|
|
10124
10197
|
unmute(callSession , withEvent = true) {
|
|
10125
|
-
logger$
|
|
10198
|
+
logger$5.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
10126
10199
|
|
|
10127
10200
|
const sipSession = this.findSipSession(callSession);
|
|
10128
10201
|
if (!sipSession) {
|
|
10129
10202
|
return;
|
|
10130
10203
|
}
|
|
10131
10204
|
|
|
10132
|
-
logger$
|
|
10205
|
+
logger$5.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
10133
10206
|
this.client.unmute(sipSession);
|
|
10134
10207
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
10135
10208
|
|
|
@@ -10156,7 +10229,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10156
10229
|
if (!sipSession) {
|
|
10157
10230
|
return;
|
|
10158
10231
|
}
|
|
10159
|
-
logger$
|
|
10232
|
+
logger$5.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
10160
10233
|
|
|
10161
10234
|
this.client.toggleCameraOn(sipSession);
|
|
10162
10235
|
|
|
@@ -10168,7 +10241,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10168
10241
|
if (!sipSession) {
|
|
10169
10242
|
return;
|
|
10170
10243
|
}
|
|
10171
|
-
logger$
|
|
10244
|
+
logger$5.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
10172
10245
|
|
|
10173
10246
|
this.client.toggleCameraOff(sipSession);
|
|
10174
10247
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -10180,7 +10253,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10180
10253
|
return;
|
|
10181
10254
|
}
|
|
10182
10255
|
|
|
10183
|
-
logger$
|
|
10256
|
+
logger$5.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
10184
10257
|
this.client.sendDTMF(sipSession, tone);
|
|
10185
10258
|
}
|
|
10186
10259
|
|
|
@@ -10188,7 +10261,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10188
10261
|
// @TODO: line is not used here
|
|
10189
10262
|
async makeCall(number , line , cameraEnabled ,
|
|
10190
10263
|
audioOnly = false, conference = false) {
|
|
10191
|
-
logger$
|
|
10264
|
+
logger$5.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
10192
10265
|
if (!number) {
|
|
10193
10266
|
return Promise.resolve(null);
|
|
10194
10267
|
}
|
|
@@ -10198,7 +10271,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10198
10271
|
}
|
|
10199
10272
|
if (this.currentSipSession) {
|
|
10200
10273
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
10201
|
-
logger$
|
|
10274
|
+
logger$5.warn('Unable to hold current session when making another call', e);
|
|
10202
10275
|
});
|
|
10203
10276
|
}
|
|
10204
10277
|
|
|
@@ -10208,7 +10281,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10208
10281
|
this._bindEvents(sipSession);
|
|
10209
10282
|
} catch (error) {
|
|
10210
10283
|
console.warn(error);
|
|
10211
|
-
logger$
|
|
10284
|
+
logger$5.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
10212
10285
|
return Promise.resolve(null);
|
|
10213
10286
|
}
|
|
10214
10287
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -10236,7 +10309,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10236
10309
|
return;
|
|
10237
10310
|
}
|
|
10238
10311
|
|
|
10239
|
-
logger$
|
|
10312
|
+
logger$5.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
10240
10313
|
|
|
10241
10314
|
this.client.transfer(sipSession, target);
|
|
10242
10315
|
}
|
|
@@ -10245,7 +10318,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10245
10318
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
10246
10319
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
10247
10320
|
|
|
10248
|
-
logger$
|
|
10321
|
+
logger$5.info('WebRTC indirect transfer', {
|
|
10249
10322
|
sipId: sipSession ? sipSession.id : null,
|
|
10250
10323
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
10251
10324
|
});
|
|
@@ -10284,7 +10357,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10284
10357
|
return false;
|
|
10285
10358
|
}
|
|
10286
10359
|
|
|
10287
|
-
logger$
|
|
10360
|
+
logger$5.info('WebRTC hangup', { sipId: sipSession.id });
|
|
10288
10361
|
|
|
10289
10362
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
10290
10363
|
|
|
@@ -10330,7 +10403,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10330
10403
|
endCurrentCall(callSession ) {
|
|
10331
10404
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
10332
10405
|
|
|
10333
|
-
logger$
|
|
10406
|
+
logger$5.info('Ending current call', {
|
|
10334
10407
|
id: callSession ? callSession.getId() : null,
|
|
10335
10408
|
isCurrent,
|
|
10336
10409
|
});
|
|
@@ -10354,7 +10427,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10354
10427
|
}
|
|
10355
10428
|
|
|
10356
10429
|
async close() {
|
|
10357
|
-
logger$
|
|
10430
|
+
logger$5.info('WebRTC close');
|
|
10358
10431
|
|
|
10359
10432
|
try {
|
|
10360
10433
|
await Promise.race([
|
|
@@ -10362,7 +10435,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10362
10435
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
10363
10436
|
]);
|
|
10364
10437
|
} catch (e) {
|
|
10365
|
-
logger$
|
|
10438
|
+
logger$5.error('WebRTC close, unregister error', e);
|
|
10366
10439
|
}
|
|
10367
10440
|
|
|
10368
10441
|
this.client.close();
|
|
@@ -10380,12 +10453,12 @@ class WebRTCPhone extends Emitter {
|
|
|
10380
10453
|
}
|
|
10381
10454
|
|
|
10382
10455
|
enableRinging() {
|
|
10383
|
-
logger$
|
|
10456
|
+
logger$5.info('WebRTC enable ringing');
|
|
10384
10457
|
this.ringingEnabled = true;
|
|
10385
10458
|
}
|
|
10386
10459
|
|
|
10387
10460
|
disableRinging() {
|
|
10388
|
-
logger$
|
|
10461
|
+
logger$5.info('WebRTC disable ringing');
|
|
10389
10462
|
this.ringingEnabled = false;
|
|
10390
10463
|
}
|
|
10391
10464
|
|
|
@@ -10425,7 +10498,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10425
10498
|
|
|
10426
10499
|
// Deprecated
|
|
10427
10500
|
getLocalMediaStream(callSession ) {
|
|
10428
|
-
logger$
|
|
10501
|
+
logger$5.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
10429
10502
|
return this.getLocalStream(callSession);
|
|
10430
10503
|
}
|
|
10431
10504
|
|
|
@@ -10445,6 +10518,10 @@ class WebRTCPhone extends Emitter {
|
|
|
10445
10518
|
return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
|
|
10446
10519
|
}
|
|
10447
10520
|
|
|
10521
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
10522
|
+
return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
|
|
10523
|
+
}
|
|
10524
|
+
|
|
10448
10525
|
hasRemoteVideo(callSession ) {
|
|
10449
10526
|
return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
|
|
10450
10527
|
}
|
|
@@ -10463,7 +10540,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10463
10540
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
10464
10541
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
10465
10542
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
10466
|
-
logger$
|
|
10543
|
+
logger$5.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
10467
10544
|
|
|
10468
10545
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
10469
10546
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -10486,7 +10563,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10486
10563
|
});
|
|
10487
10564
|
|
|
10488
10565
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
10489
|
-
logger$
|
|
10566
|
+
logger$5.info('WebRTC on reinvite', {
|
|
10490
10567
|
sessionId: args[0].id,
|
|
10491
10568
|
inviteId: args[1].id,
|
|
10492
10569
|
updatedCalleeName: args[2],
|
|
@@ -10506,7 +10583,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10506
10583
|
});
|
|
10507
10584
|
|
|
10508
10585
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
10509
|
-
logger$
|
|
10586
|
+
logger$5.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
10510
10587
|
|
|
10511
10588
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
10512
10589
|
|
|
@@ -10517,22 +10594,22 @@ class WebRTCPhone extends Emitter {
|
|
|
10517
10594
|
this.client.on('ended', () => {});
|
|
10518
10595
|
|
|
10519
10596
|
this.client.on(this.client.ON_ERROR, e => {
|
|
10520
|
-
logger$
|
|
10597
|
+
logger$5.error('WebRTC error', e);
|
|
10521
10598
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
10522
10599
|
});
|
|
10523
10600
|
|
|
10524
10601
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
10525
|
-
logger$
|
|
10602
|
+
logger$5.info('WebRTC unregistered');
|
|
10526
10603
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10527
10604
|
});
|
|
10528
10605
|
|
|
10529
10606
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
10530
|
-
logger$
|
|
10531
|
-
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
10607
|
+
logger$5.info('WebRTC disconnected');
|
|
10608
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
10532
10609
|
});
|
|
10533
10610
|
|
|
10534
10611
|
this.client.on(this.client.REGISTERED, () => {
|
|
10535
|
-
logger$
|
|
10612
|
+
logger$5.info('WebRTC registered', {
|
|
10536
10613
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
10537
10614
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
10538
10615
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -10545,23 +10622,27 @@ class WebRTCPhone extends Emitter {
|
|
|
10545
10622
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
10546
10623
|
&& this.currentSipSession.state === sessionState.SessionState.Established) {
|
|
10547
10624
|
this.shouldSendReinvite = false;
|
|
10625
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
10626
|
+
const isConference = pc ? pc.sfu : false;
|
|
10627
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
10628
|
+
|
|
10548
10629
|
try {
|
|
10549
10630
|
// Send reinvite with iceRestart
|
|
10550
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
10631
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
10551
10632
|
} catch (e) {
|
|
10552
|
-
logger$
|
|
10633
|
+
logger$5.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
10553
10634
|
}
|
|
10554
10635
|
}
|
|
10555
10636
|
});
|
|
10556
10637
|
|
|
10557
10638
|
this.client.on(this.client.CONNECTED, () => {
|
|
10558
|
-
logger$
|
|
10639
|
+
logger$5.info('WebRTC client connected');
|
|
10559
10640
|
|
|
10560
10641
|
this.stopHeartbeat();
|
|
10561
10642
|
});
|
|
10562
10643
|
|
|
10563
10644
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10564
|
-
logger$
|
|
10645
|
+
logger$5.info('WebRTC client disconnected');
|
|
10565
10646
|
|
|
10566
10647
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10567
10648
|
|
|
@@ -10575,7 +10656,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10575
10656
|
});
|
|
10576
10657
|
|
|
10577
10658
|
this.client.on(this.client.ON_TRACK, (session, event) => {
|
|
10578
|
-
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
10659
|
+
this.eventEmitter.emit(ON_TRACK$1, session, event);
|
|
10579
10660
|
});
|
|
10580
10661
|
|
|
10581
10662
|
this.client.on('onVideoInputChange', stream => {
|
|
@@ -10590,7 +10671,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10590
10671
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
10591
10672
|
const callSession = this.getCallSession(this.getSipSessionId(session));
|
|
10592
10673
|
|
|
10593
|
-
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
10674
|
+
this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
|
|
10594
10675
|
});
|
|
10595
10676
|
|
|
10596
10677
|
// Used when upgrading directly in screenshare mode
|
|
@@ -10599,7 +10680,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10599
10680
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
10600
10681
|
const callSession = this.callSessions[sipSessionId];
|
|
10601
10682
|
|
|
10602
|
-
logger$
|
|
10683
|
+
logger$5.info('Updrading directly in screensharing mode', {
|
|
10603
10684
|
sipSessionId,
|
|
10604
10685
|
tracks: localStream ? localStream.getTracks() : null,
|
|
10605
10686
|
});
|
|
@@ -10631,6 +10712,15 @@ class WebRTCPhone extends Emitter {
|
|
|
10631
10712
|
return this.client.getSipSessionId(sipSession);
|
|
10632
10713
|
}
|
|
10633
10714
|
|
|
10715
|
+
_updateCallSession(callSession ) {
|
|
10716
|
+
const sipSession = this.findSipSession(callSession);
|
|
10717
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
10718
|
+
|
|
10719
|
+
if (sipSessionId) {
|
|
10720
|
+
this.callSessions[sipSessionId] = callSession;
|
|
10721
|
+
}
|
|
10722
|
+
}
|
|
10723
|
+
|
|
10634
10724
|
_onMessage(message ) {
|
|
10635
10725
|
if (!message || message.method !== 'MESSAGE') {
|
|
10636
10726
|
return;
|
|
@@ -10768,8 +10858,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10768
10858
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10769
10859
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10770
10860
|
ON_MESSAGE: ON_MESSAGE,
|
|
10771
|
-
ON_REINVITE: ON_REINVITE,
|
|
10772
|
-
ON_TRACK: ON_TRACK,
|
|
10861
|
+
ON_REINVITE: ON_REINVITE$1,
|
|
10862
|
+
ON_TRACK: ON_TRACK$1,
|
|
10773
10863
|
ON_AUDIO_STREAM: ON_AUDIO_STREAM,
|
|
10774
10864
|
ON_VIDEO_STREAM: ON_VIDEO_STREAM,
|
|
10775
10865
|
ON_REMOVE_STREAM: ON_REMOVE_STREAM,
|
|
@@ -10784,13 +10874,13 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10784
10874
|
ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
|
|
10785
10875
|
ON_CALL_ERROR: ON_CALL_ERROR,
|
|
10786
10876
|
ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
|
|
10787
|
-
ON_NETWORK_STATS: ON_NETWORK_STATS,
|
|
10877
|
+
ON_NETWORK_STATS: ON_NETWORK_STATS$1,
|
|
10788
10878
|
ON_CHAT: ON_CHAT,
|
|
10789
10879
|
ON_SIGNAL: ON_SIGNAL,
|
|
10790
|
-
ON_DISCONNECTED: ON_DISCONNECTED,
|
|
10880
|
+
ON_DISCONNECTED: ON_DISCONNECTED$1,
|
|
10791
10881
|
MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
|
|
10792
10882
|
MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
|
|
10793
|
-
events: events,
|
|
10883
|
+
events: events$1,
|
|
10794
10884
|
'default': WebRTCPhone
|
|
10795
10885
|
});
|
|
10796
10886
|
|
|
@@ -10961,11 +11051,11 @@ var wazoWebsocket = {
|
|
|
10961
11051
|
resolve();
|
|
10962
11052
|
};
|
|
10963
11053
|
|
|
10964
|
-
client.on(SOCKET_EVENTS
|
|
11054
|
+
client.on(SOCKET_EVENTS.ON_ERROR, error => {
|
|
10965
11055
|
handleError(`Connection error : ${error}`);
|
|
10966
11056
|
});
|
|
10967
11057
|
|
|
10968
|
-
client.on(SOCKET_EVENTS
|
|
11058
|
+
client.on(SOCKET_EVENTS.ON_OPEN, () => {
|
|
10969
11059
|
if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
|
|
10970
11060
|
client.setOnHeartbeatTimeout(() => {
|
|
10971
11061
|
handleError('No response to heartbeat');
|
|
@@ -11066,7 +11156,7 @@ var webrtc = {
|
|
|
11066
11156
|
}),
|
|
11067
11157
|
};
|
|
11068
11158
|
|
|
11069
|
-
const parseCandidate = line => {
|
|
11159
|
+
const parseCandidate$1 = line => {
|
|
11070
11160
|
let parts;
|
|
11071
11161
|
// Parse both variants.
|
|
11072
11162
|
if (line.indexOf('a=candidate:') === 0) {
|
|
@@ -11157,7 +11247,7 @@ var SymmetricNat = {
|
|
|
11157
11247
|
}
|
|
11158
11248
|
|
|
11159
11249
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
11160
|
-
const cand = parseCandidate(e.candidate.candidate);
|
|
11250
|
+
const cand = parseCandidate$1(e.candidate.candidate);
|
|
11161
11251
|
if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
|
|
11162
11252
|
candidates[cand.relatedPort].push(cand.port);
|
|
11163
11253
|
} else if (!e.candidate) {
|
|
@@ -11225,7 +11315,7 @@ var iceIpv4 = {
|
|
|
11225
11315
|
const rawCandidate = e.candidate.candidate;
|
|
11226
11316
|
if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
|
|
11227
11317
|
hasSrflxOrRelay = true;
|
|
11228
|
-
const candidate = parseCandidate(e.candidate.candidate);
|
|
11318
|
+
const candidate = parseCandidate$1(e.candidate.candidate);
|
|
11229
11319
|
ips.push(candidate.ip);
|
|
11230
11320
|
}
|
|
11231
11321
|
} else if (!e.candidate) {
|
|
@@ -11395,7 +11485,7 @@ const getCallableNumber = (number , country ) => {
|
|
|
11395
11485
|
class InvalidSubscription extends Error {}
|
|
11396
11486
|
class InvalidAuthorization extends Error {}
|
|
11397
11487
|
|
|
11398
|
-
const logger$
|
|
11488
|
+
const logger$7 = IssueReporter$1.loggerFor('simple-auth');
|
|
11399
11489
|
|
|
11400
11490
|
class Auth {
|
|
11401
11491
|
|
|
@@ -11430,7 +11520,7 @@ class Auth {
|
|
|
11430
11520
|
setApiClientId(this.clientId);
|
|
11431
11521
|
setRefreshExpiration(this.expiration);
|
|
11432
11522
|
setOnRefreshToken((token , session ) => {
|
|
11433
|
-
logger$
|
|
11523
|
+
logger$7.info('on refresh token done', { token });
|
|
11434
11524
|
setApiToken(token);
|
|
11435
11525
|
Wazo.Websocket.updateToken(token);
|
|
11436
11526
|
|
|
@@ -11475,7 +11565,7 @@ class Auth {
|
|
|
11475
11565
|
const rawSession = await getApiClient().auth.authenticate(token);
|
|
11476
11566
|
return this._onAuthenticated(rawSession);
|
|
11477
11567
|
} catch (e) {
|
|
11478
|
-
logger$
|
|
11568
|
+
logger$7.error('on validate token error', e);
|
|
11479
11569
|
console.warn(e);
|
|
11480
11570
|
return false;
|
|
11481
11571
|
}
|
|
@@ -11831,7 +11921,7 @@ class AdHocAPIConference {
|
|
|
11831
11921
|
|
|
11832
11922
|
//
|
|
11833
11923
|
|
|
11834
|
-
const logger$
|
|
11924
|
+
const logger$8 = IssueReporter$1.loggerFor('simple-phone');
|
|
11835
11925
|
const sipLogger = IssueReporter$1.loggerFor('sip.js');
|
|
11836
11926
|
const protocolLogger = IssueReporter$1.loggerFor('sip');
|
|
11837
11927
|
|
|
@@ -11938,7 +12028,7 @@ class Phone extends Emitter {
|
|
|
11938
12028
|
async disconnect() {
|
|
11939
12029
|
if (this.phone) {
|
|
11940
12030
|
if (this.phone.hasAnActiveCall()) {
|
|
11941
|
-
logger$
|
|
12031
|
+
logger$8.info('hangup call on disconnect');
|
|
11942
12032
|
// $FlowFixMe
|
|
11943
12033
|
await this.phone.hangup();
|
|
11944
12034
|
}
|
|
@@ -11961,13 +12051,13 @@ class Phone extends Emitter {
|
|
|
11961
12051
|
}
|
|
11962
12052
|
|
|
11963
12053
|
async hangup(callSession ) {
|
|
11964
|
-
logger$
|
|
12054
|
+
logger$8.info('hangup via simple phone', { callId: callSession.getId() });
|
|
11965
12055
|
|
|
11966
12056
|
return this.phone && this.phone.hangup(callSession);
|
|
11967
12057
|
}
|
|
11968
12058
|
|
|
11969
12059
|
async accept(callSession , cameraEnabled ) {
|
|
11970
|
-
logger$
|
|
12060
|
+
logger$8.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
|
|
11971
12061
|
|
|
11972
12062
|
return this.phone && this.phone.accept(callSession, cameraEnabled);
|
|
11973
12063
|
}
|
|
@@ -12006,7 +12096,7 @@ class Phone extends Emitter {
|
|
|
12006
12096
|
muteViaAPI(callSession ) {
|
|
12007
12097
|
if (callSession && callSession.callId) {
|
|
12008
12098
|
Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
|
|
12009
|
-
logger$
|
|
12099
|
+
logger$8.error('Mute via API, error', e);
|
|
12010
12100
|
});
|
|
12011
12101
|
}
|
|
12012
12102
|
}
|
|
@@ -12014,7 +12104,7 @@ class Phone extends Emitter {
|
|
|
12014
12104
|
unmuteViaAPI(callSession ) {
|
|
12015
12105
|
if (callSession && callSession.callId) {
|
|
12016
12106
|
Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
|
|
12017
|
-
logger$
|
|
12107
|
+
logger$8.error('Unmute via API, error', e);
|
|
12018
12108
|
});
|
|
12019
12109
|
}
|
|
12020
12110
|
}
|
|
@@ -12122,7 +12212,7 @@ class Phone extends Emitter {
|
|
|
12122
12212
|
|
|
12123
12213
|
// @Deprecated
|
|
12124
12214
|
getLocalMediaStream(callSession ) {
|
|
12125
|
-
logger$
|
|
12215
|
+
logger$8.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
|
|
12126
12216
|
|
|
12127
12217
|
return this.phone && this.phone.getLocalStream(callSession);
|
|
12128
12218
|
}
|
|
@@ -12145,24 +12235,29 @@ class Phone extends Emitter {
|
|
|
12145
12235
|
|
|
12146
12236
|
// @Deprecated
|
|
12147
12237
|
getRemoteStreamForCall(callSession ) {
|
|
12148
|
-
logger$
|
|
12238
|
+
logger$8.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
|
|
12149
12239
|
return this.getRemoteStream(callSession);
|
|
12150
12240
|
}
|
|
12151
12241
|
|
|
12152
12242
|
// Returns remote streams directly from the peerConnection
|
|
12153
12243
|
// @Deprecated
|
|
12154
12244
|
getRemoteStreamsForCall(callSession ) {
|
|
12155
|
-
logger$
|
|
12245
|
+
logger$8.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
|
|
12156
12246
|
return this.getLocalStream(callSession);
|
|
12157
12247
|
}
|
|
12158
12248
|
|
|
12159
12249
|
// @Deprecated
|
|
12160
12250
|
getRemoteVideoStreamForCall(callSession ) {
|
|
12161
|
-
logger$
|
|
12251
|
+
logger$8.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
|
|
12162
12252
|
|
|
12163
12253
|
return this.getRemoteVideoStream(callSession);
|
|
12164
12254
|
}
|
|
12165
12255
|
|
|
12256
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
12257
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
12258
|
+
return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
|
|
12259
|
+
}
|
|
12260
|
+
|
|
12166
12261
|
hasVideo(callSession ) {
|
|
12167
12262
|
return this.phone ? this.phone.hasVideo(callSession) : false;
|
|
12168
12263
|
}
|
|
@@ -12214,7 +12309,7 @@ class Phone extends Emitter {
|
|
|
12214
12309
|
|
|
12215
12310
|
_transferEvents() {
|
|
12216
12311
|
this.unbind();
|
|
12217
|
-
[...events
|
|
12312
|
+
[...events, ...transportEvents].forEach(event => {
|
|
12218
12313
|
this.client.on(event, (...args) =>
|
|
12219
12314
|
this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
|
|
12220
12315
|
});
|
|
@@ -12236,10 +12331,10 @@ var Phone$1 = global.wazoTelephonyInstance;
|
|
|
12236
12331
|
|
|
12237
12332
|
//
|
|
12238
12333
|
|
|
12239
|
-
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
12240
|
-
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
12334
|
+
const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
12335
|
+
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
|
|
12241
12336
|
|
|
12242
|
-
const logger$
|
|
12337
|
+
const logger$9 = IssueReporter$1.loggerFor('simple-ws-client');
|
|
12243
12338
|
|
|
12244
12339
|
class Websocket extends Emitter {
|
|
12245
12340
|
|
|
@@ -12253,9 +12348,9 @@ class Websocket extends Emitter {
|
|
|
12253
12348
|
// $FlowFixMe
|
|
12254
12349
|
this[key] = OTHER_EVENTS[key];
|
|
12255
12350
|
});
|
|
12256
|
-
Object.keys(SOCKET_EVENTS).forEach(key => {
|
|
12351
|
+
Object.keys(SOCKET_EVENTS$1).forEach(key => {
|
|
12257
12352
|
// $FlowFixMe
|
|
12258
|
-
this[key] = SOCKET_EVENTS[key];
|
|
12353
|
+
this[key] = SOCKET_EVENTS$1[key];
|
|
12259
12354
|
});
|
|
12260
12355
|
this.eventLists = WebSocketClient.eventLists;
|
|
12261
12356
|
|
|
@@ -12263,7 +12358,7 @@ class Websocket extends Emitter {
|
|
|
12263
12358
|
}
|
|
12264
12359
|
|
|
12265
12360
|
open(host , session ) {
|
|
12266
|
-
logger$
|
|
12361
|
+
logger$9.info('open simple WebSocket', { host, token: session.token });
|
|
12267
12362
|
this.ws = new WebSocketClient(
|
|
12268
12363
|
{
|
|
12269
12364
|
host,
|
|
@@ -12291,7 +12386,7 @@ class Websocket extends Emitter {
|
|
|
12291
12386
|
}
|
|
12292
12387
|
|
|
12293
12388
|
updateToken(token ) {
|
|
12294
|
-
logger$
|
|
12389
|
+
logger$9.info('update token via simple Websocket', { token, ws: !!this.ws });
|
|
12295
12390
|
|
|
12296
12391
|
if (!this.ws) {
|
|
12297
12392
|
return;
|
|
@@ -12319,7 +12414,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
|
|
|
12319
12414
|
|
|
12320
12415
|
//
|
|
12321
12416
|
|
|
12322
|
-
const logger$
|
|
12417
|
+
const logger$a = IssueReporter$1.loggerFor('room');
|
|
12323
12418
|
|
|
12324
12419
|
class Participant extends Emitter {
|
|
12325
12420
|
|
|
@@ -12441,7 +12536,7 @@ class Participant extends Emitter {
|
|
|
12441
12536
|
}
|
|
12442
12537
|
|
|
12443
12538
|
onTalking(isTalking ) {
|
|
12444
|
-
logger$
|
|
12539
|
+
logger$a.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
|
|
12445
12540
|
this.isTalking = isTalking;
|
|
12446
12541
|
// you may notice we're not broadcasting: since all participants are getting this info
|
|
12447
12542
|
// directly from asterisk, there's no need to do so
|
|
@@ -12544,7 +12639,7 @@ class Participant extends Emitter {
|
|
|
12544
12639
|
}
|
|
12545
12640
|
|
|
12546
12641
|
updateStatus(status , broadcast = true) {
|
|
12547
|
-
logger$
|
|
12642
|
+
logger$a.info('updating participant status', { name: this.name, status });
|
|
12548
12643
|
|
|
12549
12644
|
if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
|
|
12550
12645
|
if (status.audioMuted) {
|
|
@@ -12592,7 +12687,7 @@ class Participant extends Emitter {
|
|
|
12592
12687
|
|
|
12593
12688
|
broadcastStatus(inboundStatus = null) {
|
|
12594
12689
|
const status = inboundStatus || this.getStatus();
|
|
12595
|
-
logger$
|
|
12690
|
+
logger$a.info('broadcasting participant status', { callId: this.callId, status });
|
|
12596
12691
|
|
|
12597
12692
|
this.room.sendSignal({
|
|
12598
12693
|
type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
|
|
@@ -12628,9 +12723,9 @@ class LocalParticipant extends Participant {
|
|
|
12628
12723
|
const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
12629
12724
|
const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
12630
12725
|
|
|
12631
|
-
const logger$
|
|
12726
|
+
const logger$b = IssueReporter$1.loggerFor('sdk-room');
|
|
12632
12727
|
|
|
12633
|
-
class Room extends Emitter {
|
|
12728
|
+
class Room$1 extends Emitter {
|
|
12634
12729
|
|
|
12635
12730
|
|
|
12636
12731
|
|
|
@@ -12688,7 +12783,7 @@ class Room extends Emitter {
|
|
|
12688
12783
|
extra = {},
|
|
12689
12784
|
) {
|
|
12690
12785
|
super();
|
|
12691
|
-
logger$
|
|
12786
|
+
logger$b.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
12692
12787
|
|
|
12693
12788
|
// Represents the room callSession
|
|
12694
12789
|
this.callSession = callSession;
|
|
@@ -12754,7 +12849,7 @@ class Room extends Emitter {
|
|
|
12754
12849
|
* @returns {Promise<Room>}
|
|
12755
12850
|
*/
|
|
12756
12851
|
static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
|
|
12757
|
-
logger$
|
|
12852
|
+
logger$b.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
12758
12853
|
|
|
12759
12854
|
if (!room) {
|
|
12760
12855
|
await Wazo.Phone.connect();
|
|
@@ -12767,7 +12862,7 @@ class Room extends Emitter {
|
|
|
12767
12862
|
|
|
12768
12863
|
// Call_created is triggered before call_accepted, so we have to listen for it here.
|
|
12769
12864
|
Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
|
|
12770
|
-
logger$
|
|
12865
|
+
logger$b.info('room call received via WS', { callId: data.call_id });
|
|
12771
12866
|
if (room) {
|
|
12772
12867
|
room.setCallId(data.call_id);
|
|
12773
12868
|
}
|
|
@@ -12775,7 +12870,7 @@ class Room extends Emitter {
|
|
|
12775
12870
|
|
|
12776
12871
|
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
12777
12872
|
// eslint-disable-next-line no-param-reassign
|
|
12778
|
-
room = new Room(callSession, extension, null, null, extra);
|
|
12873
|
+
room = new Room$1(callSession, extension, null, null, extra);
|
|
12779
12874
|
|
|
12780
12875
|
// Wait for the call to be accepted
|
|
12781
12876
|
await new Promise((resolve, reject) => {
|
|
@@ -12796,7 +12891,7 @@ class Room extends Emitter {
|
|
|
12796
12891
|
// Retrieve conference
|
|
12797
12892
|
const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
|
|
12798
12893
|
|
|
12799
|
-
logger$
|
|
12894
|
+
logger$b.info('connected to room', {
|
|
12800
12895
|
sourceId: conference ? conference.sourceId : null,
|
|
12801
12896
|
name: conference ? conference.name : null,
|
|
12802
12897
|
});
|
|
@@ -12806,7 +12901,7 @@ class Room extends Emitter {
|
|
|
12806
12901
|
room.setName(conference.name);
|
|
12807
12902
|
}
|
|
12808
12903
|
} else if (meeting) {
|
|
12809
|
-
logger$
|
|
12904
|
+
logger$b.info('Already connected to meeting', {
|
|
12810
12905
|
uuid: meeting.uuid,
|
|
12811
12906
|
name: meeting.name,
|
|
12812
12907
|
});
|
|
@@ -12819,13 +12914,13 @@ class Room extends Emitter {
|
|
|
12819
12914
|
}
|
|
12820
12915
|
|
|
12821
12916
|
static disconnect() {
|
|
12822
|
-
logger$
|
|
12917
|
+
logger$b.info('static disconnection to room');
|
|
12823
12918
|
|
|
12824
12919
|
Wazo.Phone.disconnect();
|
|
12825
12920
|
}
|
|
12826
12921
|
|
|
12827
12922
|
async disconnect() {
|
|
12828
|
-
logger$
|
|
12923
|
+
logger$b.info('disconnection to room called');
|
|
12829
12924
|
|
|
12830
12925
|
await Wazo.Phone.hangup(this.callSession);
|
|
12831
12926
|
this.callSession = null;
|
|
@@ -12845,19 +12940,19 @@ class Room extends Emitter {
|
|
|
12845
12940
|
}
|
|
12846
12941
|
|
|
12847
12942
|
setSourceId(sourceId ) {
|
|
12848
|
-
logger$
|
|
12943
|
+
logger$b.info('set room source id', { sourceId });
|
|
12849
12944
|
|
|
12850
12945
|
this.sourceId = sourceId;
|
|
12851
12946
|
}
|
|
12852
12947
|
|
|
12853
12948
|
setMeetingUuid(meetingUuid ) {
|
|
12854
|
-
logger$
|
|
12949
|
+
logger$b.info('set meeting uuid', { meetingUuid });
|
|
12855
12950
|
|
|
12856
12951
|
this.meetingUuid = meetingUuid;
|
|
12857
12952
|
}
|
|
12858
12953
|
|
|
12859
12954
|
setCallId(callId ) {
|
|
12860
|
-
logger$
|
|
12955
|
+
logger$b.info('set room call id', { callId });
|
|
12861
12956
|
|
|
12862
12957
|
if (callId) {
|
|
12863
12958
|
this.callId = callId;
|
|
@@ -12865,7 +12960,7 @@ class Room extends Emitter {
|
|
|
12865
12960
|
}
|
|
12866
12961
|
|
|
12867
12962
|
setName(name ) {
|
|
12868
|
-
logger$
|
|
12963
|
+
logger$b.info('set room name', { name });
|
|
12869
12964
|
|
|
12870
12965
|
this.name = name;
|
|
12871
12966
|
}
|
|
@@ -12884,7 +12979,7 @@ class Room extends Emitter {
|
|
|
12884
12979
|
}
|
|
12885
12980
|
|
|
12886
12981
|
async startScreenSharing(constraints ) {
|
|
12887
|
-
logger$
|
|
12982
|
+
logger$b.info('start room screen sharing', { constraints });
|
|
12888
12983
|
|
|
12889
12984
|
const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
|
|
12890
12985
|
if (!screensharingStream) {
|
|
@@ -12898,7 +12993,7 @@ class Room extends Emitter {
|
|
|
12898
12993
|
}
|
|
12899
12994
|
|
|
12900
12995
|
async stopScreenSharing(restoreLocalStream = true) {
|
|
12901
|
-
logger$
|
|
12996
|
+
logger$b.info('stop room screen sharing');
|
|
12902
12997
|
|
|
12903
12998
|
await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
12904
12999
|
|
|
@@ -12910,7 +13005,7 @@ class Room extends Emitter {
|
|
|
12910
13005
|
}
|
|
12911
13006
|
|
|
12912
13007
|
turnCameraOff() {
|
|
12913
|
-
logger$
|
|
13008
|
+
logger$b.info('turn room camera off');
|
|
12914
13009
|
|
|
12915
13010
|
Wazo.Phone.turnCameraOff(this.callSession);
|
|
12916
13011
|
|
|
@@ -12920,7 +13015,7 @@ class Room extends Emitter {
|
|
|
12920
13015
|
}
|
|
12921
13016
|
|
|
12922
13017
|
turnCameraOn() {
|
|
12923
|
-
logger$
|
|
13018
|
+
logger$b.info('turn room camera on');
|
|
12924
13019
|
|
|
12925
13020
|
Wazo.Phone.turnCameraOn(this.callSession);
|
|
12926
13021
|
|
|
@@ -12930,7 +13025,7 @@ class Room extends Emitter {
|
|
|
12930
13025
|
}
|
|
12931
13026
|
|
|
12932
13027
|
mute() {
|
|
12933
|
-
logger$
|
|
13028
|
+
logger$b.info('mute room');
|
|
12934
13029
|
|
|
12935
13030
|
Wazo.Phone.mute(this.callSession);
|
|
12936
13031
|
|
|
@@ -12938,7 +13033,7 @@ class Room extends Emitter {
|
|
|
12938
13033
|
}
|
|
12939
13034
|
|
|
12940
13035
|
unmute() {
|
|
12941
|
-
logger$
|
|
13036
|
+
logger$b.info('unmute room');
|
|
12942
13037
|
|
|
12943
13038
|
Wazo.Phone.unmute(this.callSession);
|
|
12944
13039
|
|
|
@@ -12958,7 +13053,7 @@ class Room extends Emitter {
|
|
|
12958
13053
|
}
|
|
12959
13054
|
|
|
12960
13055
|
hold() {
|
|
12961
|
-
logger$
|
|
13056
|
+
logger$b.info('hold room');
|
|
12962
13057
|
|
|
12963
13058
|
Wazo.Phone.hold(this.callSession, true);
|
|
12964
13059
|
|
|
@@ -12968,7 +13063,7 @@ class Room extends Emitter {
|
|
|
12968
13063
|
}
|
|
12969
13064
|
|
|
12970
13065
|
async resume() {
|
|
12971
|
-
logger$
|
|
13066
|
+
logger$b.info('resume room');
|
|
12972
13067
|
|
|
12973
13068
|
const newStream = await Wazo.Phone.resume(this.callSession, true);
|
|
12974
13069
|
|
|
@@ -12996,13 +13091,13 @@ class Room extends Emitter {
|
|
|
12996
13091
|
}
|
|
12997
13092
|
|
|
12998
13093
|
sendDTMF(tone ) {
|
|
12999
|
-
logger$
|
|
13094
|
+
logger$b.info('send room DTMF', { tone });
|
|
13000
13095
|
|
|
13001
13096
|
Wazo.Phone.sendDTMF(tone, this.callSession);
|
|
13002
13097
|
}
|
|
13003
13098
|
|
|
13004
13099
|
async sendReinvite(newConstraints = null) {
|
|
13005
|
-
logger$
|
|
13100
|
+
logger$b.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
13006
13101
|
const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
|
|
13007
13102
|
|
|
13008
13103
|
Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
|
|
@@ -13061,7 +13156,7 @@ class Room extends Emitter {
|
|
|
13061
13156
|
Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
13062
13157
|
|
|
13063
13158
|
this.on(this.ON_AUDIO_STREAM, stream => {
|
|
13064
|
-
logger$
|
|
13159
|
+
logger$b.info('on room audio stream');
|
|
13065
13160
|
|
|
13066
13161
|
this.audioStream = stream;
|
|
13067
13162
|
if (!this.roomAudioElement) {
|
|
@@ -13074,7 +13169,7 @@ class Room extends Emitter {
|
|
|
13074
13169
|
});
|
|
13075
13170
|
|
|
13076
13171
|
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
13077
|
-
logger$
|
|
13172
|
+
logger$b.info('on room video stream', { streamId });
|
|
13078
13173
|
|
|
13079
13174
|
this._mapMsid(sipSession.body.body);
|
|
13080
13175
|
|
|
@@ -13089,7 +13184,7 @@ class Room extends Emitter {
|
|
|
13089
13184
|
});
|
|
13090
13185
|
|
|
13091
13186
|
this.on(this.ON_REMOVE_STREAM, stream => {
|
|
13092
|
-
logger$
|
|
13187
|
+
logger$b.info('on room remove stream');
|
|
13093
13188
|
|
|
13094
13189
|
const participant = this.participants.find(someParticipant =>
|
|
13095
13190
|
someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
|
|
@@ -13221,7 +13316,7 @@ class Room extends Emitter {
|
|
|
13221
13316
|
const requester = this._getParticipantFromCallId(origin.callId);
|
|
13222
13317
|
if (requester) {
|
|
13223
13318
|
// @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
|
|
13224
|
-
logger$
|
|
13319
|
+
logger$b.info('trigger room requester status', { origin });
|
|
13225
13320
|
requester.triggerUpdate('REQUESTER_UPDATE');
|
|
13226
13321
|
}
|
|
13227
13322
|
break;
|
|
@@ -13252,24 +13347,24 @@ class Room extends Emitter {
|
|
|
13252
13347
|
|
|
13253
13348
|
// When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
|
|
13254
13349
|
if (participant.user_uuid === session.uuid) {
|
|
13255
|
-
logger$
|
|
13350
|
+
logger$b.info('room current user joined');
|
|
13256
13351
|
|
|
13257
13352
|
// Retrieve participants via an API calls
|
|
13258
13353
|
const conferenceId = this.sourceId || payload.data.conference_id;
|
|
13259
13354
|
let response;
|
|
13260
13355
|
try {
|
|
13261
13356
|
if (this.meetingUuid) {
|
|
13262
|
-
logger$
|
|
13357
|
+
logger$b.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
13263
13358
|
response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
|
|
13264
13359
|
} else {
|
|
13265
|
-
logger$
|
|
13360
|
+
logger$b.info('fetching conference participants', { conferenceId });
|
|
13266
13361
|
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
13267
13362
|
}
|
|
13268
13363
|
} catch (e) {
|
|
13269
|
-
logger$
|
|
13364
|
+
logger$b.error('room participants fetching, error', e);
|
|
13270
13365
|
}
|
|
13271
13366
|
if (response) {
|
|
13272
|
-
logger$
|
|
13367
|
+
logger$b.info('conference participants fetched', { nb: response.items.length });
|
|
13273
13368
|
participants = response.items.map(item => {
|
|
13274
13369
|
const isMe = item.call_id === this.callId;
|
|
13275
13370
|
|
|
@@ -13296,7 +13391,7 @@ class Room extends Emitter {
|
|
|
13296
13391
|
? new Wazo.RemoteParticipant(this, participant)
|
|
13297
13392
|
: null;
|
|
13298
13393
|
|
|
13299
|
-
logger$
|
|
13394
|
+
logger$b.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
13300
13395
|
|
|
13301
13396
|
if (remoteParticipant) {
|
|
13302
13397
|
this.participants.push(remoteParticipant);
|
|
@@ -13461,12 +13556,12 @@ class Room extends Emitter {
|
|
|
13461
13556
|
|
|
13462
13557
|
//
|
|
13463
13558
|
|
|
13464
|
-
const logger = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
13559
|
+
const logger$c = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
13465
13560
|
|
|
13466
|
-
class SipRoom extends Room {
|
|
13561
|
+
class SipRoom extends Room$1 {
|
|
13467
13562
|
|
|
13468
13563
|
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
13469
|
-
logger.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
13564
|
+
logger$c.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
13470
13565
|
|
|
13471
13566
|
if (!room) {
|
|
13472
13567
|
await Wazo.Phone.connect();
|
|
@@ -13482,7 +13577,7 @@ class SipRoom extends Room {
|
|
|
13482
13577
|
room.setCallId(room.callSession.call.id);
|
|
13483
13578
|
}
|
|
13484
13579
|
|
|
13485
|
-
logger.info('connected to room', {
|
|
13580
|
+
logger$c.info('connected to room', {
|
|
13486
13581
|
extension: room.extension,
|
|
13487
13582
|
});
|
|
13488
13583
|
|
|
@@ -13490,7 +13585,7 @@ class SipRoom extends Room {
|
|
|
13490
13585
|
}
|
|
13491
13586
|
|
|
13492
13587
|
mute() {
|
|
13493
|
-
logger.info('mute sip room');
|
|
13588
|
+
logger$c.info('mute sip room');
|
|
13494
13589
|
|
|
13495
13590
|
Wazo.Phone.mute(this.callSession, false);
|
|
13496
13591
|
|
|
@@ -13498,7 +13593,7 @@ class SipRoom extends Room {
|
|
|
13498
13593
|
}
|
|
13499
13594
|
|
|
13500
13595
|
unmute() {
|
|
13501
|
-
logger.info('unmute sip room');
|
|
13596
|
+
logger$c.info('unmute sip room');
|
|
13502
13597
|
|
|
13503
13598
|
Wazo.Phone.unmute(this.callSession, false);
|
|
13504
13599
|
|
|
@@ -13711,7 +13806,7 @@ const Wazo = {
|
|
|
13711
13806
|
Auth: Auth$1,
|
|
13712
13807
|
Phone: Phone$1,
|
|
13713
13808
|
Websocket: Websocket$1,
|
|
13714
|
-
Room,
|
|
13809
|
+
Room: Room$1,
|
|
13715
13810
|
SipRoom,
|
|
13716
13811
|
RemoteParticipant,
|
|
13717
13812
|
LocalParticipant,
|
|
@@ -13744,7 +13839,7 @@ const Wazo = {
|
|
|
13744
13839
|
Session,
|
|
13745
13840
|
Voicemail,
|
|
13746
13841
|
Relocation,
|
|
13747
|
-
ConferenceRoom: Room
|
|
13842
|
+
ConferenceRoom: Room,
|
|
13748
13843
|
CallSession,
|
|
13749
13844
|
IndirectTransfer,
|
|
13750
13845
|
SwitchboardCall,
|
|
@@ -13830,13 +13925,13 @@ var index = {
|
|
|
13830
13925
|
Session,
|
|
13831
13926
|
Voicemail,
|
|
13832
13927
|
Relocation,
|
|
13833
|
-
Room
|
|
13928
|
+
Room,
|
|
13834
13929
|
IssueReporter: IssueReporter$1,
|
|
13835
13930
|
DebugDevice,
|
|
13836
13931
|
PROFILE_STATE: STATE,
|
|
13837
13932
|
FORWARD_KEYS,
|
|
13838
13933
|
LINE_STATE,
|
|
13839
|
-
SOCKET_EVENTS
|
|
13934
|
+
SOCKET_EVENTS,
|
|
13840
13935
|
Wazo,
|
|
13841
13936
|
WebRTCPhone,
|
|
13842
13937
|
Meeting,
|