@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/simple/room/Room.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
|
|
|
@@ -3998,7 +4065,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3998
4065
|
|
|
3999
4066
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
4000
4067
|
|
|
4001
|
-
const logger$
|
|
4068
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
4002
4069
|
|
|
4003
4070
|
class CTIPhone extends Emitter {
|
|
4004
4071
|
|
|
@@ -4011,7 +4078,7 @@ class CTIPhone extends Emitter {
|
|
|
4011
4078
|
|
|
4012
4079
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
4013
4080
|
super();
|
|
4014
|
-
logger$
|
|
4081
|
+
logger$1.info('CTI Phone created');
|
|
4015
4082
|
this.session = session;
|
|
4016
4083
|
this.isMobile = isMobile;
|
|
4017
4084
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -4072,7 +4139,7 @@ class CTIPhone extends Emitter {
|
|
|
4072
4139
|
}
|
|
4073
4140
|
|
|
4074
4141
|
async makeCall(number , line ) {
|
|
4075
|
-
logger$
|
|
4142
|
+
logger$1.info('make CTI call', { number });
|
|
4076
4143
|
|
|
4077
4144
|
if (!number) {
|
|
4078
4145
|
return null;
|
|
@@ -4095,7 +4162,7 @@ class CTIPhone extends Emitter {
|
|
|
4095
4162
|
if (!callSession) {
|
|
4096
4163
|
return Promise.resolve(null);
|
|
4097
4164
|
}
|
|
4098
|
-
logger$
|
|
4165
|
+
logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4099
4166
|
|
|
4100
4167
|
if (!this.currentCall) {
|
|
4101
4168
|
this.currentCall = callSession.call;
|
|
@@ -4108,7 +4175,7 @@ class CTIPhone extends Emitter {
|
|
|
4108
4175
|
if (!callSession) {
|
|
4109
4176
|
return;
|
|
4110
4177
|
}
|
|
4111
|
-
logger$
|
|
4178
|
+
logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4112
4179
|
|
|
4113
4180
|
this.currentCall = undefined;
|
|
4114
4181
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4118,7 +4185,7 @@ class CTIPhone extends Emitter {
|
|
|
4118
4185
|
if (!callSession) {
|
|
4119
4186
|
return Promise.resolve(false);
|
|
4120
4187
|
}
|
|
4121
|
-
logger$
|
|
4188
|
+
logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4122
4189
|
|
|
4123
4190
|
try {
|
|
4124
4191
|
await CallApi.cancelCall(callSession);
|
|
@@ -4129,7 +4196,7 @@ class CTIPhone extends Emitter {
|
|
|
4129
4196
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
4130
4197
|
return true;
|
|
4131
4198
|
} catch (e) {
|
|
4132
|
-
logger$
|
|
4199
|
+
logger$1.error('hangup CTI call, error', e);
|
|
4133
4200
|
|
|
4134
4201
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
4135
4202
|
return false;
|
|
@@ -4142,7 +4209,7 @@ class CTIPhone extends Emitter {
|
|
|
4142
4209
|
if (!callSession) {
|
|
4143
4210
|
return;
|
|
4144
4211
|
}
|
|
4145
|
-
logger$
|
|
4212
|
+
logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4146
4213
|
|
|
4147
4214
|
await CallApi.cancelCall(callSession);
|
|
4148
4215
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4152,7 +4219,7 @@ class CTIPhone extends Emitter {
|
|
|
4152
4219
|
if (!callSession) {
|
|
4153
4220
|
return;
|
|
4154
4221
|
}
|
|
4155
|
-
logger$
|
|
4222
|
+
logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4156
4223
|
|
|
4157
4224
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
4158
4225
|
}
|
|
@@ -4165,19 +4232,19 @@ class CTIPhone extends Emitter {
|
|
|
4165
4232
|
if (!callSession) {
|
|
4166
4233
|
return;
|
|
4167
4234
|
}
|
|
4168
|
-
logger$
|
|
4235
|
+
logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4169
4236
|
|
|
4170
4237
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
4171
4238
|
}
|
|
4172
4239
|
|
|
4173
4240
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
4174
|
-
logger$
|
|
4241
|
+
logger$1.info('cancel CTI transfer', { transferId });
|
|
4175
4242
|
|
|
4176
4243
|
return CallApi.cancelCallTransfer(transferId);
|
|
4177
4244
|
}
|
|
4178
4245
|
|
|
4179
4246
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
4180
|
-
logger$
|
|
4247
|
+
logger$1.info('confirm CTI transfer', { transferId });
|
|
4181
4248
|
|
|
4182
4249
|
return CallApi.confirmCallTransfer(transferId);
|
|
4183
4250
|
}
|
|
@@ -4186,19 +4253,19 @@ class CTIPhone extends Emitter {
|
|
|
4186
4253
|
if (!callSession) {
|
|
4187
4254
|
return;
|
|
4188
4255
|
}
|
|
4189
|
-
logger$
|
|
4256
|
+
logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4190
4257
|
|
|
4191
4258
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4192
4259
|
}
|
|
4193
4260
|
|
|
4194
4261
|
onConnectionMade() {
|
|
4195
|
-
logger$
|
|
4262
|
+
logger$1.info('on CTI connection made');
|
|
4196
4263
|
|
|
4197
4264
|
this.eventEmitter.emit('onCallAccepted');
|
|
4198
4265
|
}
|
|
4199
4266
|
|
|
4200
4267
|
async close() {
|
|
4201
|
-
logger$
|
|
4268
|
+
logger$1.info('CTI close');
|
|
4202
4269
|
|
|
4203
4270
|
return Promise.resolve();
|
|
4204
4271
|
}
|
|
@@ -4207,7 +4274,7 @@ class CTIPhone extends Emitter {
|
|
|
4207
4274
|
if (!callSession) {
|
|
4208
4275
|
return;
|
|
4209
4276
|
}
|
|
4210
|
-
logger$
|
|
4277
|
+
logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4211
4278
|
|
|
4212
4279
|
return CallApi.hold(callSession.callId);
|
|
4213
4280
|
}
|
|
@@ -4216,7 +4283,7 @@ class CTIPhone extends Emitter {
|
|
|
4216
4283
|
if (!callSession) {
|
|
4217
4284
|
return;
|
|
4218
4285
|
}
|
|
4219
|
-
logger$
|
|
4286
|
+
logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4220
4287
|
|
|
4221
4288
|
return CallApi.resume(callSession.callId);
|
|
4222
4289
|
}
|
|
@@ -4225,7 +4292,7 @@ class CTIPhone extends Emitter {
|
|
|
4225
4292
|
if (!callSession) {
|
|
4226
4293
|
return;
|
|
4227
4294
|
}
|
|
4228
|
-
logger$
|
|
4295
|
+
logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4229
4296
|
|
|
4230
4297
|
return CallApi.mute(callSession.callId);
|
|
4231
4298
|
}
|
|
@@ -4234,7 +4301,7 @@ class CTIPhone extends Emitter {
|
|
|
4234
4301
|
if (!callSession) {
|
|
4235
4302
|
return;
|
|
4236
4303
|
}
|
|
4237
|
-
logger$
|
|
4304
|
+
logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4238
4305
|
|
|
4239
4306
|
return CallApi.unmute(callSession.callId);
|
|
4240
4307
|
}
|
|
@@ -4263,6 +4330,10 @@ class CTIPhone extends Emitter {
|
|
|
4263
4330
|
return false;
|
|
4264
4331
|
}
|
|
4265
4332
|
|
|
4333
|
+
hasAVideoTrack() {
|
|
4334
|
+
return false;
|
|
4335
|
+
}
|
|
4336
|
+
|
|
4266
4337
|
getLocalStreamForCall() {
|
|
4267
4338
|
return null;
|
|
4268
4339
|
}
|
|
@@ -4656,6 +4727,9 @@ class ChatRoom {
|
|
|
4656
4727
|
|
|
4657
4728
|
|
|
4658
4729
|
static parseMany(plain ) {
|
|
4730
|
+
if (!plain || !plain.items) {
|
|
4731
|
+
return [];
|
|
4732
|
+
}
|
|
4659
4733
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
4660
4734
|
}
|
|
4661
4735
|
|
|
@@ -5236,7 +5310,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5236
5310
|
const WEBHOOKD_VERSION = '1.0';
|
|
5237
5311
|
const AMID_VERSION = '1.0';
|
|
5238
5312
|
|
|
5239
|
-
const logger$
|
|
5313
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5240
5314
|
|
|
5241
5315
|
class ApiClient {
|
|
5242
5316
|
|
|
@@ -5288,12 +5362,12 @@ class ApiClient {
|
|
|
5288
5362
|
}
|
|
5289
5363
|
|
|
5290
5364
|
async forceRefreshToken() {
|
|
5291
|
-
logger$
|
|
5365
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
5292
5366
|
return this.refreshTokenCallback();
|
|
5293
5367
|
}
|
|
5294
5368
|
|
|
5295
5369
|
async refreshTokenCallback() {
|
|
5296
|
-
logger$
|
|
5370
|
+
logger$2.info('refresh token callback called', {
|
|
5297
5371
|
refreshToken: this.refreshToken,
|
|
5298
5372
|
refreshBackend: this.refreshBackend,
|
|
5299
5373
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5311,7 +5385,7 @@ class ApiClient {
|
|
|
5311
5385
|
this.isMobile,
|
|
5312
5386
|
);
|
|
5313
5387
|
|
|
5314
|
-
logger$
|
|
5388
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
5315
5389
|
|
|
5316
5390
|
if (this.onRefreshToken) {
|
|
5317
5391
|
this.onRefreshToken(session.token, session);
|
|
@@ -5452,7 +5526,7 @@ var getApiClient = (forServer ) => {
|
|
|
5452
5526
|
class InvalidSubscription extends Error {}
|
|
5453
5527
|
class InvalidAuthorization extends Error {}
|
|
5454
5528
|
|
|
5455
|
-
const logger$
|
|
5529
|
+
const logger$3 = IssueReporter$1.loggerFor('simple-auth');
|
|
5456
5530
|
|
|
5457
5531
|
class Auth {
|
|
5458
5532
|
|
|
@@ -5487,7 +5561,7 @@ class Auth {
|
|
|
5487
5561
|
setApiClientId(this.clientId);
|
|
5488
5562
|
setRefreshExpiration(this.expiration);
|
|
5489
5563
|
setOnRefreshToken((token , session ) => {
|
|
5490
|
-
logger$
|
|
5564
|
+
logger$3.info('on refresh token done', { token });
|
|
5491
5565
|
setApiToken(token);
|
|
5492
5566
|
Wazo.Websocket.updateToken(token);
|
|
5493
5567
|
|
|
@@ -5532,7 +5606,7 @@ class Auth {
|
|
|
5532
5606
|
const rawSession = await getApiClient().auth.authenticate(token);
|
|
5533
5607
|
return this._onAuthenticated(rawSession);
|
|
5534
5608
|
} catch (e) {
|
|
5535
|
-
logger$
|
|
5609
|
+
logger$3.error('on validate token error', e);
|
|
5536
5610
|
console.warn(e);
|
|
5537
5611
|
return false;
|
|
5538
5612
|
}
|
|
@@ -5888,7 +5962,7 @@ class AdHocAPIConference {
|
|
|
5888
5962
|
|
|
5889
5963
|
/* */
|
|
5890
5964
|
|
|
5891
|
-
const parseCandidate
|
|
5965
|
+
const parseCandidate = (candidate ) => {
|
|
5892
5966
|
if (!candidate) {
|
|
5893
5967
|
return null;
|
|
5894
5968
|
}
|
|
@@ -5901,10 +5975,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
5901
5975
|
candidates
|
|
5902
5976
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
5903
5977
|
|
|
5904
|
-
const areCandidateValid = (candidates ) =>
|
|
5905
|
-
getSrflxOrRelay(candidates)
|
|
5906
|
-
.length > 0;
|
|
5907
|
-
|
|
5908
5978
|
const getVideoDirection = (sdp ) => {
|
|
5909
5979
|
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
5910
5980
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -5957,8 +6027,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
5957
6027
|
/* global RTCSessionDescriptionInit, navigator */
|
|
5958
6028
|
|
|
5959
6029
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
5960
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
5961
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
5962
6030
|
|
|
5963
6031
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
5964
6032
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -6048,7 +6116,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6048
6116
|
this.peerConnectionDelegate.onicecandidate = event => {
|
|
6049
6117
|
wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
|
|
6050
6118
|
if (event.candidate) {
|
|
6051
|
-
this.gatheredCandidates.push(parseCandidate
|
|
6119
|
+
this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
|
|
6052
6120
|
}
|
|
6053
6121
|
};
|
|
6054
6122
|
|
|
@@ -6148,38 +6216,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6148
6216
|
this._peerConnection = undefined;
|
|
6149
6217
|
}
|
|
6150
6218
|
|
|
6151
|
-
async _waitForValidGatheredIce() {
|
|
6152
|
-
let tries = 0;
|
|
6153
|
-
|
|
6154
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
6155
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
6156
|
-
tries,
|
|
6157
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
6158
|
-
});
|
|
6159
|
-
|
|
6160
|
-
tries++;
|
|
6161
|
-
|
|
6162
|
-
// eslint-disable-next-line no-await-in-loop
|
|
6163
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
6164
|
-
}
|
|
6165
|
-
|
|
6166
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
6167
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
6168
|
-
const error = new Error(errorMsg);
|
|
6169
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
6170
|
-
|
|
6171
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
6172
|
-
this.eventEmitter.emit('error', error);
|
|
6173
|
-
|
|
6174
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
6175
|
-
}
|
|
6176
|
-
|
|
6177
|
-
// eslint-disable-next-line
|
|
6178
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
6179
|
-
|
|
6180
|
-
return this.getLocalSessionDescription();
|
|
6181
|
-
}
|
|
6182
|
-
|
|
6183
6219
|
// Overridden to send `inactive` in conference
|
|
6184
6220
|
updateDirection(options , isConference = false,
|
|
6185
6221
|
audioOnly = false) {
|
|
@@ -6544,7 +6580,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
6544
6580
|
const SEND_STATS_DELAY = 5000;
|
|
6545
6581
|
|
|
6546
6582
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
6547
|
-
const logger$
|
|
6583
|
+
const logger$4 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
6548
6584
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
6549
6585
|
|
|
6550
6586
|
// events
|
|
@@ -6558,14 +6594,14 @@ const TRANSPORT_ERROR = 'transportError';
|
|
|
6558
6594
|
const MESSAGE = 'message';
|
|
6559
6595
|
const ACCEPTED = 'accepted';
|
|
6560
6596
|
const REJECTED = 'rejected';
|
|
6561
|
-
const ON_TRACK
|
|
6562
|
-
const ON_REINVITE
|
|
6597
|
+
const ON_TRACK = 'onTrack';
|
|
6598
|
+
const ON_REINVITE = 'reinvite';
|
|
6563
6599
|
const ON_ERROR = 'onError';
|
|
6564
6600
|
const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
|
|
6565
|
-
const ON_NETWORK_STATS
|
|
6566
|
-
const ON_DISCONNECTED
|
|
6601
|
+
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
6602
|
+
const ON_DISCONNECTED = 'onDisconnected';
|
|
6567
6603
|
|
|
6568
|
-
const events
|
|
6604
|
+
const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
6569
6605
|
const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
6570
6606
|
class CanceledCallError extends Error {}
|
|
6571
6607
|
|
|
@@ -6701,12 +6737,12 @@ class WebRTCClient extends Emitter {
|
|
|
6701
6737
|
this.MESSAGE = MESSAGE;
|
|
6702
6738
|
this.ACCEPTED = ACCEPTED;
|
|
6703
6739
|
this.REJECTED = REJECTED;
|
|
6704
|
-
this.ON_TRACK = ON_TRACK
|
|
6705
|
-
this.ON_REINVITE = ON_REINVITE
|
|
6740
|
+
this.ON_TRACK = ON_TRACK;
|
|
6741
|
+
this.ON_REINVITE = ON_REINVITE;
|
|
6706
6742
|
this.ON_ERROR = ON_ERROR;
|
|
6707
6743
|
this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
|
|
6708
|
-
this.ON_NETWORK_STATS = ON_NETWORK_STATS
|
|
6709
|
-
this.ON_DISCONNECTED = ON_DISCONNECTED
|
|
6744
|
+
this.ON_NETWORK_STATS = ON_NETWORK_STATS;
|
|
6745
|
+
this.ON_DISCONNECTED = ON_DISCONNECTED;
|
|
6710
6746
|
}
|
|
6711
6747
|
|
|
6712
6748
|
configureMedia(media ) {
|
|
@@ -6723,13 +6759,13 @@ class WebRTCClient extends Emitter {
|
|
|
6723
6759
|
|
|
6724
6760
|
createUserAgent(configOverrides ) {
|
|
6725
6761
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6726
|
-
logger$
|
|
6762
|
+
logger$4.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6727
6763
|
|
|
6728
6764
|
webRTCConfiguration.delegate = {
|
|
6729
6765
|
onConnect: this.onConnect.bind(this),
|
|
6730
6766
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6731
6767
|
onInvite: (invitation ) => {
|
|
6732
|
-
logger$
|
|
6768
|
+
logger$4.info('sdk webrtc on invite', {
|
|
6733
6769
|
method: 'delegate.onInvite',
|
|
6734
6770
|
id: invitation.id,
|
|
6735
6771
|
remoteURI: invitation.remoteURI,
|
|
@@ -6772,7 +6808,7 @@ class WebRTCClient extends Emitter {
|
|
|
6772
6808
|
}
|
|
6773
6809
|
|
|
6774
6810
|
onConnect() {
|
|
6775
|
-
logger$
|
|
6811
|
+
logger$4.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6776
6812
|
this.eventEmitter.emit(CONNECTED);
|
|
6777
6813
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6778
6814
|
this.registerer.waitingToggle(false);
|
|
@@ -6781,7 +6817,7 @@ class WebRTCClient extends Emitter {
|
|
|
6781
6817
|
}
|
|
6782
6818
|
|
|
6783
6819
|
async onDisconnect(error ) {
|
|
6784
|
-
logger$
|
|
6820
|
+
logger$4.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6785
6821
|
this.connectionPromise = null;
|
|
6786
6822
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6787
6823
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6806,37 +6842,37 @@ class WebRTCClient extends Emitter {
|
|
|
6806
6842
|
};
|
|
6807
6843
|
|
|
6808
6844
|
if (this.skipRegister) {
|
|
6809
|
-
logger$
|
|
6845
|
+
logger$4.info('sdk webrtc skip register...', logInfo);
|
|
6810
6846
|
return Promise.resolve();
|
|
6811
6847
|
}
|
|
6812
6848
|
|
|
6813
|
-
logger$
|
|
6849
|
+
logger$4.info('sdk webrtc registering...', logInfo);
|
|
6814
6850
|
|
|
6815
6851
|
if (!this.userAgent) {
|
|
6816
|
-
logger$
|
|
6852
|
+
logger$4.info('sdk webrtc recreating User Agent');
|
|
6817
6853
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6818
6854
|
}
|
|
6819
6855
|
if (!this.userAgent || this.isRegistered()) {
|
|
6820
|
-
logger$
|
|
6856
|
+
logger$4.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6821
6857
|
return Promise.resolve();
|
|
6822
6858
|
}
|
|
6823
6859
|
|
|
6824
6860
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6825
|
-
logger$
|
|
6861
|
+
logger$4.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6826
6862
|
return Promise.resolve();
|
|
6827
6863
|
}
|
|
6828
6864
|
|
|
6829
6865
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6830
6866
|
|
|
6831
6867
|
const onRegisterFailed = () => {
|
|
6832
|
-
logger$
|
|
6868
|
+
logger$4.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6833
6869
|
this.connectionPromise = null;
|
|
6834
6870
|
if (this.registerer && this.registerer.waiting) {
|
|
6835
6871
|
this.registerer.waitingToggle(false);
|
|
6836
6872
|
}
|
|
6837
6873
|
|
|
6838
6874
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6839
|
-
logger$
|
|
6875
|
+
logger$4.info('sdk webrtc registering, retrying...', { tries });
|
|
6840
6876
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6841
6877
|
}
|
|
6842
6878
|
};
|
|
@@ -6845,18 +6881,18 @@ class WebRTCClient extends Emitter {
|
|
|
6845
6881
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6846
6882
|
// during the resolution of the primise.
|
|
6847
6883
|
if (!this.userAgent) {
|
|
6848
|
-
logger$
|
|
6884
|
+
logger$4.info('sdk webrtc recreating User Agent after connection');
|
|
6849
6885
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6850
6886
|
}
|
|
6851
6887
|
|
|
6852
|
-
logger$
|
|
6888
|
+
logger$4.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6853
6889
|
this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
|
|
6854
6890
|
this.connectionPromise = null;
|
|
6855
6891
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6856
6892
|
|
|
6857
6893
|
// Bind registerer events
|
|
6858
6894
|
this.registerer.stateChange.addListener(newState => {
|
|
6859
|
-
logger$
|
|
6895
|
+
logger$4.info('sdk webrtc registering, state changed', { newState });
|
|
6860
6896
|
|
|
6861
6897
|
if (newState === registererState.RegistererState.Registered && this.registerer
|
|
6862
6898
|
&& this.registerer.state === registererState.RegistererState.Registered) {
|
|
@@ -6869,7 +6905,7 @@ class WebRTCClient extends Emitter {
|
|
|
6869
6905
|
const options = {
|
|
6870
6906
|
requestDelegate: {
|
|
6871
6907
|
onReject: response => {
|
|
6872
|
-
logger$
|
|
6908
|
+
logger$4.error('sdk webrtc registering, rejected', { response });
|
|
6873
6909
|
|
|
6874
6910
|
onRegisterFailed();
|
|
6875
6911
|
},
|
|
@@ -6877,13 +6913,13 @@ class WebRTCClient extends Emitter {
|
|
|
6877
6913
|
};
|
|
6878
6914
|
|
|
6879
6915
|
return this.registerer.register(options).catch((e) => {
|
|
6880
|
-
logger$
|
|
6916
|
+
logger$4.error('sdk webrtc registering, error', e);
|
|
6881
6917
|
|
|
6882
6918
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6883
6919
|
return e;
|
|
6884
6920
|
});
|
|
6885
6921
|
}).catch(error => {
|
|
6886
|
-
logger$
|
|
6922
|
+
logger$4.error('sdk webrtc registering, transport error', error);
|
|
6887
6923
|
onRegisterFailed();
|
|
6888
6924
|
});
|
|
6889
6925
|
}
|
|
@@ -6912,21 +6948,21 @@ class WebRTCClient extends Emitter {
|
|
|
6912
6948
|
}
|
|
6913
6949
|
|
|
6914
6950
|
unregister() {
|
|
6915
|
-
logger$
|
|
6951
|
+
logger$4.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6916
6952
|
if (!this.registerer) {
|
|
6917
6953
|
return Promise.resolve();
|
|
6918
6954
|
}
|
|
6919
6955
|
|
|
6920
6956
|
try {
|
|
6921
6957
|
return this.registerer.unregister().then(() => {
|
|
6922
|
-
logger$
|
|
6958
|
+
logger$4.info('sdk webrtc unregistered');
|
|
6923
6959
|
this._cleanupRegister();
|
|
6924
6960
|
}).catch(e => {
|
|
6925
|
-
logger$
|
|
6961
|
+
logger$4.error('sdk webrtc unregistering, promise error', e);
|
|
6926
6962
|
this._cleanupRegister();
|
|
6927
6963
|
});
|
|
6928
6964
|
} catch (e) {
|
|
6929
|
-
logger$
|
|
6965
|
+
logger$4.error('sdk webrtc unregistering, error', e);
|
|
6930
6966
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6931
6967
|
// error when the registerer is in a bad state
|
|
6932
6968
|
this._cleanupRegister();
|
|
@@ -6934,7 +6970,7 @@ class WebRTCClient extends Emitter {
|
|
|
6934
6970
|
}
|
|
6935
6971
|
|
|
6936
6972
|
stop() {
|
|
6937
|
-
logger$
|
|
6973
|
+
logger$4.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6938
6974
|
if (!this.userAgent) {
|
|
6939
6975
|
return Promise.resolve();
|
|
6940
6976
|
}
|
|
@@ -6942,12 +6978,12 @@ class WebRTCClient extends Emitter {
|
|
|
6942
6978
|
return this.userAgent.stop().then(() => {
|
|
6943
6979
|
return this._cleanupRegister();
|
|
6944
6980
|
}).catch(e => {
|
|
6945
|
-
logger$
|
|
6981
|
+
logger$4.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6946
6982
|
});
|
|
6947
6983
|
}
|
|
6948
6984
|
|
|
6949
6985
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6950
|
-
logger$
|
|
6986
|
+
logger$4.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6951
6987
|
const inviterOptions = {
|
|
6952
6988
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6953
6989
|
conference,
|
|
@@ -6972,11 +7008,13 @@ class WebRTCClient extends Emitter {
|
|
|
6972
7008
|
const inviteOptions = {
|
|
6973
7009
|
requestDelegate: {
|
|
6974
7010
|
onAccept: (response ) => {
|
|
6975
|
-
session.sessionDescriptionHandler.peerConnection
|
|
7011
|
+
if (session.sessionDescriptionHandler.peerConnection) {
|
|
7012
|
+
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
7013
|
+
}
|
|
6976
7014
|
this._onAccepted(session, response.session, true);
|
|
6977
7015
|
},
|
|
6978
7016
|
onReject: (response ) => {
|
|
6979
|
-
logger$
|
|
7017
|
+
logger$4.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6980
7018
|
this._stopSendingStats(session);
|
|
6981
7019
|
this.stopNetworkMonitoring(session);
|
|
6982
7020
|
|
|
@@ -6999,11 +7037,11 @@ class WebRTCClient extends Emitter {
|
|
|
6999
7037
|
}
|
|
7000
7038
|
|
|
7001
7039
|
answer(session , enableVideo ) {
|
|
7002
|
-
logger$
|
|
7040
|
+
logger$4.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
7003
7041
|
|
|
7004
7042
|
if (!session || !session.accept) {
|
|
7005
7043
|
const error = 'No session to answer, or not an invitation';
|
|
7006
|
-
logger$
|
|
7044
|
+
logger$4.warn(error);
|
|
7007
7045
|
return Promise.reject(new Error(error));
|
|
7008
7046
|
}
|
|
7009
7047
|
const options = {
|
|
@@ -7013,15 +7051,15 @@ class WebRTCClient extends Emitter {
|
|
|
7013
7051
|
return session.accept(options).then(() => {
|
|
7014
7052
|
if (session.isCanceled) {
|
|
7015
7053
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
7016
|
-
logger$
|
|
7054
|
+
logger$4.error(message, { id: session.id });
|
|
7017
7055
|
this.onCallEnded(session);
|
|
7018
7056
|
|
|
7019
7057
|
throw new CanceledCallError(message);
|
|
7020
7058
|
}
|
|
7021
|
-
logger$
|
|
7059
|
+
logger$4.info('sdk webrtc answer, accepted.');
|
|
7022
7060
|
this._onAccepted(session);
|
|
7023
7061
|
}).catch(e => {
|
|
7024
|
-
logger$
|
|
7062
|
+
logger$4.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
7025
7063
|
|
|
7026
7064
|
throw e;
|
|
7027
7065
|
});
|
|
@@ -7029,7 +7067,7 @@ class WebRTCClient extends Emitter {
|
|
|
7029
7067
|
|
|
7030
7068
|
hangup(session ) {
|
|
7031
7069
|
const { state, id } = session;
|
|
7032
|
-
logger$
|
|
7070
|
+
logger$4.info('sdk webrtc hangup call', { id, state });
|
|
7033
7071
|
|
|
7034
7072
|
try {
|
|
7035
7073
|
this._stopSendingStats(session);
|
|
@@ -7058,7 +7096,7 @@ class WebRTCClient extends Emitter {
|
|
|
7058
7096
|
|
|
7059
7097
|
return bye();
|
|
7060
7098
|
} catch (error) {
|
|
7061
|
-
logger$
|
|
7099
|
+
logger$4.warn('sdk webrtc hangup, error', error);
|
|
7062
7100
|
}
|
|
7063
7101
|
|
|
7064
7102
|
return null;
|
|
@@ -7076,7 +7114,7 @@ class WebRTCClient extends Emitter {
|
|
|
7076
7114
|
// Fetch and emit an event at `interval` with session network stats
|
|
7077
7115
|
startNetworkMonitoring(session , interval = 1000) {
|
|
7078
7116
|
const sessionId = this.getSipSessionId(session);
|
|
7079
|
-
logger$
|
|
7117
|
+
logger$4.info('starting network inspection', { id: sessionId });
|
|
7080
7118
|
|
|
7081
7119
|
this.sessionNetworkStats[sessionId] = [];
|
|
7082
7120
|
|
|
@@ -7086,7 +7124,7 @@ class WebRTCClient extends Emitter {
|
|
|
7086
7124
|
stopNetworkMonitoring(session ) {
|
|
7087
7125
|
const sessionId = this.getSipSessionId(session);
|
|
7088
7126
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
7089
|
-
logger$
|
|
7127
|
+
logger$4.info('stopping network inspection', { id: sessionId, exists });
|
|
7090
7128
|
|
|
7091
7129
|
if (exists) {
|
|
7092
7130
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -7096,17 +7134,17 @@ class WebRTCClient extends Emitter {
|
|
|
7096
7134
|
}
|
|
7097
7135
|
|
|
7098
7136
|
reject(session ) {
|
|
7099
|
-
logger$
|
|
7137
|
+
logger$4.info('sdk webrtc reject call', { id: session.id });
|
|
7100
7138
|
|
|
7101
7139
|
try {
|
|
7102
7140
|
return session.reject ? session.reject() : session.cancel();
|
|
7103
7141
|
} catch (e) {
|
|
7104
|
-
logger$
|
|
7142
|
+
logger$4.warn('Error when rejecting call', e.message, e.stack);
|
|
7105
7143
|
}
|
|
7106
7144
|
}
|
|
7107
7145
|
|
|
7108
7146
|
async close() {
|
|
7109
|
-
logger$
|
|
7147
|
+
logger$4.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
7110
7148
|
this._cleanupMedia();
|
|
7111
7149
|
this.connectionPromise = null;
|
|
7112
7150
|
|
|
@@ -7137,7 +7175,7 @@ class WebRTCClient extends Emitter {
|
|
|
7137
7175
|
// eg: "INVITE not rejectable in state Completed"
|
|
7138
7176
|
}
|
|
7139
7177
|
this.userAgent = null;
|
|
7140
|
-
logger$
|
|
7178
|
+
logger$4.info('sdk webrtc client closed');
|
|
7141
7179
|
}
|
|
7142
7180
|
|
|
7143
7181
|
getNumber(session ) {
|
|
@@ -7150,13 +7188,13 @@ class WebRTCClient extends Emitter {
|
|
|
7150
7188
|
}
|
|
7151
7189
|
|
|
7152
7190
|
mute(session ) {
|
|
7153
|
-
logger$
|
|
7191
|
+
logger$4.info('sdk webrtc mute', { id: session.id });
|
|
7154
7192
|
|
|
7155
7193
|
this._toggleAudio(session, true);
|
|
7156
7194
|
}
|
|
7157
7195
|
|
|
7158
7196
|
unmute(session ) {
|
|
7159
|
-
logger$
|
|
7197
|
+
logger$4.info('sdk webrtc unmute', { id: session.id });
|
|
7160
7198
|
|
|
7161
7199
|
this._toggleAudio(session, false);
|
|
7162
7200
|
}
|
|
@@ -7196,13 +7234,13 @@ class WebRTCClient extends Emitter {
|
|
|
7196
7234
|
}
|
|
7197
7235
|
|
|
7198
7236
|
toggleCameraOn(session ) {
|
|
7199
|
-
logger$
|
|
7237
|
+
logger$4.info('sdk webrtc toggle camera on', { id: session.id });
|
|
7200
7238
|
|
|
7201
7239
|
this._toggleVideo(session, false);
|
|
7202
7240
|
}
|
|
7203
7241
|
|
|
7204
7242
|
toggleCameraOff(session ) {
|
|
7205
|
-
logger$
|
|
7243
|
+
logger$4.info('sdk webrtc toggle camera off', { id: session.id });
|
|
7206
7244
|
|
|
7207
7245
|
this._toggleVideo(session, true);
|
|
7208
7246
|
}
|
|
@@ -7211,7 +7249,7 @@ class WebRTCClient extends Emitter {
|
|
|
7211
7249
|
const sessionId = this.getSipSessionId(session);
|
|
7212
7250
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
7213
7251
|
|
|
7214
|
-
logger$
|
|
7252
|
+
logger$4.info('sdk webrtc hold', {
|
|
7215
7253
|
sessionId,
|
|
7216
7254
|
keys: Object.keys(this.heldSessions),
|
|
7217
7255
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7260,7 +7298,7 @@ class WebRTCClient extends Emitter {
|
|
|
7260
7298
|
const sessionId = this.getSipSessionId(session);
|
|
7261
7299
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
7262
7300
|
|
|
7263
|
-
logger$
|
|
7301
|
+
logger$4.info('sdk webrtc unhold', {
|
|
7264
7302
|
sessionId,
|
|
7265
7303
|
keys: Object.keys(this.heldSessions),
|
|
7266
7304
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7408,7 +7446,7 @@ class WebRTCClient extends Emitter {
|
|
|
7408
7446
|
if (!session.sessionDescriptionHandler) {
|
|
7409
7447
|
return;
|
|
7410
7448
|
}
|
|
7411
|
-
logger$
|
|
7449
|
+
logger$4.info('Sending DTMF', {
|
|
7412
7450
|
id: this.getSipSessionId(session),
|
|
7413
7451
|
tone,
|
|
7414
7452
|
});
|
|
@@ -7424,7 +7462,7 @@ class WebRTCClient extends Emitter {
|
|
|
7424
7462
|
transfer(session , target ) {
|
|
7425
7463
|
this.hold(session);
|
|
7426
7464
|
|
|
7427
|
-
logger$
|
|
7465
|
+
logger$4.info('Transfering a session', {
|
|
7428
7466
|
id: this.getSipSessionId(session),
|
|
7429
7467
|
target,
|
|
7430
7468
|
});
|
|
@@ -7446,17 +7484,17 @@ class WebRTCClient extends Emitter {
|
|
|
7446
7484
|
atxfer(session ) {
|
|
7447
7485
|
this.hold(session);
|
|
7448
7486
|
|
|
7449
|
-
logger$
|
|
7487
|
+
logger$4.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
7450
7488
|
|
|
7451
7489
|
const result = {
|
|
7452
7490
|
newSession: null,
|
|
7453
7491
|
init: async (target ) => {
|
|
7454
|
-
logger$
|
|
7492
|
+
logger$4.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
7455
7493
|
|
|
7456
7494
|
result.newSession = await this.call(target);
|
|
7457
7495
|
},
|
|
7458
7496
|
complete: () => {
|
|
7459
|
-
logger$
|
|
7497
|
+
logger$4.info('webrtc transfer completed', {
|
|
7460
7498
|
id: this.getSipSessionId(session),
|
|
7461
7499
|
referId: this.getSipSessionId(result.newSession),
|
|
7462
7500
|
});
|
|
@@ -7477,7 +7515,7 @@ class WebRTCClient extends Emitter {
|
|
|
7477
7515
|
return;
|
|
7478
7516
|
}
|
|
7479
7517
|
|
|
7480
|
-
logger$
|
|
7518
|
+
logger$4.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
7481
7519
|
|
|
7482
7520
|
try {
|
|
7483
7521
|
sipSession.message({
|
|
@@ -7519,7 +7557,7 @@ class WebRTCClient extends Emitter {
|
|
|
7519
7557
|
}
|
|
7520
7558
|
|
|
7521
7559
|
changeAudioOutputVolume(volume ) {
|
|
7522
|
-
logger$
|
|
7560
|
+
logger$4.info('Changing audio output volume', { volume });
|
|
7523
7561
|
|
|
7524
7562
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7525
7563
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -7531,7 +7569,7 @@ class WebRTCClient extends Emitter {
|
|
|
7531
7569
|
}
|
|
7532
7570
|
|
|
7533
7571
|
changeAudioOutputDevice(id ) {
|
|
7534
|
-
logger$
|
|
7572
|
+
logger$4.info('Changing audio output device', { id });
|
|
7535
7573
|
|
|
7536
7574
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7537
7575
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -7548,7 +7586,7 @@ class WebRTCClient extends Emitter {
|
|
|
7548
7586
|
|
|
7549
7587
|
changeAudioInputDevice(id , session ) {
|
|
7550
7588
|
const currentId = this.getAudioDeviceId();
|
|
7551
|
-
logger$
|
|
7589
|
+
logger$4.info('setting audio input device', { id, currentId, session: !!session });
|
|
7552
7590
|
|
|
7553
7591
|
if (id === currentId) {
|
|
7554
7592
|
return null;
|
|
@@ -7594,7 +7632,7 @@ class WebRTCClient extends Emitter {
|
|
|
7594
7632
|
|
|
7595
7633
|
setVideoInputDevice(id ) {
|
|
7596
7634
|
const currentId = this.getVideoDeviceId();
|
|
7597
|
-
logger$
|
|
7635
|
+
logger$4.info('setting video input device', { id, currentId });
|
|
7598
7636
|
|
|
7599
7637
|
if (id === currentId) {
|
|
7600
7638
|
return null;
|
|
@@ -7619,7 +7657,7 @@ class WebRTCClient extends Emitter {
|
|
|
7619
7657
|
const sessionId = this.getSipSessionId(session);
|
|
7620
7658
|
const localStream = this.getLocalStream(sessionId);
|
|
7621
7659
|
|
|
7622
|
-
logger$
|
|
7660
|
+
logger$4.info('changing video input device', { id, sessionId });
|
|
7623
7661
|
|
|
7624
7662
|
// Release old video stream
|
|
7625
7663
|
if (localStream) {
|
|
@@ -7687,7 +7725,7 @@ class WebRTCClient extends Emitter {
|
|
|
7687
7725
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
7688
7726
|
const desktop = newConstraints && newConstraints.desktop;
|
|
7689
7727
|
|
|
7690
|
-
logger$
|
|
7728
|
+
logger$4.info('Sending reinvite', {
|
|
7691
7729
|
id: this.getSipSessionId(sipSession),
|
|
7692
7730
|
newConstraints,
|
|
7693
7731
|
conference,
|
|
@@ -7725,7 +7763,7 @@ class WebRTCClient extends Emitter {
|
|
|
7725
7763
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
7726
7764
|
}
|
|
7727
7765
|
|
|
7728
|
-
logger$
|
|
7766
|
+
logger$4.info('on re-INVITE accepted', {
|
|
7729
7767
|
id: this.getSipSessionId(sipSession),
|
|
7730
7768
|
wasMuted,
|
|
7731
7769
|
shouldDoScreenSharing,
|
|
@@ -7743,7 +7781,7 @@ class WebRTCClient extends Emitter {
|
|
|
7743
7781
|
this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
|
|
7744
7782
|
}
|
|
7745
7783
|
|
|
7746
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
7784
|
+
return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
|
|
7747
7785
|
},
|
|
7748
7786
|
},
|
|
7749
7787
|
sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
|
|
@@ -7844,6 +7882,16 @@ class WebRTCClient extends Emitter {
|
|
|
7844
7882
|
return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
|
|
7845
7883
|
}
|
|
7846
7884
|
|
|
7885
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
7886
|
+
getRemoteVideoStreamFromPc(sessionId ) {
|
|
7887
|
+
const pc = this.getPeerConnection(sessionId);
|
|
7888
|
+
if (!pc) {
|
|
7889
|
+
return null;
|
|
7890
|
+
}
|
|
7891
|
+
|
|
7892
|
+
return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
|
|
7893
|
+
}
|
|
7894
|
+
|
|
7847
7895
|
hasVideo(sessionId ) {
|
|
7848
7896
|
return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
|
|
7849
7897
|
}
|
|
@@ -7890,7 +7938,7 @@ class WebRTCClient extends Emitter {
|
|
|
7890
7938
|
}
|
|
7891
7939
|
|
|
7892
7940
|
startHeartbeat() {
|
|
7893
|
-
logger$
|
|
7941
|
+
logger$4.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7894
7942
|
if (!this.userAgent) {
|
|
7895
7943
|
this.heartbeat.stop();
|
|
7896
7944
|
return;
|
|
@@ -7903,7 +7951,7 @@ class WebRTCClient extends Emitter {
|
|
|
7903
7951
|
}
|
|
7904
7952
|
|
|
7905
7953
|
stopHeartbeat() {
|
|
7906
|
-
logger$
|
|
7954
|
+
logger$4.info('sdk webrtc stop heartbeat');
|
|
7907
7955
|
this.heartbeat.stop();
|
|
7908
7956
|
}
|
|
7909
7957
|
|
|
@@ -7924,7 +7972,7 @@ class WebRTCClient extends Emitter {
|
|
|
7924
7972
|
}
|
|
7925
7973
|
|
|
7926
7974
|
attemptReconnection() {
|
|
7927
|
-
logger$
|
|
7975
|
+
logger$4.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7928
7976
|
if (!this.userAgent) {
|
|
7929
7977
|
return;
|
|
7930
7978
|
}
|
|
@@ -7949,7 +7997,7 @@ class WebRTCClient extends Emitter {
|
|
|
7949
7997
|
return;
|
|
7950
7998
|
}
|
|
7951
7999
|
|
|
7952
|
-
logger$
|
|
8000
|
+
logger$4.info('setting local media stream', {
|
|
7953
8001
|
sipSessionId,
|
|
7954
8002
|
tracks: newStream ? newStream.getTracks() : null,
|
|
7955
8003
|
});
|
|
@@ -7966,7 +8014,7 @@ class WebRTCClient extends Emitter {
|
|
|
7966
8014
|
|
|
7967
8015
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
7968
8016
|
|
|
7969
|
-
logger$
|
|
8017
|
+
logger$4.info('updating local stream', {
|
|
7970
8018
|
sipSessionId,
|
|
7971
8019
|
oldStream: !!oldStream,
|
|
7972
8020
|
tracks: newStream.getTracks(),
|
|
@@ -7986,7 +8034,7 @@ class WebRTCClient extends Emitter {
|
|
|
7986
8034
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
7987
8035
|
const pc = this.getPeerConnection(sessionId);
|
|
7988
8036
|
|
|
7989
|
-
logger$
|
|
8037
|
+
logger$4.info('Updating remote stream', {
|
|
7990
8038
|
sessionId,
|
|
7991
8039
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
7992
8040
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -8012,7 +8060,7 @@ class WebRTCClient extends Emitter {
|
|
|
8012
8060
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
8013
8061
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
8014
8062
|
|
|
8015
|
-
logger$
|
|
8063
|
+
logger$4.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
8016
8064
|
|
|
8017
8065
|
return {
|
|
8018
8066
|
constraints: {
|
|
@@ -8061,7 +8109,7 @@ class WebRTCClient extends Emitter {
|
|
|
8061
8109
|
}
|
|
8062
8110
|
|
|
8063
8111
|
_onTransportError() {
|
|
8064
|
-
logger$
|
|
8112
|
+
logger$4.error('on transport error');
|
|
8065
8113
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
8066
8114
|
this.attemptReconnection();
|
|
8067
8115
|
}
|
|
@@ -8070,7 +8118,7 @@ class WebRTCClient extends Emitter {
|
|
|
8070
8118
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
8071
8119
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
8072
8120
|
if (this.hasHeartbeat()) {
|
|
8073
|
-
logger$
|
|
8121
|
+
logger$4.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
8074
8122
|
|
|
8075
8123
|
this.heartbeat.onHeartbeat();
|
|
8076
8124
|
if (this.heartbeatCb) {
|
|
@@ -8081,7 +8129,7 @@ class WebRTCClient extends Emitter {
|
|
|
8081
8129
|
}
|
|
8082
8130
|
|
|
8083
8131
|
async _onHeartbeatTimeout() {
|
|
8084
|
-
logger$
|
|
8132
|
+
logger$4.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
8085
8133
|
|
|
8086
8134
|
if (this.heartbeatTimeoutCb) {
|
|
8087
8135
|
this.heartbeatTimeoutCb();
|
|
@@ -8093,7 +8141,7 @@ class WebRTCClient extends Emitter {
|
|
|
8093
8141
|
try {
|
|
8094
8142
|
await this.userAgent.transport.disconnect();
|
|
8095
8143
|
} catch (e) {
|
|
8096
|
-
logger$
|
|
8144
|
+
logger$4.error('Transport disconnection after heartbeat timeout, error', e);
|
|
8097
8145
|
}
|
|
8098
8146
|
}
|
|
8099
8147
|
|
|
@@ -8126,31 +8174,31 @@ class WebRTCClient extends Emitter {
|
|
|
8126
8174
|
}
|
|
8127
8175
|
|
|
8128
8176
|
_connectIfNeeded() {
|
|
8129
|
-
logger$
|
|
8177
|
+
logger$4.info('connect if needed, checking', { connected: this.isConnected() });
|
|
8130
8178
|
if (!this.userAgent) {
|
|
8131
|
-
logger$
|
|
8179
|
+
logger$4.info('need to recreate User Agent');
|
|
8132
8180
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
8133
8181
|
}
|
|
8134
8182
|
|
|
8135
8183
|
if (this.isConnected()) {
|
|
8136
|
-
logger$
|
|
8184
|
+
logger$4.info('webrtc sdk, already connected');
|
|
8137
8185
|
return Promise.resolve();
|
|
8138
8186
|
}
|
|
8139
8187
|
|
|
8140
8188
|
if (this.isConnecting()) {
|
|
8141
|
-
logger$
|
|
8189
|
+
logger$4.info('webrtc sdk, already connecting...');
|
|
8142
8190
|
|
|
8143
8191
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
8144
8192
|
return this.connectionPromise;
|
|
8145
8193
|
}
|
|
8146
8194
|
|
|
8147
8195
|
if (this.connectionPromise) {
|
|
8148
|
-
logger$
|
|
8196
|
+
logger$4.info('webrtc sdk, connection promise connecting...');
|
|
8149
8197
|
// $FlowFixMe
|
|
8150
8198
|
return this.connectionPromise;
|
|
8151
8199
|
}
|
|
8152
8200
|
|
|
8153
|
-
logger$
|
|
8201
|
+
logger$4.info('WebRTC UA needs to connect');
|
|
8154
8202
|
|
|
8155
8203
|
// Force UA to reconnect
|
|
8156
8204
|
if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
|
|
@@ -8275,7 +8323,7 @@ class WebRTCClient extends Emitter {
|
|
|
8275
8323
|
|
|
8276
8324
|
sdh.peerConnectionDelegate = {
|
|
8277
8325
|
onicecandidateerror: (error ) => {
|
|
8278
|
-
logger$
|
|
8326
|
+
logger$4.error('on icecandidate error', {
|
|
8279
8327
|
address: error.address,
|
|
8280
8328
|
port: error.port,
|
|
8281
8329
|
errorCode: error.errorCode,
|
|
@@ -8304,7 +8352,7 @@ class WebRTCClient extends Emitter {
|
|
|
8304
8352
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
8305
8353
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
8306
8354
|
}
|
|
8307
|
-
logger$
|
|
8355
|
+
logger$4.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
8308
8356
|
|
|
8309
8357
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
8310
8358
|
|
|
@@ -8320,12 +8368,12 @@ class WebRTCClient extends Emitter {
|
|
|
8320
8368
|
|
|
8321
8369
|
this._setupMedias(session);
|
|
8322
8370
|
|
|
8323
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
8371
|
+
return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
|
|
8324
8372
|
};
|
|
8325
8373
|
}
|
|
8326
8374
|
|
|
8327
8375
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
8328
|
-
logger$
|
|
8376
|
+
logger$4.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
8329
8377
|
|
|
8330
8378
|
this.storeSipSession(session);
|
|
8331
8379
|
|
|
@@ -8337,14 +8385,14 @@ class WebRTCClient extends Emitter {
|
|
|
8337
8385
|
const onTrack = (event ) => {
|
|
8338
8386
|
const isAudioOnly = this._isAudioOnly(session);
|
|
8339
8387
|
const { kind, label, readyState, id, muted } = event.track;
|
|
8340
|
-
logger$
|
|
8388
|
+
logger$4.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
8341
8389
|
|
|
8342
8390
|
// Stop video track in audio only mode
|
|
8343
8391
|
if (isAudioOnly && kind === 'video') {
|
|
8344
8392
|
event.track.stop();
|
|
8345
8393
|
}
|
|
8346
8394
|
|
|
8347
|
-
this.eventEmitter.emit(ON_TRACK
|
|
8395
|
+
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
8348
8396
|
};
|
|
8349
8397
|
|
|
8350
8398
|
if (session.sessionDescriptionHandler.peerConnection) {
|
|
@@ -8354,8 +8402,9 @@ class WebRTCClient extends Emitter {
|
|
|
8354
8402
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
8355
8403
|
|
|
8356
8404
|
pc.oniceconnectionstatechange = () => {
|
|
8405
|
+
logger$4.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
8357
8406
|
if (pc.iceConnectionState === 'disconnected') {
|
|
8358
|
-
this.eventEmitter.emit(ON_DISCONNECTED
|
|
8407
|
+
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
8359
8408
|
}
|
|
8360
8409
|
};
|
|
8361
8410
|
|
|
@@ -8526,10 +8575,10 @@ class WebRTCClient extends Emitter {
|
|
|
8526
8575
|
|
|
8527
8576
|
_stopSendingStats(session ) {
|
|
8528
8577
|
const sessionId = this.getSipSessionId(session);
|
|
8529
|
-
logger$
|
|
8578
|
+
logger$4.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
8530
8579
|
|
|
8531
8580
|
if (sessionId in this.statsIntervals) {
|
|
8532
|
-
logger$
|
|
8581
|
+
logger$4.trace('Stop sending stats for call', { sessionId });
|
|
8533
8582
|
this.statsIntervals[sessionId]();
|
|
8534
8583
|
delete this.statsIntervals[sessionId];
|
|
8535
8584
|
}
|
|
@@ -8545,7 +8594,7 @@ class WebRTCClient extends Emitter {
|
|
|
8545
8594
|
try {
|
|
8546
8595
|
await this.userAgent.transport.disconnect();
|
|
8547
8596
|
} catch (e) {
|
|
8548
|
-
logger$
|
|
8597
|
+
logger$4.error('WebRTC transport disconnect, error', e);
|
|
8549
8598
|
}
|
|
8550
8599
|
}
|
|
8551
8600
|
}
|
|
@@ -8582,25 +8631,25 @@ class WebRTCClient extends Emitter {
|
|
|
8582
8631
|
|
|
8583
8632
|
stats.forEach(report => {
|
|
8584
8633
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
8585
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8634
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8586
8635
|
}
|
|
8587
8636
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
8588
|
-
audioBytesSent += report.bytesSent;
|
|
8637
|
+
audioBytesSent += Number(report.bytesSent);
|
|
8589
8638
|
}
|
|
8590
8639
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8591
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8640
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8592
8641
|
}
|
|
8593
8642
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
8594
|
-
packetsLost += report.packetsLost;
|
|
8595
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
8596
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8643
|
+
packetsLost += Number(report.packetsLost);
|
|
8644
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
8645
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8597
8646
|
}
|
|
8598
8647
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
8599
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8648
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8600
8649
|
}
|
|
8601
8650
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8602
8651
|
if ('framesPerSecond' in report) {
|
|
8603
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
8652
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
8604
8653
|
}
|
|
8605
8654
|
if ('framerateMean' in report) {
|
|
8606
8655
|
// framerateMean is only available in FF
|
|
@@ -8608,34 +8657,38 @@ class WebRTCClient extends Emitter {
|
|
|
8608
8657
|
}
|
|
8609
8658
|
}
|
|
8610
8659
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
8611
|
-
packetsLost += report.packetsLost;
|
|
8612
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
8613
|
-
networkStats.jitter = report.jitter;
|
|
8660
|
+
packetsLost += Number(report.packetsLost);
|
|
8661
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
8662
|
+
networkStats.jitter = Number(report.jitter);
|
|
8614
8663
|
}
|
|
8615
8664
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
8616
|
-
packetsLost += report.packetsLost;
|
|
8665
|
+
packetsLost += Number(report.packetsLost);
|
|
8617
8666
|
}
|
|
8618
8667
|
if (report.type === 'transport') {
|
|
8619
|
-
transportSent += report.bytesSent;
|
|
8620
|
-
transportReceived += report.bytesReceived;
|
|
8668
|
+
transportSent += Number(report.bytesSent);
|
|
8669
|
+
transportReceived += Number(report.bytesReceived);
|
|
8621
8670
|
}
|
|
8622
8671
|
});
|
|
8623
8672
|
|
|
8624
8673
|
networkStats.packetsLost = packetsLost;
|
|
8625
|
-
networkStats.
|
|
8674
|
+
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
8675
|
+
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
8676
|
+
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
8626
8677
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
8627
|
-
networkStats.
|
|
8628
|
-
networkStats.
|
|
8678
|
+
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
8679
|
+
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
8680
|
+
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
8681
|
+
networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
|
|
8682
|
+
networkStats.totalTransportSent = transportSent - lastTransportSent;
|
|
8629
8683
|
networkStats.transportSent = transportSent;
|
|
8630
|
-
networkStats.
|
|
8631
|
-
|
|
8632
|
-
const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
|
|
8633
|
-
+ (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
|
|
8634
|
-
+ (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
|
|
8684
|
+
networkStats.totalTransportReceived = transportReceived;
|
|
8685
|
+
networkStats.transportReceived = transportReceived - lastTransportReceived;
|
|
8635
8686
|
|
|
8636
|
-
networkStats.bandwidth =
|
|
8687
|
+
networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
|
|
8688
|
+
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
8689
|
+
+ networkStats.transportSent;
|
|
8637
8690
|
|
|
8638
|
-
this.eventEmitter.emit(ON_NETWORK_STATS
|
|
8691
|
+
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
8639
8692
|
this.sessionNetworkStats[sessionId].push(networkStats);
|
|
8640
8693
|
}
|
|
8641
8694
|
|
|
@@ -8663,8 +8716,8 @@ const ON_CALL_FAILED = 'onCallFailed';
|
|
|
8663
8716
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
8664
8717
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
8665
8718
|
const ON_MESSAGE = 'onMessage';
|
|
8666
|
-
const ON_REINVITE = 'reinvite';
|
|
8667
|
-
const ON_TRACK = 'onTrack';
|
|
8719
|
+
const ON_REINVITE$1 = 'reinvite';
|
|
8720
|
+
const ON_TRACK$1 = 'onTrack';
|
|
8668
8721
|
const ON_AUDIO_STREAM = 'onAudioStream';
|
|
8669
8722
|
const ON_VIDEO_STREAM = 'onVideoStream';
|
|
8670
8723
|
const ON_REMOVE_STREAM = 'onRemoveStream';
|
|
@@ -8679,15 +8732,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
|
|
|
8679
8732
|
const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
|
|
8680
8733
|
const ON_CALL_ERROR = 'onCallError';
|
|
8681
8734
|
const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
|
|
8682
|
-
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
8735
|
+
const ON_NETWORK_STATS$1 = 'onNetworkStats';
|
|
8683
8736
|
const ON_CHAT = 'phone/ON_CHAT';
|
|
8684
8737
|
const ON_SIGNAL = 'phone/ON_SIGNAL';
|
|
8685
|
-
const ON_DISCONNECTED = 'onDisconnected';
|
|
8738
|
+
const ON_DISCONNECTED$1 = 'onDisconnected';
|
|
8686
8739
|
|
|
8687
8740
|
const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
8688
8741
|
const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
8689
8742
|
|
|
8690
|
-
const events = [
|
|
8743
|
+
const events$1 = [
|
|
8691
8744
|
ON_USER_AGENT,
|
|
8692
8745
|
ON_REGISTERED,
|
|
8693
8746
|
ON_UNREGISTERED,
|
|
@@ -8705,8 +8758,8 @@ const events = [
|
|
|
8705
8758
|
ON_CALL_FAILED,
|
|
8706
8759
|
ON_CALL_ENDED,
|
|
8707
8760
|
ON_MESSAGE,
|
|
8708
|
-
ON_REINVITE,
|
|
8709
|
-
ON_TRACK,
|
|
8761
|
+
ON_REINVITE$1,
|
|
8762
|
+
ON_TRACK$1,
|
|
8710
8763
|
ON_AUDIO_STREAM,
|
|
8711
8764
|
ON_VIDEO_STREAM,
|
|
8712
8765
|
ON_REMOVE_STREAM,
|
|
@@ -8721,11 +8774,11 @@ const events = [
|
|
|
8721
8774
|
ON_CALL_ERROR,
|
|
8722
8775
|
ON_CHAT,
|
|
8723
8776
|
ON_SIGNAL,
|
|
8724
|
-
ON_NETWORK_STATS,
|
|
8725
|
-
ON_DISCONNECTED,
|
|
8777
|
+
ON_NETWORK_STATS$1,
|
|
8778
|
+
ON_DISCONNECTED$1,
|
|
8726
8779
|
];
|
|
8727
8780
|
|
|
8728
|
-
const logger$
|
|
8781
|
+
const logger$5 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
8729
8782
|
|
|
8730
8783
|
class WebRTCPhone extends Emitter {
|
|
8731
8784
|
|
|
@@ -8798,7 +8851,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8798
8851
|
}).catch(error => {
|
|
8799
8852
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
8800
8853
|
console.error('register error', error, error.message, error.stack);
|
|
8801
|
-
logger$
|
|
8854
|
+
logger$5.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
8802
8855
|
});
|
|
8803
8856
|
}
|
|
8804
8857
|
|
|
@@ -8813,7 +8866,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8813
8866
|
if (!this.client) {
|
|
8814
8867
|
return;
|
|
8815
8868
|
}
|
|
8816
|
-
logger$
|
|
8869
|
+
logger$5.info('WebRTC phone stop');
|
|
8817
8870
|
this.client.stop();
|
|
8818
8871
|
}
|
|
8819
8872
|
|
|
@@ -8828,7 +8881,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8828
8881
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
8829
8882
|
audioOnly = false, iceRestart = false) {
|
|
8830
8883
|
const sipSession = this.findSipSession(callSession);
|
|
8831
|
-
logger$
|
|
8884
|
+
logger$5.info('WebRTC phone - send reinvite', {
|
|
8832
8885
|
sessionId: sipSession ? sipSession.id : null,
|
|
8833
8886
|
constraints,
|
|
8834
8887
|
audioOnly,
|
|
@@ -8865,7 +8918,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8865
8918
|
}
|
|
8866
8919
|
|
|
8867
8920
|
startHeartbeat() {
|
|
8868
|
-
logger$
|
|
8921
|
+
logger$5.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
8869
8922
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
8870
8923
|
return;
|
|
8871
8924
|
}
|
|
@@ -8874,7 +8927,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8874
8927
|
}
|
|
8875
8928
|
|
|
8876
8929
|
stopHeartbeat() {
|
|
8877
|
-
logger$
|
|
8930
|
+
logger$5.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
8878
8931
|
if (!this.client) {
|
|
8879
8932
|
return;
|
|
8880
8933
|
}
|
|
@@ -8891,7 +8944,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8891
8944
|
}
|
|
8892
8945
|
|
|
8893
8946
|
reconnect() {
|
|
8894
|
-
logger$
|
|
8947
|
+
logger$5.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
8895
8948
|
if (!this.client) {
|
|
8896
8949
|
return;
|
|
8897
8950
|
}
|
|
@@ -8932,10 +8985,15 @@ class WebRTCPhone extends Emitter {
|
|
|
8932
8985
|
return false;
|
|
8933
8986
|
}
|
|
8934
8987
|
|
|
8935
|
-
logger$
|
|
8988
|
+
logger$5.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
8936
8989
|
|
|
8937
8990
|
this.client.downgradeToAudio(sipSession);
|
|
8938
8991
|
|
|
8992
|
+
if (callSession) {
|
|
8993
|
+
callSession.cameraEnabled = false;
|
|
8994
|
+
this._updateCallSession(callSession);
|
|
8995
|
+
}
|
|
8996
|
+
|
|
8939
8997
|
if (withMessage) {
|
|
8940
8998
|
this._sendReinviteMessage(callSession, false);
|
|
8941
8999
|
}
|
|
@@ -8950,7 +9008,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8950
9008
|
return Promise.resolve(false);
|
|
8951
9009
|
}
|
|
8952
9010
|
|
|
8953
|
-
logger$
|
|
9011
|
+
logger$5.info('Upgrade to video', {
|
|
8954
9012
|
id: callSession ? callSession.getId() : null,
|
|
8955
9013
|
constraints,
|
|
8956
9014
|
isConference,
|
|
@@ -8963,6 +9021,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8963
9021
|
|
|
8964
9022
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
8965
9023
|
|
|
9024
|
+
if (callSession) {
|
|
9025
|
+
callSession.cameraEnabled = true;
|
|
9026
|
+
this._updateCallSession(callSession);
|
|
9027
|
+
}
|
|
9028
|
+
|
|
8966
9029
|
// If no stream is returned, it means we have to reinvite
|
|
8967
9030
|
if (!newStream) {
|
|
8968
9031
|
return true;
|
|
@@ -8985,7 +9048,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8985
9048
|
|
|
8986
9049
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
8987
9050
|
const sipSession = this.findSipSession(callSession);
|
|
8988
|
-
logger$
|
|
9051
|
+
logger$5.info('Sending reinvite message', {
|
|
8989
9052
|
id: callSession ? callSession.getId() : null,
|
|
8990
9053
|
isUpgrade,
|
|
8991
9054
|
});
|
|
@@ -9011,11 +9074,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9011
9074
|
// Monkey patch to know when canceled with the CANCEL message
|
|
9012
9075
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
9013
9076
|
sipSession._onCancel = (message ) => {
|
|
9014
|
-
logger$
|
|
9077
|
+
logger$5.trace('on sip session canceled', { callId: message.callId });
|
|
9015
9078
|
|
|
9016
9079
|
onCancel(message);
|
|
9017
9080
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
9018
|
-
|
|
9081
|
+
const callSession = this._createCallSession(sipSession);
|
|
9082
|
+
delete this.callSessions[callSession.getId()];
|
|
9083
|
+
|
|
9084
|
+
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
9019
9085
|
};
|
|
9020
9086
|
} else if (sipSession instanceof invitation.Invitation) {
|
|
9021
9087
|
console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
|
|
@@ -9036,17 +9102,19 @@ class WebRTCPhone extends Emitter {
|
|
|
9036
9102
|
this.audioOutputVolume,
|
|
9037
9103
|
);
|
|
9038
9104
|
case sessionState.SessionState.Terminating:
|
|
9039
|
-
logger$
|
|
9105
|
+
logger$5.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
9040
9106
|
|
|
9041
9107
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
9042
9108
|
|
|
9043
9109
|
break;
|
|
9044
9110
|
case sessionState.SessionState.Terminated: {
|
|
9045
|
-
logger$
|
|
9111
|
+
logger$5.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
9046
9112
|
|
|
9113
|
+
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
9114
|
+
const callSession = this._createCallSession(sipSession);
|
|
9047
9115
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
9048
9116
|
|
|
9049
|
-
return this.eventEmitter.emit(ON_CALL_ENDED,
|
|
9117
|
+
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
9050
9118
|
}
|
|
9051
9119
|
}
|
|
9052
9120
|
});
|
|
@@ -9062,7 +9130,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9062
9130
|
const [stream] = event.streams;
|
|
9063
9131
|
const kind = event && event.track && event.track.kind;
|
|
9064
9132
|
|
|
9065
|
-
logger$
|
|
9133
|
+
logger$5.info('on track stream called on the peer connection', {
|
|
9066
9134
|
callId: this.getSipSessionId(sipSession),
|
|
9067
9135
|
streamId: stream ? stream.id : null,
|
|
9068
9136
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -9082,7 +9150,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9082
9150
|
};
|
|
9083
9151
|
|
|
9084
9152
|
peerConnection.onremovestream = event => {
|
|
9085
|
-
logger$
|
|
9153
|
+
logger$5.info('on remove stream called on the peer connection', {
|
|
9086
9154
|
id: event.stream.id,
|
|
9087
9155
|
tracks: event.stream.getTracks(),
|
|
9088
9156
|
});
|
|
@@ -9092,7 +9160,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9092
9160
|
}
|
|
9093
9161
|
|
|
9094
9162
|
async startScreenSharing(constraints , callSession ) {
|
|
9095
|
-
logger$
|
|
9163
|
+
logger$5.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
9096
9164
|
|
|
9097
9165
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
9098
9166
|
if (!screenShareStream) {
|
|
@@ -9132,7 +9200,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9132
9200
|
return;
|
|
9133
9201
|
}
|
|
9134
9202
|
|
|
9135
|
-
logger$
|
|
9203
|
+
logger$5.info('WebRTC phone - stop screen sharing', {
|
|
9136
9204
|
restoreLocalStream,
|
|
9137
9205
|
});
|
|
9138
9206
|
|
|
@@ -9188,24 +9256,26 @@ class WebRTCPhone extends Emitter {
|
|
|
9188
9256
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
9189
9257
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
9190
9258
|
|
|
9191
|
-
logger$
|
|
9259
|
+
logger$5.info('WebRTC phone - on screensharing', {
|
|
9192
9260
|
hadVideo,
|
|
9193
9261
|
id: this.getSipSessionId(sipSession),
|
|
9194
9262
|
screenTrack,
|
|
9195
9263
|
});
|
|
9196
9264
|
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
9202
|
-
|
|
9265
|
+
if (screenTrack) {
|
|
9266
|
+
screenTrack.onended = () => {
|
|
9267
|
+
logger$5.info('WebRTC phone - on screenshare ended', {
|
|
9268
|
+
hadVideo,
|
|
9269
|
+
id: this.getSipSessionId(sipSession),
|
|
9270
|
+
screenTrack,
|
|
9271
|
+
});
|
|
9203
9272
|
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9273
|
+
this.eventEmitter.emit(
|
|
9274
|
+
ON_SHARE_SCREEN_ENDING,
|
|
9275
|
+
this._createCallSession(sipSession, callSession),
|
|
9276
|
+
);
|
|
9277
|
+
};
|
|
9278
|
+
}
|
|
9209
9279
|
|
|
9210
9280
|
this.currentScreenShare = {
|
|
9211
9281
|
stream: screenStream,
|
|
@@ -9225,7 +9295,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9225
9295
|
}
|
|
9226
9296
|
|
|
9227
9297
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
9228
|
-
logger$
|
|
9298
|
+
logger$5.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
9229
9299
|
|
|
9230
9300
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
9231
9301
|
this.currentSipSession = sipSession;
|
|
@@ -9243,7 +9313,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9243
9313
|
}
|
|
9244
9314
|
|
|
9245
9315
|
changeAudioDevice(id ) {
|
|
9246
|
-
logger$
|
|
9316
|
+
logger$5.info('WebRTC phone - change audio device', { deviceId: id });
|
|
9247
9317
|
this.audioOutputDeviceId = id;
|
|
9248
9318
|
this.client.changeAudioOutputDevice(id);
|
|
9249
9319
|
}
|
|
@@ -9253,14 +9323,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9253
9323
|
}
|
|
9254
9324
|
|
|
9255
9325
|
changeRingDevice(id ) {
|
|
9256
|
-
logger$
|
|
9326
|
+
logger$5.info('WebRTC phone - changing ring device', { id });
|
|
9257
9327
|
|
|
9258
9328
|
this.audioRingDeviceId = id;
|
|
9259
9329
|
}
|
|
9260
9330
|
|
|
9261
9331
|
// volume is a value between 0 and 1
|
|
9262
9332
|
changeAudioVolume(volume ) {
|
|
9263
|
-
logger$
|
|
9333
|
+
logger$5.info('WebRTC phone - changing audio volume', { volume });
|
|
9264
9334
|
|
|
9265
9335
|
this.audioOutputVolume = volume;
|
|
9266
9336
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -9268,31 +9338,31 @@ class WebRTCPhone extends Emitter {
|
|
|
9268
9338
|
|
|
9269
9339
|
// volume is a value between 0 and 1
|
|
9270
9340
|
changeRingVolume(volume ) {
|
|
9271
|
-
logger$
|
|
9341
|
+
logger$5.info('WebRTC phone - changing ring volume', { volume });
|
|
9272
9342
|
|
|
9273
9343
|
this.audioRingVolume = volume;
|
|
9274
9344
|
}
|
|
9275
9345
|
|
|
9276
9346
|
changeAudioInputDevice(id ) {
|
|
9277
|
-
logger$
|
|
9347
|
+
logger$5.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
9278
9348
|
|
|
9279
9349
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
9280
9350
|
}
|
|
9281
9351
|
|
|
9282
9352
|
changeVideoInputDevice(id ) {
|
|
9283
|
-
logger$
|
|
9353
|
+
logger$5.info('WebRTC phone - change video input device', { deviceId: id });
|
|
9284
9354
|
|
|
9285
9355
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
9286
9356
|
}
|
|
9287
9357
|
|
|
9288
9358
|
changeSessionVideoInputDevice(id ) {
|
|
9289
|
-
logger$
|
|
9359
|
+
logger$5.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
9290
9360
|
|
|
9291
9361
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
9292
9362
|
}
|
|
9293
9363
|
|
|
9294
9364
|
_onCallTerminated(sipSession ) {
|
|
9295
|
-
logger$
|
|
9365
|
+
logger$5.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9296
9366
|
|
|
9297
9367
|
const callSession = this._createCallSession(sipSession);
|
|
9298
9368
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -9326,7 +9396,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9326
9396
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
9327
9397
|
|
|
9328
9398
|
// Re-trigger incoming call event for remaining incoming calls
|
|
9329
|
-
logger$
|
|
9399
|
+
logger$5.info('WebRTC phone - check to re-trigger incoming call', {
|
|
9330
9400
|
sipId: sipSession.id,
|
|
9331
9401
|
shouldRetrigger,
|
|
9332
9402
|
hasIncomingCallSession,
|
|
@@ -9417,37 +9487,37 @@ class WebRTCPhone extends Emitter {
|
|
|
9417
9487
|
|
|
9418
9488
|
// Deprecated
|
|
9419
9489
|
getLocalStreamForCall(callSession ) {
|
|
9420
|
-
logger$
|
|
9490
|
+
logger$5.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9421
9491
|
|
|
9422
9492
|
return this.getLocalStream(callSession);
|
|
9423
9493
|
}
|
|
9424
9494
|
|
|
9425
9495
|
// Deprecated
|
|
9426
9496
|
getRemoteStreamForCall(callSession ) {
|
|
9427
|
-
logger$
|
|
9497
|
+
logger$5.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
9428
9498
|
|
|
9429
9499
|
return this.getRemoteVideoStream(callSession);
|
|
9430
9500
|
}
|
|
9431
9501
|
|
|
9432
9502
|
getRemoteStreamsForCall(callSession ) {
|
|
9433
|
-
logger$
|
|
9503
|
+
logger$5.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
9434
9504
|
|
|
9435
9505
|
return this.getRemoteStream(callSession);
|
|
9436
9506
|
}
|
|
9437
9507
|
|
|
9438
9508
|
accept(callSession , cameraEnabled ) {
|
|
9439
|
-
logger$
|
|
9509
|
+
logger$5.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
9440
9510
|
if (this.currentSipSession) {
|
|
9441
9511
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
9442
9512
|
}
|
|
9443
9513
|
|
|
9444
9514
|
if (!callSession) {
|
|
9445
|
-
logger$
|
|
9515
|
+
logger$5.warn('no CallSession to accept.');
|
|
9446
9516
|
return Promise.resolve(null);
|
|
9447
9517
|
}
|
|
9448
9518
|
|
|
9449
9519
|
if (callSession.getId() in this.acceptedSessions) {
|
|
9450
|
-
logger$
|
|
9520
|
+
logger$5.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9451
9521
|
return Promise.resolve(callSession.sipCallId);
|
|
9452
9522
|
}
|
|
9453
9523
|
|
|
@@ -9459,24 +9529,24 @@ class WebRTCPhone extends Emitter {
|
|
|
9459
9529
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
9460
9530
|
if (sipSession) {
|
|
9461
9531
|
if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
|
|
9462
|
-
logger$
|
|
9532
|
+
logger$5.warn('Trying to answer a terminated sipSession.');
|
|
9463
9533
|
|
|
9464
9534
|
return Promise.resolve(null);
|
|
9465
9535
|
}
|
|
9466
9536
|
|
|
9467
|
-
logger$
|
|
9537
|
+
logger$5.info('accept call, session found', { sipId: sipSession.id });
|
|
9468
9538
|
|
|
9469
9539
|
// $FlowFixMe
|
|
9470
9540
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
9471
9541
|
return callSession.sipCallId;
|
|
9472
9542
|
}).catch(e => {
|
|
9473
|
-
logger$
|
|
9543
|
+
logger$5.error(e);
|
|
9474
9544
|
this.endCurrentCall(callSession);
|
|
9475
9545
|
throw e;
|
|
9476
9546
|
});
|
|
9477
9547
|
}
|
|
9478
9548
|
|
|
9479
|
-
logger$
|
|
9549
|
+
logger$5.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9480
9550
|
|
|
9481
9551
|
return Promise.resolve(null);
|
|
9482
9552
|
}
|
|
@@ -9486,7 +9556,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9486
9556
|
}
|
|
9487
9557
|
|
|
9488
9558
|
async reject(callSession ) {
|
|
9489
|
-
logger$
|
|
9559
|
+
logger$5.info('reject WebRTC called', { id: callSession.getId() });
|
|
9490
9560
|
|
|
9491
9561
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
9492
9562
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -9498,14 +9568,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9498
9568
|
|
|
9499
9569
|
const sipSession = this.findSipSession(callSession);
|
|
9500
9570
|
if (sipSession) {
|
|
9501
|
-
logger$
|
|
9571
|
+
logger$5.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
9502
9572
|
|
|
9503
9573
|
this.client.hangup(sipSession);
|
|
9504
9574
|
}
|
|
9505
9575
|
}
|
|
9506
9576
|
|
|
9507
9577
|
async ignore(callSession ) {
|
|
9508
|
-
logger$
|
|
9578
|
+
logger$5.info('WebRTC ignore', { id: callSession.getId() });
|
|
9509
9579
|
|
|
9510
9580
|
// kill the ring
|
|
9511
9581
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -9517,14 +9587,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9517
9587
|
const sipSession = this.findSipSession(callSession);
|
|
9518
9588
|
|
|
9519
9589
|
if (sipSession) {
|
|
9520
|
-
logger$
|
|
9590
|
+
logger$5.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
9521
9591
|
|
|
9522
9592
|
return this.client.atxfer(sipSession);
|
|
9523
9593
|
}
|
|
9524
9594
|
}
|
|
9525
9595
|
|
|
9526
9596
|
hold(callSession , withEvent = true, isConference = false) {
|
|
9527
|
-
logger$
|
|
9597
|
+
logger$5.info('WebRTC hold', { id: callSession.getId() });
|
|
9528
9598
|
|
|
9529
9599
|
const sipSession = this.findSipSession(callSession);
|
|
9530
9600
|
|
|
@@ -9539,18 +9609,18 @@ class WebRTCPhone extends Emitter {
|
|
|
9539
9609
|
}
|
|
9540
9610
|
|
|
9541
9611
|
resume(callSession , isConference = false, withEvent = true) {
|
|
9542
|
-
logger$
|
|
9612
|
+
logger$5.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
9543
9613
|
|
|
9544
9614
|
const sipSession = this.findSipSession(callSession);
|
|
9545
9615
|
if (!sipSession) {
|
|
9546
9616
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
9547
9617
|
}
|
|
9548
9618
|
|
|
9549
|
-
logger$
|
|
9619
|
+
logger$5.info('WebRTC resuming', { sipId: sipSession.id });
|
|
9550
9620
|
|
|
9551
9621
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
9552
9622
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
9553
|
-
logger$
|
|
9623
|
+
logger$5.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
9554
9624
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
9555
9625
|
}
|
|
9556
9626
|
|
|
@@ -9575,7 +9645,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9575
9645
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9576
9646
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
9577
9647
|
|
|
9578
|
-
logger$
|
|
9648
|
+
logger$5.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9579
9649
|
|
|
9580
9650
|
// Stop screenshre if needed
|
|
9581
9651
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -9606,7 +9676,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9606
9676
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
9607
9677
|
}
|
|
9608
9678
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9609
|
-
logger$
|
|
9679
|
+
logger$5.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
9610
9680
|
|
|
9611
9681
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
9612
9682
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -9650,14 +9720,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9650
9720
|
}
|
|
9651
9721
|
|
|
9652
9722
|
mute(callSession , withEvent = true) {
|
|
9653
|
-
logger$
|
|
9723
|
+
logger$5.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
9654
9724
|
|
|
9655
9725
|
const sipSession = this.findSipSession(callSession);
|
|
9656
9726
|
if (!sipSession) {
|
|
9657
9727
|
return;
|
|
9658
9728
|
}
|
|
9659
9729
|
|
|
9660
|
-
logger$
|
|
9730
|
+
logger$5.info('WebRTC muting', { sipId: sipSession.id });
|
|
9661
9731
|
this.client.mute(sipSession);
|
|
9662
9732
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
9663
9733
|
|
|
@@ -9671,14 +9741,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9671
9741
|
}
|
|
9672
9742
|
|
|
9673
9743
|
unmute(callSession , withEvent = true) {
|
|
9674
|
-
logger$
|
|
9744
|
+
logger$5.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
9675
9745
|
|
|
9676
9746
|
const sipSession = this.findSipSession(callSession);
|
|
9677
9747
|
if (!sipSession) {
|
|
9678
9748
|
return;
|
|
9679
9749
|
}
|
|
9680
9750
|
|
|
9681
|
-
logger$
|
|
9751
|
+
logger$5.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
9682
9752
|
this.client.unmute(sipSession);
|
|
9683
9753
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
9684
9754
|
|
|
@@ -9705,7 +9775,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9705
9775
|
if (!sipSession) {
|
|
9706
9776
|
return;
|
|
9707
9777
|
}
|
|
9708
|
-
logger$
|
|
9778
|
+
logger$5.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
9709
9779
|
|
|
9710
9780
|
this.client.toggleCameraOn(sipSession);
|
|
9711
9781
|
|
|
@@ -9717,7 +9787,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9717
9787
|
if (!sipSession) {
|
|
9718
9788
|
return;
|
|
9719
9789
|
}
|
|
9720
|
-
logger$
|
|
9790
|
+
logger$5.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
9721
9791
|
|
|
9722
9792
|
this.client.toggleCameraOff(sipSession);
|
|
9723
9793
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -9729,7 +9799,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9729
9799
|
return;
|
|
9730
9800
|
}
|
|
9731
9801
|
|
|
9732
|
-
logger$
|
|
9802
|
+
logger$5.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
9733
9803
|
this.client.sendDTMF(sipSession, tone);
|
|
9734
9804
|
}
|
|
9735
9805
|
|
|
@@ -9737,7 +9807,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9737
9807
|
// @TODO: line is not used here
|
|
9738
9808
|
async makeCall(number , line , cameraEnabled ,
|
|
9739
9809
|
audioOnly = false, conference = false) {
|
|
9740
|
-
logger$
|
|
9810
|
+
logger$5.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
9741
9811
|
if (!number) {
|
|
9742
9812
|
return Promise.resolve(null);
|
|
9743
9813
|
}
|
|
@@ -9747,7 +9817,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9747
9817
|
}
|
|
9748
9818
|
if (this.currentSipSession) {
|
|
9749
9819
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
9750
|
-
logger$
|
|
9820
|
+
logger$5.warn('Unable to hold current session when making another call', e);
|
|
9751
9821
|
});
|
|
9752
9822
|
}
|
|
9753
9823
|
|
|
@@ -9757,7 +9827,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9757
9827
|
this._bindEvents(sipSession);
|
|
9758
9828
|
} catch (error) {
|
|
9759
9829
|
console.warn(error);
|
|
9760
|
-
logger$
|
|
9830
|
+
logger$5.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
9761
9831
|
return Promise.resolve(null);
|
|
9762
9832
|
}
|
|
9763
9833
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -9785,7 +9855,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9785
9855
|
return;
|
|
9786
9856
|
}
|
|
9787
9857
|
|
|
9788
|
-
logger$
|
|
9858
|
+
logger$5.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
9789
9859
|
|
|
9790
9860
|
this.client.transfer(sipSession, target);
|
|
9791
9861
|
}
|
|
@@ -9794,7 +9864,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9794
9864
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
9795
9865
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
9796
9866
|
|
|
9797
|
-
logger$
|
|
9867
|
+
logger$5.info('WebRTC indirect transfer', {
|
|
9798
9868
|
sipId: sipSession ? sipSession.id : null,
|
|
9799
9869
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
9800
9870
|
});
|
|
@@ -9833,7 +9903,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9833
9903
|
return false;
|
|
9834
9904
|
}
|
|
9835
9905
|
|
|
9836
|
-
logger$
|
|
9906
|
+
logger$5.info('WebRTC hangup', { sipId: sipSession.id });
|
|
9837
9907
|
|
|
9838
9908
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9839
9909
|
|
|
@@ -9879,7 +9949,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9879
9949
|
endCurrentCall(callSession ) {
|
|
9880
9950
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
9881
9951
|
|
|
9882
|
-
logger$
|
|
9952
|
+
logger$5.info('Ending current call', {
|
|
9883
9953
|
id: callSession ? callSession.getId() : null,
|
|
9884
9954
|
isCurrent,
|
|
9885
9955
|
});
|
|
@@ -9903,7 +9973,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9903
9973
|
}
|
|
9904
9974
|
|
|
9905
9975
|
async close() {
|
|
9906
|
-
logger$
|
|
9976
|
+
logger$5.info('WebRTC close');
|
|
9907
9977
|
|
|
9908
9978
|
try {
|
|
9909
9979
|
await Promise.race([
|
|
@@ -9911,7 +9981,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9911
9981
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
9912
9982
|
]);
|
|
9913
9983
|
} catch (e) {
|
|
9914
|
-
logger$
|
|
9984
|
+
logger$5.error('WebRTC close, unregister error', e);
|
|
9915
9985
|
}
|
|
9916
9986
|
|
|
9917
9987
|
this.client.close();
|
|
@@ -9929,12 +9999,12 @@ class WebRTCPhone extends Emitter {
|
|
|
9929
9999
|
}
|
|
9930
10000
|
|
|
9931
10001
|
enableRinging() {
|
|
9932
|
-
logger$
|
|
10002
|
+
logger$5.info('WebRTC enable ringing');
|
|
9933
10003
|
this.ringingEnabled = true;
|
|
9934
10004
|
}
|
|
9935
10005
|
|
|
9936
10006
|
disableRinging() {
|
|
9937
|
-
logger$
|
|
10007
|
+
logger$5.info('WebRTC disable ringing');
|
|
9938
10008
|
this.ringingEnabled = false;
|
|
9939
10009
|
}
|
|
9940
10010
|
|
|
@@ -9974,7 +10044,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9974
10044
|
|
|
9975
10045
|
// Deprecated
|
|
9976
10046
|
getLocalMediaStream(callSession ) {
|
|
9977
|
-
logger$
|
|
10047
|
+
logger$5.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9978
10048
|
return this.getLocalStream(callSession);
|
|
9979
10049
|
}
|
|
9980
10050
|
|
|
@@ -9994,6 +10064,10 @@ class WebRTCPhone extends Emitter {
|
|
|
9994
10064
|
return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
|
|
9995
10065
|
}
|
|
9996
10066
|
|
|
10067
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
10068
|
+
return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
|
|
10069
|
+
}
|
|
10070
|
+
|
|
9997
10071
|
hasRemoteVideo(callSession ) {
|
|
9998
10072
|
return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
|
|
9999
10073
|
}
|
|
@@ -10012,7 +10086,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10012
10086
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
10013
10087
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
10014
10088
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
10015
|
-
logger$
|
|
10089
|
+
logger$5.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
10016
10090
|
|
|
10017
10091
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
10018
10092
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -10035,7 +10109,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10035
10109
|
});
|
|
10036
10110
|
|
|
10037
10111
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
10038
|
-
logger$
|
|
10112
|
+
logger$5.info('WebRTC on reinvite', {
|
|
10039
10113
|
sessionId: args[0].id,
|
|
10040
10114
|
inviteId: args[1].id,
|
|
10041
10115
|
updatedCalleeName: args[2],
|
|
@@ -10055,7 +10129,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10055
10129
|
});
|
|
10056
10130
|
|
|
10057
10131
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
10058
|
-
logger$
|
|
10132
|
+
logger$5.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
10059
10133
|
|
|
10060
10134
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
10061
10135
|
|
|
@@ -10066,22 +10140,22 @@ class WebRTCPhone extends Emitter {
|
|
|
10066
10140
|
this.client.on('ended', () => {});
|
|
10067
10141
|
|
|
10068
10142
|
this.client.on(this.client.ON_ERROR, e => {
|
|
10069
|
-
logger$
|
|
10143
|
+
logger$5.error('WebRTC error', e);
|
|
10070
10144
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
10071
10145
|
});
|
|
10072
10146
|
|
|
10073
10147
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
10074
|
-
logger$
|
|
10148
|
+
logger$5.info('WebRTC unregistered');
|
|
10075
10149
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10076
10150
|
});
|
|
10077
10151
|
|
|
10078
10152
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
10079
|
-
logger$
|
|
10080
|
-
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
10153
|
+
logger$5.info('WebRTC disconnected');
|
|
10154
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
10081
10155
|
});
|
|
10082
10156
|
|
|
10083
10157
|
this.client.on(this.client.REGISTERED, () => {
|
|
10084
|
-
logger$
|
|
10158
|
+
logger$5.info('WebRTC registered', {
|
|
10085
10159
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
10086
10160
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
10087
10161
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -10094,23 +10168,27 @@ class WebRTCPhone extends Emitter {
|
|
|
10094
10168
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
10095
10169
|
&& this.currentSipSession.state === sessionState.SessionState.Established) {
|
|
10096
10170
|
this.shouldSendReinvite = false;
|
|
10171
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
10172
|
+
const isConference = pc ? pc.sfu : false;
|
|
10173
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
10174
|
+
|
|
10097
10175
|
try {
|
|
10098
10176
|
// Send reinvite with iceRestart
|
|
10099
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
10177
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
10100
10178
|
} catch (e) {
|
|
10101
|
-
logger$
|
|
10179
|
+
logger$5.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
10102
10180
|
}
|
|
10103
10181
|
}
|
|
10104
10182
|
});
|
|
10105
10183
|
|
|
10106
10184
|
this.client.on(this.client.CONNECTED, () => {
|
|
10107
|
-
logger$
|
|
10185
|
+
logger$5.info('WebRTC client connected');
|
|
10108
10186
|
|
|
10109
10187
|
this.stopHeartbeat();
|
|
10110
10188
|
});
|
|
10111
10189
|
|
|
10112
10190
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10113
|
-
logger$
|
|
10191
|
+
logger$5.info('WebRTC client disconnected');
|
|
10114
10192
|
|
|
10115
10193
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10116
10194
|
|
|
@@ -10124,7 +10202,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10124
10202
|
});
|
|
10125
10203
|
|
|
10126
10204
|
this.client.on(this.client.ON_TRACK, (session, event) => {
|
|
10127
|
-
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
10205
|
+
this.eventEmitter.emit(ON_TRACK$1, session, event);
|
|
10128
10206
|
});
|
|
10129
10207
|
|
|
10130
10208
|
this.client.on('onVideoInputChange', stream => {
|
|
@@ -10139,7 +10217,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10139
10217
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
10140
10218
|
const callSession = this.getCallSession(this.getSipSessionId(session));
|
|
10141
10219
|
|
|
10142
|
-
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
10220
|
+
this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
|
|
10143
10221
|
});
|
|
10144
10222
|
|
|
10145
10223
|
// Used when upgrading directly in screenshare mode
|
|
@@ -10148,7 +10226,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10148
10226
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
10149
10227
|
const callSession = this.callSessions[sipSessionId];
|
|
10150
10228
|
|
|
10151
|
-
logger$
|
|
10229
|
+
logger$5.info('Updrading directly in screensharing mode', {
|
|
10152
10230
|
sipSessionId,
|
|
10153
10231
|
tracks: localStream ? localStream.getTracks() : null,
|
|
10154
10232
|
});
|
|
@@ -10180,6 +10258,15 @@ class WebRTCPhone extends Emitter {
|
|
|
10180
10258
|
return this.client.getSipSessionId(sipSession);
|
|
10181
10259
|
}
|
|
10182
10260
|
|
|
10261
|
+
_updateCallSession(callSession ) {
|
|
10262
|
+
const sipSession = this.findSipSession(callSession);
|
|
10263
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
10264
|
+
|
|
10265
|
+
if (sipSessionId) {
|
|
10266
|
+
this.callSessions[sipSessionId] = callSession;
|
|
10267
|
+
}
|
|
10268
|
+
}
|
|
10269
|
+
|
|
10183
10270
|
_onMessage(message ) {
|
|
10184
10271
|
if (!message || message.method !== 'MESSAGE') {
|
|
10185
10272
|
return;
|
|
@@ -10317,8 +10404,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10317
10404
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10318
10405
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10319
10406
|
ON_MESSAGE: ON_MESSAGE,
|
|
10320
|
-
ON_REINVITE: ON_REINVITE,
|
|
10321
|
-
ON_TRACK: ON_TRACK,
|
|
10407
|
+
ON_REINVITE: ON_REINVITE$1,
|
|
10408
|
+
ON_TRACK: ON_TRACK$1,
|
|
10322
10409
|
ON_AUDIO_STREAM: ON_AUDIO_STREAM,
|
|
10323
10410
|
ON_VIDEO_STREAM: ON_VIDEO_STREAM,
|
|
10324
10411
|
ON_REMOVE_STREAM: ON_REMOVE_STREAM,
|
|
@@ -10333,13 +10420,13 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10333
10420
|
ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
|
|
10334
10421
|
ON_CALL_ERROR: ON_CALL_ERROR,
|
|
10335
10422
|
ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
|
|
10336
|
-
ON_NETWORK_STATS: ON_NETWORK_STATS,
|
|
10423
|
+
ON_NETWORK_STATS: ON_NETWORK_STATS$1,
|
|
10337
10424
|
ON_CHAT: ON_CHAT,
|
|
10338
10425
|
ON_SIGNAL: ON_SIGNAL,
|
|
10339
|
-
ON_DISCONNECTED: ON_DISCONNECTED,
|
|
10426
|
+
ON_DISCONNECTED: ON_DISCONNECTED$1,
|
|
10340
10427
|
MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
|
|
10341
10428
|
MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
|
|
10342
|
-
events: events,
|
|
10429
|
+
events: events$1,
|
|
10343
10430
|
'default': WebRTCPhone
|
|
10344
10431
|
});
|
|
10345
10432
|
|
|
@@ -10677,6 +10764,11 @@ class Phone extends Emitter {
|
|
|
10677
10764
|
return this.getRemoteVideoStream(callSession);
|
|
10678
10765
|
}
|
|
10679
10766
|
|
|
10767
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
10768
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
10769
|
+
return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
|
|
10770
|
+
}
|
|
10771
|
+
|
|
10680
10772
|
hasVideo(callSession ) {
|
|
10681
10773
|
return this.phone ? this.phone.hasVideo(callSession) : false;
|
|
10682
10774
|
}
|
|
@@ -10728,7 +10820,7 @@ class Phone extends Emitter {
|
|
|
10728
10820
|
|
|
10729
10821
|
_transferEvents() {
|
|
10730
10822
|
this.unbind();
|
|
10731
|
-
[...events
|
|
10823
|
+
[...events, ...transportEvents].forEach(event => {
|
|
10732
10824
|
this.client.on(event, (...args) =>
|
|
10733
10825
|
this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
|
|
10734
10826
|
});
|
|
@@ -10750,7 +10842,7 @@ var Phone$1 = global.wazoTelephonyInstance;
|
|
|
10750
10842
|
|
|
10751
10843
|
//
|
|
10752
10844
|
|
|
10753
|
-
const SOCKET_EVENTS
|
|
10845
|
+
const SOCKET_EVENTS = {
|
|
10754
10846
|
ON_OPEN: 'onopen',
|
|
10755
10847
|
ON_MESSAGE: 'onmessage',
|
|
10756
10848
|
ON_ERROR: 'onerror',
|
|
@@ -10836,6 +10928,7 @@ const AGENT_PAUSED = 'agent_paused';
|
|
|
10836
10928
|
const AGENT_UNPAUSED = 'agent_unpaused';
|
|
10837
10929
|
const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
|
|
10838
10930
|
const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
|
|
10931
|
+
const MEETING_USER_PROGRESS = 'meeting_user_progress';
|
|
10839
10932
|
|
|
10840
10933
|
const BLACKLIST_EVENTS = [
|
|
10841
10934
|
CHAT_MESSAGE_SENT,
|
|
@@ -10845,7 +10938,7 @@ const BLACKLIST_EVENTS = [
|
|
|
10845
10938
|
];
|
|
10846
10939
|
|
|
10847
10940
|
const HEARTBEAT_ENGINE_VERSION = '20.09';
|
|
10848
|
-
const logger$
|
|
10941
|
+
const logger$7 = IssueReporter$1.loggerFor('wazo-ws');
|
|
10849
10942
|
const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
|
|
10850
10943
|
|
|
10851
10944
|
class WebSocketClient extends Emitter {
|
|
@@ -10894,24 +10987,24 @@ class WebSocketClient extends Emitter {
|
|
|
10894
10987
|
}
|
|
10895
10988
|
|
|
10896
10989
|
connect() {
|
|
10897
|
-
logger$
|
|
10990
|
+
logger$7.info('connect method started', { host: this.host, token: this.token });
|
|
10898
10991
|
this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
|
|
10899
10992
|
if (this.options.binaryType) {
|
|
10900
10993
|
this.socket.binaryType = this.options.binaryType;
|
|
10901
10994
|
}
|
|
10902
10995
|
|
|
10903
10996
|
this.socket.onopen = () => {
|
|
10904
|
-
logger$
|
|
10905
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10997
|
+
logger$7.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
10998
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
10906
10999
|
};
|
|
10907
11000
|
|
|
10908
11001
|
this.socket.onerror = event => {
|
|
10909
|
-
logger$
|
|
10910
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11002
|
+
logger$7.error('on Wazo WS error', event.target);
|
|
11003
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
10911
11004
|
};
|
|
10912
11005
|
|
|
10913
11006
|
this.socket.onmessage = (event ) => {
|
|
10914
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11007
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
|
|
10915
11008
|
|
|
10916
11009
|
const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
|
|
10917
11010
|
let { name } = message;
|
|
@@ -10936,7 +11029,7 @@ class WebSocketClient extends Emitter {
|
|
|
10936
11029
|
|
|
10937
11030
|
this.socket.onclose = event => {
|
|
10938
11031
|
// Can't be converted to JSON (circular structure)
|
|
10939
|
-
logger$
|
|
11032
|
+
logger$7.info('on Wazo WS close', {
|
|
10940
11033
|
reason: event.reason,
|
|
10941
11034
|
code: event.code,
|
|
10942
11035
|
readyState: event.target.readyState,
|
|
@@ -10944,22 +11037,22 @@ class WebSocketClient extends Emitter {
|
|
|
10944
11037
|
token: this.token,
|
|
10945
11038
|
});
|
|
10946
11039
|
this.initialized = false;
|
|
10947
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11040
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
|
|
10948
11041
|
|
|
10949
11042
|
switch (event.code) {
|
|
10950
11043
|
case 4002:
|
|
10951
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11044
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
|
|
10952
11045
|
break;
|
|
10953
11046
|
}
|
|
10954
11047
|
};
|
|
10955
11048
|
|
|
10956
11049
|
this.socket.onerror = event => {
|
|
10957
|
-
logger$
|
|
11050
|
+
logger$7.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
10958
11051
|
};
|
|
10959
11052
|
}
|
|
10960
11053
|
|
|
10961
11054
|
close(force = false) {
|
|
10962
|
-
logger$
|
|
11055
|
+
logger$7.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
10963
11056
|
|
|
10964
11057
|
if (!this.socket) {
|
|
10965
11058
|
return;
|
|
@@ -10977,7 +11070,7 @@ class WebSocketClient extends Emitter {
|
|
|
10977
11070
|
|
|
10978
11071
|
updateToken(token ) {
|
|
10979
11072
|
this.token = token;
|
|
10980
|
-
logger$
|
|
11073
|
+
logger$7.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
10981
11074
|
|
|
10982
11075
|
if (this.socket) {
|
|
10983
11076
|
// If still connected, send the token to the WS
|
|
@@ -10995,7 +11088,7 @@ class WebSocketClient extends Emitter {
|
|
|
10995
11088
|
}
|
|
10996
11089
|
|
|
10997
11090
|
startHeartbeat() {
|
|
10998
|
-
logger$
|
|
11091
|
+
logger$7.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
10999
11092
|
|
|
11000
11093
|
if (!this.socket) {
|
|
11001
11094
|
this.heartbeat.stop();
|
|
@@ -11009,7 +11102,7 @@ class WebSocketClient extends Emitter {
|
|
|
11009
11102
|
}
|
|
11010
11103
|
|
|
11011
11104
|
stopHeartbeat() {
|
|
11012
|
-
logger$
|
|
11105
|
+
logger$7.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
11013
11106
|
|
|
11014
11107
|
this.heartbeat.stop();
|
|
11015
11108
|
}
|
|
@@ -11039,7 +11132,7 @@ class WebSocketClient extends Emitter {
|
|
|
11039
11132
|
}
|
|
11040
11133
|
|
|
11041
11134
|
reconnect(reason ) {
|
|
11042
|
-
logger$
|
|
11135
|
+
logger$7.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
11043
11136
|
if (!this.socket) {
|
|
11044
11137
|
return;
|
|
11045
11138
|
}
|
|
@@ -11064,7 +11157,7 @@ class WebSocketClient extends Emitter {
|
|
|
11064
11157
|
break;
|
|
11065
11158
|
case 'start':
|
|
11066
11159
|
this.initialized = true;
|
|
11067
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11160
|
+
this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
|
|
11068
11161
|
break;
|
|
11069
11162
|
default:
|
|
11070
11163
|
this.eventEmitter.emit('message', message);
|
|
@@ -11095,7 +11188,7 @@ class WebSocketClient extends Emitter {
|
|
|
11095
11188
|
this.close();
|
|
11096
11189
|
}
|
|
11097
11190
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
11098
|
-
logger$
|
|
11191
|
+
logger$7.log('Wazo WS url computed to reconnect', { url });
|
|
11099
11192
|
|
|
11100
11193
|
return url;
|
|
11101
11194
|
}
|
|
@@ -11103,15 +11196,15 @@ class WebSocketClient extends Emitter {
|
|
|
11103
11196
|
_onHeartbeat(message ) {
|
|
11104
11197
|
if (message.payload === 'pong') {
|
|
11105
11198
|
this.heartbeat.onHeartbeat();
|
|
11106
|
-
logger$
|
|
11199
|
+
logger$7.log('on heartbeat received from Wazo WS');
|
|
11107
11200
|
}
|
|
11108
11201
|
}
|
|
11109
11202
|
|
|
11110
11203
|
async _onHeartbeatTimeout() {
|
|
11111
|
-
logger$
|
|
11204
|
+
logger$7.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
11112
11205
|
|
|
11113
11206
|
this.close();
|
|
11114
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11207
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
11115
11208
|
|
|
11116
11209
|
if (this.onHeartBeatTimeout) {
|
|
11117
11210
|
this.onHeartBeatTimeout();
|
|
@@ -11186,11 +11279,12 @@ WebSocketClient.eventLists = [
|
|
|
11186
11279
|
AGENT_UNPAUSED,
|
|
11187
11280
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
11188
11281
|
CONFERENCE_ADHOC_DELETED,
|
|
11282
|
+
MEETING_USER_PROGRESS,
|
|
11189
11283
|
];
|
|
11190
11284
|
|
|
11191
11285
|
var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
11192
11286
|
__proto__: null,
|
|
11193
|
-
SOCKET_EVENTS: SOCKET_EVENTS
|
|
11287
|
+
SOCKET_EVENTS: SOCKET_EVENTS,
|
|
11194
11288
|
AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
|
|
11195
11289
|
FAVORITE_ADDED: FAVORITE_ADDED,
|
|
11196
11290
|
FAVORITE_DELETED: FAVORITE_DELETED,
|
|
@@ -11256,16 +11350,17 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
11256
11350
|
AGENT_UNPAUSED: AGENT_UNPAUSED,
|
|
11257
11351
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
11258
11352
|
CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
|
|
11353
|
+
MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
|
|
11259
11354
|
HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
|
|
11260
11355
|
'default': WebSocketClient
|
|
11261
11356
|
});
|
|
11262
11357
|
|
|
11263
11358
|
//
|
|
11264
11359
|
|
|
11265
|
-
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
11266
|
-
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
11360
|
+
const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
11361
|
+
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
|
|
11267
11362
|
|
|
11268
|
-
const logger$
|
|
11363
|
+
const logger$8 = IssueReporter$1.loggerFor('simple-ws-client');
|
|
11269
11364
|
|
|
11270
11365
|
class Websocket extends Emitter {
|
|
11271
11366
|
|
|
@@ -11279,9 +11374,9 @@ class Websocket extends Emitter {
|
|
|
11279
11374
|
// $FlowFixMe
|
|
11280
11375
|
this[key] = OTHER_EVENTS[key];
|
|
11281
11376
|
});
|
|
11282
|
-
Object.keys(SOCKET_EVENTS).forEach(key => {
|
|
11377
|
+
Object.keys(SOCKET_EVENTS$1).forEach(key => {
|
|
11283
11378
|
// $FlowFixMe
|
|
11284
|
-
this[key] = SOCKET_EVENTS[key];
|
|
11379
|
+
this[key] = SOCKET_EVENTS$1[key];
|
|
11285
11380
|
});
|
|
11286
11381
|
this.eventLists = WebSocketClient.eventLists;
|
|
11287
11382
|
|
|
@@ -11289,7 +11384,7 @@ class Websocket extends Emitter {
|
|
|
11289
11384
|
}
|
|
11290
11385
|
|
|
11291
11386
|
open(host , session ) {
|
|
11292
|
-
logger$
|
|
11387
|
+
logger$8.info('open simple WebSocket', { host, token: session.token });
|
|
11293
11388
|
this.ws = new WebSocketClient(
|
|
11294
11389
|
{
|
|
11295
11390
|
host,
|
|
@@ -11317,7 +11412,7 @@ class Websocket extends Emitter {
|
|
|
11317
11412
|
}
|
|
11318
11413
|
|
|
11319
11414
|
updateToken(token ) {
|
|
11320
|
-
logger$
|
|
11415
|
+
logger$8.info('update token via simple Websocket', { token, ws: !!this.ws });
|
|
11321
11416
|
|
|
11322
11417
|
if (!this.ws) {
|
|
11323
11418
|
return;
|
|
@@ -11345,12 +11440,12 @@ var Websocket$1 = global.wazoWebsocketInstance;
|
|
|
11345
11440
|
|
|
11346
11441
|
//
|
|
11347
11442
|
|
|
11348
|
-
const logger$
|
|
11443
|
+
const logger$9 = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
11349
11444
|
|
|
11350
|
-
class SipRoom extends Room {
|
|
11445
|
+
class SipRoom extends Room$1 {
|
|
11351
11446
|
|
|
11352
11447
|
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
11353
|
-
logger$
|
|
11448
|
+
logger$9.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
11354
11449
|
|
|
11355
11450
|
if (!room) {
|
|
11356
11451
|
await Wazo.Phone.connect();
|
|
@@ -11366,7 +11461,7 @@ class SipRoom extends Room {
|
|
|
11366
11461
|
room.setCallId(room.callSession.call.id);
|
|
11367
11462
|
}
|
|
11368
11463
|
|
|
11369
|
-
logger$
|
|
11464
|
+
logger$9.info('connected to room', {
|
|
11370
11465
|
extension: room.extension,
|
|
11371
11466
|
});
|
|
11372
11467
|
|
|
@@ -11374,7 +11469,7 @@ class SipRoom extends Room {
|
|
|
11374
11469
|
}
|
|
11375
11470
|
|
|
11376
11471
|
mute() {
|
|
11377
|
-
logger$
|
|
11472
|
+
logger$9.info('mute sip room');
|
|
11378
11473
|
|
|
11379
11474
|
Wazo.Phone.mute(this.callSession, false);
|
|
11380
11475
|
|
|
@@ -11382,7 +11477,7 @@ class SipRoom extends Room {
|
|
|
11382
11477
|
}
|
|
11383
11478
|
|
|
11384
11479
|
unmute() {
|
|
11385
|
-
logger$
|
|
11480
|
+
logger$9.info('unmute sip room');
|
|
11386
11481
|
|
|
11387
11482
|
Wazo.Phone.unmute(this.callSession, false);
|
|
11388
11483
|
|
|
@@ -11484,7 +11579,7 @@ class SipRoom extends Room {
|
|
|
11484
11579
|
|
|
11485
11580
|
//
|
|
11486
11581
|
|
|
11487
|
-
const logger$
|
|
11582
|
+
const logger$a = IssueReporter$1.loggerFor('room');
|
|
11488
11583
|
|
|
11489
11584
|
class Participant extends Emitter {
|
|
11490
11585
|
|
|
@@ -11606,7 +11701,7 @@ class Participant extends Emitter {
|
|
|
11606
11701
|
}
|
|
11607
11702
|
|
|
11608
11703
|
onTalking(isTalking ) {
|
|
11609
|
-
logger$
|
|
11704
|
+
logger$a.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
|
|
11610
11705
|
this.isTalking = isTalking;
|
|
11611
11706
|
// you may notice we're not broadcasting: since all participants are getting this info
|
|
11612
11707
|
// directly from asterisk, there's no need to do so
|
|
@@ -11709,7 +11804,7 @@ class Participant extends Emitter {
|
|
|
11709
11804
|
}
|
|
11710
11805
|
|
|
11711
11806
|
updateStatus(status , broadcast = true) {
|
|
11712
|
-
logger$
|
|
11807
|
+
logger$a.info('updating participant status', { name: this.name, status });
|
|
11713
11808
|
|
|
11714
11809
|
if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
|
|
11715
11810
|
if (status.audioMuted) {
|
|
@@ -11757,7 +11852,7 @@ class Participant extends Emitter {
|
|
|
11757
11852
|
|
|
11758
11853
|
broadcastStatus(inboundStatus = null) {
|
|
11759
11854
|
const status = inboundStatus || this.getStatus();
|
|
11760
|
-
logger$
|
|
11855
|
+
logger$a.info('broadcasting participant status', { callId: this.callId, status });
|
|
11761
11856
|
|
|
11762
11857
|
this.room.sendSignal({
|
|
11763
11858
|
type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
|
|
@@ -11972,7 +12067,7 @@ class NotificationOptions {
|
|
|
11972
12067
|
|
|
11973
12068
|
|
|
11974
12069
|
// Represents a conference room, like `9000`.
|
|
11975
|
-
class Room
|
|
12070
|
+
class Room {
|
|
11976
12071
|
|
|
11977
12072
|
|
|
11978
12073
|
|
|
@@ -11993,7 +12088,7 @@ class Room$1 {
|
|
|
11993
12088
|
}
|
|
11994
12089
|
|
|
11995
12090
|
connect(callSession ) {
|
|
11996
|
-
return new Room
|
|
12091
|
+
return new Room({ ...this, connectedCallSession: callSession });
|
|
11997
12092
|
}
|
|
11998
12093
|
|
|
11999
12094
|
has(callSession ) {
|
|
@@ -12002,7 +12097,7 @@ class Room$1 {
|
|
|
12002
12097
|
|
|
12003
12098
|
addParticipant(uuid , extension , talking = null) {
|
|
12004
12099
|
if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
|
|
12005
|
-
return new Room
|
|
12100
|
+
return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
12006
12101
|
}
|
|
12007
12102
|
|
|
12008
12103
|
return this;
|
|
@@ -12021,7 +12116,7 @@ class Room$1 {
|
|
|
12021
12116
|
updatedParticipants.push(participant);
|
|
12022
12117
|
}
|
|
12023
12118
|
|
|
12024
|
-
return new Room
|
|
12119
|
+
return new Room({ ...this, participants: updatedParticipants });
|
|
12025
12120
|
}
|
|
12026
12121
|
|
|
12027
12122
|
updateParticipantByExtension(extension , participant , shouldAdd = false) {
|
|
@@ -12037,7 +12132,7 @@ class Room$1 {
|
|
|
12037
12132
|
updatedParticipants.push(participant);
|
|
12038
12133
|
}
|
|
12039
12134
|
|
|
12040
|
-
return new Room
|
|
12135
|
+
return new Room({ ...this, participants: updatedParticipants });
|
|
12041
12136
|
}
|
|
12042
12137
|
|
|
12043
12138
|
hasCallWithId(id ) {
|
|
@@ -12045,18 +12140,18 @@ class Room$1 {
|
|
|
12045
12140
|
}
|
|
12046
12141
|
|
|
12047
12142
|
disconnect() {
|
|
12048
|
-
return new Room
|
|
12143
|
+
return new Room({ ...this, connectedCallSession: null });
|
|
12049
12144
|
}
|
|
12050
12145
|
|
|
12051
12146
|
removeParticipantWithUUID(uuid ) {
|
|
12052
|
-
return new Room
|
|
12147
|
+
return new Room({
|
|
12053
12148
|
...this,
|
|
12054
12149
|
participants: this.participants.filter(participant => participant.uuid !== uuid),
|
|
12055
12150
|
});
|
|
12056
12151
|
}
|
|
12057
12152
|
|
|
12058
12153
|
removeParticipantWithExtension(extension ) {
|
|
12059
|
-
return new Room
|
|
12154
|
+
return new Room({
|
|
12060
12155
|
...this,
|
|
12061
12156
|
participants: this.participants.filter(participant => participant.extension !== extension),
|
|
12062
12157
|
});
|
|
@@ -12067,7 +12162,7 @@ class Room$1 {
|
|
|
12067
12162
|
}
|
|
12068
12163
|
|
|
12069
12164
|
static newFrom(room ) {
|
|
12070
|
-
return newFrom(room, Room
|
|
12165
|
+
return newFrom(room, Room);
|
|
12071
12166
|
}
|
|
12072
12167
|
}
|
|
12073
12168
|
|
|
@@ -12374,11 +12469,11 @@ var wazoWebsocket = {
|
|
|
12374
12469
|
resolve();
|
|
12375
12470
|
};
|
|
12376
12471
|
|
|
12377
|
-
client.on(SOCKET_EVENTS
|
|
12472
|
+
client.on(SOCKET_EVENTS.ON_ERROR, error => {
|
|
12378
12473
|
handleError(`Connection error : ${error}`);
|
|
12379
12474
|
});
|
|
12380
12475
|
|
|
12381
|
-
client.on(SOCKET_EVENTS
|
|
12476
|
+
client.on(SOCKET_EVENTS.ON_OPEN, () => {
|
|
12382
12477
|
if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
|
|
12383
12478
|
client.setOnHeartbeatTimeout(() => {
|
|
12384
12479
|
handleError('No response to heartbeat');
|
|
@@ -12479,7 +12574,7 @@ var webrtc = {
|
|
|
12479
12574
|
}),
|
|
12480
12575
|
};
|
|
12481
12576
|
|
|
12482
|
-
const parseCandidate = line => {
|
|
12577
|
+
const parseCandidate$1 = line => {
|
|
12483
12578
|
let parts;
|
|
12484
12579
|
// Parse both variants.
|
|
12485
12580
|
if (line.indexOf('a=candidate:') === 0) {
|
|
@@ -12570,7 +12665,7 @@ var SymmetricNat = {
|
|
|
12570
12665
|
}
|
|
12571
12666
|
|
|
12572
12667
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
12573
|
-
const cand = parseCandidate(e.candidate.candidate);
|
|
12668
|
+
const cand = parseCandidate$1(e.candidate.candidate);
|
|
12574
12669
|
if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
|
|
12575
12670
|
candidates[cand.relatedPort].push(cand.port);
|
|
12576
12671
|
} else if (!e.candidate) {
|
|
@@ -12638,7 +12733,7 @@ var iceIpv4 = {
|
|
|
12638
12733
|
const rawCandidate = e.candidate.candidate;
|
|
12639
12734
|
if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
|
|
12640
12735
|
hasSrflxOrRelay = true;
|
|
12641
|
-
const candidate = parseCandidate(e.candidate.candidate);
|
|
12736
|
+
const candidate = parseCandidate$1(e.candidate.candidate);
|
|
12642
12737
|
ips.push(candidate.ip);
|
|
12643
12738
|
}
|
|
12644
12739
|
} else if (!e.candidate) {
|
|
@@ -12675,7 +12770,7 @@ var checks = [
|
|
|
12675
12770
|
|
|
12676
12771
|
//
|
|
12677
12772
|
|
|
12678
|
-
const logger$
|
|
12773
|
+
const logger$b = IssueReporter$1.loggerFor('engine-check');
|
|
12679
12774
|
|
|
12680
12775
|
class Checker {
|
|
12681
12776
|
|
|
@@ -12693,28 +12788,28 @@ class Checker {
|
|
|
12693
12788
|
async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
|
|
12694
12789
|
await this._addEngineVersion();
|
|
12695
12790
|
|
|
12696
|
-
logger$
|
|
12791
|
+
logger$b.info('Engine check starting');
|
|
12697
12792
|
|
|
12698
12793
|
for (let i = 0; i < this.checks.length; i++) {
|
|
12699
12794
|
const { name, check } = this.checks[i];
|
|
12700
12795
|
|
|
12701
|
-
logger$
|
|
12796
|
+
logger$b.info(`Checking ${name} ...`);
|
|
12702
12797
|
|
|
12703
12798
|
onCheckBegin(name);
|
|
12704
12799
|
try {
|
|
12705
12800
|
// eslint-disable-next-line no-await-in-loop
|
|
12706
12801
|
const result = await check(this.server, this.session, this.externalAppConfig);
|
|
12707
|
-
logger$
|
|
12802
|
+
logger$b.info(`Checking ${name} success.`, { result });
|
|
12708
12803
|
|
|
12709
12804
|
onCheckResult(name, result);
|
|
12710
12805
|
} catch (e) {
|
|
12711
|
-
logger$
|
|
12806
|
+
logger$b.info(`Checking ${name} failure`, { message: e.message });
|
|
12712
12807
|
|
|
12713
12808
|
onCheckResult(name, e);
|
|
12714
12809
|
}
|
|
12715
12810
|
}
|
|
12716
12811
|
|
|
12717
|
-
logger$
|
|
12812
|
+
logger$b.info('Engine check done.');
|
|
12718
12813
|
}
|
|
12719
12814
|
|
|
12720
12815
|
addCheck(check ) {
|
|
@@ -12738,7 +12833,7 @@ const Wazo = {
|
|
|
12738
12833
|
Auth: Auth$1,
|
|
12739
12834
|
Phone: Phone$1,
|
|
12740
12835
|
Websocket: Websocket$1,
|
|
12741
|
-
Room,
|
|
12836
|
+
Room: Room$1,
|
|
12742
12837
|
SipRoom,
|
|
12743
12838
|
RemoteParticipant,
|
|
12744
12839
|
LocalParticipant,
|
|
@@ -12771,7 +12866,7 @@ const Wazo = {
|
|
|
12771
12866
|
Session,
|
|
12772
12867
|
Voicemail,
|
|
12773
12868
|
Relocation,
|
|
12774
|
-
ConferenceRoom: Room
|
|
12869
|
+
ConferenceRoom: Room,
|
|
12775
12870
|
CallSession,
|
|
12776
12871
|
IndirectTransfer,
|
|
12777
12872
|
SwitchboardCall,
|
|
@@ -12810,9 +12905,9 @@ if (global) {
|
|
|
12810
12905
|
const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
12811
12906
|
const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
12812
12907
|
|
|
12813
|
-
const logger = IssueReporter$1.loggerFor('sdk-room');
|
|
12908
|
+
const logger$c = IssueReporter$1.loggerFor('sdk-room');
|
|
12814
12909
|
|
|
12815
|
-
class Room extends Emitter {
|
|
12910
|
+
class Room$1 extends Emitter {
|
|
12816
12911
|
|
|
12817
12912
|
|
|
12818
12913
|
|
|
@@ -12870,7 +12965,7 @@ class Room extends Emitter {
|
|
|
12870
12965
|
extra = {},
|
|
12871
12966
|
) {
|
|
12872
12967
|
super();
|
|
12873
|
-
logger.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
12968
|
+
logger$c.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
12874
12969
|
|
|
12875
12970
|
// Represents the room callSession
|
|
12876
12971
|
this.callSession = callSession;
|
|
@@ -12936,7 +13031,7 @@ class Room extends Emitter {
|
|
|
12936
13031
|
* @returns {Promise<Room>}
|
|
12937
13032
|
*/
|
|
12938
13033
|
static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
|
|
12939
|
-
logger.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
13034
|
+
logger$c.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
12940
13035
|
|
|
12941
13036
|
if (!room) {
|
|
12942
13037
|
await Wazo.Phone.connect();
|
|
@@ -12949,7 +13044,7 @@ class Room extends Emitter {
|
|
|
12949
13044
|
|
|
12950
13045
|
// Call_created is triggered before call_accepted, so we have to listen for it here.
|
|
12951
13046
|
Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
|
|
12952
|
-
logger.info('room call received via WS', { callId: data.call_id });
|
|
13047
|
+
logger$c.info('room call received via WS', { callId: data.call_id });
|
|
12953
13048
|
if (room) {
|
|
12954
13049
|
room.setCallId(data.call_id);
|
|
12955
13050
|
}
|
|
@@ -12957,7 +13052,7 @@ class Room extends Emitter {
|
|
|
12957
13052
|
|
|
12958
13053
|
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
12959
13054
|
// eslint-disable-next-line no-param-reassign
|
|
12960
|
-
room = new Room(callSession, extension, null, null, extra);
|
|
13055
|
+
room = new Room$1(callSession, extension, null, null, extra);
|
|
12961
13056
|
|
|
12962
13057
|
// Wait for the call to be accepted
|
|
12963
13058
|
await new Promise((resolve, reject) => {
|
|
@@ -12978,7 +13073,7 @@ class Room extends Emitter {
|
|
|
12978
13073
|
// Retrieve conference
|
|
12979
13074
|
const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
|
|
12980
13075
|
|
|
12981
|
-
logger.info('connected to room', {
|
|
13076
|
+
logger$c.info('connected to room', {
|
|
12982
13077
|
sourceId: conference ? conference.sourceId : null,
|
|
12983
13078
|
name: conference ? conference.name : null,
|
|
12984
13079
|
});
|
|
@@ -12988,7 +13083,7 @@ class Room extends Emitter {
|
|
|
12988
13083
|
room.setName(conference.name);
|
|
12989
13084
|
}
|
|
12990
13085
|
} else if (meeting) {
|
|
12991
|
-
logger.info('Already connected to meeting', {
|
|
13086
|
+
logger$c.info('Already connected to meeting', {
|
|
12992
13087
|
uuid: meeting.uuid,
|
|
12993
13088
|
name: meeting.name,
|
|
12994
13089
|
});
|
|
@@ -13001,13 +13096,13 @@ class Room extends Emitter {
|
|
|
13001
13096
|
}
|
|
13002
13097
|
|
|
13003
13098
|
static disconnect() {
|
|
13004
|
-
logger.info('static disconnection to room');
|
|
13099
|
+
logger$c.info('static disconnection to room');
|
|
13005
13100
|
|
|
13006
13101
|
Wazo.Phone.disconnect();
|
|
13007
13102
|
}
|
|
13008
13103
|
|
|
13009
13104
|
async disconnect() {
|
|
13010
|
-
logger.info('disconnection to room called');
|
|
13105
|
+
logger$c.info('disconnection to room called');
|
|
13011
13106
|
|
|
13012
13107
|
await Wazo.Phone.hangup(this.callSession);
|
|
13013
13108
|
this.callSession = null;
|
|
@@ -13027,19 +13122,19 @@ class Room extends Emitter {
|
|
|
13027
13122
|
}
|
|
13028
13123
|
|
|
13029
13124
|
setSourceId(sourceId ) {
|
|
13030
|
-
logger.info('set room source id', { sourceId });
|
|
13125
|
+
logger$c.info('set room source id', { sourceId });
|
|
13031
13126
|
|
|
13032
13127
|
this.sourceId = sourceId;
|
|
13033
13128
|
}
|
|
13034
13129
|
|
|
13035
13130
|
setMeetingUuid(meetingUuid ) {
|
|
13036
|
-
logger.info('set meeting uuid', { meetingUuid });
|
|
13131
|
+
logger$c.info('set meeting uuid', { meetingUuid });
|
|
13037
13132
|
|
|
13038
13133
|
this.meetingUuid = meetingUuid;
|
|
13039
13134
|
}
|
|
13040
13135
|
|
|
13041
13136
|
setCallId(callId ) {
|
|
13042
|
-
logger.info('set room call id', { callId });
|
|
13137
|
+
logger$c.info('set room call id', { callId });
|
|
13043
13138
|
|
|
13044
13139
|
if (callId) {
|
|
13045
13140
|
this.callId = callId;
|
|
@@ -13047,7 +13142,7 @@ class Room extends Emitter {
|
|
|
13047
13142
|
}
|
|
13048
13143
|
|
|
13049
13144
|
setName(name ) {
|
|
13050
|
-
logger.info('set room name', { name });
|
|
13145
|
+
logger$c.info('set room name', { name });
|
|
13051
13146
|
|
|
13052
13147
|
this.name = name;
|
|
13053
13148
|
}
|
|
@@ -13066,7 +13161,7 @@ class Room extends Emitter {
|
|
|
13066
13161
|
}
|
|
13067
13162
|
|
|
13068
13163
|
async startScreenSharing(constraints ) {
|
|
13069
|
-
logger.info('start room screen sharing', { constraints });
|
|
13164
|
+
logger$c.info('start room screen sharing', { constraints });
|
|
13070
13165
|
|
|
13071
13166
|
const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
|
|
13072
13167
|
if (!screensharingStream) {
|
|
@@ -13080,7 +13175,7 @@ class Room extends Emitter {
|
|
|
13080
13175
|
}
|
|
13081
13176
|
|
|
13082
13177
|
async stopScreenSharing(restoreLocalStream = true) {
|
|
13083
|
-
logger.info('stop room screen sharing');
|
|
13178
|
+
logger$c.info('stop room screen sharing');
|
|
13084
13179
|
|
|
13085
13180
|
await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
13086
13181
|
|
|
@@ -13092,7 +13187,7 @@ class Room extends Emitter {
|
|
|
13092
13187
|
}
|
|
13093
13188
|
|
|
13094
13189
|
turnCameraOff() {
|
|
13095
|
-
logger.info('turn room camera off');
|
|
13190
|
+
logger$c.info('turn room camera off');
|
|
13096
13191
|
|
|
13097
13192
|
Wazo.Phone.turnCameraOff(this.callSession);
|
|
13098
13193
|
|
|
@@ -13102,7 +13197,7 @@ class Room extends Emitter {
|
|
|
13102
13197
|
}
|
|
13103
13198
|
|
|
13104
13199
|
turnCameraOn() {
|
|
13105
|
-
logger.info('turn room camera on');
|
|
13200
|
+
logger$c.info('turn room camera on');
|
|
13106
13201
|
|
|
13107
13202
|
Wazo.Phone.turnCameraOn(this.callSession);
|
|
13108
13203
|
|
|
@@ -13112,7 +13207,7 @@ class Room extends Emitter {
|
|
|
13112
13207
|
}
|
|
13113
13208
|
|
|
13114
13209
|
mute() {
|
|
13115
|
-
logger.info('mute room');
|
|
13210
|
+
logger$c.info('mute room');
|
|
13116
13211
|
|
|
13117
13212
|
Wazo.Phone.mute(this.callSession);
|
|
13118
13213
|
|
|
@@ -13120,7 +13215,7 @@ class Room extends Emitter {
|
|
|
13120
13215
|
}
|
|
13121
13216
|
|
|
13122
13217
|
unmute() {
|
|
13123
|
-
logger.info('unmute room');
|
|
13218
|
+
logger$c.info('unmute room');
|
|
13124
13219
|
|
|
13125
13220
|
Wazo.Phone.unmute(this.callSession);
|
|
13126
13221
|
|
|
@@ -13140,7 +13235,7 @@ class Room extends Emitter {
|
|
|
13140
13235
|
}
|
|
13141
13236
|
|
|
13142
13237
|
hold() {
|
|
13143
|
-
logger.info('hold room');
|
|
13238
|
+
logger$c.info('hold room');
|
|
13144
13239
|
|
|
13145
13240
|
Wazo.Phone.hold(this.callSession, true);
|
|
13146
13241
|
|
|
@@ -13150,7 +13245,7 @@ class Room extends Emitter {
|
|
|
13150
13245
|
}
|
|
13151
13246
|
|
|
13152
13247
|
async resume() {
|
|
13153
|
-
logger.info('resume room');
|
|
13248
|
+
logger$c.info('resume room');
|
|
13154
13249
|
|
|
13155
13250
|
const newStream = await Wazo.Phone.resume(this.callSession, true);
|
|
13156
13251
|
|
|
@@ -13178,13 +13273,13 @@ class Room extends Emitter {
|
|
|
13178
13273
|
}
|
|
13179
13274
|
|
|
13180
13275
|
sendDTMF(tone ) {
|
|
13181
|
-
logger.info('send room DTMF', { tone });
|
|
13276
|
+
logger$c.info('send room DTMF', { tone });
|
|
13182
13277
|
|
|
13183
13278
|
Wazo.Phone.sendDTMF(tone, this.callSession);
|
|
13184
13279
|
}
|
|
13185
13280
|
|
|
13186
13281
|
async sendReinvite(newConstraints = null) {
|
|
13187
|
-
logger.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
13282
|
+
logger$c.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
13188
13283
|
const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
|
|
13189
13284
|
|
|
13190
13285
|
Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
|
|
@@ -13243,7 +13338,7 @@ class Room extends Emitter {
|
|
|
13243
13338
|
Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
13244
13339
|
|
|
13245
13340
|
this.on(this.ON_AUDIO_STREAM, stream => {
|
|
13246
|
-
logger.info('on room audio stream');
|
|
13341
|
+
logger$c.info('on room audio stream');
|
|
13247
13342
|
|
|
13248
13343
|
this.audioStream = stream;
|
|
13249
13344
|
if (!this.roomAudioElement) {
|
|
@@ -13256,7 +13351,7 @@ class Room extends Emitter {
|
|
|
13256
13351
|
});
|
|
13257
13352
|
|
|
13258
13353
|
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
13259
|
-
logger.info('on room video stream', { streamId });
|
|
13354
|
+
logger$c.info('on room video stream', { streamId });
|
|
13260
13355
|
|
|
13261
13356
|
this._mapMsid(sipSession.body.body);
|
|
13262
13357
|
|
|
@@ -13271,7 +13366,7 @@ class Room extends Emitter {
|
|
|
13271
13366
|
});
|
|
13272
13367
|
|
|
13273
13368
|
this.on(this.ON_REMOVE_STREAM, stream => {
|
|
13274
|
-
logger.info('on room remove stream');
|
|
13369
|
+
logger$c.info('on room remove stream');
|
|
13275
13370
|
|
|
13276
13371
|
const participant = this.participants.find(someParticipant =>
|
|
13277
13372
|
someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
|
|
@@ -13403,7 +13498,7 @@ class Room extends Emitter {
|
|
|
13403
13498
|
const requester = this._getParticipantFromCallId(origin.callId);
|
|
13404
13499
|
if (requester) {
|
|
13405
13500
|
// @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
|
|
13406
|
-
logger.info('trigger room requester status', { origin });
|
|
13501
|
+
logger$c.info('trigger room requester status', { origin });
|
|
13407
13502
|
requester.triggerUpdate('REQUESTER_UPDATE');
|
|
13408
13503
|
}
|
|
13409
13504
|
break;
|
|
@@ -13434,24 +13529,24 @@ class Room extends Emitter {
|
|
|
13434
13529
|
|
|
13435
13530
|
// When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
|
|
13436
13531
|
if (participant.user_uuid === session.uuid) {
|
|
13437
|
-
logger.info('room current user joined');
|
|
13532
|
+
logger$c.info('room current user joined');
|
|
13438
13533
|
|
|
13439
13534
|
// Retrieve participants via an API calls
|
|
13440
13535
|
const conferenceId = this.sourceId || payload.data.conference_id;
|
|
13441
13536
|
let response;
|
|
13442
13537
|
try {
|
|
13443
13538
|
if (this.meetingUuid) {
|
|
13444
|
-
logger.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
13539
|
+
logger$c.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
13445
13540
|
response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
|
|
13446
13541
|
} else {
|
|
13447
|
-
logger.info('fetching conference participants', { conferenceId });
|
|
13542
|
+
logger$c.info('fetching conference participants', { conferenceId });
|
|
13448
13543
|
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
13449
13544
|
}
|
|
13450
13545
|
} catch (e) {
|
|
13451
|
-
logger.error('room participants fetching, error', e);
|
|
13546
|
+
logger$c.error('room participants fetching, error', e);
|
|
13452
13547
|
}
|
|
13453
13548
|
if (response) {
|
|
13454
|
-
logger.info('conference participants fetched', { nb: response.items.length });
|
|
13549
|
+
logger$c.info('conference participants fetched', { nb: response.items.length });
|
|
13455
13550
|
participants = response.items.map(item => {
|
|
13456
13551
|
const isMe = item.call_id === this.callId;
|
|
13457
13552
|
|
|
@@ -13478,7 +13573,7 @@ class Room extends Emitter {
|
|
|
13478
13573
|
? new Wazo.RemoteParticipant(this, participant)
|
|
13479
13574
|
: null;
|
|
13480
13575
|
|
|
13481
|
-
logger.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
13576
|
+
logger$c.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
13482
13577
|
|
|
13483
13578
|
if (remoteParticipant) {
|
|
13484
13579
|
this.participants.push(remoteParticipant);
|
|
@@ -13643,4 +13738,4 @@ class Room extends Emitter {
|
|
|
13643
13738
|
|
|
13644
13739
|
exports.SIGNAL_TYPE_PARTICIPANT_REQUEST = SIGNAL_TYPE_PARTICIPANT_REQUEST;
|
|
13645
13740
|
exports.SIGNAL_TYPE_PARTICIPANT_UPDATE = SIGNAL_TYPE_PARTICIPANT_UPDATE;
|
|
13646
|
-
exports.default = Room;
|
|
13741
|
+
exports.default = Room$1;
|