@wazo/sdk 0.37.20 → 0.37.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/api-client.test.js +91 -21
- package/esm/__tests__/web-rtc-client.test.js +214 -165
- package/esm/api/agentd.js +25 -2
- package/esm/api/amid.js +26 -3
- package/esm/api/application.js +25 -2
- package/esm/api/auth.js +25 -2
- package/esm/api/call-logd.js +34 -4
- package/esm/api/calld.js +35 -2
- package/esm/api/chatd.js +32 -2
- package/esm/api/confd.js +56 -9
- package/esm/api/ctid-ng.js +38 -5
- package/esm/api/dird.js +29 -3
- package/esm/api/webhookd.js +26 -3
- package/esm/api-client.js +91 -21
- package/esm/checker/Checker.js +241 -190
- package/esm/checker/checks/aor.js +91 -21
- package/esm/checker/checks/api.js +91 -21
- package/esm/checker/checks/index.js +231 -180
- package/esm/checker/checks/wazo-websocket.js +42 -17
- package/esm/checker/checks/webrtc-transport.js +214 -165
- package/esm/checker/checks/webrtc.js +214 -165
- package/esm/domain/AdHocAPIConference.js +91 -21
- package/esm/domain/Call.js +3 -0
- package/esm/domain/CallLog.js +8 -1
- package/esm/domain/ChatMessage.js +4 -0
- package/esm/domain/ChatRoom.js +3 -0
- package/esm/domain/Contact.js +4 -1
- package/esm/domain/Features.js +91 -21
- package/esm/domain/Meeting.js +28 -5
- package/esm/domain/Phone/CTIPhone.js +109 -35
- package/esm/domain/Phone/WebRTCPhone.js +159 -102
- package/esm/domain/Recording.js +3 -0
- package/esm/domain/Voicemail.js +3 -0
- package/esm/domain/__tests__/Call.test.js +3 -0
- package/esm/domain/__tests__/CallLog.test.js +8 -1
- package/esm/domain/__tests__/Contact.test.js +4 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +509 -414
- package/esm/lib/WazoSessionDescriptionHandler.js +26 -41
- package/esm/service/CallApi.js +91 -21
- package/esm/service/IssueReporter.js +26 -3
- package/esm/service/__tests__/IssueReporter.test.js +26 -3
- package/esm/service/getApiClient.js +91 -21
- package/esm/simple/Auth.js +499 -404
- package/esm/simple/Configuration.js +499 -404
- package/esm/simple/Directory.js +91 -21
- package/esm/simple/Phone.js +499 -404
- package/esm/simple/Websocket.js +45 -19
- package/esm/simple/index.js +503 -408
- package/esm/simple/room/LocalParticipant.js +503 -408
- package/esm/simple/room/Participant.js +503 -408
- package/esm/simple/room/RemoteParticipant.js +503 -408
- package/esm/simple/room/Room.js +504 -409
- package/esm/simple/room/SipRoom.js +503 -408
- package/esm/simple/room/Stream.js +503 -408
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/esm/simple/utils.js +503 -408
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/utils/__tests__/api-requester.test.js +25 -2
- package/esm/utils/api-requester.js +25 -2
- package/esm/web-rtc-client.js +214 -165
- package/esm/websocket-client.js +43 -18
- package/lib/__tests__/api-client.test.js +91 -21
- package/lib/__tests__/web-rtc-client.test.js +214 -165
- package/lib/api/agentd.js +25 -2
- package/lib/api/amid.js +26 -3
- package/lib/api/application.js +25 -2
- package/lib/api/auth.js +25 -2
- package/lib/api/call-logd.js +34 -4
- package/lib/api/calld.js +35 -2
- package/lib/api/chatd.js +32 -2
- package/lib/api/confd.js +56 -9
- package/lib/api/ctid-ng.js +38 -5
- package/lib/api/dird.js +29 -3
- package/lib/api/webhookd.js +26 -3
- package/lib/api-client.js +91 -21
- package/lib/checker/Checker.js +241 -190
- package/lib/checker/checks/aor.js +91 -21
- package/lib/checker/checks/api.js +91 -21
- package/lib/checker/checks/index.js +231 -180
- package/lib/checker/checks/wazo-websocket.js +42 -17
- package/lib/checker/checks/webrtc-transport.js +214 -165
- package/lib/checker/checks/webrtc.js +214 -165
- package/lib/domain/AdHocAPIConference.js +91 -21
- package/lib/domain/Call.js +3 -0
- package/lib/domain/CallLog.js +8 -1
- package/lib/domain/ChatMessage.js +4 -0
- package/lib/domain/ChatRoom.js +3 -0
- package/lib/domain/Contact.js +4 -1
- package/lib/domain/Features.js +91 -21
- package/lib/domain/Meeting.js +32 -5
- package/lib/domain/Phone/CTIPhone.js +109 -35
- package/lib/domain/Phone/WebRTCPhone.js +159 -102
- package/lib/domain/Recording.js +3 -0
- package/lib/domain/Voicemail.js +3 -0
- package/lib/domain/__tests__/Call.test.js +3 -0
- package/lib/domain/__tests__/CallLog.test.js +8 -1
- package/lib/domain/__tests__/Contact.test.js +4 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +509 -414
- package/lib/lib/WazoSessionDescriptionHandler.js +26 -41
- package/lib/service/CallApi.js +91 -21
- package/lib/service/IssueReporter.js +26 -3
- package/lib/service/__tests__/IssueReporter.test.js +26 -3
- package/lib/service/getApiClient.js +91 -21
- package/lib/simple/Auth.js +499 -404
- package/lib/simple/Configuration.js +499 -404
- package/lib/simple/Directory.js +91 -21
- package/lib/simple/Phone.js +499 -404
- package/lib/simple/Websocket.js +45 -19
- package/lib/simple/index.js +503 -408
- package/lib/simple/room/LocalParticipant.js +503 -408
- package/lib/simple/room/Participant.js +503 -408
- package/lib/simple/room/RemoteParticipant.js +503 -408
- package/lib/simple/room/Room.js +504 -409
- package/lib/simple/room/SipRoom.js +503 -408
- package/lib/simple/room/Stream.js +503 -408
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/lib/simple/utils.js +503 -408
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/utils/__tests__/api-requester.test.js +25 -2
- package/lib/utils/api-requester.js +25 -2
- package/lib/web-rtc-client.js +214 -165
- package/lib/websocket-client.js +43 -17
- package/package.json +1 -1
- package/src/api/confd.js +5 -2
- package/src/domain/Call.js +3 -0
- package/src/domain/CallLog.js +4 -0
- package/src/domain/ChatMessage.js +4 -0
- package/src/domain/ChatRoom.js +3 -0
- package/src/domain/Contact.js +3 -0
- package/src/domain/Meeting.js +28 -5
- package/src/domain/Phone/CTIPhone.js +4 -0
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +49 -15
- package/src/domain/Recording.js +3 -0
- package/src/domain/Voicemail.js +3 -0
- package/src/domain/__tests__/Meeting.test.js +50 -0
- package/src/lib/WazoSessionDescriptionHandler.js +1 -35
- package/src/service/IssueReporter.js +25 -2
- package/src/simple/Phone.js +5 -0
- package/src/types/WebSocketMessage.js +5 -1
- package/src/web-rtc-client.js +41 -24
- package/src/websocket-client.js +2 -0
package/esm/simple/Phone.js
CHANGED
|
@@ -95,6 +95,9 @@ class Call {
|
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
static parseMany(plain ) {
|
|
98
|
+
if (!plain) {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
98
101
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
99
102
|
}
|
|
100
103
|
|
|
@@ -711,6 +714,7 @@ class IssueReporter {
|
|
|
711
714
|
|
|
712
715
|
|
|
713
716
|
|
|
717
|
+
|
|
714
718
|
|
|
715
719
|
constructor() {
|
|
716
720
|
addLevelsTo(this);
|
|
@@ -722,12 +726,17 @@ class IssueReporter {
|
|
|
722
726
|
this.bufferTimeout = null;
|
|
723
727
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
724
728
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
729
|
+
this._callback = null;
|
|
725
730
|
}
|
|
726
731
|
|
|
727
732
|
init() {
|
|
728
733
|
this._catchConsole();
|
|
729
734
|
}
|
|
730
735
|
|
|
736
|
+
setCallback(cb ) {
|
|
737
|
+
this._callback = cb;
|
|
738
|
+
}
|
|
739
|
+
|
|
731
740
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
732
741
|
this.remoteClientConfiguration = configuration;
|
|
733
742
|
}
|
|
@@ -763,6 +772,7 @@ class IssueReporter {
|
|
|
763
772
|
|
|
764
773
|
// Handle category label
|
|
765
774
|
let category = null;
|
|
775
|
+
let skipSendToRemote = false;
|
|
766
776
|
let extra = {};
|
|
767
777
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
768
778
|
category = args[0].split('=')[1];
|
|
@@ -778,6 +788,7 @@ class IssueReporter {
|
|
|
778
788
|
errorMessage: lastArg.message,
|
|
779
789
|
errorStack: lastArg.stack,
|
|
780
790
|
errorType: lastArg.constructor.name,
|
|
791
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
781
792
|
};
|
|
782
793
|
} else {
|
|
783
794
|
extra = lastArg;
|
|
@@ -786,6 +797,11 @@ class IssueReporter {
|
|
|
786
797
|
args.splice(1, 1);
|
|
787
798
|
}
|
|
788
799
|
|
|
800
|
+
if (extra.skipSendToRemote) {
|
|
801
|
+
skipSendToRemote = true;
|
|
802
|
+
delete extra.skipSendToRemote;
|
|
803
|
+
}
|
|
804
|
+
|
|
789
805
|
const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
790
806
|
const message = args.join(', ');
|
|
791
807
|
let consoleMessage = message;
|
|
@@ -806,7 +822,13 @@ class IssueReporter {
|
|
|
806
822
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
807
823
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
808
824
|
|
|
809
|
-
this.
|
|
825
|
+
if (this._callback) {
|
|
826
|
+
this._callback(level, consoleMessage);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
if (!skipSendToRemote) {
|
|
830
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
831
|
+
}
|
|
810
832
|
}
|
|
811
833
|
|
|
812
834
|
logRequest(url , options , response , start ) {
|
|
@@ -951,7 +973,11 @@ class IssueReporter {
|
|
|
951
973
|
},
|
|
952
974
|
// $FlowFixMe
|
|
953
975
|
body,
|
|
954
|
-
}).catch(() => {
|
|
976
|
+
}).catch((e ) => {
|
|
977
|
+
// $FlowFixMe
|
|
978
|
+
e.skipSendToRemote = true;
|
|
979
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
980
|
+
|
|
955
981
|
setTimeout(() => {
|
|
956
982
|
if (isArray) {
|
|
957
983
|
payload = payload.map(message => {
|
|
@@ -998,7 +1024,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
998
1024
|
|
|
999
1025
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
1000
1026
|
|
|
1001
|
-
const logger
|
|
1027
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
1002
1028
|
|
|
1003
1029
|
// Use a function here to be able to mock it in tests
|
|
1004
1030
|
const realFetch = () => {
|
|
@@ -1137,7 +1163,7 @@ class ApiRequester {
|
|
|
1137
1163
|
};
|
|
1138
1164
|
|
|
1139
1165
|
if (this.refreshTokenPromise) {
|
|
1140
|
-
logger
|
|
1166
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
1141
1167
|
await this.refreshTokenPromise;
|
|
1142
1168
|
}
|
|
1143
1169
|
|
|
@@ -1157,7 +1183,7 @@ class ApiRequester {
|
|
|
1157
1183
|
return promise.then(async (err ) => {
|
|
1158
1184
|
// Check if the token is still valid
|
|
1159
1185
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
1160
|
-
logger
|
|
1186
|
+
logger.warn('token expired', { error: err.reason });
|
|
1161
1187
|
// Replay the call after refreshing the token
|
|
1162
1188
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
1163
1189
|
}
|
|
@@ -1167,7 +1193,7 @@ class ApiRequester {
|
|
|
1167
1193
|
: exceptionClass.fromResponse(err, response.status);
|
|
1168
1194
|
|
|
1169
1195
|
if (this.shouldLogErrors) {
|
|
1170
|
-
logger
|
|
1196
|
+
logger.error('API error', error);
|
|
1171
1197
|
}
|
|
1172
1198
|
|
|
1173
1199
|
throw error;
|
|
@@ -1177,7 +1203,7 @@ class ApiRequester {
|
|
|
1177
1203
|
return newParse(response, isJson);
|
|
1178
1204
|
}).catch(error => {
|
|
1179
1205
|
if (this.shouldLogErrors) {
|
|
1180
|
-
logger
|
|
1206
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
1181
1207
|
}
|
|
1182
1208
|
|
|
1183
1209
|
throw error;
|
|
@@ -1205,13 +1231,13 @@ class ApiRequester {
|
|
|
1205
1231
|
) {
|
|
1206
1232
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
1207
1233
|
let newPath = path;
|
|
1208
|
-
logger
|
|
1234
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
1209
1235
|
|
|
1210
1236
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
1211
1237
|
|
|
1212
1238
|
return this.refreshTokenPromise.then(() => {
|
|
1213
1239
|
this.refreshTokenPromise = null;
|
|
1214
|
-
logger
|
|
1240
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
1215
1241
|
if (isTokenNotFound) {
|
|
1216
1242
|
const pathParts = path.split('/');
|
|
1217
1243
|
pathParts.pop();
|
|
@@ -2078,6 +2104,9 @@ class Contact {
|
|
|
2078
2104
|
}
|
|
2079
2105
|
|
|
2080
2106
|
static parseMany(response ) {
|
|
2107
|
+
if (!response || !response.results) {
|
|
2108
|
+
return [];
|
|
2109
|
+
}
|
|
2081
2110
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
2082
2111
|
}
|
|
2083
2112
|
|
|
@@ -3155,8 +3184,9 @@ class ExternalApp {
|
|
|
3155
3184
|
|
|
3156
3185
|
|
|
3157
3186
|
|
|
3158
|
-
|
|
3187
|
+
|
|
3159
3188
|
|
|
3189
|
+
|
|
3160
3190
|
|
|
3161
3191
|
|
|
3162
3192
|
class Meeting {
|
|
@@ -3167,9 +3197,10 @@ class Meeting {
|
|
|
3167
3197
|
|
|
3168
3198
|
|
|
3169
3199
|
|
|
3170
|
-
|
|
3200
|
+
|
|
3171
3201
|
|
|
3172
3202
|
|
|
3203
|
+
|
|
3173
3204
|
|
|
3174
3205
|
static parse(plain ) {
|
|
3175
3206
|
return new Meeting({
|
|
@@ -3179,24 +3210,43 @@ class Meeting {
|
|
|
3179
3210
|
ownerUuids: plain.owner_uuids,
|
|
3180
3211
|
port: plain.port,
|
|
3181
3212
|
uuid: plain.uuid,
|
|
3182
|
-
|
|
3213
|
+
extension: plain.exten,
|
|
3183
3214
|
persistent: plain.persistent,
|
|
3215
|
+
creationTime: moment(plain.creation_time).toDate(),
|
|
3184
3216
|
});
|
|
3185
3217
|
}
|
|
3186
3218
|
|
|
3219
|
+
static parseMany(items ) {
|
|
3220
|
+
if (!items) {
|
|
3221
|
+
return [];
|
|
3222
|
+
}
|
|
3223
|
+
return items.map(plain => Meeting.parse(plain));
|
|
3224
|
+
}
|
|
3225
|
+
|
|
3187
3226
|
static newFrom(meeting ) {
|
|
3188
3227
|
return newFrom(meeting, Meeting);
|
|
3189
3228
|
}
|
|
3190
3229
|
|
|
3191
|
-
constructor({
|
|
3230
|
+
constructor({
|
|
3231
|
+
uuid,
|
|
3232
|
+
name,
|
|
3233
|
+
guestSipAuthorization,
|
|
3234
|
+
ownerUuids,
|
|
3235
|
+
port,
|
|
3236
|
+
uri,
|
|
3237
|
+
extension,
|
|
3238
|
+
persistent,
|
|
3239
|
+
creationTime,
|
|
3240
|
+
} = {}) {
|
|
3192
3241
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
3193
3242
|
this.uri = uri;
|
|
3194
3243
|
this.name = name;
|
|
3195
3244
|
this.ownerUuids = ownerUuids;
|
|
3196
3245
|
this.port = port;
|
|
3197
3246
|
this.uuid = uuid;
|
|
3198
|
-
this.
|
|
3247
|
+
this.extension = extension;
|
|
3199
3248
|
this.persistent = persistent;
|
|
3249
|
+
this.creationTime = creationTime;
|
|
3200
3250
|
|
|
3201
3251
|
// Useful to compare instead of instanceof with minified code
|
|
3202
3252
|
this.type = 'Meeting';
|
|
@@ -3274,8 +3324,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3274
3324
|
}
|
|
3275
3325
|
},
|
|
3276
3326
|
|
|
3277
|
-
|
|
3278
|
-
client.
|
|
3327
|
+
getMyMeetings: () =>
|
|
3328
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
3329
|
+
|
|
3330
|
+
createMyMeeting: (name , persistent ) =>
|
|
3331
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
3279
3332
|
|
|
3280
3333
|
deleteMyMeeting: (meetingUuid ) =>
|
|
3281
3334
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -3371,6 +3424,10 @@ class ChatMessage {
|
|
|
3371
3424
|
|
|
3372
3425
|
|
|
3373
3426
|
static parseMany(plain ) {
|
|
3427
|
+
if (!plain || !plain.items) {
|
|
3428
|
+
return [];
|
|
3429
|
+
}
|
|
3430
|
+
|
|
3374
3431
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
3375
3432
|
}
|
|
3376
3433
|
|
|
@@ -3480,6 +3537,9 @@ class Voicemail {
|
|
|
3480
3537
|
}
|
|
3481
3538
|
|
|
3482
3539
|
static parseMany(plain ) {
|
|
3540
|
+
if (!plain) {
|
|
3541
|
+
return [];
|
|
3542
|
+
}
|
|
3483
3543
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
3484
3544
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
3485
3545
|
|
|
@@ -3581,6 +3641,9 @@ class Recording {
|
|
|
3581
3641
|
|
|
3582
3642
|
|
|
3583
3643
|
static parseMany(recordings = []) {
|
|
3644
|
+
if (!recordings) {
|
|
3645
|
+
return [];
|
|
3646
|
+
}
|
|
3584
3647
|
return recordings.map(item => Recording.parse(item));
|
|
3585
3648
|
}
|
|
3586
3649
|
|
|
@@ -3682,6 +3745,10 @@ class CallLog {
|
|
|
3682
3745
|
}
|
|
3683
3746
|
|
|
3684
3747
|
static parseMany(plain ) {
|
|
3748
|
+
if (!plain || !plain.items) {
|
|
3749
|
+
return [];
|
|
3750
|
+
}
|
|
3751
|
+
|
|
3685
3752
|
return plain.items.map(item => CallLog.parse(item));
|
|
3686
3753
|
}
|
|
3687
3754
|
|
|
@@ -3986,7 +4053,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3986
4053
|
|
|
3987
4054
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3988
4055
|
|
|
3989
|
-
const logger$
|
|
4056
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3990
4057
|
|
|
3991
4058
|
class CTIPhone extends Emitter {
|
|
3992
4059
|
|
|
@@ -3999,7 +4066,7 @@ class CTIPhone extends Emitter {
|
|
|
3999
4066
|
|
|
4000
4067
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
4001
4068
|
super();
|
|
4002
|
-
logger$
|
|
4069
|
+
logger$1.info('CTI Phone created');
|
|
4003
4070
|
this.session = session;
|
|
4004
4071
|
this.isMobile = isMobile;
|
|
4005
4072
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -4060,7 +4127,7 @@ class CTIPhone extends Emitter {
|
|
|
4060
4127
|
}
|
|
4061
4128
|
|
|
4062
4129
|
async makeCall(number , line ) {
|
|
4063
|
-
logger$
|
|
4130
|
+
logger$1.info('make CTI call', { number });
|
|
4064
4131
|
|
|
4065
4132
|
if (!number) {
|
|
4066
4133
|
return null;
|
|
@@ -4083,7 +4150,7 @@ class CTIPhone extends Emitter {
|
|
|
4083
4150
|
if (!callSession) {
|
|
4084
4151
|
return Promise.resolve(null);
|
|
4085
4152
|
}
|
|
4086
|
-
logger$
|
|
4153
|
+
logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4087
4154
|
|
|
4088
4155
|
if (!this.currentCall) {
|
|
4089
4156
|
this.currentCall = callSession.call;
|
|
@@ -4096,7 +4163,7 @@ class CTIPhone extends Emitter {
|
|
|
4096
4163
|
if (!callSession) {
|
|
4097
4164
|
return;
|
|
4098
4165
|
}
|
|
4099
|
-
logger$
|
|
4166
|
+
logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4100
4167
|
|
|
4101
4168
|
this.currentCall = undefined;
|
|
4102
4169
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4106,7 +4173,7 @@ class CTIPhone extends Emitter {
|
|
|
4106
4173
|
if (!callSession) {
|
|
4107
4174
|
return Promise.resolve(false);
|
|
4108
4175
|
}
|
|
4109
|
-
logger$
|
|
4176
|
+
logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4110
4177
|
|
|
4111
4178
|
try {
|
|
4112
4179
|
await CallApi.cancelCall(callSession);
|
|
@@ -4117,7 +4184,7 @@ class CTIPhone extends Emitter {
|
|
|
4117
4184
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
4118
4185
|
return true;
|
|
4119
4186
|
} catch (e) {
|
|
4120
|
-
logger$
|
|
4187
|
+
logger$1.error('hangup CTI call, error', e);
|
|
4121
4188
|
|
|
4122
4189
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
4123
4190
|
return false;
|
|
@@ -4130,7 +4197,7 @@ class CTIPhone extends Emitter {
|
|
|
4130
4197
|
if (!callSession) {
|
|
4131
4198
|
return;
|
|
4132
4199
|
}
|
|
4133
|
-
logger$
|
|
4200
|
+
logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4134
4201
|
|
|
4135
4202
|
await CallApi.cancelCall(callSession);
|
|
4136
4203
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4140,7 +4207,7 @@ class CTIPhone extends Emitter {
|
|
|
4140
4207
|
if (!callSession) {
|
|
4141
4208
|
return;
|
|
4142
4209
|
}
|
|
4143
|
-
logger$
|
|
4210
|
+
logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4144
4211
|
|
|
4145
4212
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
4146
4213
|
}
|
|
@@ -4153,19 +4220,19 @@ class CTIPhone extends Emitter {
|
|
|
4153
4220
|
if (!callSession) {
|
|
4154
4221
|
return;
|
|
4155
4222
|
}
|
|
4156
|
-
logger$
|
|
4223
|
+
logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4157
4224
|
|
|
4158
4225
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
4159
4226
|
}
|
|
4160
4227
|
|
|
4161
4228
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
4162
|
-
logger$
|
|
4229
|
+
logger$1.info('cancel CTI transfer', { transferId });
|
|
4163
4230
|
|
|
4164
4231
|
return CallApi.cancelCallTransfer(transferId);
|
|
4165
4232
|
}
|
|
4166
4233
|
|
|
4167
4234
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
4168
|
-
logger$
|
|
4235
|
+
logger$1.info('confirm CTI transfer', { transferId });
|
|
4169
4236
|
|
|
4170
4237
|
return CallApi.confirmCallTransfer(transferId);
|
|
4171
4238
|
}
|
|
@@ -4174,19 +4241,19 @@ class CTIPhone extends Emitter {
|
|
|
4174
4241
|
if (!callSession) {
|
|
4175
4242
|
return;
|
|
4176
4243
|
}
|
|
4177
|
-
logger$
|
|
4244
|
+
logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4178
4245
|
|
|
4179
4246
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4180
4247
|
}
|
|
4181
4248
|
|
|
4182
4249
|
onConnectionMade() {
|
|
4183
|
-
logger$
|
|
4250
|
+
logger$1.info('on CTI connection made');
|
|
4184
4251
|
|
|
4185
4252
|
this.eventEmitter.emit('onCallAccepted');
|
|
4186
4253
|
}
|
|
4187
4254
|
|
|
4188
4255
|
async close() {
|
|
4189
|
-
logger$
|
|
4256
|
+
logger$1.info('CTI close');
|
|
4190
4257
|
|
|
4191
4258
|
return Promise.resolve();
|
|
4192
4259
|
}
|
|
@@ -4195,7 +4262,7 @@ class CTIPhone extends Emitter {
|
|
|
4195
4262
|
if (!callSession) {
|
|
4196
4263
|
return;
|
|
4197
4264
|
}
|
|
4198
|
-
logger$
|
|
4265
|
+
logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4199
4266
|
|
|
4200
4267
|
return CallApi.hold(callSession.callId);
|
|
4201
4268
|
}
|
|
@@ -4204,7 +4271,7 @@ class CTIPhone extends Emitter {
|
|
|
4204
4271
|
if (!callSession) {
|
|
4205
4272
|
return;
|
|
4206
4273
|
}
|
|
4207
|
-
logger$
|
|
4274
|
+
logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4208
4275
|
|
|
4209
4276
|
return CallApi.resume(callSession.callId);
|
|
4210
4277
|
}
|
|
@@ -4213,7 +4280,7 @@ class CTIPhone extends Emitter {
|
|
|
4213
4280
|
if (!callSession) {
|
|
4214
4281
|
return;
|
|
4215
4282
|
}
|
|
4216
|
-
logger$
|
|
4283
|
+
logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4217
4284
|
|
|
4218
4285
|
return CallApi.mute(callSession.callId);
|
|
4219
4286
|
}
|
|
@@ -4222,7 +4289,7 @@ class CTIPhone extends Emitter {
|
|
|
4222
4289
|
if (!callSession) {
|
|
4223
4290
|
return;
|
|
4224
4291
|
}
|
|
4225
|
-
logger$
|
|
4292
|
+
logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4226
4293
|
|
|
4227
4294
|
return CallApi.unmute(callSession.callId);
|
|
4228
4295
|
}
|
|
@@ -4251,6 +4318,10 @@ class CTIPhone extends Emitter {
|
|
|
4251
4318
|
return false;
|
|
4252
4319
|
}
|
|
4253
4320
|
|
|
4321
|
+
hasAVideoTrack() {
|
|
4322
|
+
return false;
|
|
4323
|
+
}
|
|
4324
|
+
|
|
4254
4325
|
getLocalStreamForCall() {
|
|
4255
4326
|
return null;
|
|
4256
4327
|
}
|
|
@@ -4644,6 +4715,9 @@ class ChatRoom {
|
|
|
4644
4715
|
|
|
4645
4716
|
|
|
4646
4717
|
static parseMany(plain ) {
|
|
4718
|
+
if (!plain || !plain.items) {
|
|
4719
|
+
return [];
|
|
4720
|
+
}
|
|
4647
4721
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
4648
4722
|
}
|
|
4649
4723
|
|
|
@@ -5224,7 +5298,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5224
5298
|
const WEBHOOKD_VERSION = '1.0';
|
|
5225
5299
|
const AMID_VERSION = '1.0';
|
|
5226
5300
|
|
|
5227
|
-
const logger$
|
|
5301
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5228
5302
|
|
|
5229
5303
|
class ApiClient {
|
|
5230
5304
|
|
|
@@ -5276,12 +5350,12 @@ class ApiClient {
|
|
|
5276
5350
|
}
|
|
5277
5351
|
|
|
5278
5352
|
async forceRefreshToken() {
|
|
5279
|
-
logger$
|
|
5353
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
5280
5354
|
return this.refreshTokenCallback();
|
|
5281
5355
|
}
|
|
5282
5356
|
|
|
5283
5357
|
async refreshTokenCallback() {
|
|
5284
|
-
logger$
|
|
5358
|
+
logger$2.info('refresh token callback called', {
|
|
5285
5359
|
refreshToken: this.refreshToken,
|
|
5286
5360
|
refreshBackend: this.refreshBackend,
|
|
5287
5361
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5299,7 +5373,7 @@ class ApiClient {
|
|
|
5299
5373
|
this.isMobile,
|
|
5300
5374
|
);
|
|
5301
5375
|
|
|
5302
|
-
logger$
|
|
5376
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
5303
5377
|
|
|
5304
5378
|
if (this.onRefreshToken) {
|
|
5305
5379
|
this.onRefreshToken(session.token, session);
|
|
@@ -5612,7 +5686,7 @@ class AdHocAPIConference {
|
|
|
5612
5686
|
|
|
5613
5687
|
/* */
|
|
5614
5688
|
|
|
5615
|
-
const parseCandidate
|
|
5689
|
+
const parseCandidate = (candidate ) => {
|
|
5616
5690
|
if (!candidate) {
|
|
5617
5691
|
return null;
|
|
5618
5692
|
}
|
|
@@ -5625,10 +5699,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
5625
5699
|
candidates
|
|
5626
5700
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
5627
5701
|
|
|
5628
|
-
const areCandidateValid = (candidates ) =>
|
|
5629
|
-
getSrflxOrRelay(candidates)
|
|
5630
|
-
.length > 0;
|
|
5631
|
-
|
|
5632
5702
|
const getVideoDirection = (sdp ) => {
|
|
5633
5703
|
const parsedSdp = sdpParser.parse(sdp);
|
|
5634
5704
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -5681,8 +5751,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
5681
5751
|
/* global RTCSessionDescriptionInit, navigator */
|
|
5682
5752
|
|
|
5683
5753
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
5684
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
5685
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
5686
5754
|
|
|
5687
5755
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
5688
5756
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -5772,7 +5840,7 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5772
5840
|
this.peerConnectionDelegate.onicecandidate = event => {
|
|
5773
5841
|
wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
|
|
5774
5842
|
if (event.candidate) {
|
|
5775
|
-
this.gatheredCandidates.push(parseCandidate
|
|
5843
|
+
this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
|
|
5776
5844
|
}
|
|
5777
5845
|
};
|
|
5778
5846
|
|
|
@@ -5872,38 +5940,6 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5872
5940
|
this._peerConnection = undefined;
|
|
5873
5941
|
}
|
|
5874
5942
|
|
|
5875
|
-
async _waitForValidGatheredIce() {
|
|
5876
|
-
let tries = 0;
|
|
5877
|
-
|
|
5878
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
5879
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
5880
|
-
tries,
|
|
5881
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
5882
|
-
});
|
|
5883
|
-
|
|
5884
|
-
tries++;
|
|
5885
|
-
|
|
5886
|
-
// eslint-disable-next-line no-await-in-loop
|
|
5887
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
5888
|
-
}
|
|
5889
|
-
|
|
5890
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
5891
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
5892
|
-
const error = new Error(errorMsg);
|
|
5893
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
5894
|
-
|
|
5895
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
5896
|
-
this.eventEmitter.emit('error', error);
|
|
5897
|
-
|
|
5898
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5899
|
-
}
|
|
5900
|
-
|
|
5901
|
-
// eslint-disable-next-line
|
|
5902
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5903
|
-
|
|
5904
|
-
return this.getLocalSessionDescription();
|
|
5905
|
-
}
|
|
5906
|
-
|
|
5907
5943
|
// Overridden to send `inactive` in conference
|
|
5908
5944
|
updateDirection(options , isConference = false,
|
|
5909
5945
|
audioOnly = false) {
|
|
@@ -6268,7 +6304,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
6268
6304
|
const SEND_STATS_DELAY = 5000;
|
|
6269
6305
|
|
|
6270
6306
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
6271
|
-
const logger$
|
|
6307
|
+
const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
6272
6308
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
6273
6309
|
|
|
6274
6310
|
// events
|
|
@@ -6282,14 +6318,14 @@ const TRANSPORT_ERROR = 'transportError';
|
|
|
6282
6318
|
const MESSAGE = 'message';
|
|
6283
6319
|
const ACCEPTED = 'accepted';
|
|
6284
6320
|
const REJECTED = 'rejected';
|
|
6285
|
-
const ON_TRACK
|
|
6286
|
-
const ON_REINVITE
|
|
6321
|
+
const ON_TRACK = 'onTrack';
|
|
6322
|
+
const ON_REINVITE = 'reinvite';
|
|
6287
6323
|
const ON_ERROR = 'onError';
|
|
6288
6324
|
const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
|
|
6289
|
-
const ON_NETWORK_STATS
|
|
6290
|
-
const ON_DISCONNECTED
|
|
6325
|
+
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
6326
|
+
const ON_DISCONNECTED = 'onDisconnected';
|
|
6291
6327
|
|
|
6292
|
-
const events
|
|
6328
|
+
const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
6293
6329
|
const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
6294
6330
|
class CanceledCallError extends Error {}
|
|
6295
6331
|
|
|
@@ -6425,12 +6461,12 @@ class WebRTCClient extends Emitter {
|
|
|
6425
6461
|
this.MESSAGE = MESSAGE;
|
|
6426
6462
|
this.ACCEPTED = ACCEPTED;
|
|
6427
6463
|
this.REJECTED = REJECTED;
|
|
6428
|
-
this.ON_TRACK = ON_TRACK
|
|
6429
|
-
this.ON_REINVITE = ON_REINVITE
|
|
6464
|
+
this.ON_TRACK = ON_TRACK;
|
|
6465
|
+
this.ON_REINVITE = ON_REINVITE;
|
|
6430
6466
|
this.ON_ERROR = ON_ERROR;
|
|
6431
6467
|
this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
|
|
6432
|
-
this.ON_NETWORK_STATS = ON_NETWORK_STATS
|
|
6433
|
-
this.ON_DISCONNECTED = ON_DISCONNECTED
|
|
6468
|
+
this.ON_NETWORK_STATS = ON_NETWORK_STATS;
|
|
6469
|
+
this.ON_DISCONNECTED = ON_DISCONNECTED;
|
|
6434
6470
|
}
|
|
6435
6471
|
|
|
6436
6472
|
configureMedia(media ) {
|
|
@@ -6447,13 +6483,13 @@ class WebRTCClient extends Emitter {
|
|
|
6447
6483
|
|
|
6448
6484
|
createUserAgent(configOverrides ) {
|
|
6449
6485
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6450
|
-
logger$
|
|
6486
|
+
logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6451
6487
|
|
|
6452
6488
|
webRTCConfiguration.delegate = {
|
|
6453
6489
|
onConnect: this.onConnect.bind(this),
|
|
6454
6490
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6455
6491
|
onInvite: (invitation ) => {
|
|
6456
|
-
logger$
|
|
6492
|
+
logger$3.info('sdk webrtc on invite', {
|
|
6457
6493
|
method: 'delegate.onInvite',
|
|
6458
6494
|
id: invitation.id,
|
|
6459
6495
|
remoteURI: invitation.remoteURI,
|
|
@@ -6496,7 +6532,7 @@ class WebRTCClient extends Emitter {
|
|
|
6496
6532
|
}
|
|
6497
6533
|
|
|
6498
6534
|
onConnect() {
|
|
6499
|
-
logger$
|
|
6535
|
+
logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6500
6536
|
this.eventEmitter.emit(CONNECTED);
|
|
6501
6537
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6502
6538
|
this.registerer.waitingToggle(false);
|
|
@@ -6505,7 +6541,7 @@ class WebRTCClient extends Emitter {
|
|
|
6505
6541
|
}
|
|
6506
6542
|
|
|
6507
6543
|
async onDisconnect(error ) {
|
|
6508
|
-
logger$
|
|
6544
|
+
logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6509
6545
|
this.connectionPromise = null;
|
|
6510
6546
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6511
6547
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6530,37 +6566,37 @@ class WebRTCClient extends Emitter {
|
|
|
6530
6566
|
};
|
|
6531
6567
|
|
|
6532
6568
|
if (this.skipRegister) {
|
|
6533
|
-
logger$
|
|
6569
|
+
logger$3.info('sdk webrtc skip register...', logInfo);
|
|
6534
6570
|
return Promise.resolve();
|
|
6535
6571
|
}
|
|
6536
6572
|
|
|
6537
|
-
logger$
|
|
6573
|
+
logger$3.info('sdk webrtc registering...', logInfo);
|
|
6538
6574
|
|
|
6539
6575
|
if (!this.userAgent) {
|
|
6540
|
-
logger$
|
|
6576
|
+
logger$3.info('sdk webrtc recreating User Agent');
|
|
6541
6577
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6542
6578
|
}
|
|
6543
6579
|
if (!this.userAgent || this.isRegistered()) {
|
|
6544
|
-
logger$
|
|
6580
|
+
logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6545
6581
|
return Promise.resolve();
|
|
6546
6582
|
}
|
|
6547
6583
|
|
|
6548
6584
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6549
|
-
logger$
|
|
6585
|
+
logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6550
6586
|
return Promise.resolve();
|
|
6551
6587
|
}
|
|
6552
6588
|
|
|
6553
6589
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6554
6590
|
|
|
6555
6591
|
const onRegisterFailed = () => {
|
|
6556
|
-
logger$
|
|
6592
|
+
logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6557
6593
|
this.connectionPromise = null;
|
|
6558
6594
|
if (this.registerer && this.registerer.waiting) {
|
|
6559
6595
|
this.registerer.waitingToggle(false);
|
|
6560
6596
|
}
|
|
6561
6597
|
|
|
6562
6598
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6563
|
-
logger$
|
|
6599
|
+
logger$3.info('sdk webrtc registering, retrying...', { tries });
|
|
6564
6600
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6565
6601
|
}
|
|
6566
6602
|
};
|
|
@@ -6569,18 +6605,18 @@ class WebRTCClient extends Emitter {
|
|
|
6569
6605
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6570
6606
|
// during the resolution of the primise.
|
|
6571
6607
|
if (!this.userAgent) {
|
|
6572
|
-
logger$
|
|
6608
|
+
logger$3.info('sdk webrtc recreating User Agent after connection');
|
|
6573
6609
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6574
6610
|
}
|
|
6575
6611
|
|
|
6576
|
-
logger$
|
|
6612
|
+
logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6577
6613
|
this.registerer = new Registerer(this.userAgent, registerOptions);
|
|
6578
6614
|
this.connectionPromise = null;
|
|
6579
6615
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6580
6616
|
|
|
6581
6617
|
// Bind registerer events
|
|
6582
6618
|
this.registerer.stateChange.addListener(newState => {
|
|
6583
|
-
logger$
|
|
6619
|
+
logger$3.info('sdk webrtc registering, state changed', { newState });
|
|
6584
6620
|
|
|
6585
6621
|
if (newState === RegistererState.Registered && this.registerer
|
|
6586
6622
|
&& this.registerer.state === RegistererState.Registered) {
|
|
@@ -6593,7 +6629,7 @@ class WebRTCClient extends Emitter {
|
|
|
6593
6629
|
const options = {
|
|
6594
6630
|
requestDelegate: {
|
|
6595
6631
|
onReject: response => {
|
|
6596
|
-
logger$
|
|
6632
|
+
logger$3.error('sdk webrtc registering, rejected', { response });
|
|
6597
6633
|
|
|
6598
6634
|
onRegisterFailed();
|
|
6599
6635
|
},
|
|
@@ -6601,13 +6637,13 @@ class WebRTCClient extends Emitter {
|
|
|
6601
6637
|
};
|
|
6602
6638
|
|
|
6603
6639
|
return this.registerer.register(options).catch((e) => {
|
|
6604
|
-
logger$
|
|
6640
|
+
logger$3.error('sdk webrtc registering, error', e);
|
|
6605
6641
|
|
|
6606
6642
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6607
6643
|
return e;
|
|
6608
6644
|
});
|
|
6609
6645
|
}).catch(error => {
|
|
6610
|
-
logger$
|
|
6646
|
+
logger$3.error('sdk webrtc registering, transport error', error);
|
|
6611
6647
|
onRegisterFailed();
|
|
6612
6648
|
});
|
|
6613
6649
|
}
|
|
@@ -6636,21 +6672,21 @@ class WebRTCClient extends Emitter {
|
|
|
6636
6672
|
}
|
|
6637
6673
|
|
|
6638
6674
|
unregister() {
|
|
6639
|
-
logger$
|
|
6675
|
+
logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6640
6676
|
if (!this.registerer) {
|
|
6641
6677
|
return Promise.resolve();
|
|
6642
6678
|
}
|
|
6643
6679
|
|
|
6644
6680
|
try {
|
|
6645
6681
|
return this.registerer.unregister().then(() => {
|
|
6646
|
-
logger$
|
|
6682
|
+
logger$3.info('sdk webrtc unregistered');
|
|
6647
6683
|
this._cleanupRegister();
|
|
6648
6684
|
}).catch(e => {
|
|
6649
|
-
logger$
|
|
6685
|
+
logger$3.error('sdk webrtc unregistering, promise error', e);
|
|
6650
6686
|
this._cleanupRegister();
|
|
6651
6687
|
});
|
|
6652
6688
|
} catch (e) {
|
|
6653
|
-
logger$
|
|
6689
|
+
logger$3.error('sdk webrtc unregistering, error', e);
|
|
6654
6690
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6655
6691
|
// error when the registerer is in a bad state
|
|
6656
6692
|
this._cleanupRegister();
|
|
@@ -6658,7 +6694,7 @@ class WebRTCClient extends Emitter {
|
|
|
6658
6694
|
}
|
|
6659
6695
|
|
|
6660
6696
|
stop() {
|
|
6661
|
-
logger$
|
|
6697
|
+
logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6662
6698
|
if (!this.userAgent) {
|
|
6663
6699
|
return Promise.resolve();
|
|
6664
6700
|
}
|
|
@@ -6666,12 +6702,12 @@ class WebRTCClient extends Emitter {
|
|
|
6666
6702
|
return this.userAgent.stop().then(() => {
|
|
6667
6703
|
return this._cleanupRegister();
|
|
6668
6704
|
}).catch(e => {
|
|
6669
|
-
logger$
|
|
6705
|
+
logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6670
6706
|
});
|
|
6671
6707
|
}
|
|
6672
6708
|
|
|
6673
6709
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6674
|
-
logger$
|
|
6710
|
+
logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6675
6711
|
const inviterOptions = {
|
|
6676
6712
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6677
6713
|
conference,
|
|
@@ -6696,11 +6732,13 @@ class WebRTCClient extends Emitter {
|
|
|
6696
6732
|
const inviteOptions = {
|
|
6697
6733
|
requestDelegate: {
|
|
6698
6734
|
onAccept: (response ) => {
|
|
6699
|
-
session.sessionDescriptionHandler.peerConnection
|
|
6735
|
+
if (session.sessionDescriptionHandler.peerConnection) {
|
|
6736
|
+
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
6737
|
+
}
|
|
6700
6738
|
this._onAccepted(session, response.session, true);
|
|
6701
6739
|
},
|
|
6702
6740
|
onReject: (response ) => {
|
|
6703
|
-
logger$
|
|
6741
|
+
logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6704
6742
|
this._stopSendingStats(session);
|
|
6705
6743
|
this.stopNetworkMonitoring(session);
|
|
6706
6744
|
|
|
@@ -6723,11 +6761,11 @@ class WebRTCClient extends Emitter {
|
|
|
6723
6761
|
}
|
|
6724
6762
|
|
|
6725
6763
|
answer(session , enableVideo ) {
|
|
6726
|
-
logger$
|
|
6764
|
+
logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
6727
6765
|
|
|
6728
6766
|
if (!session || !session.accept) {
|
|
6729
6767
|
const error = 'No session to answer, or not an invitation';
|
|
6730
|
-
logger$
|
|
6768
|
+
logger$3.warn(error);
|
|
6731
6769
|
return Promise.reject(new Error(error));
|
|
6732
6770
|
}
|
|
6733
6771
|
const options = {
|
|
@@ -6737,15 +6775,15 @@ class WebRTCClient extends Emitter {
|
|
|
6737
6775
|
return session.accept(options).then(() => {
|
|
6738
6776
|
if (session.isCanceled) {
|
|
6739
6777
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
6740
|
-
logger$
|
|
6778
|
+
logger$3.error(message, { id: session.id });
|
|
6741
6779
|
this.onCallEnded(session);
|
|
6742
6780
|
|
|
6743
6781
|
throw new CanceledCallError(message);
|
|
6744
6782
|
}
|
|
6745
|
-
logger$
|
|
6783
|
+
logger$3.info('sdk webrtc answer, accepted.');
|
|
6746
6784
|
this._onAccepted(session);
|
|
6747
6785
|
}).catch(e => {
|
|
6748
|
-
logger$
|
|
6786
|
+
logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
6749
6787
|
|
|
6750
6788
|
throw e;
|
|
6751
6789
|
});
|
|
@@ -6753,7 +6791,7 @@ class WebRTCClient extends Emitter {
|
|
|
6753
6791
|
|
|
6754
6792
|
hangup(session ) {
|
|
6755
6793
|
const { state, id } = session;
|
|
6756
|
-
logger$
|
|
6794
|
+
logger$3.info('sdk webrtc hangup call', { id, state });
|
|
6757
6795
|
|
|
6758
6796
|
try {
|
|
6759
6797
|
this._stopSendingStats(session);
|
|
@@ -6782,7 +6820,7 @@ class WebRTCClient extends Emitter {
|
|
|
6782
6820
|
|
|
6783
6821
|
return bye();
|
|
6784
6822
|
} catch (error) {
|
|
6785
|
-
logger$
|
|
6823
|
+
logger$3.warn('sdk webrtc hangup, error', error);
|
|
6786
6824
|
}
|
|
6787
6825
|
|
|
6788
6826
|
return null;
|
|
@@ -6800,7 +6838,7 @@ class WebRTCClient extends Emitter {
|
|
|
6800
6838
|
// Fetch and emit an event at `interval` with session network stats
|
|
6801
6839
|
startNetworkMonitoring(session , interval = 1000) {
|
|
6802
6840
|
const sessionId = this.getSipSessionId(session);
|
|
6803
|
-
logger$
|
|
6841
|
+
logger$3.info('starting network inspection', { id: sessionId });
|
|
6804
6842
|
|
|
6805
6843
|
this.sessionNetworkStats[sessionId] = [];
|
|
6806
6844
|
|
|
@@ -6810,7 +6848,7 @@ class WebRTCClient extends Emitter {
|
|
|
6810
6848
|
stopNetworkMonitoring(session ) {
|
|
6811
6849
|
const sessionId = this.getSipSessionId(session);
|
|
6812
6850
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
6813
|
-
logger$
|
|
6851
|
+
logger$3.info('stopping network inspection', { id: sessionId, exists });
|
|
6814
6852
|
|
|
6815
6853
|
if (exists) {
|
|
6816
6854
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -6820,17 +6858,17 @@ class WebRTCClient extends Emitter {
|
|
|
6820
6858
|
}
|
|
6821
6859
|
|
|
6822
6860
|
reject(session ) {
|
|
6823
|
-
logger$
|
|
6861
|
+
logger$3.info('sdk webrtc reject call', { id: session.id });
|
|
6824
6862
|
|
|
6825
6863
|
try {
|
|
6826
6864
|
return session.reject ? session.reject() : session.cancel();
|
|
6827
6865
|
} catch (e) {
|
|
6828
|
-
logger$
|
|
6866
|
+
logger$3.warn('Error when rejecting call', e.message, e.stack);
|
|
6829
6867
|
}
|
|
6830
6868
|
}
|
|
6831
6869
|
|
|
6832
6870
|
async close() {
|
|
6833
|
-
logger$
|
|
6871
|
+
logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
6834
6872
|
this._cleanupMedia();
|
|
6835
6873
|
this.connectionPromise = null;
|
|
6836
6874
|
|
|
@@ -6861,7 +6899,7 @@ class WebRTCClient extends Emitter {
|
|
|
6861
6899
|
// eg: "INVITE not rejectable in state Completed"
|
|
6862
6900
|
}
|
|
6863
6901
|
this.userAgent = null;
|
|
6864
|
-
logger$
|
|
6902
|
+
logger$3.info('sdk webrtc client closed');
|
|
6865
6903
|
}
|
|
6866
6904
|
|
|
6867
6905
|
getNumber(session ) {
|
|
@@ -6874,13 +6912,13 @@ class WebRTCClient extends Emitter {
|
|
|
6874
6912
|
}
|
|
6875
6913
|
|
|
6876
6914
|
mute(session ) {
|
|
6877
|
-
logger$
|
|
6915
|
+
logger$3.info('sdk webrtc mute', { id: session.id });
|
|
6878
6916
|
|
|
6879
6917
|
this._toggleAudio(session, true);
|
|
6880
6918
|
}
|
|
6881
6919
|
|
|
6882
6920
|
unmute(session ) {
|
|
6883
|
-
logger$
|
|
6921
|
+
logger$3.info('sdk webrtc unmute', { id: session.id });
|
|
6884
6922
|
|
|
6885
6923
|
this._toggleAudio(session, false);
|
|
6886
6924
|
}
|
|
@@ -6920,13 +6958,13 @@ class WebRTCClient extends Emitter {
|
|
|
6920
6958
|
}
|
|
6921
6959
|
|
|
6922
6960
|
toggleCameraOn(session ) {
|
|
6923
|
-
logger$
|
|
6961
|
+
logger$3.info('sdk webrtc toggle camera on', { id: session.id });
|
|
6924
6962
|
|
|
6925
6963
|
this._toggleVideo(session, false);
|
|
6926
6964
|
}
|
|
6927
6965
|
|
|
6928
6966
|
toggleCameraOff(session ) {
|
|
6929
|
-
logger$
|
|
6967
|
+
logger$3.info('sdk webrtc toggle camera off', { id: session.id });
|
|
6930
6968
|
|
|
6931
6969
|
this._toggleVideo(session, true);
|
|
6932
6970
|
}
|
|
@@ -6935,7 +6973,7 @@ class WebRTCClient extends Emitter {
|
|
|
6935
6973
|
const sessionId = this.getSipSessionId(session);
|
|
6936
6974
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
6937
6975
|
|
|
6938
|
-
logger$
|
|
6976
|
+
logger$3.info('sdk webrtc hold', {
|
|
6939
6977
|
sessionId,
|
|
6940
6978
|
keys: Object.keys(this.heldSessions),
|
|
6941
6979
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6984,7 +7022,7 @@ class WebRTCClient extends Emitter {
|
|
|
6984
7022
|
const sessionId = this.getSipSessionId(session);
|
|
6985
7023
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
6986
7024
|
|
|
6987
|
-
logger$
|
|
7025
|
+
logger$3.info('sdk webrtc unhold', {
|
|
6988
7026
|
sessionId,
|
|
6989
7027
|
keys: Object.keys(this.heldSessions),
|
|
6990
7028
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7132,7 +7170,7 @@ class WebRTCClient extends Emitter {
|
|
|
7132
7170
|
if (!session.sessionDescriptionHandler) {
|
|
7133
7171
|
return;
|
|
7134
7172
|
}
|
|
7135
|
-
logger$
|
|
7173
|
+
logger$3.info('Sending DTMF', {
|
|
7136
7174
|
id: this.getSipSessionId(session),
|
|
7137
7175
|
tone,
|
|
7138
7176
|
});
|
|
@@ -7148,7 +7186,7 @@ class WebRTCClient extends Emitter {
|
|
|
7148
7186
|
transfer(session , target ) {
|
|
7149
7187
|
this.hold(session);
|
|
7150
7188
|
|
|
7151
|
-
logger$
|
|
7189
|
+
logger$3.info('Transfering a session', {
|
|
7152
7190
|
id: this.getSipSessionId(session),
|
|
7153
7191
|
target,
|
|
7154
7192
|
});
|
|
@@ -7170,17 +7208,17 @@ class WebRTCClient extends Emitter {
|
|
|
7170
7208
|
atxfer(session ) {
|
|
7171
7209
|
this.hold(session);
|
|
7172
7210
|
|
|
7173
|
-
logger$
|
|
7211
|
+
logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
7174
7212
|
|
|
7175
7213
|
const result = {
|
|
7176
7214
|
newSession: null,
|
|
7177
7215
|
init: async (target ) => {
|
|
7178
|
-
logger$
|
|
7216
|
+
logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
7179
7217
|
|
|
7180
7218
|
result.newSession = await this.call(target);
|
|
7181
7219
|
},
|
|
7182
7220
|
complete: () => {
|
|
7183
|
-
logger$
|
|
7221
|
+
logger$3.info('webrtc transfer completed', {
|
|
7184
7222
|
id: this.getSipSessionId(session),
|
|
7185
7223
|
referId: this.getSipSessionId(result.newSession),
|
|
7186
7224
|
});
|
|
@@ -7201,7 +7239,7 @@ class WebRTCClient extends Emitter {
|
|
|
7201
7239
|
return;
|
|
7202
7240
|
}
|
|
7203
7241
|
|
|
7204
|
-
logger$
|
|
7242
|
+
logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
7205
7243
|
|
|
7206
7244
|
try {
|
|
7207
7245
|
sipSession.message({
|
|
@@ -7243,7 +7281,7 @@ class WebRTCClient extends Emitter {
|
|
|
7243
7281
|
}
|
|
7244
7282
|
|
|
7245
7283
|
changeAudioOutputVolume(volume ) {
|
|
7246
|
-
logger$
|
|
7284
|
+
logger$3.info('Changing audio output volume', { volume });
|
|
7247
7285
|
|
|
7248
7286
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7249
7287
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -7255,7 +7293,7 @@ class WebRTCClient extends Emitter {
|
|
|
7255
7293
|
}
|
|
7256
7294
|
|
|
7257
7295
|
changeAudioOutputDevice(id ) {
|
|
7258
|
-
logger$
|
|
7296
|
+
logger$3.info('Changing audio output device', { id });
|
|
7259
7297
|
|
|
7260
7298
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7261
7299
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -7272,7 +7310,7 @@ class WebRTCClient extends Emitter {
|
|
|
7272
7310
|
|
|
7273
7311
|
changeAudioInputDevice(id , session ) {
|
|
7274
7312
|
const currentId = this.getAudioDeviceId();
|
|
7275
|
-
logger$
|
|
7313
|
+
logger$3.info('setting audio input device', { id, currentId, session: !!session });
|
|
7276
7314
|
|
|
7277
7315
|
if (id === currentId) {
|
|
7278
7316
|
return null;
|
|
@@ -7318,7 +7356,7 @@ class WebRTCClient extends Emitter {
|
|
|
7318
7356
|
|
|
7319
7357
|
setVideoInputDevice(id ) {
|
|
7320
7358
|
const currentId = this.getVideoDeviceId();
|
|
7321
|
-
logger$
|
|
7359
|
+
logger$3.info('setting video input device', { id, currentId });
|
|
7322
7360
|
|
|
7323
7361
|
if (id === currentId) {
|
|
7324
7362
|
return null;
|
|
@@ -7343,7 +7381,7 @@ class WebRTCClient extends Emitter {
|
|
|
7343
7381
|
const sessionId = this.getSipSessionId(session);
|
|
7344
7382
|
const localStream = this.getLocalStream(sessionId);
|
|
7345
7383
|
|
|
7346
|
-
logger$
|
|
7384
|
+
logger$3.info('changing video input device', { id, sessionId });
|
|
7347
7385
|
|
|
7348
7386
|
// Release old video stream
|
|
7349
7387
|
if (localStream) {
|
|
@@ -7411,7 +7449,7 @@ class WebRTCClient extends Emitter {
|
|
|
7411
7449
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
7412
7450
|
const desktop = newConstraints && newConstraints.desktop;
|
|
7413
7451
|
|
|
7414
|
-
logger$
|
|
7452
|
+
logger$3.info('Sending reinvite', {
|
|
7415
7453
|
id: this.getSipSessionId(sipSession),
|
|
7416
7454
|
newConstraints,
|
|
7417
7455
|
conference,
|
|
@@ -7449,7 +7487,7 @@ class WebRTCClient extends Emitter {
|
|
|
7449
7487
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
7450
7488
|
}
|
|
7451
7489
|
|
|
7452
|
-
logger$
|
|
7490
|
+
logger$3.info('on re-INVITE accepted', {
|
|
7453
7491
|
id: this.getSipSessionId(sipSession),
|
|
7454
7492
|
wasMuted,
|
|
7455
7493
|
shouldDoScreenSharing,
|
|
@@ -7467,7 +7505,7 @@ class WebRTCClient extends Emitter {
|
|
|
7467
7505
|
this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
|
|
7468
7506
|
}
|
|
7469
7507
|
|
|
7470
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
7508
|
+
return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
|
|
7471
7509
|
},
|
|
7472
7510
|
},
|
|
7473
7511
|
sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
|
|
@@ -7568,6 +7606,16 @@ class WebRTCClient extends Emitter {
|
|
|
7568
7606
|
return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
|
|
7569
7607
|
}
|
|
7570
7608
|
|
|
7609
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
7610
|
+
getRemoteVideoStreamFromPc(sessionId ) {
|
|
7611
|
+
const pc = this.getPeerConnection(sessionId);
|
|
7612
|
+
if (!pc) {
|
|
7613
|
+
return null;
|
|
7614
|
+
}
|
|
7615
|
+
|
|
7616
|
+
return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
|
|
7617
|
+
}
|
|
7618
|
+
|
|
7571
7619
|
hasVideo(sessionId ) {
|
|
7572
7620
|
return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
|
|
7573
7621
|
}
|
|
@@ -7614,7 +7662,7 @@ class WebRTCClient extends Emitter {
|
|
|
7614
7662
|
}
|
|
7615
7663
|
|
|
7616
7664
|
startHeartbeat() {
|
|
7617
|
-
logger$
|
|
7665
|
+
logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7618
7666
|
if (!this.userAgent) {
|
|
7619
7667
|
this.heartbeat.stop();
|
|
7620
7668
|
return;
|
|
@@ -7627,7 +7675,7 @@ class WebRTCClient extends Emitter {
|
|
|
7627
7675
|
}
|
|
7628
7676
|
|
|
7629
7677
|
stopHeartbeat() {
|
|
7630
|
-
logger$
|
|
7678
|
+
logger$3.info('sdk webrtc stop heartbeat');
|
|
7631
7679
|
this.heartbeat.stop();
|
|
7632
7680
|
}
|
|
7633
7681
|
|
|
@@ -7648,7 +7696,7 @@ class WebRTCClient extends Emitter {
|
|
|
7648
7696
|
}
|
|
7649
7697
|
|
|
7650
7698
|
attemptReconnection() {
|
|
7651
|
-
logger$
|
|
7699
|
+
logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7652
7700
|
if (!this.userAgent) {
|
|
7653
7701
|
return;
|
|
7654
7702
|
}
|
|
@@ -7673,7 +7721,7 @@ class WebRTCClient extends Emitter {
|
|
|
7673
7721
|
return;
|
|
7674
7722
|
}
|
|
7675
7723
|
|
|
7676
|
-
logger$
|
|
7724
|
+
logger$3.info('setting local media stream', {
|
|
7677
7725
|
sipSessionId,
|
|
7678
7726
|
tracks: newStream ? newStream.getTracks() : null,
|
|
7679
7727
|
});
|
|
@@ -7690,7 +7738,7 @@ class WebRTCClient extends Emitter {
|
|
|
7690
7738
|
|
|
7691
7739
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
7692
7740
|
|
|
7693
|
-
logger$
|
|
7741
|
+
logger$3.info('updating local stream', {
|
|
7694
7742
|
sipSessionId,
|
|
7695
7743
|
oldStream: !!oldStream,
|
|
7696
7744
|
tracks: newStream.getTracks(),
|
|
@@ -7710,7 +7758,7 @@ class WebRTCClient extends Emitter {
|
|
|
7710
7758
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
7711
7759
|
const pc = this.getPeerConnection(sessionId);
|
|
7712
7760
|
|
|
7713
|
-
logger$
|
|
7761
|
+
logger$3.info('Updating remote stream', {
|
|
7714
7762
|
sessionId,
|
|
7715
7763
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
7716
7764
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -7736,7 +7784,7 @@ class WebRTCClient extends Emitter {
|
|
|
7736
7784
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
7737
7785
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
7738
7786
|
|
|
7739
|
-
logger$
|
|
7787
|
+
logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
7740
7788
|
|
|
7741
7789
|
return {
|
|
7742
7790
|
constraints: {
|
|
@@ -7785,7 +7833,7 @@ class WebRTCClient extends Emitter {
|
|
|
7785
7833
|
}
|
|
7786
7834
|
|
|
7787
7835
|
_onTransportError() {
|
|
7788
|
-
logger$
|
|
7836
|
+
logger$3.error('on transport error');
|
|
7789
7837
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
7790
7838
|
this.attemptReconnection();
|
|
7791
7839
|
}
|
|
@@ -7794,7 +7842,7 @@ class WebRTCClient extends Emitter {
|
|
|
7794
7842
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
7795
7843
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
7796
7844
|
if (this.hasHeartbeat()) {
|
|
7797
|
-
logger$
|
|
7845
|
+
logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
7798
7846
|
|
|
7799
7847
|
this.heartbeat.onHeartbeat();
|
|
7800
7848
|
if (this.heartbeatCb) {
|
|
@@ -7805,7 +7853,7 @@ class WebRTCClient extends Emitter {
|
|
|
7805
7853
|
}
|
|
7806
7854
|
|
|
7807
7855
|
async _onHeartbeatTimeout() {
|
|
7808
|
-
logger$
|
|
7856
|
+
logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
7809
7857
|
|
|
7810
7858
|
if (this.heartbeatTimeoutCb) {
|
|
7811
7859
|
this.heartbeatTimeoutCb();
|
|
@@ -7817,7 +7865,7 @@ class WebRTCClient extends Emitter {
|
|
|
7817
7865
|
try {
|
|
7818
7866
|
await this.userAgent.transport.disconnect();
|
|
7819
7867
|
} catch (e) {
|
|
7820
|
-
logger$
|
|
7868
|
+
logger$3.error('Transport disconnection after heartbeat timeout, error', e);
|
|
7821
7869
|
}
|
|
7822
7870
|
}
|
|
7823
7871
|
|
|
@@ -7850,31 +7898,31 @@ class WebRTCClient extends Emitter {
|
|
|
7850
7898
|
}
|
|
7851
7899
|
|
|
7852
7900
|
_connectIfNeeded() {
|
|
7853
|
-
logger$
|
|
7901
|
+
logger$3.info('connect if needed, checking', { connected: this.isConnected() });
|
|
7854
7902
|
if (!this.userAgent) {
|
|
7855
|
-
logger$
|
|
7903
|
+
logger$3.info('need to recreate User Agent');
|
|
7856
7904
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
7857
7905
|
}
|
|
7858
7906
|
|
|
7859
7907
|
if (this.isConnected()) {
|
|
7860
|
-
logger$
|
|
7908
|
+
logger$3.info('webrtc sdk, already connected');
|
|
7861
7909
|
return Promise.resolve();
|
|
7862
7910
|
}
|
|
7863
7911
|
|
|
7864
7912
|
if (this.isConnecting()) {
|
|
7865
|
-
logger$
|
|
7913
|
+
logger$3.info('webrtc sdk, already connecting...');
|
|
7866
7914
|
|
|
7867
7915
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
7868
7916
|
return this.connectionPromise;
|
|
7869
7917
|
}
|
|
7870
7918
|
|
|
7871
7919
|
if (this.connectionPromise) {
|
|
7872
|
-
logger$
|
|
7920
|
+
logger$3.info('webrtc sdk, connection promise connecting...');
|
|
7873
7921
|
// $FlowFixMe
|
|
7874
7922
|
return this.connectionPromise;
|
|
7875
7923
|
}
|
|
7876
7924
|
|
|
7877
|
-
logger$
|
|
7925
|
+
logger$3.info('WebRTC UA needs to connect');
|
|
7878
7926
|
|
|
7879
7927
|
// Force UA to reconnect
|
|
7880
7928
|
if (this.userAgent && this.userAgent.state !== UserAgentState.Stopped) {
|
|
@@ -7999,7 +8047,7 @@ class WebRTCClient extends Emitter {
|
|
|
7999
8047
|
|
|
8000
8048
|
sdh.peerConnectionDelegate = {
|
|
8001
8049
|
onicecandidateerror: (error ) => {
|
|
8002
|
-
logger$
|
|
8050
|
+
logger$3.error('on icecandidate error', {
|
|
8003
8051
|
address: error.address,
|
|
8004
8052
|
port: error.port,
|
|
8005
8053
|
errorCode: error.errorCode,
|
|
@@ -8028,7 +8076,7 @@ class WebRTCClient extends Emitter {
|
|
|
8028
8076
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
8029
8077
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
8030
8078
|
}
|
|
8031
|
-
logger$
|
|
8079
|
+
logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
8032
8080
|
|
|
8033
8081
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
8034
8082
|
|
|
@@ -8044,12 +8092,12 @@ class WebRTCClient extends Emitter {
|
|
|
8044
8092
|
|
|
8045
8093
|
this._setupMedias(session);
|
|
8046
8094
|
|
|
8047
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
8095
|
+
return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
|
|
8048
8096
|
};
|
|
8049
8097
|
}
|
|
8050
8098
|
|
|
8051
8099
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
8052
|
-
logger$
|
|
8100
|
+
logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
8053
8101
|
|
|
8054
8102
|
this.storeSipSession(session);
|
|
8055
8103
|
|
|
@@ -8061,14 +8109,14 @@ class WebRTCClient extends Emitter {
|
|
|
8061
8109
|
const onTrack = (event ) => {
|
|
8062
8110
|
const isAudioOnly = this._isAudioOnly(session);
|
|
8063
8111
|
const { kind, label, readyState, id, muted } = event.track;
|
|
8064
|
-
logger$
|
|
8112
|
+
logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
8065
8113
|
|
|
8066
8114
|
// Stop video track in audio only mode
|
|
8067
8115
|
if (isAudioOnly && kind === 'video') {
|
|
8068
8116
|
event.track.stop();
|
|
8069
8117
|
}
|
|
8070
8118
|
|
|
8071
|
-
this.eventEmitter.emit(ON_TRACK
|
|
8119
|
+
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
8072
8120
|
};
|
|
8073
8121
|
|
|
8074
8122
|
if (session.sessionDescriptionHandler.peerConnection) {
|
|
@@ -8078,8 +8126,9 @@ class WebRTCClient extends Emitter {
|
|
|
8078
8126
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
8079
8127
|
|
|
8080
8128
|
pc.oniceconnectionstatechange = () => {
|
|
8129
|
+
logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
8081
8130
|
if (pc.iceConnectionState === 'disconnected') {
|
|
8082
|
-
this.eventEmitter.emit(ON_DISCONNECTED
|
|
8131
|
+
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
8083
8132
|
}
|
|
8084
8133
|
};
|
|
8085
8134
|
|
|
@@ -8250,10 +8299,10 @@ class WebRTCClient extends Emitter {
|
|
|
8250
8299
|
|
|
8251
8300
|
_stopSendingStats(session ) {
|
|
8252
8301
|
const sessionId = this.getSipSessionId(session);
|
|
8253
|
-
logger$
|
|
8302
|
+
logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
8254
8303
|
|
|
8255
8304
|
if (sessionId in this.statsIntervals) {
|
|
8256
|
-
logger$
|
|
8305
|
+
logger$3.trace('Stop sending stats for call', { sessionId });
|
|
8257
8306
|
this.statsIntervals[sessionId]();
|
|
8258
8307
|
delete this.statsIntervals[sessionId];
|
|
8259
8308
|
}
|
|
@@ -8269,7 +8318,7 @@ class WebRTCClient extends Emitter {
|
|
|
8269
8318
|
try {
|
|
8270
8319
|
await this.userAgent.transport.disconnect();
|
|
8271
8320
|
} catch (e) {
|
|
8272
|
-
logger$
|
|
8321
|
+
logger$3.error('WebRTC transport disconnect, error', e);
|
|
8273
8322
|
}
|
|
8274
8323
|
}
|
|
8275
8324
|
}
|
|
@@ -8306,25 +8355,25 @@ class WebRTCClient extends Emitter {
|
|
|
8306
8355
|
|
|
8307
8356
|
stats.forEach(report => {
|
|
8308
8357
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
8309
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8358
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8310
8359
|
}
|
|
8311
8360
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
8312
|
-
audioBytesSent += report.bytesSent;
|
|
8361
|
+
audioBytesSent += Number(report.bytesSent);
|
|
8313
8362
|
}
|
|
8314
8363
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8315
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8364
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8316
8365
|
}
|
|
8317
8366
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
8318
|
-
packetsLost += report.packetsLost;
|
|
8319
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
8320
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8367
|
+
packetsLost += Number(report.packetsLost);
|
|
8368
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
8369
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8321
8370
|
}
|
|
8322
8371
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
8323
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8372
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8324
8373
|
}
|
|
8325
8374
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8326
8375
|
if ('framesPerSecond' in report) {
|
|
8327
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
8376
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
8328
8377
|
}
|
|
8329
8378
|
if ('framerateMean' in report) {
|
|
8330
8379
|
// framerateMean is only available in FF
|
|
@@ -8332,34 +8381,38 @@ class WebRTCClient extends Emitter {
|
|
|
8332
8381
|
}
|
|
8333
8382
|
}
|
|
8334
8383
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
8335
|
-
packetsLost += report.packetsLost;
|
|
8336
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
8337
|
-
networkStats.jitter = report.jitter;
|
|
8384
|
+
packetsLost += Number(report.packetsLost);
|
|
8385
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
8386
|
+
networkStats.jitter = Number(report.jitter);
|
|
8338
8387
|
}
|
|
8339
8388
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
8340
|
-
packetsLost += report.packetsLost;
|
|
8389
|
+
packetsLost += Number(report.packetsLost);
|
|
8341
8390
|
}
|
|
8342
8391
|
if (report.type === 'transport') {
|
|
8343
|
-
transportSent += report.bytesSent;
|
|
8344
|
-
transportReceived += report.bytesReceived;
|
|
8392
|
+
transportSent += Number(report.bytesSent);
|
|
8393
|
+
transportReceived += Number(report.bytesReceived);
|
|
8345
8394
|
}
|
|
8346
8395
|
});
|
|
8347
8396
|
|
|
8348
8397
|
networkStats.packetsLost = packetsLost;
|
|
8349
|
-
networkStats.
|
|
8398
|
+
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
8399
|
+
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
8400
|
+
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
8350
8401
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
8351
|
-
networkStats.
|
|
8352
|
-
networkStats.
|
|
8402
|
+
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
8403
|
+
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
8404
|
+
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
8405
|
+
networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
|
|
8406
|
+
networkStats.totalTransportSent = transportSent - lastTransportSent;
|
|
8353
8407
|
networkStats.transportSent = transportSent;
|
|
8354
|
-
networkStats.
|
|
8355
|
-
|
|
8356
|
-
const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
|
|
8357
|
-
+ (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
|
|
8358
|
-
+ (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
|
|
8408
|
+
networkStats.totalTransportReceived = transportReceived;
|
|
8409
|
+
networkStats.transportReceived = transportReceived - lastTransportReceived;
|
|
8359
8410
|
|
|
8360
|
-
networkStats.bandwidth =
|
|
8411
|
+
networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
|
|
8412
|
+
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
8413
|
+
+ networkStats.transportSent;
|
|
8361
8414
|
|
|
8362
|
-
this.eventEmitter.emit(ON_NETWORK_STATS
|
|
8415
|
+
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
8363
8416
|
this.sessionNetworkStats[sessionId].push(networkStats);
|
|
8364
8417
|
}
|
|
8365
8418
|
|
|
@@ -8387,8 +8440,8 @@ const ON_CALL_FAILED = 'onCallFailed';
|
|
|
8387
8440
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
8388
8441
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
8389
8442
|
const ON_MESSAGE = 'onMessage';
|
|
8390
|
-
const ON_REINVITE = 'reinvite';
|
|
8391
|
-
const ON_TRACK = 'onTrack';
|
|
8443
|
+
const ON_REINVITE$1 = 'reinvite';
|
|
8444
|
+
const ON_TRACK$1 = 'onTrack';
|
|
8392
8445
|
const ON_AUDIO_STREAM = 'onAudioStream';
|
|
8393
8446
|
const ON_VIDEO_STREAM = 'onVideoStream';
|
|
8394
8447
|
const ON_REMOVE_STREAM = 'onRemoveStream';
|
|
@@ -8403,15 +8456,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
|
|
|
8403
8456
|
const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
|
|
8404
8457
|
const ON_CALL_ERROR = 'onCallError';
|
|
8405
8458
|
const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
|
|
8406
|
-
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
8459
|
+
const ON_NETWORK_STATS$1 = 'onNetworkStats';
|
|
8407
8460
|
const ON_CHAT = 'phone/ON_CHAT';
|
|
8408
8461
|
const ON_SIGNAL = 'phone/ON_SIGNAL';
|
|
8409
|
-
const ON_DISCONNECTED = 'onDisconnected';
|
|
8462
|
+
const ON_DISCONNECTED$1 = 'onDisconnected';
|
|
8410
8463
|
|
|
8411
8464
|
const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
8412
8465
|
const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
8413
8466
|
|
|
8414
|
-
const events = [
|
|
8467
|
+
const events$1 = [
|
|
8415
8468
|
ON_USER_AGENT,
|
|
8416
8469
|
ON_REGISTERED,
|
|
8417
8470
|
ON_UNREGISTERED,
|
|
@@ -8429,8 +8482,8 @@ const events = [
|
|
|
8429
8482
|
ON_CALL_FAILED,
|
|
8430
8483
|
ON_CALL_ENDED,
|
|
8431
8484
|
ON_MESSAGE,
|
|
8432
|
-
ON_REINVITE,
|
|
8433
|
-
ON_TRACK,
|
|
8485
|
+
ON_REINVITE$1,
|
|
8486
|
+
ON_TRACK$1,
|
|
8434
8487
|
ON_AUDIO_STREAM,
|
|
8435
8488
|
ON_VIDEO_STREAM,
|
|
8436
8489
|
ON_REMOVE_STREAM,
|
|
@@ -8445,11 +8498,11 @@ const events = [
|
|
|
8445
8498
|
ON_CALL_ERROR,
|
|
8446
8499
|
ON_CHAT,
|
|
8447
8500
|
ON_SIGNAL,
|
|
8448
|
-
ON_NETWORK_STATS,
|
|
8449
|
-
ON_DISCONNECTED,
|
|
8501
|
+
ON_NETWORK_STATS$1,
|
|
8502
|
+
ON_DISCONNECTED$1,
|
|
8450
8503
|
];
|
|
8451
8504
|
|
|
8452
|
-
const logger$
|
|
8505
|
+
const logger$4 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
8453
8506
|
|
|
8454
8507
|
class WebRTCPhone extends Emitter {
|
|
8455
8508
|
|
|
@@ -8522,7 +8575,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8522
8575
|
}).catch(error => {
|
|
8523
8576
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
8524
8577
|
console.error('register error', error, error.message, error.stack);
|
|
8525
|
-
logger$
|
|
8578
|
+
logger$4.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
8526
8579
|
});
|
|
8527
8580
|
}
|
|
8528
8581
|
|
|
@@ -8537,7 +8590,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8537
8590
|
if (!this.client) {
|
|
8538
8591
|
return;
|
|
8539
8592
|
}
|
|
8540
|
-
logger$
|
|
8593
|
+
logger$4.info('WebRTC phone stop');
|
|
8541
8594
|
this.client.stop();
|
|
8542
8595
|
}
|
|
8543
8596
|
|
|
@@ -8552,7 +8605,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8552
8605
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
8553
8606
|
audioOnly = false, iceRestart = false) {
|
|
8554
8607
|
const sipSession = this.findSipSession(callSession);
|
|
8555
|
-
logger$
|
|
8608
|
+
logger$4.info('WebRTC phone - send reinvite', {
|
|
8556
8609
|
sessionId: sipSession ? sipSession.id : null,
|
|
8557
8610
|
constraints,
|
|
8558
8611
|
audioOnly,
|
|
@@ -8589,7 +8642,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8589
8642
|
}
|
|
8590
8643
|
|
|
8591
8644
|
startHeartbeat() {
|
|
8592
|
-
logger$
|
|
8645
|
+
logger$4.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
8593
8646
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
8594
8647
|
return;
|
|
8595
8648
|
}
|
|
@@ -8598,7 +8651,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8598
8651
|
}
|
|
8599
8652
|
|
|
8600
8653
|
stopHeartbeat() {
|
|
8601
|
-
logger$
|
|
8654
|
+
logger$4.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
8602
8655
|
if (!this.client) {
|
|
8603
8656
|
return;
|
|
8604
8657
|
}
|
|
@@ -8615,7 +8668,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8615
8668
|
}
|
|
8616
8669
|
|
|
8617
8670
|
reconnect() {
|
|
8618
|
-
logger$
|
|
8671
|
+
logger$4.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
8619
8672
|
if (!this.client) {
|
|
8620
8673
|
return;
|
|
8621
8674
|
}
|
|
@@ -8656,10 +8709,15 @@ class WebRTCPhone extends Emitter {
|
|
|
8656
8709
|
return false;
|
|
8657
8710
|
}
|
|
8658
8711
|
|
|
8659
|
-
logger$
|
|
8712
|
+
logger$4.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
8660
8713
|
|
|
8661
8714
|
this.client.downgradeToAudio(sipSession);
|
|
8662
8715
|
|
|
8716
|
+
if (callSession) {
|
|
8717
|
+
callSession.cameraEnabled = false;
|
|
8718
|
+
this._updateCallSession(callSession);
|
|
8719
|
+
}
|
|
8720
|
+
|
|
8663
8721
|
if (withMessage) {
|
|
8664
8722
|
this._sendReinviteMessage(callSession, false);
|
|
8665
8723
|
}
|
|
@@ -8674,7 +8732,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8674
8732
|
return Promise.resolve(false);
|
|
8675
8733
|
}
|
|
8676
8734
|
|
|
8677
|
-
logger$
|
|
8735
|
+
logger$4.info('Upgrade to video', {
|
|
8678
8736
|
id: callSession ? callSession.getId() : null,
|
|
8679
8737
|
constraints,
|
|
8680
8738
|
isConference,
|
|
@@ -8687,6 +8745,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8687
8745
|
|
|
8688
8746
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
8689
8747
|
|
|
8748
|
+
if (callSession) {
|
|
8749
|
+
callSession.cameraEnabled = true;
|
|
8750
|
+
this._updateCallSession(callSession);
|
|
8751
|
+
}
|
|
8752
|
+
|
|
8690
8753
|
// If no stream is returned, it means we have to reinvite
|
|
8691
8754
|
if (!newStream) {
|
|
8692
8755
|
return true;
|
|
@@ -8709,7 +8772,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8709
8772
|
|
|
8710
8773
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
8711
8774
|
const sipSession = this.findSipSession(callSession);
|
|
8712
|
-
logger$
|
|
8775
|
+
logger$4.info('Sending reinvite message', {
|
|
8713
8776
|
id: callSession ? callSession.getId() : null,
|
|
8714
8777
|
isUpgrade,
|
|
8715
8778
|
});
|
|
@@ -8735,11 +8798,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8735
8798
|
// Monkey patch to know when canceled with the CANCEL message
|
|
8736
8799
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
8737
8800
|
sipSession._onCancel = (message ) => {
|
|
8738
|
-
logger$
|
|
8801
|
+
logger$4.trace('on sip session canceled', { callId: message.callId });
|
|
8739
8802
|
|
|
8740
8803
|
onCancel(message);
|
|
8741
8804
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
8742
|
-
|
|
8805
|
+
const callSession = this._createCallSession(sipSession);
|
|
8806
|
+
delete this.callSessions[callSession.getId()];
|
|
8807
|
+
|
|
8808
|
+
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
8743
8809
|
};
|
|
8744
8810
|
} else if (sipSession instanceof Invitation) {
|
|
8745
8811
|
console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
|
|
@@ -8760,17 +8826,19 @@ class WebRTCPhone extends Emitter {
|
|
|
8760
8826
|
this.audioOutputVolume,
|
|
8761
8827
|
);
|
|
8762
8828
|
case SessionState.Terminating:
|
|
8763
|
-
logger$
|
|
8829
|
+
logger$4.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
8764
8830
|
|
|
8765
8831
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
8766
8832
|
|
|
8767
8833
|
break;
|
|
8768
8834
|
case SessionState.Terminated: {
|
|
8769
|
-
logger$
|
|
8835
|
+
logger$4.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
8770
8836
|
|
|
8837
|
+
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
8838
|
+
const callSession = this._createCallSession(sipSession);
|
|
8771
8839
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
8772
8840
|
|
|
8773
|
-
return this.eventEmitter.emit(ON_CALL_ENDED,
|
|
8841
|
+
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
8774
8842
|
}
|
|
8775
8843
|
}
|
|
8776
8844
|
});
|
|
@@ -8786,7 +8854,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8786
8854
|
const [stream] = event.streams;
|
|
8787
8855
|
const kind = event && event.track && event.track.kind;
|
|
8788
8856
|
|
|
8789
|
-
logger$
|
|
8857
|
+
logger$4.info('on track stream called on the peer connection', {
|
|
8790
8858
|
callId: this.getSipSessionId(sipSession),
|
|
8791
8859
|
streamId: stream ? stream.id : null,
|
|
8792
8860
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -8806,7 +8874,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8806
8874
|
};
|
|
8807
8875
|
|
|
8808
8876
|
peerConnection.onremovestream = event => {
|
|
8809
|
-
logger$
|
|
8877
|
+
logger$4.info('on remove stream called on the peer connection', {
|
|
8810
8878
|
id: event.stream.id,
|
|
8811
8879
|
tracks: event.stream.getTracks(),
|
|
8812
8880
|
});
|
|
@@ -8816,7 +8884,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8816
8884
|
}
|
|
8817
8885
|
|
|
8818
8886
|
async startScreenSharing(constraints , callSession ) {
|
|
8819
|
-
logger$
|
|
8887
|
+
logger$4.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
8820
8888
|
|
|
8821
8889
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
8822
8890
|
if (!screenShareStream) {
|
|
@@ -8856,7 +8924,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8856
8924
|
return;
|
|
8857
8925
|
}
|
|
8858
8926
|
|
|
8859
|
-
logger$
|
|
8927
|
+
logger$4.info('WebRTC phone - stop screen sharing', {
|
|
8860
8928
|
restoreLocalStream,
|
|
8861
8929
|
});
|
|
8862
8930
|
|
|
@@ -8912,24 +8980,26 @@ class WebRTCPhone extends Emitter {
|
|
|
8912
8980
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
8913
8981
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
8914
8982
|
|
|
8915
|
-
logger$
|
|
8983
|
+
logger$4.info('WebRTC phone - on screensharing', {
|
|
8916
8984
|
hadVideo,
|
|
8917
8985
|
id: this.getSipSessionId(sipSession),
|
|
8918
8986
|
screenTrack,
|
|
8919
8987
|
});
|
|
8920
8988
|
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
8925
|
-
|
|
8926
|
-
|
|
8989
|
+
if (screenTrack) {
|
|
8990
|
+
screenTrack.onended = () => {
|
|
8991
|
+
logger$4.info('WebRTC phone - on screenshare ended', {
|
|
8992
|
+
hadVideo,
|
|
8993
|
+
id: this.getSipSessionId(sipSession),
|
|
8994
|
+
screenTrack,
|
|
8995
|
+
});
|
|
8927
8996
|
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
8997
|
+
this.eventEmitter.emit(
|
|
8998
|
+
ON_SHARE_SCREEN_ENDING,
|
|
8999
|
+
this._createCallSession(sipSession, callSession),
|
|
9000
|
+
);
|
|
9001
|
+
};
|
|
9002
|
+
}
|
|
8933
9003
|
|
|
8934
9004
|
this.currentScreenShare = {
|
|
8935
9005
|
stream: screenStream,
|
|
@@ -8949,7 +9019,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8949
9019
|
}
|
|
8950
9020
|
|
|
8951
9021
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
8952
|
-
logger$
|
|
9022
|
+
logger$4.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
8953
9023
|
|
|
8954
9024
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
8955
9025
|
this.currentSipSession = sipSession;
|
|
@@ -8967,7 +9037,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8967
9037
|
}
|
|
8968
9038
|
|
|
8969
9039
|
changeAudioDevice(id ) {
|
|
8970
|
-
logger$
|
|
9040
|
+
logger$4.info('WebRTC phone - change audio device', { deviceId: id });
|
|
8971
9041
|
this.audioOutputDeviceId = id;
|
|
8972
9042
|
this.client.changeAudioOutputDevice(id);
|
|
8973
9043
|
}
|
|
@@ -8977,14 +9047,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8977
9047
|
}
|
|
8978
9048
|
|
|
8979
9049
|
changeRingDevice(id ) {
|
|
8980
|
-
logger$
|
|
9050
|
+
logger$4.info('WebRTC phone - changing ring device', { id });
|
|
8981
9051
|
|
|
8982
9052
|
this.audioRingDeviceId = id;
|
|
8983
9053
|
}
|
|
8984
9054
|
|
|
8985
9055
|
// volume is a value between 0 and 1
|
|
8986
9056
|
changeAudioVolume(volume ) {
|
|
8987
|
-
logger$
|
|
9057
|
+
logger$4.info('WebRTC phone - changing audio volume', { volume });
|
|
8988
9058
|
|
|
8989
9059
|
this.audioOutputVolume = volume;
|
|
8990
9060
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -8992,31 +9062,31 @@ class WebRTCPhone extends Emitter {
|
|
|
8992
9062
|
|
|
8993
9063
|
// volume is a value between 0 and 1
|
|
8994
9064
|
changeRingVolume(volume ) {
|
|
8995
|
-
logger$
|
|
9065
|
+
logger$4.info('WebRTC phone - changing ring volume', { volume });
|
|
8996
9066
|
|
|
8997
9067
|
this.audioRingVolume = volume;
|
|
8998
9068
|
}
|
|
8999
9069
|
|
|
9000
9070
|
changeAudioInputDevice(id ) {
|
|
9001
|
-
logger$
|
|
9071
|
+
logger$4.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
9002
9072
|
|
|
9003
9073
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
9004
9074
|
}
|
|
9005
9075
|
|
|
9006
9076
|
changeVideoInputDevice(id ) {
|
|
9007
|
-
logger$
|
|
9077
|
+
logger$4.info('WebRTC phone - change video input device', { deviceId: id });
|
|
9008
9078
|
|
|
9009
9079
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
9010
9080
|
}
|
|
9011
9081
|
|
|
9012
9082
|
changeSessionVideoInputDevice(id ) {
|
|
9013
|
-
logger$
|
|
9083
|
+
logger$4.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
9014
9084
|
|
|
9015
9085
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
9016
9086
|
}
|
|
9017
9087
|
|
|
9018
9088
|
_onCallTerminated(sipSession ) {
|
|
9019
|
-
logger$
|
|
9089
|
+
logger$4.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9020
9090
|
|
|
9021
9091
|
const callSession = this._createCallSession(sipSession);
|
|
9022
9092
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -9050,7 +9120,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9050
9120
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
9051
9121
|
|
|
9052
9122
|
// Re-trigger incoming call event for remaining incoming calls
|
|
9053
|
-
logger$
|
|
9123
|
+
logger$4.info('WebRTC phone - check to re-trigger incoming call', {
|
|
9054
9124
|
sipId: sipSession.id,
|
|
9055
9125
|
shouldRetrigger,
|
|
9056
9126
|
hasIncomingCallSession,
|
|
@@ -9141,37 +9211,37 @@ class WebRTCPhone extends Emitter {
|
|
|
9141
9211
|
|
|
9142
9212
|
// Deprecated
|
|
9143
9213
|
getLocalStreamForCall(callSession ) {
|
|
9144
|
-
logger$
|
|
9214
|
+
logger$4.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9145
9215
|
|
|
9146
9216
|
return this.getLocalStream(callSession);
|
|
9147
9217
|
}
|
|
9148
9218
|
|
|
9149
9219
|
// Deprecated
|
|
9150
9220
|
getRemoteStreamForCall(callSession ) {
|
|
9151
|
-
logger$
|
|
9221
|
+
logger$4.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
9152
9222
|
|
|
9153
9223
|
return this.getRemoteVideoStream(callSession);
|
|
9154
9224
|
}
|
|
9155
9225
|
|
|
9156
9226
|
getRemoteStreamsForCall(callSession ) {
|
|
9157
|
-
logger$
|
|
9227
|
+
logger$4.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
9158
9228
|
|
|
9159
9229
|
return this.getRemoteStream(callSession);
|
|
9160
9230
|
}
|
|
9161
9231
|
|
|
9162
9232
|
accept(callSession , cameraEnabled ) {
|
|
9163
|
-
logger$
|
|
9233
|
+
logger$4.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
9164
9234
|
if (this.currentSipSession) {
|
|
9165
9235
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
9166
9236
|
}
|
|
9167
9237
|
|
|
9168
9238
|
if (!callSession) {
|
|
9169
|
-
logger$
|
|
9239
|
+
logger$4.warn('no CallSession to accept.');
|
|
9170
9240
|
return Promise.resolve(null);
|
|
9171
9241
|
}
|
|
9172
9242
|
|
|
9173
9243
|
if (callSession.getId() in this.acceptedSessions) {
|
|
9174
|
-
logger$
|
|
9244
|
+
logger$4.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9175
9245
|
return Promise.resolve(callSession.sipCallId);
|
|
9176
9246
|
}
|
|
9177
9247
|
|
|
@@ -9183,24 +9253,24 @@ class WebRTCPhone extends Emitter {
|
|
|
9183
9253
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
9184
9254
|
if (sipSession) {
|
|
9185
9255
|
if (sipSession.state === SessionState.Terminated || sipSession.state === SessionState.Terminating) {
|
|
9186
|
-
logger$
|
|
9256
|
+
logger$4.warn('Trying to answer a terminated sipSession.');
|
|
9187
9257
|
|
|
9188
9258
|
return Promise.resolve(null);
|
|
9189
9259
|
}
|
|
9190
9260
|
|
|
9191
|
-
logger$
|
|
9261
|
+
logger$4.info('accept call, session found', { sipId: sipSession.id });
|
|
9192
9262
|
|
|
9193
9263
|
// $FlowFixMe
|
|
9194
9264
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
9195
9265
|
return callSession.sipCallId;
|
|
9196
9266
|
}).catch(e => {
|
|
9197
|
-
logger$
|
|
9267
|
+
logger$4.error(e);
|
|
9198
9268
|
this.endCurrentCall(callSession);
|
|
9199
9269
|
throw e;
|
|
9200
9270
|
});
|
|
9201
9271
|
}
|
|
9202
9272
|
|
|
9203
|
-
logger$
|
|
9273
|
+
logger$4.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9204
9274
|
|
|
9205
9275
|
return Promise.resolve(null);
|
|
9206
9276
|
}
|
|
@@ -9210,7 +9280,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9210
9280
|
}
|
|
9211
9281
|
|
|
9212
9282
|
async reject(callSession ) {
|
|
9213
|
-
logger$
|
|
9283
|
+
logger$4.info('reject WebRTC called', { id: callSession.getId() });
|
|
9214
9284
|
|
|
9215
9285
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
9216
9286
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -9222,14 +9292,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9222
9292
|
|
|
9223
9293
|
const sipSession = this.findSipSession(callSession);
|
|
9224
9294
|
if (sipSession) {
|
|
9225
|
-
logger$
|
|
9295
|
+
logger$4.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
9226
9296
|
|
|
9227
9297
|
this.client.hangup(sipSession);
|
|
9228
9298
|
}
|
|
9229
9299
|
}
|
|
9230
9300
|
|
|
9231
9301
|
async ignore(callSession ) {
|
|
9232
|
-
logger$
|
|
9302
|
+
logger$4.info('WebRTC ignore', { id: callSession.getId() });
|
|
9233
9303
|
|
|
9234
9304
|
// kill the ring
|
|
9235
9305
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -9241,14 +9311,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9241
9311
|
const sipSession = this.findSipSession(callSession);
|
|
9242
9312
|
|
|
9243
9313
|
if (sipSession) {
|
|
9244
|
-
logger$
|
|
9314
|
+
logger$4.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
9245
9315
|
|
|
9246
9316
|
return this.client.atxfer(sipSession);
|
|
9247
9317
|
}
|
|
9248
9318
|
}
|
|
9249
9319
|
|
|
9250
9320
|
hold(callSession , withEvent = true, isConference = false) {
|
|
9251
|
-
logger$
|
|
9321
|
+
logger$4.info('WebRTC hold', { id: callSession.getId() });
|
|
9252
9322
|
|
|
9253
9323
|
const sipSession = this.findSipSession(callSession);
|
|
9254
9324
|
|
|
@@ -9263,18 +9333,18 @@ class WebRTCPhone extends Emitter {
|
|
|
9263
9333
|
}
|
|
9264
9334
|
|
|
9265
9335
|
resume(callSession , isConference = false, withEvent = true) {
|
|
9266
|
-
logger$
|
|
9336
|
+
logger$4.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
9267
9337
|
|
|
9268
9338
|
const sipSession = this.findSipSession(callSession);
|
|
9269
9339
|
if (!sipSession) {
|
|
9270
9340
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
9271
9341
|
}
|
|
9272
9342
|
|
|
9273
|
-
logger$
|
|
9343
|
+
logger$4.info('WebRTC resuming', { sipId: sipSession.id });
|
|
9274
9344
|
|
|
9275
9345
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
9276
9346
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
9277
|
-
logger$
|
|
9347
|
+
logger$4.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
9278
9348
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
9279
9349
|
}
|
|
9280
9350
|
|
|
@@ -9299,7 +9369,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9299
9369
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9300
9370
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
9301
9371
|
|
|
9302
|
-
logger$
|
|
9372
|
+
logger$4.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9303
9373
|
|
|
9304
9374
|
// Stop screenshre if needed
|
|
9305
9375
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -9330,7 +9400,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9330
9400
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
9331
9401
|
}
|
|
9332
9402
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9333
|
-
logger$
|
|
9403
|
+
logger$4.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
9334
9404
|
|
|
9335
9405
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
9336
9406
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -9374,14 +9444,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9374
9444
|
}
|
|
9375
9445
|
|
|
9376
9446
|
mute(callSession , withEvent = true) {
|
|
9377
|
-
logger$
|
|
9447
|
+
logger$4.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
9378
9448
|
|
|
9379
9449
|
const sipSession = this.findSipSession(callSession);
|
|
9380
9450
|
if (!sipSession) {
|
|
9381
9451
|
return;
|
|
9382
9452
|
}
|
|
9383
9453
|
|
|
9384
|
-
logger$
|
|
9454
|
+
logger$4.info('WebRTC muting', { sipId: sipSession.id });
|
|
9385
9455
|
this.client.mute(sipSession);
|
|
9386
9456
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
9387
9457
|
|
|
@@ -9395,14 +9465,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9395
9465
|
}
|
|
9396
9466
|
|
|
9397
9467
|
unmute(callSession , withEvent = true) {
|
|
9398
|
-
logger$
|
|
9468
|
+
logger$4.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
9399
9469
|
|
|
9400
9470
|
const sipSession = this.findSipSession(callSession);
|
|
9401
9471
|
if (!sipSession) {
|
|
9402
9472
|
return;
|
|
9403
9473
|
}
|
|
9404
9474
|
|
|
9405
|
-
logger$
|
|
9475
|
+
logger$4.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
9406
9476
|
this.client.unmute(sipSession);
|
|
9407
9477
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
9408
9478
|
|
|
@@ -9429,7 +9499,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9429
9499
|
if (!sipSession) {
|
|
9430
9500
|
return;
|
|
9431
9501
|
}
|
|
9432
|
-
logger$
|
|
9502
|
+
logger$4.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
9433
9503
|
|
|
9434
9504
|
this.client.toggleCameraOn(sipSession);
|
|
9435
9505
|
|
|
@@ -9441,7 +9511,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9441
9511
|
if (!sipSession) {
|
|
9442
9512
|
return;
|
|
9443
9513
|
}
|
|
9444
|
-
logger$
|
|
9514
|
+
logger$4.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
9445
9515
|
|
|
9446
9516
|
this.client.toggleCameraOff(sipSession);
|
|
9447
9517
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -9453,7 +9523,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9453
9523
|
return;
|
|
9454
9524
|
}
|
|
9455
9525
|
|
|
9456
|
-
logger$
|
|
9526
|
+
logger$4.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
9457
9527
|
this.client.sendDTMF(sipSession, tone);
|
|
9458
9528
|
}
|
|
9459
9529
|
|
|
@@ -9461,7 +9531,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9461
9531
|
// @TODO: line is not used here
|
|
9462
9532
|
async makeCall(number , line , cameraEnabled ,
|
|
9463
9533
|
audioOnly = false, conference = false) {
|
|
9464
|
-
logger$
|
|
9534
|
+
logger$4.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
9465
9535
|
if (!number) {
|
|
9466
9536
|
return Promise.resolve(null);
|
|
9467
9537
|
}
|
|
@@ -9471,7 +9541,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9471
9541
|
}
|
|
9472
9542
|
if (this.currentSipSession) {
|
|
9473
9543
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
9474
|
-
logger$
|
|
9544
|
+
logger$4.warn('Unable to hold current session when making another call', e);
|
|
9475
9545
|
});
|
|
9476
9546
|
}
|
|
9477
9547
|
|
|
@@ -9481,7 +9551,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9481
9551
|
this._bindEvents(sipSession);
|
|
9482
9552
|
} catch (error) {
|
|
9483
9553
|
console.warn(error);
|
|
9484
|
-
logger$
|
|
9554
|
+
logger$4.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
9485
9555
|
return Promise.resolve(null);
|
|
9486
9556
|
}
|
|
9487
9557
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -9509,7 +9579,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9509
9579
|
return;
|
|
9510
9580
|
}
|
|
9511
9581
|
|
|
9512
|
-
logger$
|
|
9582
|
+
logger$4.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
9513
9583
|
|
|
9514
9584
|
this.client.transfer(sipSession, target);
|
|
9515
9585
|
}
|
|
@@ -9518,7 +9588,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9518
9588
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
9519
9589
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
9520
9590
|
|
|
9521
|
-
logger$
|
|
9591
|
+
logger$4.info('WebRTC indirect transfer', {
|
|
9522
9592
|
sipId: sipSession ? sipSession.id : null,
|
|
9523
9593
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
9524
9594
|
});
|
|
@@ -9557,7 +9627,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9557
9627
|
return false;
|
|
9558
9628
|
}
|
|
9559
9629
|
|
|
9560
|
-
logger$
|
|
9630
|
+
logger$4.info('WebRTC hangup', { sipId: sipSession.id });
|
|
9561
9631
|
|
|
9562
9632
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9563
9633
|
|
|
@@ -9603,7 +9673,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9603
9673
|
endCurrentCall(callSession ) {
|
|
9604
9674
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
9605
9675
|
|
|
9606
|
-
logger$
|
|
9676
|
+
logger$4.info('Ending current call', {
|
|
9607
9677
|
id: callSession ? callSession.getId() : null,
|
|
9608
9678
|
isCurrent,
|
|
9609
9679
|
});
|
|
@@ -9627,7 +9697,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9627
9697
|
}
|
|
9628
9698
|
|
|
9629
9699
|
async close() {
|
|
9630
|
-
logger$
|
|
9700
|
+
logger$4.info('WebRTC close');
|
|
9631
9701
|
|
|
9632
9702
|
try {
|
|
9633
9703
|
await Promise.race([
|
|
@@ -9635,7 +9705,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9635
9705
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
9636
9706
|
]);
|
|
9637
9707
|
} catch (e) {
|
|
9638
|
-
logger$
|
|
9708
|
+
logger$4.error('WebRTC close, unregister error', e);
|
|
9639
9709
|
}
|
|
9640
9710
|
|
|
9641
9711
|
this.client.close();
|
|
@@ -9653,12 +9723,12 @@ class WebRTCPhone extends Emitter {
|
|
|
9653
9723
|
}
|
|
9654
9724
|
|
|
9655
9725
|
enableRinging() {
|
|
9656
|
-
logger$
|
|
9726
|
+
logger$4.info('WebRTC enable ringing');
|
|
9657
9727
|
this.ringingEnabled = true;
|
|
9658
9728
|
}
|
|
9659
9729
|
|
|
9660
9730
|
disableRinging() {
|
|
9661
|
-
logger$
|
|
9731
|
+
logger$4.info('WebRTC disable ringing');
|
|
9662
9732
|
this.ringingEnabled = false;
|
|
9663
9733
|
}
|
|
9664
9734
|
|
|
@@ -9698,7 +9768,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9698
9768
|
|
|
9699
9769
|
// Deprecated
|
|
9700
9770
|
getLocalMediaStream(callSession ) {
|
|
9701
|
-
logger$
|
|
9771
|
+
logger$4.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9702
9772
|
return this.getLocalStream(callSession);
|
|
9703
9773
|
}
|
|
9704
9774
|
|
|
@@ -9718,6 +9788,10 @@ class WebRTCPhone extends Emitter {
|
|
|
9718
9788
|
return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
|
|
9719
9789
|
}
|
|
9720
9790
|
|
|
9791
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
9792
|
+
return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
|
|
9793
|
+
}
|
|
9794
|
+
|
|
9721
9795
|
hasRemoteVideo(callSession ) {
|
|
9722
9796
|
return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
|
|
9723
9797
|
}
|
|
@@ -9736,7 +9810,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9736
9810
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
9737
9811
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
9738
9812
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
9739
|
-
logger$
|
|
9813
|
+
logger$4.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
9740
9814
|
|
|
9741
9815
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
9742
9816
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -9759,7 +9833,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9759
9833
|
});
|
|
9760
9834
|
|
|
9761
9835
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
9762
|
-
logger$
|
|
9836
|
+
logger$4.info('WebRTC on reinvite', {
|
|
9763
9837
|
sessionId: args[0].id,
|
|
9764
9838
|
inviteId: args[1].id,
|
|
9765
9839
|
updatedCalleeName: args[2],
|
|
@@ -9779,7 +9853,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9779
9853
|
});
|
|
9780
9854
|
|
|
9781
9855
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
9782
|
-
logger$
|
|
9856
|
+
logger$4.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
9783
9857
|
|
|
9784
9858
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
9785
9859
|
|
|
@@ -9790,22 +9864,22 @@ class WebRTCPhone extends Emitter {
|
|
|
9790
9864
|
this.client.on('ended', () => {});
|
|
9791
9865
|
|
|
9792
9866
|
this.client.on(this.client.ON_ERROR, e => {
|
|
9793
|
-
logger$
|
|
9867
|
+
logger$4.error('WebRTC error', e);
|
|
9794
9868
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
9795
9869
|
});
|
|
9796
9870
|
|
|
9797
9871
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
9798
|
-
logger$
|
|
9872
|
+
logger$4.info('WebRTC unregistered');
|
|
9799
9873
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
9800
9874
|
});
|
|
9801
9875
|
|
|
9802
9876
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
9803
|
-
logger$
|
|
9804
|
-
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
9877
|
+
logger$4.info('WebRTC disconnected');
|
|
9878
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
9805
9879
|
});
|
|
9806
9880
|
|
|
9807
9881
|
this.client.on(this.client.REGISTERED, () => {
|
|
9808
|
-
logger$
|
|
9882
|
+
logger$4.info('WebRTC registered', {
|
|
9809
9883
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
9810
9884
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
9811
9885
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -9818,23 +9892,27 @@ class WebRTCPhone extends Emitter {
|
|
|
9818
9892
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
9819
9893
|
&& this.currentSipSession.state === SessionState.Established) {
|
|
9820
9894
|
this.shouldSendReinvite = false;
|
|
9895
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
9896
|
+
const isConference = pc ? pc.sfu : false;
|
|
9897
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
9898
|
+
|
|
9821
9899
|
try {
|
|
9822
9900
|
// Send reinvite with iceRestart
|
|
9823
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
9901
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
9824
9902
|
} catch (e) {
|
|
9825
|
-
logger$
|
|
9903
|
+
logger$4.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
9826
9904
|
}
|
|
9827
9905
|
}
|
|
9828
9906
|
});
|
|
9829
9907
|
|
|
9830
9908
|
this.client.on(this.client.CONNECTED, () => {
|
|
9831
|
-
logger$
|
|
9909
|
+
logger$4.info('WebRTC client connected');
|
|
9832
9910
|
|
|
9833
9911
|
this.stopHeartbeat();
|
|
9834
9912
|
});
|
|
9835
9913
|
|
|
9836
9914
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
9837
|
-
logger$
|
|
9915
|
+
logger$4.info('WebRTC client disconnected');
|
|
9838
9916
|
|
|
9839
9917
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
9840
9918
|
|
|
@@ -9848,7 +9926,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9848
9926
|
});
|
|
9849
9927
|
|
|
9850
9928
|
this.client.on(this.client.ON_TRACK, (session, event) => {
|
|
9851
|
-
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
9929
|
+
this.eventEmitter.emit(ON_TRACK$1, session, event);
|
|
9852
9930
|
});
|
|
9853
9931
|
|
|
9854
9932
|
this.client.on('onVideoInputChange', stream => {
|
|
@@ -9863,7 +9941,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9863
9941
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
9864
9942
|
const callSession = this.getCallSession(this.getSipSessionId(session));
|
|
9865
9943
|
|
|
9866
|
-
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
9944
|
+
this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
|
|
9867
9945
|
});
|
|
9868
9946
|
|
|
9869
9947
|
// Used when upgrading directly in screenshare mode
|
|
@@ -9872,7 +9950,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9872
9950
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
9873
9951
|
const callSession = this.callSessions[sipSessionId];
|
|
9874
9952
|
|
|
9875
|
-
logger$
|
|
9953
|
+
logger$4.info('Updrading directly in screensharing mode', {
|
|
9876
9954
|
sipSessionId,
|
|
9877
9955
|
tracks: localStream ? localStream.getTracks() : null,
|
|
9878
9956
|
});
|
|
@@ -9904,6 +9982,15 @@ class WebRTCPhone extends Emitter {
|
|
|
9904
9982
|
return this.client.getSipSessionId(sipSession);
|
|
9905
9983
|
}
|
|
9906
9984
|
|
|
9985
|
+
_updateCallSession(callSession ) {
|
|
9986
|
+
const sipSession = this.findSipSession(callSession);
|
|
9987
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
9988
|
+
|
|
9989
|
+
if (sipSessionId) {
|
|
9990
|
+
this.callSessions[sipSessionId] = callSession;
|
|
9991
|
+
}
|
|
9992
|
+
}
|
|
9993
|
+
|
|
9907
9994
|
_onMessage(message ) {
|
|
9908
9995
|
if (!message || message.method !== 'MESSAGE') {
|
|
9909
9996
|
return;
|
|
@@ -10041,8 +10128,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10041
10128
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10042
10129
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10043
10130
|
ON_MESSAGE: ON_MESSAGE,
|
|
10044
|
-
ON_REINVITE: ON_REINVITE,
|
|
10045
|
-
ON_TRACK: ON_TRACK,
|
|
10131
|
+
ON_REINVITE: ON_REINVITE$1,
|
|
10132
|
+
ON_TRACK: ON_TRACK$1,
|
|
10046
10133
|
ON_AUDIO_STREAM: ON_AUDIO_STREAM,
|
|
10047
10134
|
ON_VIDEO_STREAM: ON_VIDEO_STREAM,
|
|
10048
10135
|
ON_REMOVE_STREAM: ON_REMOVE_STREAM,
|
|
@@ -10057,13 +10144,13 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10057
10144
|
ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
|
|
10058
10145
|
ON_CALL_ERROR: ON_CALL_ERROR,
|
|
10059
10146
|
ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
|
|
10060
|
-
ON_NETWORK_STATS: ON_NETWORK_STATS,
|
|
10147
|
+
ON_NETWORK_STATS: ON_NETWORK_STATS$1,
|
|
10061
10148
|
ON_CHAT: ON_CHAT,
|
|
10062
10149
|
ON_SIGNAL: ON_SIGNAL,
|
|
10063
|
-
ON_DISCONNECTED: ON_DISCONNECTED,
|
|
10150
|
+
ON_DISCONNECTED: ON_DISCONNECTED$1,
|
|
10064
10151
|
MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
|
|
10065
10152
|
MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
|
|
10066
|
-
events: events,
|
|
10153
|
+
events: events$1,
|
|
10067
10154
|
'default': WebRTCPhone
|
|
10068
10155
|
});
|
|
10069
10156
|
|
|
@@ -10072,7 +10159,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10072
10159
|
class InvalidSubscription extends Error {}
|
|
10073
10160
|
class InvalidAuthorization extends Error {}
|
|
10074
10161
|
|
|
10075
|
-
const logger$
|
|
10162
|
+
const logger$5 = IssueReporter$1.loggerFor('simple-auth');
|
|
10076
10163
|
|
|
10077
10164
|
class Auth {
|
|
10078
10165
|
|
|
@@ -10107,7 +10194,7 @@ class Auth {
|
|
|
10107
10194
|
setApiClientId(this.clientId);
|
|
10108
10195
|
setRefreshExpiration(this.expiration);
|
|
10109
10196
|
setOnRefreshToken((token , session ) => {
|
|
10110
|
-
logger$
|
|
10197
|
+
logger$5.info('on refresh token done', { token });
|
|
10111
10198
|
setApiToken(token);
|
|
10112
10199
|
Wazo.Websocket.updateToken(token);
|
|
10113
10200
|
|
|
@@ -10152,7 +10239,7 @@ class Auth {
|
|
|
10152
10239
|
const rawSession = await getApiClient().auth.authenticate(token);
|
|
10153
10240
|
return this._onAuthenticated(rawSession);
|
|
10154
10241
|
} catch (e) {
|
|
10155
|
-
logger$
|
|
10242
|
+
logger$5.error('on validate token error', e);
|
|
10156
10243
|
console.warn(e);
|
|
10157
10244
|
return false;
|
|
10158
10245
|
}
|
|
@@ -10333,7 +10420,7 @@ var Auth$1 = global.wazoAuthInstance;
|
|
|
10333
10420
|
|
|
10334
10421
|
//
|
|
10335
10422
|
|
|
10336
|
-
const SOCKET_EVENTS
|
|
10423
|
+
const SOCKET_EVENTS = {
|
|
10337
10424
|
ON_OPEN: 'onopen',
|
|
10338
10425
|
ON_MESSAGE: 'onmessage',
|
|
10339
10426
|
ON_ERROR: 'onerror',
|
|
@@ -10419,6 +10506,7 @@ const AGENT_PAUSED = 'agent_paused';
|
|
|
10419
10506
|
const AGENT_UNPAUSED = 'agent_unpaused';
|
|
10420
10507
|
const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
|
|
10421
10508
|
const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
|
|
10509
|
+
const MEETING_USER_PROGRESS = 'meeting_user_progress';
|
|
10422
10510
|
|
|
10423
10511
|
const BLACKLIST_EVENTS = [
|
|
10424
10512
|
CHAT_MESSAGE_SENT,
|
|
@@ -10485,16 +10573,16 @@ class WebSocketClient extends Emitter {
|
|
|
10485
10573
|
|
|
10486
10574
|
this.socket.onopen = () => {
|
|
10487
10575
|
logger$6.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
10488
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10576
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
10489
10577
|
};
|
|
10490
10578
|
|
|
10491
10579
|
this.socket.onerror = event => {
|
|
10492
10580
|
logger$6.error('on Wazo WS error', event.target);
|
|
10493
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10581
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
10494
10582
|
};
|
|
10495
10583
|
|
|
10496
10584
|
this.socket.onmessage = (event ) => {
|
|
10497
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10585
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
|
|
10498
10586
|
|
|
10499
10587
|
const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
|
|
10500
10588
|
let { name } = message;
|
|
@@ -10527,11 +10615,11 @@ class WebSocketClient extends Emitter {
|
|
|
10527
10615
|
token: this.token,
|
|
10528
10616
|
});
|
|
10529
10617
|
this.initialized = false;
|
|
10530
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10618
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
|
|
10531
10619
|
|
|
10532
10620
|
switch (event.code) {
|
|
10533
10621
|
case 4002:
|
|
10534
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10622
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
|
|
10535
10623
|
break;
|
|
10536
10624
|
}
|
|
10537
10625
|
};
|
|
@@ -10647,7 +10735,7 @@ class WebSocketClient extends Emitter {
|
|
|
10647
10735
|
break;
|
|
10648
10736
|
case 'start':
|
|
10649
10737
|
this.initialized = true;
|
|
10650
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10738
|
+
this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
|
|
10651
10739
|
break;
|
|
10652
10740
|
default:
|
|
10653
10741
|
this.eventEmitter.emit('message', message);
|
|
@@ -10694,7 +10782,7 @@ class WebSocketClient extends Emitter {
|
|
|
10694
10782
|
logger$6.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
10695
10783
|
|
|
10696
10784
|
this.close();
|
|
10697
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10785
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
10698
10786
|
|
|
10699
10787
|
if (this.onHeartBeatTimeout) {
|
|
10700
10788
|
this.onHeartBeatTimeout();
|
|
@@ -10769,11 +10857,12 @@ WebSocketClient.eventLists = [
|
|
|
10769
10857
|
AGENT_UNPAUSED,
|
|
10770
10858
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
10771
10859
|
CONFERENCE_ADHOC_DELETED,
|
|
10860
|
+
MEETING_USER_PROGRESS,
|
|
10772
10861
|
];
|
|
10773
10862
|
|
|
10774
10863
|
var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
10775
10864
|
__proto__: null,
|
|
10776
|
-
SOCKET_EVENTS: SOCKET_EVENTS
|
|
10865
|
+
SOCKET_EVENTS: SOCKET_EVENTS,
|
|
10777
10866
|
AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
|
|
10778
10867
|
FAVORITE_ADDED: FAVORITE_ADDED,
|
|
10779
10868
|
FAVORITE_DELETED: FAVORITE_DELETED,
|
|
@@ -10839,16 +10928,17 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
10839
10928
|
AGENT_UNPAUSED: AGENT_UNPAUSED,
|
|
10840
10929
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
10841
10930
|
CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
|
|
10931
|
+
MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
|
|
10842
10932
|
HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
|
|
10843
10933
|
'default': WebSocketClient
|
|
10844
10934
|
});
|
|
10845
10935
|
|
|
10846
10936
|
//
|
|
10847
10937
|
|
|
10848
|
-
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
10849
|
-
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
10938
|
+
const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
10939
|
+
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
|
|
10850
10940
|
|
|
10851
|
-
const logger$
|
|
10941
|
+
const logger$7 = IssueReporter$1.loggerFor('simple-ws-client');
|
|
10852
10942
|
|
|
10853
10943
|
class Websocket extends Emitter {
|
|
10854
10944
|
|
|
@@ -10862,9 +10952,9 @@ class Websocket extends Emitter {
|
|
|
10862
10952
|
// $FlowFixMe
|
|
10863
10953
|
this[key] = OTHER_EVENTS[key];
|
|
10864
10954
|
});
|
|
10865
|
-
Object.keys(SOCKET_EVENTS).forEach(key => {
|
|
10955
|
+
Object.keys(SOCKET_EVENTS$1).forEach(key => {
|
|
10866
10956
|
// $FlowFixMe
|
|
10867
|
-
this[key] = SOCKET_EVENTS[key];
|
|
10957
|
+
this[key] = SOCKET_EVENTS$1[key];
|
|
10868
10958
|
});
|
|
10869
10959
|
this.eventLists = WebSocketClient.eventLists;
|
|
10870
10960
|
|
|
@@ -10872,7 +10962,7 @@ class Websocket extends Emitter {
|
|
|
10872
10962
|
}
|
|
10873
10963
|
|
|
10874
10964
|
open(host , session ) {
|
|
10875
|
-
logger$
|
|
10965
|
+
logger$7.info('open simple WebSocket', { host, token: session.token });
|
|
10876
10966
|
this.ws = new WebSocketClient(
|
|
10877
10967
|
{
|
|
10878
10968
|
host,
|
|
@@ -10900,7 +10990,7 @@ class Websocket extends Emitter {
|
|
|
10900
10990
|
}
|
|
10901
10991
|
|
|
10902
10992
|
updateToken(token ) {
|
|
10903
|
-
logger$
|
|
10993
|
+
logger$7.info('update token via simple Websocket', { token, ws: !!this.ws });
|
|
10904
10994
|
|
|
10905
10995
|
if (!this.ws) {
|
|
10906
10996
|
return;
|
|
@@ -10928,7 +11018,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
|
|
|
10928
11018
|
|
|
10929
11019
|
//
|
|
10930
11020
|
|
|
10931
|
-
const logger$
|
|
11021
|
+
const logger$8 = IssueReporter$1.loggerFor('room');
|
|
10932
11022
|
|
|
10933
11023
|
class Participant extends Emitter {
|
|
10934
11024
|
|
|
@@ -11050,7 +11140,7 @@ class Participant extends Emitter {
|
|
|
11050
11140
|
}
|
|
11051
11141
|
|
|
11052
11142
|
onTalking(isTalking ) {
|
|
11053
|
-
logger$
|
|
11143
|
+
logger$8.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
|
|
11054
11144
|
this.isTalking = isTalking;
|
|
11055
11145
|
// you may notice we're not broadcasting: since all participants are getting this info
|
|
11056
11146
|
// directly from asterisk, there's no need to do so
|
|
@@ -11153,7 +11243,7 @@ class Participant extends Emitter {
|
|
|
11153
11243
|
}
|
|
11154
11244
|
|
|
11155
11245
|
updateStatus(status , broadcast = true) {
|
|
11156
|
-
logger$
|
|
11246
|
+
logger$8.info('updating participant status', { name: this.name, status });
|
|
11157
11247
|
|
|
11158
11248
|
if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
|
|
11159
11249
|
if (status.audioMuted) {
|
|
@@ -11201,7 +11291,7 @@ class Participant extends Emitter {
|
|
|
11201
11291
|
|
|
11202
11292
|
broadcastStatus(inboundStatus = null) {
|
|
11203
11293
|
const status = inboundStatus || this.getStatus();
|
|
11204
|
-
logger$
|
|
11294
|
+
logger$8.info('broadcasting participant status', { callId: this.callId, status });
|
|
11205
11295
|
|
|
11206
11296
|
this.room.sendSignal({
|
|
11207
11297
|
type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
|
|
@@ -11237,9 +11327,9 @@ class LocalParticipant extends Participant {
|
|
|
11237
11327
|
const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
11238
11328
|
const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
11239
11329
|
|
|
11240
|
-
const logger$
|
|
11330
|
+
const logger$9 = IssueReporter$1.loggerFor('sdk-room');
|
|
11241
11331
|
|
|
11242
|
-
class Room
|
|
11332
|
+
class Room extends Emitter {
|
|
11243
11333
|
|
|
11244
11334
|
|
|
11245
11335
|
|
|
@@ -11297,7 +11387,7 @@ class Room$1 extends Emitter {
|
|
|
11297
11387
|
extra = {},
|
|
11298
11388
|
) {
|
|
11299
11389
|
super();
|
|
11300
|
-
logger$
|
|
11390
|
+
logger$9.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
11301
11391
|
|
|
11302
11392
|
// Represents the room callSession
|
|
11303
11393
|
this.callSession = callSession;
|
|
@@ -11363,7 +11453,7 @@ class Room$1 extends Emitter {
|
|
|
11363
11453
|
* @returns {Promise<Room>}
|
|
11364
11454
|
*/
|
|
11365
11455
|
static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
|
|
11366
|
-
logger$
|
|
11456
|
+
logger$9.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
11367
11457
|
|
|
11368
11458
|
if (!room) {
|
|
11369
11459
|
await Wazo.Phone.connect();
|
|
@@ -11376,7 +11466,7 @@ class Room$1 extends Emitter {
|
|
|
11376
11466
|
|
|
11377
11467
|
// Call_created is triggered before call_accepted, so we have to listen for it here.
|
|
11378
11468
|
Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
|
|
11379
|
-
logger$
|
|
11469
|
+
logger$9.info('room call received via WS', { callId: data.call_id });
|
|
11380
11470
|
if (room) {
|
|
11381
11471
|
room.setCallId(data.call_id);
|
|
11382
11472
|
}
|
|
@@ -11384,7 +11474,7 @@ class Room$1 extends Emitter {
|
|
|
11384
11474
|
|
|
11385
11475
|
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
11386
11476
|
// eslint-disable-next-line no-param-reassign
|
|
11387
|
-
room = new Room
|
|
11477
|
+
room = new Room(callSession, extension, null, null, extra);
|
|
11388
11478
|
|
|
11389
11479
|
// Wait for the call to be accepted
|
|
11390
11480
|
await new Promise((resolve, reject) => {
|
|
@@ -11405,7 +11495,7 @@ class Room$1 extends Emitter {
|
|
|
11405
11495
|
// Retrieve conference
|
|
11406
11496
|
const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
|
|
11407
11497
|
|
|
11408
|
-
logger$
|
|
11498
|
+
logger$9.info('connected to room', {
|
|
11409
11499
|
sourceId: conference ? conference.sourceId : null,
|
|
11410
11500
|
name: conference ? conference.name : null,
|
|
11411
11501
|
});
|
|
@@ -11415,7 +11505,7 @@ class Room$1 extends Emitter {
|
|
|
11415
11505
|
room.setName(conference.name);
|
|
11416
11506
|
}
|
|
11417
11507
|
} else if (meeting) {
|
|
11418
|
-
logger$
|
|
11508
|
+
logger$9.info('Already connected to meeting', {
|
|
11419
11509
|
uuid: meeting.uuid,
|
|
11420
11510
|
name: meeting.name,
|
|
11421
11511
|
});
|
|
@@ -11428,13 +11518,13 @@ class Room$1 extends Emitter {
|
|
|
11428
11518
|
}
|
|
11429
11519
|
|
|
11430
11520
|
static disconnect() {
|
|
11431
|
-
logger$
|
|
11521
|
+
logger$9.info('static disconnection to room');
|
|
11432
11522
|
|
|
11433
11523
|
Wazo.Phone.disconnect();
|
|
11434
11524
|
}
|
|
11435
11525
|
|
|
11436
11526
|
async disconnect() {
|
|
11437
|
-
logger$
|
|
11527
|
+
logger$9.info('disconnection to room called');
|
|
11438
11528
|
|
|
11439
11529
|
await Wazo.Phone.hangup(this.callSession);
|
|
11440
11530
|
this.callSession = null;
|
|
@@ -11454,19 +11544,19 @@ class Room$1 extends Emitter {
|
|
|
11454
11544
|
}
|
|
11455
11545
|
|
|
11456
11546
|
setSourceId(sourceId ) {
|
|
11457
|
-
logger$
|
|
11547
|
+
logger$9.info('set room source id', { sourceId });
|
|
11458
11548
|
|
|
11459
11549
|
this.sourceId = sourceId;
|
|
11460
11550
|
}
|
|
11461
11551
|
|
|
11462
11552
|
setMeetingUuid(meetingUuid ) {
|
|
11463
|
-
logger$
|
|
11553
|
+
logger$9.info('set meeting uuid', { meetingUuid });
|
|
11464
11554
|
|
|
11465
11555
|
this.meetingUuid = meetingUuid;
|
|
11466
11556
|
}
|
|
11467
11557
|
|
|
11468
11558
|
setCallId(callId ) {
|
|
11469
|
-
logger$
|
|
11559
|
+
logger$9.info('set room call id', { callId });
|
|
11470
11560
|
|
|
11471
11561
|
if (callId) {
|
|
11472
11562
|
this.callId = callId;
|
|
@@ -11474,7 +11564,7 @@ class Room$1 extends Emitter {
|
|
|
11474
11564
|
}
|
|
11475
11565
|
|
|
11476
11566
|
setName(name ) {
|
|
11477
|
-
logger$
|
|
11567
|
+
logger$9.info('set room name', { name });
|
|
11478
11568
|
|
|
11479
11569
|
this.name = name;
|
|
11480
11570
|
}
|
|
@@ -11493,7 +11583,7 @@ class Room$1 extends Emitter {
|
|
|
11493
11583
|
}
|
|
11494
11584
|
|
|
11495
11585
|
async startScreenSharing(constraints ) {
|
|
11496
|
-
logger$
|
|
11586
|
+
logger$9.info('start room screen sharing', { constraints });
|
|
11497
11587
|
|
|
11498
11588
|
const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
|
|
11499
11589
|
if (!screensharingStream) {
|
|
@@ -11507,7 +11597,7 @@ class Room$1 extends Emitter {
|
|
|
11507
11597
|
}
|
|
11508
11598
|
|
|
11509
11599
|
async stopScreenSharing(restoreLocalStream = true) {
|
|
11510
|
-
logger$
|
|
11600
|
+
logger$9.info('stop room screen sharing');
|
|
11511
11601
|
|
|
11512
11602
|
await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
11513
11603
|
|
|
@@ -11519,7 +11609,7 @@ class Room$1 extends Emitter {
|
|
|
11519
11609
|
}
|
|
11520
11610
|
|
|
11521
11611
|
turnCameraOff() {
|
|
11522
|
-
logger$
|
|
11612
|
+
logger$9.info('turn room camera off');
|
|
11523
11613
|
|
|
11524
11614
|
Wazo.Phone.turnCameraOff(this.callSession);
|
|
11525
11615
|
|
|
@@ -11529,7 +11619,7 @@ class Room$1 extends Emitter {
|
|
|
11529
11619
|
}
|
|
11530
11620
|
|
|
11531
11621
|
turnCameraOn() {
|
|
11532
|
-
logger$
|
|
11622
|
+
logger$9.info('turn room camera on');
|
|
11533
11623
|
|
|
11534
11624
|
Wazo.Phone.turnCameraOn(this.callSession);
|
|
11535
11625
|
|
|
@@ -11539,7 +11629,7 @@ class Room$1 extends Emitter {
|
|
|
11539
11629
|
}
|
|
11540
11630
|
|
|
11541
11631
|
mute() {
|
|
11542
|
-
logger$
|
|
11632
|
+
logger$9.info('mute room');
|
|
11543
11633
|
|
|
11544
11634
|
Wazo.Phone.mute(this.callSession);
|
|
11545
11635
|
|
|
@@ -11547,7 +11637,7 @@ class Room$1 extends Emitter {
|
|
|
11547
11637
|
}
|
|
11548
11638
|
|
|
11549
11639
|
unmute() {
|
|
11550
|
-
logger$
|
|
11640
|
+
logger$9.info('unmute room');
|
|
11551
11641
|
|
|
11552
11642
|
Wazo.Phone.unmute(this.callSession);
|
|
11553
11643
|
|
|
@@ -11567,7 +11657,7 @@ class Room$1 extends Emitter {
|
|
|
11567
11657
|
}
|
|
11568
11658
|
|
|
11569
11659
|
hold() {
|
|
11570
|
-
logger$
|
|
11660
|
+
logger$9.info('hold room');
|
|
11571
11661
|
|
|
11572
11662
|
Wazo.Phone.hold(this.callSession, true);
|
|
11573
11663
|
|
|
@@ -11577,7 +11667,7 @@ class Room$1 extends Emitter {
|
|
|
11577
11667
|
}
|
|
11578
11668
|
|
|
11579
11669
|
async resume() {
|
|
11580
|
-
logger$
|
|
11670
|
+
logger$9.info('resume room');
|
|
11581
11671
|
|
|
11582
11672
|
const newStream = await Wazo.Phone.resume(this.callSession, true);
|
|
11583
11673
|
|
|
@@ -11605,13 +11695,13 @@ class Room$1 extends Emitter {
|
|
|
11605
11695
|
}
|
|
11606
11696
|
|
|
11607
11697
|
sendDTMF(tone ) {
|
|
11608
|
-
logger$
|
|
11698
|
+
logger$9.info('send room DTMF', { tone });
|
|
11609
11699
|
|
|
11610
11700
|
Wazo.Phone.sendDTMF(tone, this.callSession);
|
|
11611
11701
|
}
|
|
11612
11702
|
|
|
11613
11703
|
async sendReinvite(newConstraints = null) {
|
|
11614
|
-
logger$
|
|
11704
|
+
logger$9.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
11615
11705
|
const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
|
|
11616
11706
|
|
|
11617
11707
|
Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
|
|
@@ -11670,7 +11760,7 @@ class Room$1 extends Emitter {
|
|
|
11670
11760
|
Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
11671
11761
|
|
|
11672
11762
|
this.on(this.ON_AUDIO_STREAM, stream => {
|
|
11673
|
-
logger$
|
|
11763
|
+
logger$9.info('on room audio stream');
|
|
11674
11764
|
|
|
11675
11765
|
this.audioStream = stream;
|
|
11676
11766
|
if (!this.roomAudioElement) {
|
|
@@ -11683,7 +11773,7 @@ class Room$1 extends Emitter {
|
|
|
11683
11773
|
});
|
|
11684
11774
|
|
|
11685
11775
|
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
11686
|
-
logger$
|
|
11776
|
+
logger$9.info('on room video stream', { streamId });
|
|
11687
11777
|
|
|
11688
11778
|
this._mapMsid(sipSession.body.body);
|
|
11689
11779
|
|
|
@@ -11698,7 +11788,7 @@ class Room$1 extends Emitter {
|
|
|
11698
11788
|
});
|
|
11699
11789
|
|
|
11700
11790
|
this.on(this.ON_REMOVE_STREAM, stream => {
|
|
11701
|
-
logger$
|
|
11791
|
+
logger$9.info('on room remove stream');
|
|
11702
11792
|
|
|
11703
11793
|
const participant = this.participants.find(someParticipant =>
|
|
11704
11794
|
someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
|
|
@@ -11830,7 +11920,7 @@ class Room$1 extends Emitter {
|
|
|
11830
11920
|
const requester = this._getParticipantFromCallId(origin.callId);
|
|
11831
11921
|
if (requester) {
|
|
11832
11922
|
// @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
|
|
11833
|
-
logger$
|
|
11923
|
+
logger$9.info('trigger room requester status', { origin });
|
|
11834
11924
|
requester.triggerUpdate('REQUESTER_UPDATE');
|
|
11835
11925
|
}
|
|
11836
11926
|
break;
|
|
@@ -11861,24 +11951,24 @@ class Room$1 extends Emitter {
|
|
|
11861
11951
|
|
|
11862
11952
|
// When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
|
|
11863
11953
|
if (participant.user_uuid === session.uuid) {
|
|
11864
|
-
logger$
|
|
11954
|
+
logger$9.info('room current user joined');
|
|
11865
11955
|
|
|
11866
11956
|
// Retrieve participants via an API calls
|
|
11867
11957
|
const conferenceId = this.sourceId || payload.data.conference_id;
|
|
11868
11958
|
let response;
|
|
11869
11959
|
try {
|
|
11870
11960
|
if (this.meetingUuid) {
|
|
11871
|
-
logger$
|
|
11961
|
+
logger$9.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
11872
11962
|
response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
|
|
11873
11963
|
} else {
|
|
11874
|
-
logger$
|
|
11964
|
+
logger$9.info('fetching conference participants', { conferenceId });
|
|
11875
11965
|
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
11876
11966
|
}
|
|
11877
11967
|
} catch (e) {
|
|
11878
|
-
logger$
|
|
11968
|
+
logger$9.error('room participants fetching, error', e);
|
|
11879
11969
|
}
|
|
11880
11970
|
if (response) {
|
|
11881
|
-
logger$
|
|
11971
|
+
logger$9.info('conference participants fetched', { nb: response.items.length });
|
|
11882
11972
|
participants = response.items.map(item => {
|
|
11883
11973
|
const isMe = item.call_id === this.callId;
|
|
11884
11974
|
|
|
@@ -11905,7 +11995,7 @@ class Room$1 extends Emitter {
|
|
|
11905
11995
|
? new Wazo.RemoteParticipant(this, participant)
|
|
11906
11996
|
: null;
|
|
11907
11997
|
|
|
11908
|
-
logger$
|
|
11998
|
+
logger$9.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
11909
11999
|
|
|
11910
12000
|
if (remoteParticipant) {
|
|
11911
12001
|
this.participants.push(remoteParticipant);
|
|
@@ -12070,12 +12160,12 @@ class Room$1 extends Emitter {
|
|
|
12070
12160
|
|
|
12071
12161
|
//
|
|
12072
12162
|
|
|
12073
|
-
const logger$
|
|
12163
|
+
const logger$a = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
12074
12164
|
|
|
12075
|
-
class SipRoom extends Room
|
|
12165
|
+
class SipRoom extends Room {
|
|
12076
12166
|
|
|
12077
12167
|
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
12078
|
-
logger$
|
|
12168
|
+
logger$a.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
12079
12169
|
|
|
12080
12170
|
if (!room) {
|
|
12081
12171
|
await Wazo.Phone.connect();
|
|
@@ -12091,7 +12181,7 @@ class SipRoom extends Room$1 {
|
|
|
12091
12181
|
room.setCallId(room.callSession.call.id);
|
|
12092
12182
|
}
|
|
12093
12183
|
|
|
12094
|
-
logger$
|
|
12184
|
+
logger$a.info('connected to room', {
|
|
12095
12185
|
extension: room.extension,
|
|
12096
12186
|
});
|
|
12097
12187
|
|
|
@@ -12099,7 +12189,7 @@ class SipRoom extends Room$1 {
|
|
|
12099
12189
|
}
|
|
12100
12190
|
|
|
12101
12191
|
mute() {
|
|
12102
|
-
logger$
|
|
12192
|
+
logger$a.info('mute sip room');
|
|
12103
12193
|
|
|
12104
12194
|
Wazo.Phone.mute(this.callSession, false);
|
|
12105
12195
|
|
|
@@ -12107,7 +12197,7 @@ class SipRoom extends Room$1 {
|
|
|
12107
12197
|
}
|
|
12108
12198
|
|
|
12109
12199
|
unmute() {
|
|
12110
|
-
logger$
|
|
12200
|
+
logger$a.info('unmute sip room');
|
|
12111
12201
|
|
|
12112
12202
|
Wazo.Phone.unmute(this.callSession, false);
|
|
12113
12203
|
|
|
@@ -12391,7 +12481,7 @@ class NotificationOptions {
|
|
|
12391
12481
|
|
|
12392
12482
|
|
|
12393
12483
|
// Represents a conference room, like `9000`.
|
|
12394
|
-
class Room {
|
|
12484
|
+
class Room$1 {
|
|
12395
12485
|
|
|
12396
12486
|
|
|
12397
12487
|
|
|
@@ -12412,7 +12502,7 @@ class Room {
|
|
|
12412
12502
|
}
|
|
12413
12503
|
|
|
12414
12504
|
connect(callSession ) {
|
|
12415
|
-
return new Room({ ...this, connectedCallSession: callSession });
|
|
12505
|
+
return new Room$1({ ...this, connectedCallSession: callSession });
|
|
12416
12506
|
}
|
|
12417
12507
|
|
|
12418
12508
|
has(callSession ) {
|
|
@@ -12421,7 +12511,7 @@ class Room {
|
|
|
12421
12511
|
|
|
12422
12512
|
addParticipant(uuid , extension , talking = null) {
|
|
12423
12513
|
if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
|
|
12424
|
-
return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
12514
|
+
return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
12425
12515
|
}
|
|
12426
12516
|
|
|
12427
12517
|
return this;
|
|
@@ -12440,7 +12530,7 @@ class Room {
|
|
|
12440
12530
|
updatedParticipants.push(participant);
|
|
12441
12531
|
}
|
|
12442
12532
|
|
|
12443
|
-
return new Room({ ...this, participants: updatedParticipants });
|
|
12533
|
+
return new Room$1({ ...this, participants: updatedParticipants });
|
|
12444
12534
|
}
|
|
12445
12535
|
|
|
12446
12536
|
updateParticipantByExtension(extension , participant , shouldAdd = false) {
|
|
@@ -12456,7 +12546,7 @@ class Room {
|
|
|
12456
12546
|
updatedParticipants.push(participant);
|
|
12457
12547
|
}
|
|
12458
12548
|
|
|
12459
|
-
return new Room({ ...this, participants: updatedParticipants });
|
|
12549
|
+
return new Room$1({ ...this, participants: updatedParticipants });
|
|
12460
12550
|
}
|
|
12461
12551
|
|
|
12462
12552
|
hasCallWithId(id ) {
|
|
@@ -12464,18 +12554,18 @@ class Room {
|
|
|
12464
12554
|
}
|
|
12465
12555
|
|
|
12466
12556
|
disconnect() {
|
|
12467
|
-
return new Room({ ...this, connectedCallSession: null });
|
|
12557
|
+
return new Room$1({ ...this, connectedCallSession: null });
|
|
12468
12558
|
}
|
|
12469
12559
|
|
|
12470
12560
|
removeParticipantWithUUID(uuid ) {
|
|
12471
|
-
return new Room({
|
|
12561
|
+
return new Room$1({
|
|
12472
12562
|
...this,
|
|
12473
12563
|
participants: this.participants.filter(participant => participant.uuid !== uuid),
|
|
12474
12564
|
});
|
|
12475
12565
|
}
|
|
12476
12566
|
|
|
12477
12567
|
removeParticipantWithExtension(extension ) {
|
|
12478
|
-
return new Room({
|
|
12568
|
+
return new Room$1({
|
|
12479
12569
|
...this,
|
|
12480
12570
|
participants: this.participants.filter(participant => participant.extension !== extension),
|
|
12481
12571
|
});
|
|
@@ -12486,7 +12576,7 @@ class Room {
|
|
|
12486
12576
|
}
|
|
12487
12577
|
|
|
12488
12578
|
static newFrom(room ) {
|
|
12489
|
-
return newFrom(room, Room);
|
|
12579
|
+
return newFrom(room, Room$1);
|
|
12490
12580
|
}
|
|
12491
12581
|
}
|
|
12492
12582
|
|
|
@@ -12793,11 +12883,11 @@ var wazoWebsocket = {
|
|
|
12793
12883
|
resolve();
|
|
12794
12884
|
};
|
|
12795
12885
|
|
|
12796
|
-
client.on(SOCKET_EVENTS
|
|
12886
|
+
client.on(SOCKET_EVENTS.ON_ERROR, error => {
|
|
12797
12887
|
handleError(`Connection error : ${error}`);
|
|
12798
12888
|
});
|
|
12799
12889
|
|
|
12800
|
-
client.on(SOCKET_EVENTS
|
|
12890
|
+
client.on(SOCKET_EVENTS.ON_OPEN, () => {
|
|
12801
12891
|
if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
|
|
12802
12892
|
client.setOnHeartbeatTimeout(() => {
|
|
12803
12893
|
handleError('No response to heartbeat');
|
|
@@ -12898,7 +12988,7 @@ var webrtc = {
|
|
|
12898
12988
|
}),
|
|
12899
12989
|
};
|
|
12900
12990
|
|
|
12901
|
-
const parseCandidate = line => {
|
|
12991
|
+
const parseCandidate$1 = line => {
|
|
12902
12992
|
let parts;
|
|
12903
12993
|
// Parse both variants.
|
|
12904
12994
|
if (line.indexOf('a=candidate:') === 0) {
|
|
@@ -12989,7 +13079,7 @@ var SymmetricNat = {
|
|
|
12989
13079
|
}
|
|
12990
13080
|
|
|
12991
13081
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
12992
|
-
const cand = parseCandidate(e.candidate.candidate);
|
|
13082
|
+
const cand = parseCandidate$1(e.candidate.candidate);
|
|
12993
13083
|
if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
|
|
12994
13084
|
candidates[cand.relatedPort].push(cand.port);
|
|
12995
13085
|
} else if (!e.candidate) {
|
|
@@ -13057,7 +13147,7 @@ var iceIpv4 = {
|
|
|
13057
13147
|
const rawCandidate = e.candidate.candidate;
|
|
13058
13148
|
if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
|
|
13059
13149
|
hasSrflxOrRelay = true;
|
|
13060
|
-
const candidate = parseCandidate(e.candidate.candidate);
|
|
13150
|
+
const candidate = parseCandidate$1(e.candidate.candidate);
|
|
13061
13151
|
ips.push(candidate.ip);
|
|
13062
13152
|
}
|
|
13063
13153
|
} else if (!e.candidate) {
|
|
@@ -13094,7 +13184,7 @@ var checks = [
|
|
|
13094
13184
|
|
|
13095
13185
|
//
|
|
13096
13186
|
|
|
13097
|
-
const logger$
|
|
13187
|
+
const logger$b = IssueReporter$1.loggerFor('engine-check');
|
|
13098
13188
|
|
|
13099
13189
|
class Checker {
|
|
13100
13190
|
|
|
@@ -13112,28 +13202,28 @@ class Checker {
|
|
|
13112
13202
|
async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
|
|
13113
13203
|
await this._addEngineVersion();
|
|
13114
13204
|
|
|
13115
|
-
logger$
|
|
13205
|
+
logger$b.info('Engine check starting');
|
|
13116
13206
|
|
|
13117
13207
|
for (let i = 0; i < this.checks.length; i++) {
|
|
13118
13208
|
const { name, check } = this.checks[i];
|
|
13119
13209
|
|
|
13120
|
-
logger$
|
|
13210
|
+
logger$b.info(`Checking ${name} ...`);
|
|
13121
13211
|
|
|
13122
13212
|
onCheckBegin(name);
|
|
13123
13213
|
try {
|
|
13124
13214
|
// eslint-disable-next-line no-await-in-loop
|
|
13125
13215
|
const result = await check(this.server, this.session, this.externalAppConfig);
|
|
13126
|
-
logger$
|
|
13216
|
+
logger$b.info(`Checking ${name} success.`, { result });
|
|
13127
13217
|
|
|
13128
13218
|
onCheckResult(name, result);
|
|
13129
13219
|
} catch (e) {
|
|
13130
|
-
logger$
|
|
13220
|
+
logger$b.info(`Checking ${name} failure`, { message: e.message });
|
|
13131
13221
|
|
|
13132
13222
|
onCheckResult(name, e);
|
|
13133
13223
|
}
|
|
13134
13224
|
}
|
|
13135
13225
|
|
|
13136
|
-
logger$
|
|
13226
|
+
logger$b.info('Engine check done.');
|
|
13137
13227
|
}
|
|
13138
13228
|
|
|
13139
13229
|
addCheck(check ) {
|
|
@@ -13157,7 +13247,7 @@ const Wazo = {
|
|
|
13157
13247
|
Auth: Auth$1,
|
|
13158
13248
|
Phone: Phone$1,
|
|
13159
13249
|
Websocket: Websocket$1,
|
|
13160
|
-
Room
|
|
13250
|
+
Room,
|
|
13161
13251
|
SipRoom,
|
|
13162
13252
|
RemoteParticipant,
|
|
13163
13253
|
LocalParticipant,
|
|
@@ -13190,7 +13280,7 @@ const Wazo = {
|
|
|
13190
13280
|
Session,
|
|
13191
13281
|
Voicemail,
|
|
13192
13282
|
Relocation,
|
|
13193
|
-
ConferenceRoom: Room,
|
|
13283
|
+
ConferenceRoom: Room$1,
|
|
13194
13284
|
CallSession,
|
|
13195
13285
|
IndirectTransfer,
|
|
13196
13286
|
SwitchboardCall,
|
|
@@ -13226,7 +13316,7 @@ if (global) {
|
|
|
13226
13316
|
|
|
13227
13317
|
//
|
|
13228
13318
|
|
|
13229
|
-
const logger = IssueReporter$1.loggerFor('simple-phone');
|
|
13319
|
+
const logger$c = IssueReporter$1.loggerFor('simple-phone');
|
|
13230
13320
|
const sipLogger = IssueReporter$1.loggerFor('sip.js');
|
|
13231
13321
|
const protocolLogger = IssueReporter$1.loggerFor('sip');
|
|
13232
13322
|
|
|
@@ -13333,7 +13423,7 @@ class Phone extends Emitter {
|
|
|
13333
13423
|
async disconnect() {
|
|
13334
13424
|
if (this.phone) {
|
|
13335
13425
|
if (this.phone.hasAnActiveCall()) {
|
|
13336
|
-
logger.info('hangup call on disconnect');
|
|
13426
|
+
logger$c.info('hangup call on disconnect');
|
|
13337
13427
|
// $FlowFixMe
|
|
13338
13428
|
await this.phone.hangup();
|
|
13339
13429
|
}
|
|
@@ -13356,13 +13446,13 @@ class Phone extends Emitter {
|
|
|
13356
13446
|
}
|
|
13357
13447
|
|
|
13358
13448
|
async hangup(callSession ) {
|
|
13359
|
-
logger.info('hangup via simple phone', { callId: callSession.getId() });
|
|
13449
|
+
logger$c.info('hangup via simple phone', { callId: callSession.getId() });
|
|
13360
13450
|
|
|
13361
13451
|
return this.phone && this.phone.hangup(callSession);
|
|
13362
13452
|
}
|
|
13363
13453
|
|
|
13364
13454
|
async accept(callSession , cameraEnabled ) {
|
|
13365
|
-
logger.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
|
|
13455
|
+
logger$c.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
|
|
13366
13456
|
|
|
13367
13457
|
return this.phone && this.phone.accept(callSession, cameraEnabled);
|
|
13368
13458
|
}
|
|
@@ -13401,7 +13491,7 @@ class Phone extends Emitter {
|
|
|
13401
13491
|
muteViaAPI(callSession ) {
|
|
13402
13492
|
if (callSession && callSession.callId) {
|
|
13403
13493
|
Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
|
|
13404
|
-
logger.error('Mute via API, error', e);
|
|
13494
|
+
logger$c.error('Mute via API, error', e);
|
|
13405
13495
|
});
|
|
13406
13496
|
}
|
|
13407
13497
|
}
|
|
@@ -13409,7 +13499,7 @@ class Phone extends Emitter {
|
|
|
13409
13499
|
unmuteViaAPI(callSession ) {
|
|
13410
13500
|
if (callSession && callSession.callId) {
|
|
13411
13501
|
Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
|
|
13412
|
-
logger.error('Unmute via API, error', e);
|
|
13502
|
+
logger$c.error('Unmute via API, error', e);
|
|
13413
13503
|
});
|
|
13414
13504
|
}
|
|
13415
13505
|
}
|
|
@@ -13517,7 +13607,7 @@ class Phone extends Emitter {
|
|
|
13517
13607
|
|
|
13518
13608
|
// @Deprecated
|
|
13519
13609
|
getLocalMediaStream(callSession ) {
|
|
13520
|
-
logger.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
|
|
13610
|
+
logger$c.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
|
|
13521
13611
|
|
|
13522
13612
|
return this.phone && this.phone.getLocalStream(callSession);
|
|
13523
13613
|
}
|
|
@@ -13540,24 +13630,29 @@ class Phone extends Emitter {
|
|
|
13540
13630
|
|
|
13541
13631
|
// @Deprecated
|
|
13542
13632
|
getRemoteStreamForCall(callSession ) {
|
|
13543
|
-
logger.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
|
|
13633
|
+
logger$c.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
|
|
13544
13634
|
return this.getRemoteStream(callSession);
|
|
13545
13635
|
}
|
|
13546
13636
|
|
|
13547
13637
|
// Returns remote streams directly from the peerConnection
|
|
13548
13638
|
// @Deprecated
|
|
13549
13639
|
getRemoteStreamsForCall(callSession ) {
|
|
13550
|
-
logger.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
|
|
13640
|
+
logger$c.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
|
|
13551
13641
|
return this.getLocalStream(callSession);
|
|
13552
13642
|
}
|
|
13553
13643
|
|
|
13554
13644
|
// @Deprecated
|
|
13555
13645
|
getRemoteVideoStreamForCall(callSession ) {
|
|
13556
|
-
logger.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
|
|
13646
|
+
logger$c.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
|
|
13557
13647
|
|
|
13558
13648
|
return this.getRemoteVideoStream(callSession);
|
|
13559
13649
|
}
|
|
13560
13650
|
|
|
13651
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
13652
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
13653
|
+
return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
|
|
13654
|
+
}
|
|
13655
|
+
|
|
13561
13656
|
hasVideo(callSession ) {
|
|
13562
13657
|
return this.phone ? this.phone.hasVideo(callSession) : false;
|
|
13563
13658
|
}
|
|
@@ -13609,7 +13704,7 @@ class Phone extends Emitter {
|
|
|
13609
13704
|
|
|
13610
13705
|
_transferEvents() {
|
|
13611
13706
|
this.unbind();
|
|
13612
|
-
[...events
|
|
13707
|
+
[...events, ...transportEvents].forEach(event => {
|
|
13613
13708
|
this.client.on(event, (...args) =>
|
|
13614
13709
|
this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
|
|
13615
13710
|
});
|