@wazo/sdk 0.37.20 → 0.37.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/api-client.test.js +91 -21
- package/esm/__tests__/web-rtc-client.test.js +214 -165
- package/esm/api/agentd.js +25 -2
- package/esm/api/amid.js +26 -3
- package/esm/api/application.js +25 -2
- package/esm/api/auth.js +25 -2
- package/esm/api/call-logd.js +34 -4
- package/esm/api/calld.js +35 -2
- package/esm/api/chatd.js +32 -2
- package/esm/api/confd.js +56 -9
- package/esm/api/ctid-ng.js +38 -5
- package/esm/api/dird.js +29 -3
- package/esm/api/webhookd.js +26 -3
- package/esm/api-client.js +91 -21
- package/esm/checker/Checker.js +241 -190
- package/esm/checker/checks/aor.js +91 -21
- package/esm/checker/checks/api.js +91 -21
- package/esm/checker/checks/index.js +231 -180
- package/esm/checker/checks/wazo-websocket.js +42 -17
- package/esm/checker/checks/webrtc-transport.js +214 -165
- package/esm/checker/checks/webrtc.js +214 -165
- package/esm/domain/AdHocAPIConference.js +91 -21
- package/esm/domain/Call.js +3 -0
- package/esm/domain/CallLog.js +8 -1
- package/esm/domain/ChatMessage.js +4 -0
- package/esm/domain/ChatRoom.js +3 -0
- package/esm/domain/Contact.js +4 -1
- package/esm/domain/Features.js +91 -21
- package/esm/domain/Meeting.js +28 -5
- package/esm/domain/Phone/CTIPhone.js +109 -35
- package/esm/domain/Phone/WebRTCPhone.js +159 -102
- package/esm/domain/Recording.js +3 -0
- package/esm/domain/Voicemail.js +3 -0
- package/esm/domain/__tests__/Call.test.js +3 -0
- package/esm/domain/__tests__/CallLog.test.js +8 -1
- package/esm/domain/__tests__/Contact.test.js +4 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +509 -414
- package/esm/lib/WazoSessionDescriptionHandler.js +26 -41
- package/esm/service/CallApi.js +91 -21
- package/esm/service/IssueReporter.js +26 -3
- package/esm/service/__tests__/IssueReporter.test.js +26 -3
- package/esm/service/getApiClient.js +91 -21
- package/esm/simple/Auth.js +499 -404
- package/esm/simple/Configuration.js +499 -404
- package/esm/simple/Directory.js +91 -21
- package/esm/simple/Phone.js +499 -404
- package/esm/simple/Websocket.js +45 -19
- package/esm/simple/index.js +503 -408
- package/esm/simple/room/LocalParticipant.js +503 -408
- package/esm/simple/room/Participant.js +503 -408
- package/esm/simple/room/RemoteParticipant.js +503 -408
- package/esm/simple/room/Room.js +504 -409
- package/esm/simple/room/SipRoom.js +503 -408
- package/esm/simple/room/Stream.js +503 -408
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/esm/simple/utils.js +503 -408
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/utils/__tests__/api-requester.test.js +25 -2
- package/esm/utils/api-requester.js +25 -2
- package/esm/web-rtc-client.js +214 -165
- package/esm/websocket-client.js +43 -18
- package/lib/__tests__/api-client.test.js +91 -21
- package/lib/__tests__/web-rtc-client.test.js +214 -165
- package/lib/api/agentd.js +25 -2
- package/lib/api/amid.js +26 -3
- package/lib/api/application.js +25 -2
- package/lib/api/auth.js +25 -2
- package/lib/api/call-logd.js +34 -4
- package/lib/api/calld.js +35 -2
- package/lib/api/chatd.js +32 -2
- package/lib/api/confd.js +56 -9
- package/lib/api/ctid-ng.js +38 -5
- package/lib/api/dird.js +29 -3
- package/lib/api/webhookd.js +26 -3
- package/lib/api-client.js +91 -21
- package/lib/checker/Checker.js +241 -190
- package/lib/checker/checks/aor.js +91 -21
- package/lib/checker/checks/api.js +91 -21
- package/lib/checker/checks/index.js +231 -180
- package/lib/checker/checks/wazo-websocket.js +42 -17
- package/lib/checker/checks/webrtc-transport.js +214 -165
- package/lib/checker/checks/webrtc.js +214 -165
- package/lib/domain/AdHocAPIConference.js +91 -21
- package/lib/domain/Call.js +3 -0
- package/lib/domain/CallLog.js +8 -1
- package/lib/domain/ChatMessage.js +4 -0
- package/lib/domain/ChatRoom.js +3 -0
- package/lib/domain/Contact.js +4 -1
- package/lib/domain/Features.js +91 -21
- package/lib/domain/Meeting.js +32 -5
- package/lib/domain/Phone/CTIPhone.js +109 -35
- package/lib/domain/Phone/WebRTCPhone.js +159 -102
- package/lib/domain/Recording.js +3 -0
- package/lib/domain/Voicemail.js +3 -0
- package/lib/domain/__tests__/Call.test.js +3 -0
- package/lib/domain/__tests__/CallLog.test.js +8 -1
- package/lib/domain/__tests__/Contact.test.js +4 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +509 -414
- package/lib/lib/WazoSessionDescriptionHandler.js +26 -41
- package/lib/service/CallApi.js +91 -21
- package/lib/service/IssueReporter.js +26 -3
- package/lib/service/__tests__/IssueReporter.test.js +26 -3
- package/lib/service/getApiClient.js +91 -21
- package/lib/simple/Auth.js +499 -404
- package/lib/simple/Configuration.js +499 -404
- package/lib/simple/Directory.js +91 -21
- package/lib/simple/Phone.js +499 -404
- package/lib/simple/Websocket.js +45 -19
- package/lib/simple/index.js +503 -408
- package/lib/simple/room/LocalParticipant.js +503 -408
- package/lib/simple/room/Participant.js +503 -408
- package/lib/simple/room/RemoteParticipant.js +503 -408
- package/lib/simple/room/Room.js +504 -409
- package/lib/simple/room/SipRoom.js +503 -408
- package/lib/simple/room/Stream.js +503 -408
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/lib/simple/utils.js +503 -408
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/utils/__tests__/api-requester.test.js +25 -2
- package/lib/utils/api-requester.js +25 -2
- package/lib/web-rtc-client.js +214 -165
- package/lib/websocket-client.js +43 -17
- package/package.json +1 -1
- package/src/api/confd.js +5 -2
- package/src/domain/Call.js +3 -0
- package/src/domain/CallLog.js +4 -0
- package/src/domain/ChatMessage.js +4 -0
- package/src/domain/ChatRoom.js +3 -0
- package/src/domain/Contact.js +3 -0
- package/src/domain/Meeting.js +28 -5
- package/src/domain/Phone/CTIPhone.js +4 -0
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +49 -15
- package/src/domain/Recording.js +3 -0
- package/src/domain/Voicemail.js +3 -0
- package/src/domain/__tests__/Meeting.test.js +50 -0
- package/src/lib/WazoSessionDescriptionHandler.js +1 -35
- package/src/service/IssueReporter.js +25 -2
- package/src/simple/Phone.js +5 -0
- package/src/types/WebSocketMessage.js +5 -1
- package/src/web-rtc-client.js +41 -24
- package/src/websocket-client.js +2 -0
package/lib/simple/Phone.js
CHANGED
|
@@ -105,6 +105,9 @@ class Call {
|
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
static parseMany(plain ) {
|
|
108
|
+
if (!plain) {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
108
111
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
109
112
|
}
|
|
110
113
|
|
|
@@ -721,6 +724,7 @@ class IssueReporter {
|
|
|
721
724
|
|
|
722
725
|
|
|
723
726
|
|
|
727
|
+
|
|
724
728
|
|
|
725
729
|
constructor() {
|
|
726
730
|
addLevelsTo(this);
|
|
@@ -732,12 +736,17 @@ class IssueReporter {
|
|
|
732
736
|
this.bufferTimeout = null;
|
|
733
737
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
734
738
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
739
|
+
this._callback = null;
|
|
735
740
|
}
|
|
736
741
|
|
|
737
742
|
init() {
|
|
738
743
|
this._catchConsole();
|
|
739
744
|
}
|
|
740
745
|
|
|
746
|
+
setCallback(cb ) {
|
|
747
|
+
this._callback = cb;
|
|
748
|
+
}
|
|
749
|
+
|
|
741
750
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
742
751
|
this.remoteClientConfiguration = configuration;
|
|
743
752
|
}
|
|
@@ -773,6 +782,7 @@ class IssueReporter {
|
|
|
773
782
|
|
|
774
783
|
// Handle category label
|
|
775
784
|
let category = null;
|
|
785
|
+
let skipSendToRemote = false;
|
|
776
786
|
let extra = {};
|
|
777
787
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
778
788
|
category = args[0].split('=')[1];
|
|
@@ -788,6 +798,7 @@ class IssueReporter {
|
|
|
788
798
|
errorMessage: lastArg.message,
|
|
789
799
|
errorStack: lastArg.stack,
|
|
790
800
|
errorType: lastArg.constructor.name,
|
|
801
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
791
802
|
};
|
|
792
803
|
} else {
|
|
793
804
|
extra = lastArg;
|
|
@@ -796,6 +807,11 @@ class IssueReporter {
|
|
|
796
807
|
args.splice(1, 1);
|
|
797
808
|
}
|
|
798
809
|
|
|
810
|
+
if (extra.skipSendToRemote) {
|
|
811
|
+
skipSendToRemote = true;
|
|
812
|
+
delete extra.skipSendToRemote;
|
|
813
|
+
}
|
|
814
|
+
|
|
799
815
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
800
816
|
const message = args.join(', ');
|
|
801
817
|
let consoleMessage = message;
|
|
@@ -816,7 +832,13 @@ class IssueReporter {
|
|
|
816
832
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
817
833
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
818
834
|
|
|
819
|
-
this.
|
|
835
|
+
if (this._callback) {
|
|
836
|
+
this._callback(level, consoleMessage);
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
if (!skipSendToRemote) {
|
|
840
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
841
|
+
}
|
|
820
842
|
}
|
|
821
843
|
|
|
822
844
|
logRequest(url , options , response , start ) {
|
|
@@ -961,7 +983,11 @@ class IssueReporter {
|
|
|
961
983
|
},
|
|
962
984
|
// $FlowFixMe
|
|
963
985
|
body,
|
|
964
|
-
}).catch(() => {
|
|
986
|
+
}).catch((e ) => {
|
|
987
|
+
// $FlowFixMe
|
|
988
|
+
e.skipSendToRemote = true;
|
|
989
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
990
|
+
|
|
965
991
|
setTimeout(() => {
|
|
966
992
|
if (isArray) {
|
|
967
993
|
payload = payload.map(message => {
|
|
@@ -1008,7 +1034,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
1008
1034
|
|
|
1009
1035
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
1010
1036
|
|
|
1011
|
-
const logger
|
|
1037
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
1012
1038
|
|
|
1013
1039
|
// Use a function here to be able to mock it in tests
|
|
1014
1040
|
const realFetch = () => {
|
|
@@ -1147,7 +1173,7 @@ class ApiRequester {
|
|
|
1147
1173
|
};
|
|
1148
1174
|
|
|
1149
1175
|
if (this.refreshTokenPromise) {
|
|
1150
|
-
logger
|
|
1176
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
1151
1177
|
await this.refreshTokenPromise;
|
|
1152
1178
|
}
|
|
1153
1179
|
|
|
@@ -1167,7 +1193,7 @@ class ApiRequester {
|
|
|
1167
1193
|
return promise.then(async (err ) => {
|
|
1168
1194
|
// Check if the token is still valid
|
|
1169
1195
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
1170
|
-
logger
|
|
1196
|
+
logger.warn('token expired', { error: err.reason });
|
|
1171
1197
|
// Replay the call after refreshing the token
|
|
1172
1198
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
1173
1199
|
}
|
|
@@ -1177,7 +1203,7 @@ class ApiRequester {
|
|
|
1177
1203
|
: exceptionClass.fromResponse(err, response.status);
|
|
1178
1204
|
|
|
1179
1205
|
if (this.shouldLogErrors) {
|
|
1180
|
-
logger
|
|
1206
|
+
logger.error('API error', error);
|
|
1181
1207
|
}
|
|
1182
1208
|
|
|
1183
1209
|
throw error;
|
|
@@ -1187,7 +1213,7 @@ class ApiRequester {
|
|
|
1187
1213
|
return newParse(response, isJson);
|
|
1188
1214
|
}).catch(error => {
|
|
1189
1215
|
if (this.shouldLogErrors) {
|
|
1190
|
-
logger
|
|
1216
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
1191
1217
|
}
|
|
1192
1218
|
|
|
1193
1219
|
throw error;
|
|
@@ -1215,13 +1241,13 @@ class ApiRequester {
|
|
|
1215
1241
|
) {
|
|
1216
1242
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
1217
1243
|
let newPath = path;
|
|
1218
|
-
logger
|
|
1244
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
1219
1245
|
|
|
1220
1246
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
1221
1247
|
|
|
1222
1248
|
return this.refreshTokenPromise.then(() => {
|
|
1223
1249
|
this.refreshTokenPromise = null;
|
|
1224
|
-
logger
|
|
1250
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
1225
1251
|
if (isTokenNotFound) {
|
|
1226
1252
|
const pathParts = path.split('/');
|
|
1227
1253
|
pathParts.pop();
|
|
@@ -2088,6 +2114,9 @@ class Contact {
|
|
|
2088
2114
|
}
|
|
2089
2115
|
|
|
2090
2116
|
static parseMany(response ) {
|
|
2117
|
+
if (!response || !response.results) {
|
|
2118
|
+
return [];
|
|
2119
|
+
}
|
|
2091
2120
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
2092
2121
|
}
|
|
2093
2122
|
|
|
@@ -3165,8 +3194,9 @@ class ExternalApp {
|
|
|
3165
3194
|
|
|
3166
3195
|
|
|
3167
3196
|
|
|
3168
|
-
|
|
3197
|
+
|
|
3169
3198
|
|
|
3199
|
+
|
|
3170
3200
|
|
|
3171
3201
|
|
|
3172
3202
|
class Meeting {
|
|
@@ -3177,9 +3207,10 @@ class Meeting {
|
|
|
3177
3207
|
|
|
3178
3208
|
|
|
3179
3209
|
|
|
3180
|
-
|
|
3210
|
+
|
|
3181
3211
|
|
|
3182
3212
|
|
|
3213
|
+
|
|
3183
3214
|
|
|
3184
3215
|
static parse(plain ) {
|
|
3185
3216
|
return new Meeting({
|
|
@@ -3189,24 +3220,43 @@ class Meeting {
|
|
|
3189
3220
|
ownerUuids: plain.owner_uuids,
|
|
3190
3221
|
port: plain.port,
|
|
3191
3222
|
uuid: plain.uuid,
|
|
3192
|
-
|
|
3223
|
+
extension: plain.exten,
|
|
3193
3224
|
persistent: plain.persistent,
|
|
3225
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
3194
3226
|
});
|
|
3195
3227
|
}
|
|
3196
3228
|
|
|
3229
|
+
static parseMany(items ) {
|
|
3230
|
+
if (!items) {
|
|
3231
|
+
return [];
|
|
3232
|
+
}
|
|
3233
|
+
return items.map(plain => Meeting.parse(plain));
|
|
3234
|
+
}
|
|
3235
|
+
|
|
3197
3236
|
static newFrom(meeting ) {
|
|
3198
3237
|
return newFrom(meeting, Meeting);
|
|
3199
3238
|
}
|
|
3200
3239
|
|
|
3201
|
-
constructor({
|
|
3240
|
+
constructor({
|
|
3241
|
+
uuid,
|
|
3242
|
+
name,
|
|
3243
|
+
guestSipAuthorization,
|
|
3244
|
+
ownerUuids,
|
|
3245
|
+
port,
|
|
3246
|
+
uri,
|
|
3247
|
+
extension,
|
|
3248
|
+
persistent,
|
|
3249
|
+
creationTime,
|
|
3250
|
+
} = {}) {
|
|
3202
3251
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
3203
3252
|
this.uri = uri;
|
|
3204
3253
|
this.name = name;
|
|
3205
3254
|
this.ownerUuids = ownerUuids;
|
|
3206
3255
|
this.port = port;
|
|
3207
3256
|
this.uuid = uuid;
|
|
3208
|
-
this.
|
|
3257
|
+
this.extension = extension;
|
|
3209
3258
|
this.persistent = persistent;
|
|
3259
|
+
this.creationTime = creationTime;
|
|
3210
3260
|
|
|
3211
3261
|
// Useful to compare instead of instanceof with minified code
|
|
3212
3262
|
this.type = 'Meeting';
|
|
@@ -3284,8 +3334,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3284
3334
|
}
|
|
3285
3335
|
},
|
|
3286
3336
|
|
|
3287
|
-
|
|
3288
|
-
client.
|
|
3337
|
+
getMyMeetings: () =>
|
|
3338
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
3339
|
+
|
|
3340
|
+
createMyMeeting: (name , persistent ) =>
|
|
3341
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
3289
3342
|
|
|
3290
3343
|
deleteMyMeeting: (meetingUuid ) =>
|
|
3291
3344
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -3381,6 +3434,10 @@ class ChatMessage {
|
|
|
3381
3434
|
|
|
3382
3435
|
|
|
3383
3436
|
static parseMany(plain ) {
|
|
3437
|
+
if (!plain || !plain.items) {
|
|
3438
|
+
return [];
|
|
3439
|
+
}
|
|
3440
|
+
|
|
3384
3441
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
3385
3442
|
}
|
|
3386
3443
|
|
|
@@ -3490,6 +3547,9 @@ class Voicemail {
|
|
|
3490
3547
|
}
|
|
3491
3548
|
|
|
3492
3549
|
static parseMany(plain ) {
|
|
3550
|
+
if (!plain) {
|
|
3551
|
+
return [];
|
|
3552
|
+
}
|
|
3493
3553
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
3494
3554
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
3495
3555
|
|
|
@@ -3591,6 +3651,9 @@ class Recording {
|
|
|
3591
3651
|
|
|
3592
3652
|
|
|
3593
3653
|
static parseMany(recordings = []) {
|
|
3654
|
+
if (!recordings) {
|
|
3655
|
+
return [];
|
|
3656
|
+
}
|
|
3594
3657
|
return recordings.map(item => Recording.parse(item));
|
|
3595
3658
|
}
|
|
3596
3659
|
|
|
@@ -3692,6 +3755,10 @@ class CallLog {
|
|
|
3692
3755
|
}
|
|
3693
3756
|
|
|
3694
3757
|
static parseMany(plain ) {
|
|
3758
|
+
if (!plain || !plain.items) {
|
|
3759
|
+
return [];
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3695
3762
|
return plain.items.map(item => CallLog.parse(item));
|
|
3696
3763
|
}
|
|
3697
3764
|
|
|
@@ -3996,7 +4063,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3996
4063
|
|
|
3997
4064
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3998
4065
|
|
|
3999
|
-
const logger$
|
|
4066
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
4000
4067
|
|
|
4001
4068
|
class CTIPhone extends Emitter {
|
|
4002
4069
|
|
|
@@ -4009,7 +4076,7 @@ class CTIPhone extends Emitter {
|
|
|
4009
4076
|
|
|
4010
4077
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
4011
4078
|
super();
|
|
4012
|
-
logger$
|
|
4079
|
+
logger$1.info('CTI Phone created');
|
|
4013
4080
|
this.session = session;
|
|
4014
4081
|
this.isMobile = isMobile;
|
|
4015
4082
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -4070,7 +4137,7 @@ class CTIPhone extends Emitter {
|
|
|
4070
4137
|
}
|
|
4071
4138
|
|
|
4072
4139
|
async makeCall(number , line ) {
|
|
4073
|
-
logger$
|
|
4140
|
+
logger$1.info('make CTI call', { number });
|
|
4074
4141
|
|
|
4075
4142
|
if (!number) {
|
|
4076
4143
|
return null;
|
|
@@ -4093,7 +4160,7 @@ class CTIPhone extends Emitter {
|
|
|
4093
4160
|
if (!callSession) {
|
|
4094
4161
|
return Promise.resolve(null);
|
|
4095
4162
|
}
|
|
4096
|
-
logger$
|
|
4163
|
+
logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4097
4164
|
|
|
4098
4165
|
if (!this.currentCall) {
|
|
4099
4166
|
this.currentCall = callSession.call;
|
|
@@ -4106,7 +4173,7 @@ class CTIPhone extends Emitter {
|
|
|
4106
4173
|
if (!callSession) {
|
|
4107
4174
|
return;
|
|
4108
4175
|
}
|
|
4109
|
-
logger$
|
|
4176
|
+
logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4110
4177
|
|
|
4111
4178
|
this.currentCall = undefined;
|
|
4112
4179
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4116,7 +4183,7 @@ class CTIPhone extends Emitter {
|
|
|
4116
4183
|
if (!callSession) {
|
|
4117
4184
|
return Promise.resolve(false);
|
|
4118
4185
|
}
|
|
4119
|
-
logger$
|
|
4186
|
+
logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4120
4187
|
|
|
4121
4188
|
try {
|
|
4122
4189
|
await CallApi.cancelCall(callSession);
|
|
@@ -4127,7 +4194,7 @@ class CTIPhone extends Emitter {
|
|
|
4127
4194
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
4128
4195
|
return true;
|
|
4129
4196
|
} catch (e) {
|
|
4130
|
-
logger$
|
|
4197
|
+
logger$1.error('hangup CTI call, error', e);
|
|
4131
4198
|
|
|
4132
4199
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
4133
4200
|
return false;
|
|
@@ -4140,7 +4207,7 @@ class CTIPhone extends Emitter {
|
|
|
4140
4207
|
if (!callSession) {
|
|
4141
4208
|
return;
|
|
4142
4209
|
}
|
|
4143
|
-
logger$
|
|
4210
|
+
logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4144
4211
|
|
|
4145
4212
|
await CallApi.cancelCall(callSession);
|
|
4146
4213
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4150,7 +4217,7 @@ class CTIPhone extends Emitter {
|
|
|
4150
4217
|
if (!callSession) {
|
|
4151
4218
|
return;
|
|
4152
4219
|
}
|
|
4153
|
-
logger$
|
|
4220
|
+
logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4154
4221
|
|
|
4155
4222
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
4156
4223
|
}
|
|
@@ -4163,19 +4230,19 @@ class CTIPhone extends Emitter {
|
|
|
4163
4230
|
if (!callSession) {
|
|
4164
4231
|
return;
|
|
4165
4232
|
}
|
|
4166
|
-
logger$
|
|
4233
|
+
logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4167
4234
|
|
|
4168
4235
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
4169
4236
|
}
|
|
4170
4237
|
|
|
4171
4238
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
4172
|
-
logger$
|
|
4239
|
+
logger$1.info('cancel CTI transfer', { transferId });
|
|
4173
4240
|
|
|
4174
4241
|
return CallApi.cancelCallTransfer(transferId);
|
|
4175
4242
|
}
|
|
4176
4243
|
|
|
4177
4244
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
4178
|
-
logger$
|
|
4245
|
+
logger$1.info('confirm CTI transfer', { transferId });
|
|
4179
4246
|
|
|
4180
4247
|
return CallApi.confirmCallTransfer(transferId);
|
|
4181
4248
|
}
|
|
@@ -4184,19 +4251,19 @@ class CTIPhone extends Emitter {
|
|
|
4184
4251
|
if (!callSession) {
|
|
4185
4252
|
return;
|
|
4186
4253
|
}
|
|
4187
|
-
logger$
|
|
4254
|
+
logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4188
4255
|
|
|
4189
4256
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4190
4257
|
}
|
|
4191
4258
|
|
|
4192
4259
|
onConnectionMade() {
|
|
4193
|
-
logger$
|
|
4260
|
+
logger$1.info('on CTI connection made');
|
|
4194
4261
|
|
|
4195
4262
|
this.eventEmitter.emit('onCallAccepted');
|
|
4196
4263
|
}
|
|
4197
4264
|
|
|
4198
4265
|
async close() {
|
|
4199
|
-
logger$
|
|
4266
|
+
logger$1.info('CTI close');
|
|
4200
4267
|
|
|
4201
4268
|
return Promise.resolve();
|
|
4202
4269
|
}
|
|
@@ -4205,7 +4272,7 @@ class CTIPhone extends Emitter {
|
|
|
4205
4272
|
if (!callSession) {
|
|
4206
4273
|
return;
|
|
4207
4274
|
}
|
|
4208
|
-
logger$
|
|
4275
|
+
logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4209
4276
|
|
|
4210
4277
|
return CallApi.hold(callSession.callId);
|
|
4211
4278
|
}
|
|
@@ -4214,7 +4281,7 @@ class CTIPhone extends Emitter {
|
|
|
4214
4281
|
if (!callSession) {
|
|
4215
4282
|
return;
|
|
4216
4283
|
}
|
|
4217
|
-
logger$
|
|
4284
|
+
logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4218
4285
|
|
|
4219
4286
|
return CallApi.resume(callSession.callId);
|
|
4220
4287
|
}
|
|
@@ -4223,7 +4290,7 @@ class CTIPhone extends Emitter {
|
|
|
4223
4290
|
if (!callSession) {
|
|
4224
4291
|
return;
|
|
4225
4292
|
}
|
|
4226
|
-
logger$
|
|
4293
|
+
logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4227
4294
|
|
|
4228
4295
|
return CallApi.mute(callSession.callId);
|
|
4229
4296
|
}
|
|
@@ -4232,7 +4299,7 @@ class CTIPhone extends Emitter {
|
|
|
4232
4299
|
if (!callSession) {
|
|
4233
4300
|
return;
|
|
4234
4301
|
}
|
|
4235
|
-
logger$
|
|
4302
|
+
logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4236
4303
|
|
|
4237
4304
|
return CallApi.unmute(callSession.callId);
|
|
4238
4305
|
}
|
|
@@ -4261,6 +4328,10 @@ class CTIPhone extends Emitter {
|
|
|
4261
4328
|
return false;
|
|
4262
4329
|
}
|
|
4263
4330
|
|
|
4331
|
+
hasAVideoTrack() {
|
|
4332
|
+
return false;
|
|
4333
|
+
}
|
|
4334
|
+
|
|
4264
4335
|
getLocalStreamForCall() {
|
|
4265
4336
|
return null;
|
|
4266
4337
|
}
|
|
@@ -4654,6 +4725,9 @@ class ChatRoom {
|
|
|
4654
4725
|
|
|
4655
4726
|
|
|
4656
4727
|
static parseMany(plain ) {
|
|
4728
|
+
if (!plain || !plain.items) {
|
|
4729
|
+
return [];
|
|
4730
|
+
}
|
|
4657
4731
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
4658
4732
|
}
|
|
4659
4733
|
|
|
@@ -5234,7 +5308,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5234
5308
|
const WEBHOOKD_VERSION = '1.0';
|
|
5235
5309
|
const AMID_VERSION = '1.0';
|
|
5236
5310
|
|
|
5237
|
-
const logger$
|
|
5311
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5238
5312
|
|
|
5239
5313
|
class ApiClient {
|
|
5240
5314
|
|
|
@@ -5286,12 +5360,12 @@ class ApiClient {
|
|
|
5286
5360
|
}
|
|
5287
5361
|
|
|
5288
5362
|
async forceRefreshToken() {
|
|
5289
|
-
logger$
|
|
5363
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
5290
5364
|
return this.refreshTokenCallback();
|
|
5291
5365
|
}
|
|
5292
5366
|
|
|
5293
5367
|
async refreshTokenCallback() {
|
|
5294
|
-
logger$
|
|
5368
|
+
logger$2.info('refresh token callback called', {
|
|
5295
5369
|
refreshToken: this.refreshToken,
|
|
5296
5370
|
refreshBackend: this.refreshBackend,
|
|
5297
5371
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5309,7 +5383,7 @@ class ApiClient {
|
|
|
5309
5383
|
this.isMobile,
|
|
5310
5384
|
);
|
|
5311
5385
|
|
|
5312
|
-
logger$
|
|
5386
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
5313
5387
|
|
|
5314
5388
|
if (this.onRefreshToken) {
|
|
5315
5389
|
this.onRefreshToken(session.token, session);
|
|
@@ -5622,7 +5696,7 @@ class AdHocAPIConference {
|
|
|
5622
5696
|
|
|
5623
5697
|
/* */
|
|
5624
5698
|
|
|
5625
|
-
const parseCandidate
|
|
5699
|
+
const parseCandidate = (candidate ) => {
|
|
5626
5700
|
if (!candidate) {
|
|
5627
5701
|
return null;
|
|
5628
5702
|
}
|
|
@@ -5635,10 +5709,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
5635
5709
|
candidates
|
|
5636
5710
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
5637
5711
|
|
|
5638
|
-
const areCandidateValid = (candidates ) =>
|
|
5639
|
-
getSrflxOrRelay(candidates)
|
|
5640
|
-
.length > 0;
|
|
5641
|
-
|
|
5642
5712
|
const getVideoDirection = (sdp ) => {
|
|
5643
5713
|
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
5644
5714
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -5691,8 +5761,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
5691
5761
|
/* global RTCSessionDescriptionInit, navigator */
|
|
5692
5762
|
|
|
5693
5763
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
5694
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
5695
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
5696
5764
|
|
|
5697
5765
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
5698
5766
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -5782,7 +5850,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5782
5850
|
this.peerConnectionDelegate.onicecandidate = event => {
|
|
5783
5851
|
wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
|
|
5784
5852
|
if (event.candidate) {
|
|
5785
|
-
this.gatheredCandidates.push(parseCandidate
|
|
5853
|
+
this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
|
|
5786
5854
|
}
|
|
5787
5855
|
};
|
|
5788
5856
|
|
|
@@ -5882,38 +5950,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5882
5950
|
this._peerConnection = undefined;
|
|
5883
5951
|
}
|
|
5884
5952
|
|
|
5885
|
-
async _waitForValidGatheredIce() {
|
|
5886
|
-
let tries = 0;
|
|
5887
|
-
|
|
5888
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
5889
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
5890
|
-
tries,
|
|
5891
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
5892
|
-
});
|
|
5893
|
-
|
|
5894
|
-
tries++;
|
|
5895
|
-
|
|
5896
|
-
// eslint-disable-next-line no-await-in-loop
|
|
5897
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
5898
|
-
}
|
|
5899
|
-
|
|
5900
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
5901
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
5902
|
-
const error = new Error(errorMsg);
|
|
5903
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
5904
|
-
|
|
5905
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
5906
|
-
this.eventEmitter.emit('error', error);
|
|
5907
|
-
|
|
5908
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5909
|
-
}
|
|
5910
|
-
|
|
5911
|
-
// eslint-disable-next-line
|
|
5912
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5913
|
-
|
|
5914
|
-
return this.getLocalSessionDescription();
|
|
5915
|
-
}
|
|
5916
|
-
|
|
5917
5953
|
// Overridden to send `inactive` in conference
|
|
5918
5954
|
updateDirection(options , isConference = false,
|
|
5919
5955
|
audioOnly = false) {
|
|
@@ -6278,7 +6314,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
6278
6314
|
const SEND_STATS_DELAY = 5000;
|
|
6279
6315
|
|
|
6280
6316
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
6281
|
-
const logger$
|
|
6317
|
+
const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
6282
6318
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
6283
6319
|
|
|
6284
6320
|
// events
|
|
@@ -6292,14 +6328,14 @@ const TRANSPORT_ERROR = 'transportError';
|
|
|
6292
6328
|
const MESSAGE = 'message';
|
|
6293
6329
|
const ACCEPTED = 'accepted';
|
|
6294
6330
|
const REJECTED = 'rejected';
|
|
6295
|
-
const ON_TRACK
|
|
6296
|
-
const ON_REINVITE
|
|
6331
|
+
const ON_TRACK = 'onTrack';
|
|
6332
|
+
const ON_REINVITE = 'reinvite';
|
|
6297
6333
|
const ON_ERROR = 'onError';
|
|
6298
6334
|
const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
|
|
6299
|
-
const ON_NETWORK_STATS
|
|
6300
|
-
const ON_DISCONNECTED
|
|
6335
|
+
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
6336
|
+
const ON_DISCONNECTED = 'onDisconnected';
|
|
6301
6337
|
|
|
6302
|
-
const events
|
|
6338
|
+
const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
6303
6339
|
const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
6304
6340
|
class CanceledCallError extends Error {}
|
|
6305
6341
|
|
|
@@ -6435,12 +6471,12 @@ class WebRTCClient extends Emitter {
|
|
|
6435
6471
|
this.MESSAGE = MESSAGE;
|
|
6436
6472
|
this.ACCEPTED = ACCEPTED;
|
|
6437
6473
|
this.REJECTED = REJECTED;
|
|
6438
|
-
this.ON_TRACK = ON_TRACK
|
|
6439
|
-
this.ON_REINVITE = ON_REINVITE
|
|
6474
|
+
this.ON_TRACK = ON_TRACK;
|
|
6475
|
+
this.ON_REINVITE = ON_REINVITE;
|
|
6440
6476
|
this.ON_ERROR = ON_ERROR;
|
|
6441
6477
|
this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
|
|
6442
|
-
this.ON_NETWORK_STATS = ON_NETWORK_STATS
|
|
6443
|
-
this.ON_DISCONNECTED = ON_DISCONNECTED
|
|
6478
|
+
this.ON_NETWORK_STATS = ON_NETWORK_STATS;
|
|
6479
|
+
this.ON_DISCONNECTED = ON_DISCONNECTED;
|
|
6444
6480
|
}
|
|
6445
6481
|
|
|
6446
6482
|
configureMedia(media ) {
|
|
@@ -6457,13 +6493,13 @@ class WebRTCClient extends Emitter {
|
|
|
6457
6493
|
|
|
6458
6494
|
createUserAgent(configOverrides ) {
|
|
6459
6495
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6460
|
-
logger$
|
|
6496
|
+
logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6461
6497
|
|
|
6462
6498
|
webRTCConfiguration.delegate = {
|
|
6463
6499
|
onConnect: this.onConnect.bind(this),
|
|
6464
6500
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6465
6501
|
onInvite: (invitation ) => {
|
|
6466
|
-
logger$
|
|
6502
|
+
logger$3.info('sdk webrtc on invite', {
|
|
6467
6503
|
method: 'delegate.onInvite',
|
|
6468
6504
|
id: invitation.id,
|
|
6469
6505
|
remoteURI: invitation.remoteURI,
|
|
@@ -6506,7 +6542,7 @@ class WebRTCClient extends Emitter {
|
|
|
6506
6542
|
}
|
|
6507
6543
|
|
|
6508
6544
|
onConnect() {
|
|
6509
|
-
logger$
|
|
6545
|
+
logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6510
6546
|
this.eventEmitter.emit(CONNECTED);
|
|
6511
6547
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6512
6548
|
this.registerer.waitingToggle(false);
|
|
@@ -6515,7 +6551,7 @@ class WebRTCClient extends Emitter {
|
|
|
6515
6551
|
}
|
|
6516
6552
|
|
|
6517
6553
|
async onDisconnect(error ) {
|
|
6518
|
-
logger$
|
|
6554
|
+
logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6519
6555
|
this.connectionPromise = null;
|
|
6520
6556
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6521
6557
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6540,37 +6576,37 @@ class WebRTCClient extends Emitter {
|
|
|
6540
6576
|
};
|
|
6541
6577
|
|
|
6542
6578
|
if (this.skipRegister) {
|
|
6543
|
-
logger$
|
|
6579
|
+
logger$3.info('sdk webrtc skip register...', logInfo);
|
|
6544
6580
|
return Promise.resolve();
|
|
6545
6581
|
}
|
|
6546
6582
|
|
|
6547
|
-
logger$
|
|
6583
|
+
logger$3.info('sdk webrtc registering...', logInfo);
|
|
6548
6584
|
|
|
6549
6585
|
if (!this.userAgent) {
|
|
6550
|
-
logger$
|
|
6586
|
+
logger$3.info('sdk webrtc recreating User Agent');
|
|
6551
6587
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6552
6588
|
}
|
|
6553
6589
|
if (!this.userAgent || this.isRegistered()) {
|
|
6554
|
-
logger$
|
|
6590
|
+
logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6555
6591
|
return Promise.resolve();
|
|
6556
6592
|
}
|
|
6557
6593
|
|
|
6558
6594
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6559
|
-
logger$
|
|
6595
|
+
logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6560
6596
|
return Promise.resolve();
|
|
6561
6597
|
}
|
|
6562
6598
|
|
|
6563
6599
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6564
6600
|
|
|
6565
6601
|
const onRegisterFailed = () => {
|
|
6566
|
-
logger$
|
|
6602
|
+
logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6567
6603
|
this.connectionPromise = null;
|
|
6568
6604
|
if (this.registerer && this.registerer.waiting) {
|
|
6569
6605
|
this.registerer.waitingToggle(false);
|
|
6570
6606
|
}
|
|
6571
6607
|
|
|
6572
6608
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6573
|
-
logger$
|
|
6609
|
+
logger$3.info('sdk webrtc registering, retrying...', { tries });
|
|
6574
6610
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6575
6611
|
}
|
|
6576
6612
|
};
|
|
@@ -6579,18 +6615,18 @@ class WebRTCClient extends Emitter {
|
|
|
6579
6615
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6580
6616
|
// during the resolution of the primise.
|
|
6581
6617
|
if (!this.userAgent) {
|
|
6582
|
-
logger$
|
|
6618
|
+
logger$3.info('sdk webrtc recreating User Agent after connection');
|
|
6583
6619
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6584
6620
|
}
|
|
6585
6621
|
|
|
6586
|
-
logger$
|
|
6622
|
+
logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6587
6623
|
this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
|
|
6588
6624
|
this.connectionPromise = null;
|
|
6589
6625
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6590
6626
|
|
|
6591
6627
|
// Bind registerer events
|
|
6592
6628
|
this.registerer.stateChange.addListener(newState => {
|
|
6593
|
-
logger$
|
|
6629
|
+
logger$3.info('sdk webrtc registering, state changed', { newState });
|
|
6594
6630
|
|
|
6595
6631
|
if (newState === registererState.RegistererState.Registered && this.registerer
|
|
6596
6632
|
&& this.registerer.state === registererState.RegistererState.Registered) {
|
|
@@ -6603,7 +6639,7 @@ class WebRTCClient extends Emitter {
|
|
|
6603
6639
|
const options = {
|
|
6604
6640
|
requestDelegate: {
|
|
6605
6641
|
onReject: response => {
|
|
6606
|
-
logger$
|
|
6642
|
+
logger$3.error('sdk webrtc registering, rejected', { response });
|
|
6607
6643
|
|
|
6608
6644
|
onRegisterFailed();
|
|
6609
6645
|
},
|
|
@@ -6611,13 +6647,13 @@ class WebRTCClient extends Emitter {
|
|
|
6611
6647
|
};
|
|
6612
6648
|
|
|
6613
6649
|
return this.registerer.register(options).catch((e) => {
|
|
6614
|
-
logger$
|
|
6650
|
+
logger$3.error('sdk webrtc registering, error', e);
|
|
6615
6651
|
|
|
6616
6652
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6617
6653
|
return e;
|
|
6618
6654
|
});
|
|
6619
6655
|
}).catch(error => {
|
|
6620
|
-
logger$
|
|
6656
|
+
logger$3.error('sdk webrtc registering, transport error', error);
|
|
6621
6657
|
onRegisterFailed();
|
|
6622
6658
|
});
|
|
6623
6659
|
}
|
|
@@ -6646,21 +6682,21 @@ class WebRTCClient extends Emitter {
|
|
|
6646
6682
|
}
|
|
6647
6683
|
|
|
6648
6684
|
unregister() {
|
|
6649
|
-
logger$
|
|
6685
|
+
logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6650
6686
|
if (!this.registerer) {
|
|
6651
6687
|
return Promise.resolve();
|
|
6652
6688
|
}
|
|
6653
6689
|
|
|
6654
6690
|
try {
|
|
6655
6691
|
return this.registerer.unregister().then(() => {
|
|
6656
|
-
logger$
|
|
6692
|
+
logger$3.info('sdk webrtc unregistered');
|
|
6657
6693
|
this._cleanupRegister();
|
|
6658
6694
|
}).catch(e => {
|
|
6659
|
-
logger$
|
|
6695
|
+
logger$3.error('sdk webrtc unregistering, promise error', e);
|
|
6660
6696
|
this._cleanupRegister();
|
|
6661
6697
|
});
|
|
6662
6698
|
} catch (e) {
|
|
6663
|
-
logger$
|
|
6699
|
+
logger$3.error('sdk webrtc unregistering, error', e);
|
|
6664
6700
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6665
6701
|
// error when the registerer is in a bad state
|
|
6666
6702
|
this._cleanupRegister();
|
|
@@ -6668,7 +6704,7 @@ class WebRTCClient extends Emitter {
|
|
|
6668
6704
|
}
|
|
6669
6705
|
|
|
6670
6706
|
stop() {
|
|
6671
|
-
logger$
|
|
6707
|
+
logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6672
6708
|
if (!this.userAgent) {
|
|
6673
6709
|
return Promise.resolve();
|
|
6674
6710
|
}
|
|
@@ -6676,12 +6712,12 @@ class WebRTCClient extends Emitter {
|
|
|
6676
6712
|
return this.userAgent.stop().then(() => {
|
|
6677
6713
|
return this._cleanupRegister();
|
|
6678
6714
|
}).catch(e => {
|
|
6679
|
-
logger$
|
|
6715
|
+
logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6680
6716
|
});
|
|
6681
6717
|
}
|
|
6682
6718
|
|
|
6683
6719
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6684
|
-
logger$
|
|
6720
|
+
logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6685
6721
|
const inviterOptions = {
|
|
6686
6722
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6687
6723
|
conference,
|
|
@@ -6706,11 +6742,13 @@ class WebRTCClient extends Emitter {
|
|
|
6706
6742
|
const inviteOptions = {
|
|
6707
6743
|
requestDelegate: {
|
|
6708
6744
|
onAccept: (response ) => {
|
|
6709
|
-
session.sessionDescriptionHandler.peerConnection
|
|
6745
|
+
if (session.sessionDescriptionHandler.peerConnection) {
|
|
6746
|
+
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
6747
|
+
}
|
|
6710
6748
|
this._onAccepted(session, response.session, true);
|
|
6711
6749
|
},
|
|
6712
6750
|
onReject: (response ) => {
|
|
6713
|
-
logger$
|
|
6751
|
+
logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6714
6752
|
this._stopSendingStats(session);
|
|
6715
6753
|
this.stopNetworkMonitoring(session);
|
|
6716
6754
|
|
|
@@ -6733,11 +6771,11 @@ class WebRTCClient extends Emitter {
|
|
|
6733
6771
|
}
|
|
6734
6772
|
|
|
6735
6773
|
answer(session , enableVideo ) {
|
|
6736
|
-
logger$
|
|
6774
|
+
logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
6737
6775
|
|
|
6738
6776
|
if (!session || !session.accept) {
|
|
6739
6777
|
const error = 'No session to answer, or not an invitation';
|
|
6740
|
-
logger$
|
|
6778
|
+
logger$3.warn(error);
|
|
6741
6779
|
return Promise.reject(new Error(error));
|
|
6742
6780
|
}
|
|
6743
6781
|
const options = {
|
|
@@ -6747,15 +6785,15 @@ class WebRTCClient extends Emitter {
|
|
|
6747
6785
|
return session.accept(options).then(() => {
|
|
6748
6786
|
if (session.isCanceled) {
|
|
6749
6787
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
6750
|
-
logger$
|
|
6788
|
+
logger$3.error(message, { id: session.id });
|
|
6751
6789
|
this.onCallEnded(session);
|
|
6752
6790
|
|
|
6753
6791
|
throw new CanceledCallError(message);
|
|
6754
6792
|
}
|
|
6755
|
-
logger$
|
|
6793
|
+
logger$3.info('sdk webrtc answer, accepted.');
|
|
6756
6794
|
this._onAccepted(session);
|
|
6757
6795
|
}).catch(e => {
|
|
6758
|
-
logger$
|
|
6796
|
+
logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
6759
6797
|
|
|
6760
6798
|
throw e;
|
|
6761
6799
|
});
|
|
@@ -6763,7 +6801,7 @@ class WebRTCClient extends Emitter {
|
|
|
6763
6801
|
|
|
6764
6802
|
hangup(session ) {
|
|
6765
6803
|
const { state, id } = session;
|
|
6766
|
-
logger$
|
|
6804
|
+
logger$3.info('sdk webrtc hangup call', { id, state });
|
|
6767
6805
|
|
|
6768
6806
|
try {
|
|
6769
6807
|
this._stopSendingStats(session);
|
|
@@ -6792,7 +6830,7 @@ class WebRTCClient extends Emitter {
|
|
|
6792
6830
|
|
|
6793
6831
|
return bye();
|
|
6794
6832
|
} catch (error) {
|
|
6795
|
-
logger$
|
|
6833
|
+
logger$3.warn('sdk webrtc hangup, error', error);
|
|
6796
6834
|
}
|
|
6797
6835
|
|
|
6798
6836
|
return null;
|
|
@@ -6810,7 +6848,7 @@ class WebRTCClient extends Emitter {
|
|
|
6810
6848
|
// Fetch and emit an event at `interval` with session network stats
|
|
6811
6849
|
startNetworkMonitoring(session , interval = 1000) {
|
|
6812
6850
|
const sessionId = this.getSipSessionId(session);
|
|
6813
|
-
logger$
|
|
6851
|
+
logger$3.info('starting network inspection', { id: sessionId });
|
|
6814
6852
|
|
|
6815
6853
|
this.sessionNetworkStats[sessionId] = [];
|
|
6816
6854
|
|
|
@@ -6820,7 +6858,7 @@ class WebRTCClient extends Emitter {
|
|
|
6820
6858
|
stopNetworkMonitoring(session ) {
|
|
6821
6859
|
const sessionId = this.getSipSessionId(session);
|
|
6822
6860
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
6823
|
-
logger$
|
|
6861
|
+
logger$3.info('stopping network inspection', { id: sessionId, exists });
|
|
6824
6862
|
|
|
6825
6863
|
if (exists) {
|
|
6826
6864
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -6830,17 +6868,17 @@ class WebRTCClient extends Emitter {
|
|
|
6830
6868
|
}
|
|
6831
6869
|
|
|
6832
6870
|
reject(session ) {
|
|
6833
|
-
logger$
|
|
6871
|
+
logger$3.info('sdk webrtc reject call', { id: session.id });
|
|
6834
6872
|
|
|
6835
6873
|
try {
|
|
6836
6874
|
return session.reject ? session.reject() : session.cancel();
|
|
6837
6875
|
} catch (e) {
|
|
6838
|
-
logger$
|
|
6876
|
+
logger$3.warn('Error when rejecting call', e.message, e.stack);
|
|
6839
6877
|
}
|
|
6840
6878
|
}
|
|
6841
6879
|
|
|
6842
6880
|
async close() {
|
|
6843
|
-
logger$
|
|
6881
|
+
logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
6844
6882
|
this._cleanupMedia();
|
|
6845
6883
|
this.connectionPromise = null;
|
|
6846
6884
|
|
|
@@ -6871,7 +6909,7 @@ class WebRTCClient extends Emitter {
|
|
|
6871
6909
|
// eg: "INVITE not rejectable in state Completed"
|
|
6872
6910
|
}
|
|
6873
6911
|
this.userAgent = null;
|
|
6874
|
-
logger$
|
|
6912
|
+
logger$3.info('sdk webrtc client closed');
|
|
6875
6913
|
}
|
|
6876
6914
|
|
|
6877
6915
|
getNumber(session ) {
|
|
@@ -6884,13 +6922,13 @@ class WebRTCClient extends Emitter {
|
|
|
6884
6922
|
}
|
|
6885
6923
|
|
|
6886
6924
|
mute(session ) {
|
|
6887
|
-
logger$
|
|
6925
|
+
logger$3.info('sdk webrtc mute', { id: session.id });
|
|
6888
6926
|
|
|
6889
6927
|
this._toggleAudio(session, true);
|
|
6890
6928
|
}
|
|
6891
6929
|
|
|
6892
6930
|
unmute(session ) {
|
|
6893
|
-
logger$
|
|
6931
|
+
logger$3.info('sdk webrtc unmute', { id: session.id });
|
|
6894
6932
|
|
|
6895
6933
|
this._toggleAudio(session, false);
|
|
6896
6934
|
}
|
|
@@ -6930,13 +6968,13 @@ class WebRTCClient extends Emitter {
|
|
|
6930
6968
|
}
|
|
6931
6969
|
|
|
6932
6970
|
toggleCameraOn(session ) {
|
|
6933
|
-
logger$
|
|
6971
|
+
logger$3.info('sdk webrtc toggle camera on', { id: session.id });
|
|
6934
6972
|
|
|
6935
6973
|
this._toggleVideo(session, false);
|
|
6936
6974
|
}
|
|
6937
6975
|
|
|
6938
6976
|
toggleCameraOff(session ) {
|
|
6939
|
-
logger$
|
|
6977
|
+
logger$3.info('sdk webrtc toggle camera off', { id: session.id });
|
|
6940
6978
|
|
|
6941
6979
|
this._toggleVideo(session, true);
|
|
6942
6980
|
}
|
|
@@ -6945,7 +6983,7 @@ class WebRTCClient extends Emitter {
|
|
|
6945
6983
|
const sessionId = this.getSipSessionId(session);
|
|
6946
6984
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
6947
6985
|
|
|
6948
|
-
logger$
|
|
6986
|
+
logger$3.info('sdk webrtc hold', {
|
|
6949
6987
|
sessionId,
|
|
6950
6988
|
keys: Object.keys(this.heldSessions),
|
|
6951
6989
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6994,7 +7032,7 @@ class WebRTCClient extends Emitter {
|
|
|
6994
7032
|
const sessionId = this.getSipSessionId(session);
|
|
6995
7033
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
6996
7034
|
|
|
6997
|
-
logger$
|
|
7035
|
+
logger$3.info('sdk webrtc unhold', {
|
|
6998
7036
|
sessionId,
|
|
6999
7037
|
keys: Object.keys(this.heldSessions),
|
|
7000
7038
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7142,7 +7180,7 @@ class WebRTCClient extends Emitter {
|
|
|
7142
7180
|
if (!session.sessionDescriptionHandler) {
|
|
7143
7181
|
return;
|
|
7144
7182
|
}
|
|
7145
|
-
logger$
|
|
7183
|
+
logger$3.info('Sending DTMF', {
|
|
7146
7184
|
id: this.getSipSessionId(session),
|
|
7147
7185
|
tone,
|
|
7148
7186
|
});
|
|
@@ -7158,7 +7196,7 @@ class WebRTCClient extends Emitter {
|
|
|
7158
7196
|
transfer(session , target ) {
|
|
7159
7197
|
this.hold(session);
|
|
7160
7198
|
|
|
7161
|
-
logger$
|
|
7199
|
+
logger$3.info('Transfering a session', {
|
|
7162
7200
|
id: this.getSipSessionId(session),
|
|
7163
7201
|
target,
|
|
7164
7202
|
});
|
|
@@ -7180,17 +7218,17 @@ class WebRTCClient extends Emitter {
|
|
|
7180
7218
|
atxfer(session ) {
|
|
7181
7219
|
this.hold(session);
|
|
7182
7220
|
|
|
7183
|
-
logger$
|
|
7221
|
+
logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
7184
7222
|
|
|
7185
7223
|
const result = {
|
|
7186
7224
|
newSession: null,
|
|
7187
7225
|
init: async (target ) => {
|
|
7188
|
-
logger$
|
|
7226
|
+
logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
7189
7227
|
|
|
7190
7228
|
result.newSession = await this.call(target);
|
|
7191
7229
|
},
|
|
7192
7230
|
complete: () => {
|
|
7193
|
-
logger$
|
|
7231
|
+
logger$3.info('webrtc transfer completed', {
|
|
7194
7232
|
id: this.getSipSessionId(session),
|
|
7195
7233
|
referId: this.getSipSessionId(result.newSession),
|
|
7196
7234
|
});
|
|
@@ -7211,7 +7249,7 @@ class WebRTCClient extends Emitter {
|
|
|
7211
7249
|
return;
|
|
7212
7250
|
}
|
|
7213
7251
|
|
|
7214
|
-
logger$
|
|
7252
|
+
logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
7215
7253
|
|
|
7216
7254
|
try {
|
|
7217
7255
|
sipSession.message({
|
|
@@ -7253,7 +7291,7 @@ class WebRTCClient extends Emitter {
|
|
|
7253
7291
|
}
|
|
7254
7292
|
|
|
7255
7293
|
changeAudioOutputVolume(volume ) {
|
|
7256
|
-
logger$
|
|
7294
|
+
logger$3.info('Changing audio output volume', { volume });
|
|
7257
7295
|
|
|
7258
7296
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7259
7297
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -7265,7 +7303,7 @@ class WebRTCClient extends Emitter {
|
|
|
7265
7303
|
}
|
|
7266
7304
|
|
|
7267
7305
|
changeAudioOutputDevice(id ) {
|
|
7268
|
-
logger$
|
|
7306
|
+
logger$3.info('Changing audio output device', { id });
|
|
7269
7307
|
|
|
7270
7308
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7271
7309
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -7282,7 +7320,7 @@ class WebRTCClient extends Emitter {
|
|
|
7282
7320
|
|
|
7283
7321
|
changeAudioInputDevice(id , session ) {
|
|
7284
7322
|
const currentId = this.getAudioDeviceId();
|
|
7285
|
-
logger$
|
|
7323
|
+
logger$3.info('setting audio input device', { id, currentId, session: !!session });
|
|
7286
7324
|
|
|
7287
7325
|
if (id === currentId) {
|
|
7288
7326
|
return null;
|
|
@@ -7328,7 +7366,7 @@ class WebRTCClient extends Emitter {
|
|
|
7328
7366
|
|
|
7329
7367
|
setVideoInputDevice(id ) {
|
|
7330
7368
|
const currentId = this.getVideoDeviceId();
|
|
7331
|
-
logger$
|
|
7369
|
+
logger$3.info('setting video input device', { id, currentId });
|
|
7332
7370
|
|
|
7333
7371
|
if (id === currentId) {
|
|
7334
7372
|
return null;
|
|
@@ -7353,7 +7391,7 @@ class WebRTCClient extends Emitter {
|
|
|
7353
7391
|
const sessionId = this.getSipSessionId(session);
|
|
7354
7392
|
const localStream = this.getLocalStream(sessionId);
|
|
7355
7393
|
|
|
7356
|
-
logger$
|
|
7394
|
+
logger$3.info('changing video input device', { id, sessionId });
|
|
7357
7395
|
|
|
7358
7396
|
// Release old video stream
|
|
7359
7397
|
if (localStream) {
|
|
@@ -7421,7 +7459,7 @@ class WebRTCClient extends Emitter {
|
|
|
7421
7459
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
7422
7460
|
const desktop = newConstraints && newConstraints.desktop;
|
|
7423
7461
|
|
|
7424
|
-
logger$
|
|
7462
|
+
logger$3.info('Sending reinvite', {
|
|
7425
7463
|
id: this.getSipSessionId(sipSession),
|
|
7426
7464
|
newConstraints,
|
|
7427
7465
|
conference,
|
|
@@ -7459,7 +7497,7 @@ class WebRTCClient extends Emitter {
|
|
|
7459
7497
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
7460
7498
|
}
|
|
7461
7499
|
|
|
7462
|
-
logger$
|
|
7500
|
+
logger$3.info('on re-INVITE accepted', {
|
|
7463
7501
|
id: this.getSipSessionId(sipSession),
|
|
7464
7502
|
wasMuted,
|
|
7465
7503
|
shouldDoScreenSharing,
|
|
@@ -7477,7 +7515,7 @@ class WebRTCClient extends Emitter {
|
|
|
7477
7515
|
this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
|
|
7478
7516
|
}
|
|
7479
7517
|
|
|
7480
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
7518
|
+
return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
|
|
7481
7519
|
},
|
|
7482
7520
|
},
|
|
7483
7521
|
sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
|
|
@@ -7578,6 +7616,16 @@ class WebRTCClient extends Emitter {
|
|
|
7578
7616
|
return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
|
|
7579
7617
|
}
|
|
7580
7618
|
|
|
7619
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
7620
|
+
getRemoteVideoStreamFromPc(sessionId ) {
|
|
7621
|
+
const pc = this.getPeerConnection(sessionId);
|
|
7622
|
+
if (!pc) {
|
|
7623
|
+
return null;
|
|
7624
|
+
}
|
|
7625
|
+
|
|
7626
|
+
return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
|
|
7627
|
+
}
|
|
7628
|
+
|
|
7581
7629
|
hasVideo(sessionId ) {
|
|
7582
7630
|
return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
|
|
7583
7631
|
}
|
|
@@ -7624,7 +7672,7 @@ class WebRTCClient extends Emitter {
|
|
|
7624
7672
|
}
|
|
7625
7673
|
|
|
7626
7674
|
startHeartbeat() {
|
|
7627
|
-
logger$
|
|
7675
|
+
logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7628
7676
|
if (!this.userAgent) {
|
|
7629
7677
|
this.heartbeat.stop();
|
|
7630
7678
|
return;
|
|
@@ -7637,7 +7685,7 @@ class WebRTCClient extends Emitter {
|
|
|
7637
7685
|
}
|
|
7638
7686
|
|
|
7639
7687
|
stopHeartbeat() {
|
|
7640
|
-
logger$
|
|
7688
|
+
logger$3.info('sdk webrtc stop heartbeat');
|
|
7641
7689
|
this.heartbeat.stop();
|
|
7642
7690
|
}
|
|
7643
7691
|
|
|
@@ -7658,7 +7706,7 @@ class WebRTCClient extends Emitter {
|
|
|
7658
7706
|
}
|
|
7659
7707
|
|
|
7660
7708
|
attemptReconnection() {
|
|
7661
|
-
logger$
|
|
7709
|
+
logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7662
7710
|
if (!this.userAgent) {
|
|
7663
7711
|
return;
|
|
7664
7712
|
}
|
|
@@ -7683,7 +7731,7 @@ class WebRTCClient extends Emitter {
|
|
|
7683
7731
|
return;
|
|
7684
7732
|
}
|
|
7685
7733
|
|
|
7686
|
-
logger$
|
|
7734
|
+
logger$3.info('setting local media stream', {
|
|
7687
7735
|
sipSessionId,
|
|
7688
7736
|
tracks: newStream ? newStream.getTracks() : null,
|
|
7689
7737
|
});
|
|
@@ -7700,7 +7748,7 @@ class WebRTCClient extends Emitter {
|
|
|
7700
7748
|
|
|
7701
7749
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
7702
7750
|
|
|
7703
|
-
logger$
|
|
7751
|
+
logger$3.info('updating local stream', {
|
|
7704
7752
|
sipSessionId,
|
|
7705
7753
|
oldStream: !!oldStream,
|
|
7706
7754
|
tracks: newStream.getTracks(),
|
|
@@ -7720,7 +7768,7 @@ class WebRTCClient extends Emitter {
|
|
|
7720
7768
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
7721
7769
|
const pc = this.getPeerConnection(sessionId);
|
|
7722
7770
|
|
|
7723
|
-
logger$
|
|
7771
|
+
logger$3.info('Updating remote stream', {
|
|
7724
7772
|
sessionId,
|
|
7725
7773
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
7726
7774
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -7746,7 +7794,7 @@ class WebRTCClient extends Emitter {
|
|
|
7746
7794
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
7747
7795
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
7748
7796
|
|
|
7749
|
-
logger$
|
|
7797
|
+
logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
7750
7798
|
|
|
7751
7799
|
return {
|
|
7752
7800
|
constraints: {
|
|
@@ -7795,7 +7843,7 @@ class WebRTCClient extends Emitter {
|
|
|
7795
7843
|
}
|
|
7796
7844
|
|
|
7797
7845
|
_onTransportError() {
|
|
7798
|
-
logger$
|
|
7846
|
+
logger$3.error('on transport error');
|
|
7799
7847
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
7800
7848
|
this.attemptReconnection();
|
|
7801
7849
|
}
|
|
@@ -7804,7 +7852,7 @@ class WebRTCClient extends Emitter {
|
|
|
7804
7852
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
7805
7853
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
7806
7854
|
if (this.hasHeartbeat()) {
|
|
7807
|
-
logger$
|
|
7855
|
+
logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
7808
7856
|
|
|
7809
7857
|
this.heartbeat.onHeartbeat();
|
|
7810
7858
|
if (this.heartbeatCb) {
|
|
@@ -7815,7 +7863,7 @@ class WebRTCClient extends Emitter {
|
|
|
7815
7863
|
}
|
|
7816
7864
|
|
|
7817
7865
|
async _onHeartbeatTimeout() {
|
|
7818
|
-
logger$
|
|
7866
|
+
logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
7819
7867
|
|
|
7820
7868
|
if (this.heartbeatTimeoutCb) {
|
|
7821
7869
|
this.heartbeatTimeoutCb();
|
|
@@ -7827,7 +7875,7 @@ class WebRTCClient extends Emitter {
|
|
|
7827
7875
|
try {
|
|
7828
7876
|
await this.userAgent.transport.disconnect();
|
|
7829
7877
|
} catch (e) {
|
|
7830
|
-
logger$
|
|
7878
|
+
logger$3.error('Transport disconnection after heartbeat timeout, error', e);
|
|
7831
7879
|
}
|
|
7832
7880
|
}
|
|
7833
7881
|
|
|
@@ -7860,31 +7908,31 @@ class WebRTCClient extends Emitter {
|
|
|
7860
7908
|
}
|
|
7861
7909
|
|
|
7862
7910
|
_connectIfNeeded() {
|
|
7863
|
-
logger$
|
|
7911
|
+
logger$3.info('connect if needed, checking', { connected: this.isConnected() });
|
|
7864
7912
|
if (!this.userAgent) {
|
|
7865
|
-
logger$
|
|
7913
|
+
logger$3.info('need to recreate User Agent');
|
|
7866
7914
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
7867
7915
|
}
|
|
7868
7916
|
|
|
7869
7917
|
if (this.isConnected()) {
|
|
7870
|
-
logger$
|
|
7918
|
+
logger$3.info('webrtc sdk, already connected');
|
|
7871
7919
|
return Promise.resolve();
|
|
7872
7920
|
}
|
|
7873
7921
|
|
|
7874
7922
|
if (this.isConnecting()) {
|
|
7875
|
-
logger$
|
|
7923
|
+
logger$3.info('webrtc sdk, already connecting...');
|
|
7876
7924
|
|
|
7877
7925
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
7878
7926
|
return this.connectionPromise;
|
|
7879
7927
|
}
|
|
7880
7928
|
|
|
7881
7929
|
if (this.connectionPromise) {
|
|
7882
|
-
logger$
|
|
7930
|
+
logger$3.info('webrtc sdk, connection promise connecting...');
|
|
7883
7931
|
// $FlowFixMe
|
|
7884
7932
|
return this.connectionPromise;
|
|
7885
7933
|
}
|
|
7886
7934
|
|
|
7887
|
-
logger$
|
|
7935
|
+
logger$3.info('WebRTC UA needs to connect');
|
|
7888
7936
|
|
|
7889
7937
|
// Force UA to reconnect
|
|
7890
7938
|
if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
|
|
@@ -8009,7 +8057,7 @@ class WebRTCClient extends Emitter {
|
|
|
8009
8057
|
|
|
8010
8058
|
sdh.peerConnectionDelegate = {
|
|
8011
8059
|
onicecandidateerror: (error ) => {
|
|
8012
|
-
logger$
|
|
8060
|
+
logger$3.error('on icecandidate error', {
|
|
8013
8061
|
address: error.address,
|
|
8014
8062
|
port: error.port,
|
|
8015
8063
|
errorCode: error.errorCode,
|
|
@@ -8038,7 +8086,7 @@ class WebRTCClient extends Emitter {
|
|
|
8038
8086
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
8039
8087
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
8040
8088
|
}
|
|
8041
|
-
logger$
|
|
8089
|
+
logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
8042
8090
|
|
|
8043
8091
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
8044
8092
|
|
|
@@ -8054,12 +8102,12 @@ class WebRTCClient extends Emitter {
|
|
|
8054
8102
|
|
|
8055
8103
|
this._setupMedias(session);
|
|
8056
8104
|
|
|
8057
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
8105
|
+
return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
|
|
8058
8106
|
};
|
|
8059
8107
|
}
|
|
8060
8108
|
|
|
8061
8109
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
8062
|
-
logger$
|
|
8110
|
+
logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
8063
8111
|
|
|
8064
8112
|
this.storeSipSession(session);
|
|
8065
8113
|
|
|
@@ -8071,14 +8119,14 @@ class WebRTCClient extends Emitter {
|
|
|
8071
8119
|
const onTrack = (event ) => {
|
|
8072
8120
|
const isAudioOnly = this._isAudioOnly(session);
|
|
8073
8121
|
const { kind, label, readyState, id, muted } = event.track;
|
|
8074
|
-
logger$
|
|
8122
|
+
logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
8075
8123
|
|
|
8076
8124
|
// Stop video track in audio only mode
|
|
8077
8125
|
if (isAudioOnly && kind === 'video') {
|
|
8078
8126
|
event.track.stop();
|
|
8079
8127
|
}
|
|
8080
8128
|
|
|
8081
|
-
this.eventEmitter.emit(ON_TRACK
|
|
8129
|
+
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
8082
8130
|
};
|
|
8083
8131
|
|
|
8084
8132
|
if (session.sessionDescriptionHandler.peerConnection) {
|
|
@@ -8088,8 +8136,9 @@ class WebRTCClient extends Emitter {
|
|
|
8088
8136
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
8089
8137
|
|
|
8090
8138
|
pc.oniceconnectionstatechange = () => {
|
|
8139
|
+
logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
8091
8140
|
if (pc.iceConnectionState === 'disconnected') {
|
|
8092
|
-
this.eventEmitter.emit(ON_DISCONNECTED
|
|
8141
|
+
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
8093
8142
|
}
|
|
8094
8143
|
};
|
|
8095
8144
|
|
|
@@ -8260,10 +8309,10 @@ class WebRTCClient extends Emitter {
|
|
|
8260
8309
|
|
|
8261
8310
|
_stopSendingStats(session ) {
|
|
8262
8311
|
const sessionId = this.getSipSessionId(session);
|
|
8263
|
-
logger$
|
|
8312
|
+
logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
8264
8313
|
|
|
8265
8314
|
if (sessionId in this.statsIntervals) {
|
|
8266
|
-
logger$
|
|
8315
|
+
logger$3.trace('Stop sending stats for call', { sessionId });
|
|
8267
8316
|
this.statsIntervals[sessionId]();
|
|
8268
8317
|
delete this.statsIntervals[sessionId];
|
|
8269
8318
|
}
|
|
@@ -8279,7 +8328,7 @@ class WebRTCClient extends Emitter {
|
|
|
8279
8328
|
try {
|
|
8280
8329
|
await this.userAgent.transport.disconnect();
|
|
8281
8330
|
} catch (e) {
|
|
8282
|
-
logger$
|
|
8331
|
+
logger$3.error('WebRTC transport disconnect, error', e);
|
|
8283
8332
|
}
|
|
8284
8333
|
}
|
|
8285
8334
|
}
|
|
@@ -8316,25 +8365,25 @@ class WebRTCClient extends Emitter {
|
|
|
8316
8365
|
|
|
8317
8366
|
stats.forEach(report => {
|
|
8318
8367
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
8319
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8368
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8320
8369
|
}
|
|
8321
8370
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
8322
|
-
audioBytesSent += report.bytesSent;
|
|
8371
|
+
audioBytesSent += Number(report.bytesSent);
|
|
8323
8372
|
}
|
|
8324
8373
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8325
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8374
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8326
8375
|
}
|
|
8327
8376
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
8328
|
-
packetsLost += report.packetsLost;
|
|
8329
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
8330
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8377
|
+
packetsLost += Number(report.packetsLost);
|
|
8378
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
8379
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8331
8380
|
}
|
|
8332
8381
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
8333
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8382
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8334
8383
|
}
|
|
8335
8384
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8336
8385
|
if ('framesPerSecond' in report) {
|
|
8337
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
8386
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
8338
8387
|
}
|
|
8339
8388
|
if ('framerateMean' in report) {
|
|
8340
8389
|
// framerateMean is only available in FF
|
|
@@ -8342,34 +8391,38 @@ class WebRTCClient extends Emitter {
|
|
|
8342
8391
|
}
|
|
8343
8392
|
}
|
|
8344
8393
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
8345
|
-
packetsLost += report.packetsLost;
|
|
8346
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
8347
|
-
networkStats.jitter = report.jitter;
|
|
8394
|
+
packetsLost += Number(report.packetsLost);
|
|
8395
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
8396
|
+
networkStats.jitter = Number(report.jitter);
|
|
8348
8397
|
}
|
|
8349
8398
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
8350
|
-
packetsLost += report.packetsLost;
|
|
8399
|
+
packetsLost += Number(report.packetsLost);
|
|
8351
8400
|
}
|
|
8352
8401
|
if (report.type === 'transport') {
|
|
8353
|
-
transportSent += report.bytesSent;
|
|
8354
|
-
transportReceived += report.bytesReceived;
|
|
8402
|
+
transportSent += Number(report.bytesSent);
|
|
8403
|
+
transportReceived += Number(report.bytesReceived);
|
|
8355
8404
|
}
|
|
8356
8405
|
});
|
|
8357
8406
|
|
|
8358
8407
|
networkStats.packetsLost = packetsLost;
|
|
8359
|
-
networkStats.
|
|
8408
|
+
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
8409
|
+
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
8410
|
+
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
8360
8411
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
8361
|
-
networkStats.
|
|
8362
|
-
networkStats.
|
|
8412
|
+
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
8413
|
+
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
8414
|
+
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
8415
|
+
networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
|
|
8416
|
+
networkStats.totalTransportSent = transportSent - lastTransportSent;
|
|
8363
8417
|
networkStats.transportSent = transportSent;
|
|
8364
|
-
networkStats.
|
|
8365
|
-
|
|
8366
|
-
const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
|
|
8367
|
-
+ (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
|
|
8368
|
-
+ (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
|
|
8418
|
+
networkStats.totalTransportReceived = transportReceived;
|
|
8419
|
+
networkStats.transportReceived = transportReceived - lastTransportReceived;
|
|
8369
8420
|
|
|
8370
|
-
networkStats.bandwidth =
|
|
8421
|
+
networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
|
|
8422
|
+
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
8423
|
+
+ networkStats.transportSent;
|
|
8371
8424
|
|
|
8372
|
-
this.eventEmitter.emit(ON_NETWORK_STATS
|
|
8425
|
+
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
8373
8426
|
this.sessionNetworkStats[sessionId].push(networkStats);
|
|
8374
8427
|
}
|
|
8375
8428
|
|
|
@@ -8397,8 +8450,8 @@ const ON_CALL_FAILED = 'onCallFailed';
|
|
|
8397
8450
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
8398
8451
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
8399
8452
|
const ON_MESSAGE = 'onMessage';
|
|
8400
|
-
const ON_REINVITE = 'reinvite';
|
|
8401
|
-
const ON_TRACK = 'onTrack';
|
|
8453
|
+
const ON_REINVITE$1 = 'reinvite';
|
|
8454
|
+
const ON_TRACK$1 = 'onTrack';
|
|
8402
8455
|
const ON_AUDIO_STREAM = 'onAudioStream';
|
|
8403
8456
|
const ON_VIDEO_STREAM = 'onVideoStream';
|
|
8404
8457
|
const ON_REMOVE_STREAM = 'onRemoveStream';
|
|
@@ -8413,15 +8466,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
|
|
|
8413
8466
|
const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
|
|
8414
8467
|
const ON_CALL_ERROR = 'onCallError';
|
|
8415
8468
|
const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
|
|
8416
|
-
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
8469
|
+
const ON_NETWORK_STATS$1 = 'onNetworkStats';
|
|
8417
8470
|
const ON_CHAT = 'phone/ON_CHAT';
|
|
8418
8471
|
const ON_SIGNAL = 'phone/ON_SIGNAL';
|
|
8419
|
-
const ON_DISCONNECTED = 'onDisconnected';
|
|
8472
|
+
const ON_DISCONNECTED$1 = 'onDisconnected';
|
|
8420
8473
|
|
|
8421
8474
|
const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
8422
8475
|
const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
8423
8476
|
|
|
8424
|
-
const events = [
|
|
8477
|
+
const events$1 = [
|
|
8425
8478
|
ON_USER_AGENT,
|
|
8426
8479
|
ON_REGISTERED,
|
|
8427
8480
|
ON_UNREGISTERED,
|
|
@@ -8439,8 +8492,8 @@ const events = [
|
|
|
8439
8492
|
ON_CALL_FAILED,
|
|
8440
8493
|
ON_CALL_ENDED,
|
|
8441
8494
|
ON_MESSAGE,
|
|
8442
|
-
ON_REINVITE,
|
|
8443
|
-
ON_TRACK,
|
|
8495
|
+
ON_REINVITE$1,
|
|
8496
|
+
ON_TRACK$1,
|
|
8444
8497
|
ON_AUDIO_STREAM,
|
|
8445
8498
|
ON_VIDEO_STREAM,
|
|
8446
8499
|
ON_REMOVE_STREAM,
|
|
@@ -8455,11 +8508,11 @@ const events = [
|
|
|
8455
8508
|
ON_CALL_ERROR,
|
|
8456
8509
|
ON_CHAT,
|
|
8457
8510
|
ON_SIGNAL,
|
|
8458
|
-
ON_NETWORK_STATS,
|
|
8459
|
-
ON_DISCONNECTED,
|
|
8511
|
+
ON_NETWORK_STATS$1,
|
|
8512
|
+
ON_DISCONNECTED$1,
|
|
8460
8513
|
];
|
|
8461
8514
|
|
|
8462
|
-
const logger$
|
|
8515
|
+
const logger$4 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
8463
8516
|
|
|
8464
8517
|
class WebRTCPhone extends Emitter {
|
|
8465
8518
|
|
|
@@ -8532,7 +8585,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8532
8585
|
}).catch(error => {
|
|
8533
8586
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
8534
8587
|
console.error('register error', error, error.message, error.stack);
|
|
8535
|
-
logger$
|
|
8588
|
+
logger$4.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
8536
8589
|
});
|
|
8537
8590
|
}
|
|
8538
8591
|
|
|
@@ -8547,7 +8600,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8547
8600
|
if (!this.client) {
|
|
8548
8601
|
return;
|
|
8549
8602
|
}
|
|
8550
|
-
logger$
|
|
8603
|
+
logger$4.info('WebRTC phone stop');
|
|
8551
8604
|
this.client.stop();
|
|
8552
8605
|
}
|
|
8553
8606
|
|
|
@@ -8562,7 +8615,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8562
8615
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
8563
8616
|
audioOnly = false, iceRestart = false) {
|
|
8564
8617
|
const sipSession = this.findSipSession(callSession);
|
|
8565
|
-
logger$
|
|
8618
|
+
logger$4.info('WebRTC phone - send reinvite', {
|
|
8566
8619
|
sessionId: sipSession ? sipSession.id : null,
|
|
8567
8620
|
constraints,
|
|
8568
8621
|
audioOnly,
|
|
@@ -8599,7 +8652,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8599
8652
|
}
|
|
8600
8653
|
|
|
8601
8654
|
startHeartbeat() {
|
|
8602
|
-
logger$
|
|
8655
|
+
logger$4.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
8603
8656
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
8604
8657
|
return;
|
|
8605
8658
|
}
|
|
@@ -8608,7 +8661,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8608
8661
|
}
|
|
8609
8662
|
|
|
8610
8663
|
stopHeartbeat() {
|
|
8611
|
-
logger$
|
|
8664
|
+
logger$4.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
8612
8665
|
if (!this.client) {
|
|
8613
8666
|
return;
|
|
8614
8667
|
}
|
|
@@ -8625,7 +8678,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8625
8678
|
}
|
|
8626
8679
|
|
|
8627
8680
|
reconnect() {
|
|
8628
|
-
logger$
|
|
8681
|
+
logger$4.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
8629
8682
|
if (!this.client) {
|
|
8630
8683
|
return;
|
|
8631
8684
|
}
|
|
@@ -8666,10 +8719,15 @@ class WebRTCPhone extends Emitter {
|
|
|
8666
8719
|
return false;
|
|
8667
8720
|
}
|
|
8668
8721
|
|
|
8669
|
-
logger$
|
|
8722
|
+
logger$4.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
8670
8723
|
|
|
8671
8724
|
this.client.downgradeToAudio(sipSession);
|
|
8672
8725
|
|
|
8726
|
+
if (callSession) {
|
|
8727
|
+
callSession.cameraEnabled = false;
|
|
8728
|
+
this._updateCallSession(callSession);
|
|
8729
|
+
}
|
|
8730
|
+
|
|
8673
8731
|
if (withMessage) {
|
|
8674
8732
|
this._sendReinviteMessage(callSession, false);
|
|
8675
8733
|
}
|
|
@@ -8684,7 +8742,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8684
8742
|
return Promise.resolve(false);
|
|
8685
8743
|
}
|
|
8686
8744
|
|
|
8687
|
-
logger$
|
|
8745
|
+
logger$4.info('Upgrade to video', {
|
|
8688
8746
|
id: callSession ? callSession.getId() : null,
|
|
8689
8747
|
constraints,
|
|
8690
8748
|
isConference,
|
|
@@ -8697,6 +8755,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8697
8755
|
|
|
8698
8756
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
8699
8757
|
|
|
8758
|
+
if (callSession) {
|
|
8759
|
+
callSession.cameraEnabled = true;
|
|
8760
|
+
this._updateCallSession(callSession);
|
|
8761
|
+
}
|
|
8762
|
+
|
|
8700
8763
|
// If no stream is returned, it means we have to reinvite
|
|
8701
8764
|
if (!newStream) {
|
|
8702
8765
|
return true;
|
|
@@ -8719,7 +8782,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8719
8782
|
|
|
8720
8783
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
8721
8784
|
const sipSession = this.findSipSession(callSession);
|
|
8722
|
-
logger$
|
|
8785
|
+
logger$4.info('Sending reinvite message', {
|
|
8723
8786
|
id: callSession ? callSession.getId() : null,
|
|
8724
8787
|
isUpgrade,
|
|
8725
8788
|
});
|
|
@@ -8745,11 +8808,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8745
8808
|
// Monkey patch to know when canceled with the CANCEL message
|
|
8746
8809
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
8747
8810
|
sipSession._onCancel = (message ) => {
|
|
8748
|
-
logger$
|
|
8811
|
+
logger$4.trace('on sip session canceled', { callId: message.callId });
|
|
8749
8812
|
|
|
8750
8813
|
onCancel(message);
|
|
8751
8814
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
8752
|
-
|
|
8815
|
+
const callSession = this._createCallSession(sipSession);
|
|
8816
|
+
delete this.callSessions[callSession.getId()];
|
|
8817
|
+
|
|
8818
|
+
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
8753
8819
|
};
|
|
8754
8820
|
} else if (sipSession instanceof invitation.Invitation) {
|
|
8755
8821
|
console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
|
|
@@ -8770,17 +8836,19 @@ class WebRTCPhone extends Emitter {
|
|
|
8770
8836
|
this.audioOutputVolume,
|
|
8771
8837
|
);
|
|
8772
8838
|
case sessionState.SessionState.Terminating:
|
|
8773
|
-
logger$
|
|
8839
|
+
logger$4.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
8774
8840
|
|
|
8775
8841
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
8776
8842
|
|
|
8777
8843
|
break;
|
|
8778
8844
|
case sessionState.SessionState.Terminated: {
|
|
8779
|
-
logger$
|
|
8845
|
+
logger$4.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
8780
8846
|
|
|
8847
|
+
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
8848
|
+
const callSession = this._createCallSession(sipSession);
|
|
8781
8849
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
8782
8850
|
|
|
8783
|
-
return this.eventEmitter.emit(ON_CALL_ENDED,
|
|
8851
|
+
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
8784
8852
|
}
|
|
8785
8853
|
}
|
|
8786
8854
|
});
|
|
@@ -8796,7 +8864,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8796
8864
|
const [stream] = event.streams;
|
|
8797
8865
|
const kind = event && event.track && event.track.kind;
|
|
8798
8866
|
|
|
8799
|
-
logger$
|
|
8867
|
+
logger$4.info('on track stream called on the peer connection', {
|
|
8800
8868
|
callId: this.getSipSessionId(sipSession),
|
|
8801
8869
|
streamId: stream ? stream.id : null,
|
|
8802
8870
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -8816,7 +8884,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8816
8884
|
};
|
|
8817
8885
|
|
|
8818
8886
|
peerConnection.onremovestream = event => {
|
|
8819
|
-
logger$
|
|
8887
|
+
logger$4.info('on remove stream called on the peer connection', {
|
|
8820
8888
|
id: event.stream.id,
|
|
8821
8889
|
tracks: event.stream.getTracks(),
|
|
8822
8890
|
});
|
|
@@ -8826,7 +8894,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8826
8894
|
}
|
|
8827
8895
|
|
|
8828
8896
|
async startScreenSharing(constraints , callSession ) {
|
|
8829
|
-
logger$
|
|
8897
|
+
logger$4.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
8830
8898
|
|
|
8831
8899
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
8832
8900
|
if (!screenShareStream) {
|
|
@@ -8866,7 +8934,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8866
8934
|
return;
|
|
8867
8935
|
}
|
|
8868
8936
|
|
|
8869
|
-
logger$
|
|
8937
|
+
logger$4.info('WebRTC phone - stop screen sharing', {
|
|
8870
8938
|
restoreLocalStream,
|
|
8871
8939
|
});
|
|
8872
8940
|
|
|
@@ -8922,24 +8990,26 @@ class WebRTCPhone extends Emitter {
|
|
|
8922
8990
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
8923
8991
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
8924
8992
|
|
|
8925
|
-
logger$
|
|
8993
|
+
logger$4.info('WebRTC phone - on screensharing', {
|
|
8926
8994
|
hadVideo,
|
|
8927
8995
|
id: this.getSipSessionId(sipSession),
|
|
8928
8996
|
screenTrack,
|
|
8929
8997
|
});
|
|
8930
8998
|
|
|
8931
|
-
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8999
|
+
if (screenTrack) {
|
|
9000
|
+
screenTrack.onended = () => {
|
|
9001
|
+
logger$4.info('WebRTC phone - on screenshare ended', {
|
|
9002
|
+
hadVideo,
|
|
9003
|
+
id: this.getSipSessionId(sipSession),
|
|
9004
|
+
screenTrack,
|
|
9005
|
+
});
|
|
8937
9006
|
|
|
8938
|
-
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
9007
|
+
this.eventEmitter.emit(
|
|
9008
|
+
ON_SHARE_SCREEN_ENDING,
|
|
9009
|
+
this._createCallSession(sipSession, callSession),
|
|
9010
|
+
);
|
|
9011
|
+
};
|
|
9012
|
+
}
|
|
8943
9013
|
|
|
8944
9014
|
this.currentScreenShare = {
|
|
8945
9015
|
stream: screenStream,
|
|
@@ -8959,7 +9029,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8959
9029
|
}
|
|
8960
9030
|
|
|
8961
9031
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
8962
|
-
logger$
|
|
9032
|
+
logger$4.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
8963
9033
|
|
|
8964
9034
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
8965
9035
|
this.currentSipSession = sipSession;
|
|
@@ -8977,7 +9047,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8977
9047
|
}
|
|
8978
9048
|
|
|
8979
9049
|
changeAudioDevice(id ) {
|
|
8980
|
-
logger$
|
|
9050
|
+
logger$4.info('WebRTC phone - change audio device', { deviceId: id });
|
|
8981
9051
|
this.audioOutputDeviceId = id;
|
|
8982
9052
|
this.client.changeAudioOutputDevice(id);
|
|
8983
9053
|
}
|
|
@@ -8987,14 +9057,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8987
9057
|
}
|
|
8988
9058
|
|
|
8989
9059
|
changeRingDevice(id ) {
|
|
8990
|
-
logger$
|
|
9060
|
+
logger$4.info('WebRTC phone - changing ring device', { id });
|
|
8991
9061
|
|
|
8992
9062
|
this.audioRingDeviceId = id;
|
|
8993
9063
|
}
|
|
8994
9064
|
|
|
8995
9065
|
// volume is a value between 0 and 1
|
|
8996
9066
|
changeAudioVolume(volume ) {
|
|
8997
|
-
logger$
|
|
9067
|
+
logger$4.info('WebRTC phone - changing audio volume', { volume });
|
|
8998
9068
|
|
|
8999
9069
|
this.audioOutputVolume = volume;
|
|
9000
9070
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -9002,31 +9072,31 @@ class WebRTCPhone extends Emitter {
|
|
|
9002
9072
|
|
|
9003
9073
|
// volume is a value between 0 and 1
|
|
9004
9074
|
changeRingVolume(volume ) {
|
|
9005
|
-
logger$
|
|
9075
|
+
logger$4.info('WebRTC phone - changing ring volume', { volume });
|
|
9006
9076
|
|
|
9007
9077
|
this.audioRingVolume = volume;
|
|
9008
9078
|
}
|
|
9009
9079
|
|
|
9010
9080
|
changeAudioInputDevice(id ) {
|
|
9011
|
-
logger$
|
|
9081
|
+
logger$4.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
9012
9082
|
|
|
9013
9083
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
9014
9084
|
}
|
|
9015
9085
|
|
|
9016
9086
|
changeVideoInputDevice(id ) {
|
|
9017
|
-
logger$
|
|
9087
|
+
logger$4.info('WebRTC phone - change video input device', { deviceId: id });
|
|
9018
9088
|
|
|
9019
9089
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
9020
9090
|
}
|
|
9021
9091
|
|
|
9022
9092
|
changeSessionVideoInputDevice(id ) {
|
|
9023
|
-
logger$
|
|
9093
|
+
logger$4.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
9024
9094
|
|
|
9025
9095
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
9026
9096
|
}
|
|
9027
9097
|
|
|
9028
9098
|
_onCallTerminated(sipSession ) {
|
|
9029
|
-
logger$
|
|
9099
|
+
logger$4.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9030
9100
|
|
|
9031
9101
|
const callSession = this._createCallSession(sipSession);
|
|
9032
9102
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -9060,7 +9130,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9060
9130
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
9061
9131
|
|
|
9062
9132
|
// Re-trigger incoming call event for remaining incoming calls
|
|
9063
|
-
logger$
|
|
9133
|
+
logger$4.info('WebRTC phone - check to re-trigger incoming call', {
|
|
9064
9134
|
sipId: sipSession.id,
|
|
9065
9135
|
shouldRetrigger,
|
|
9066
9136
|
hasIncomingCallSession,
|
|
@@ -9151,37 +9221,37 @@ class WebRTCPhone extends Emitter {
|
|
|
9151
9221
|
|
|
9152
9222
|
// Deprecated
|
|
9153
9223
|
getLocalStreamForCall(callSession ) {
|
|
9154
|
-
logger$
|
|
9224
|
+
logger$4.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9155
9225
|
|
|
9156
9226
|
return this.getLocalStream(callSession);
|
|
9157
9227
|
}
|
|
9158
9228
|
|
|
9159
9229
|
// Deprecated
|
|
9160
9230
|
getRemoteStreamForCall(callSession ) {
|
|
9161
|
-
logger$
|
|
9231
|
+
logger$4.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
9162
9232
|
|
|
9163
9233
|
return this.getRemoteVideoStream(callSession);
|
|
9164
9234
|
}
|
|
9165
9235
|
|
|
9166
9236
|
getRemoteStreamsForCall(callSession ) {
|
|
9167
|
-
logger$
|
|
9237
|
+
logger$4.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
9168
9238
|
|
|
9169
9239
|
return this.getRemoteStream(callSession);
|
|
9170
9240
|
}
|
|
9171
9241
|
|
|
9172
9242
|
accept(callSession , cameraEnabled ) {
|
|
9173
|
-
logger$
|
|
9243
|
+
logger$4.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
9174
9244
|
if (this.currentSipSession) {
|
|
9175
9245
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
9176
9246
|
}
|
|
9177
9247
|
|
|
9178
9248
|
if (!callSession) {
|
|
9179
|
-
logger$
|
|
9249
|
+
logger$4.warn('no CallSession to accept.');
|
|
9180
9250
|
return Promise.resolve(null);
|
|
9181
9251
|
}
|
|
9182
9252
|
|
|
9183
9253
|
if (callSession.getId() in this.acceptedSessions) {
|
|
9184
|
-
logger$
|
|
9254
|
+
logger$4.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9185
9255
|
return Promise.resolve(callSession.sipCallId);
|
|
9186
9256
|
}
|
|
9187
9257
|
|
|
@@ -9193,24 +9263,24 @@ class WebRTCPhone extends Emitter {
|
|
|
9193
9263
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
9194
9264
|
if (sipSession) {
|
|
9195
9265
|
if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
|
|
9196
|
-
logger$
|
|
9266
|
+
logger$4.warn('Trying to answer a terminated sipSession.');
|
|
9197
9267
|
|
|
9198
9268
|
return Promise.resolve(null);
|
|
9199
9269
|
}
|
|
9200
9270
|
|
|
9201
|
-
logger$
|
|
9271
|
+
logger$4.info('accept call, session found', { sipId: sipSession.id });
|
|
9202
9272
|
|
|
9203
9273
|
// $FlowFixMe
|
|
9204
9274
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
9205
9275
|
return callSession.sipCallId;
|
|
9206
9276
|
}).catch(e => {
|
|
9207
|
-
logger$
|
|
9277
|
+
logger$4.error(e);
|
|
9208
9278
|
this.endCurrentCall(callSession);
|
|
9209
9279
|
throw e;
|
|
9210
9280
|
});
|
|
9211
9281
|
}
|
|
9212
9282
|
|
|
9213
|
-
logger$
|
|
9283
|
+
logger$4.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9214
9284
|
|
|
9215
9285
|
return Promise.resolve(null);
|
|
9216
9286
|
}
|
|
@@ -9220,7 +9290,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9220
9290
|
}
|
|
9221
9291
|
|
|
9222
9292
|
async reject(callSession ) {
|
|
9223
|
-
logger$
|
|
9293
|
+
logger$4.info('reject WebRTC called', { id: callSession.getId() });
|
|
9224
9294
|
|
|
9225
9295
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
9226
9296
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -9232,14 +9302,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9232
9302
|
|
|
9233
9303
|
const sipSession = this.findSipSession(callSession);
|
|
9234
9304
|
if (sipSession) {
|
|
9235
|
-
logger$
|
|
9305
|
+
logger$4.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
9236
9306
|
|
|
9237
9307
|
this.client.hangup(sipSession);
|
|
9238
9308
|
}
|
|
9239
9309
|
}
|
|
9240
9310
|
|
|
9241
9311
|
async ignore(callSession ) {
|
|
9242
|
-
logger$
|
|
9312
|
+
logger$4.info('WebRTC ignore', { id: callSession.getId() });
|
|
9243
9313
|
|
|
9244
9314
|
// kill the ring
|
|
9245
9315
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -9251,14 +9321,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9251
9321
|
const sipSession = this.findSipSession(callSession);
|
|
9252
9322
|
|
|
9253
9323
|
if (sipSession) {
|
|
9254
|
-
logger$
|
|
9324
|
+
logger$4.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
9255
9325
|
|
|
9256
9326
|
return this.client.atxfer(sipSession);
|
|
9257
9327
|
}
|
|
9258
9328
|
}
|
|
9259
9329
|
|
|
9260
9330
|
hold(callSession , withEvent = true, isConference = false) {
|
|
9261
|
-
logger$
|
|
9331
|
+
logger$4.info('WebRTC hold', { id: callSession.getId() });
|
|
9262
9332
|
|
|
9263
9333
|
const sipSession = this.findSipSession(callSession);
|
|
9264
9334
|
|
|
@@ -9273,18 +9343,18 @@ class WebRTCPhone extends Emitter {
|
|
|
9273
9343
|
}
|
|
9274
9344
|
|
|
9275
9345
|
resume(callSession , isConference = false, withEvent = true) {
|
|
9276
|
-
logger$
|
|
9346
|
+
logger$4.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
9277
9347
|
|
|
9278
9348
|
const sipSession = this.findSipSession(callSession);
|
|
9279
9349
|
if (!sipSession) {
|
|
9280
9350
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
9281
9351
|
}
|
|
9282
9352
|
|
|
9283
|
-
logger$
|
|
9353
|
+
logger$4.info('WebRTC resuming', { sipId: sipSession.id });
|
|
9284
9354
|
|
|
9285
9355
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
9286
9356
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
9287
|
-
logger$
|
|
9357
|
+
logger$4.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
9288
9358
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
9289
9359
|
}
|
|
9290
9360
|
|
|
@@ -9309,7 +9379,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9309
9379
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9310
9380
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
9311
9381
|
|
|
9312
|
-
logger$
|
|
9382
|
+
logger$4.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9313
9383
|
|
|
9314
9384
|
// Stop screenshre if needed
|
|
9315
9385
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -9340,7 +9410,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9340
9410
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
9341
9411
|
}
|
|
9342
9412
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9343
|
-
logger$
|
|
9413
|
+
logger$4.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
9344
9414
|
|
|
9345
9415
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
9346
9416
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -9384,14 +9454,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9384
9454
|
}
|
|
9385
9455
|
|
|
9386
9456
|
mute(callSession , withEvent = true) {
|
|
9387
|
-
logger$
|
|
9457
|
+
logger$4.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
9388
9458
|
|
|
9389
9459
|
const sipSession = this.findSipSession(callSession);
|
|
9390
9460
|
if (!sipSession) {
|
|
9391
9461
|
return;
|
|
9392
9462
|
}
|
|
9393
9463
|
|
|
9394
|
-
logger$
|
|
9464
|
+
logger$4.info('WebRTC muting', { sipId: sipSession.id });
|
|
9395
9465
|
this.client.mute(sipSession);
|
|
9396
9466
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
9397
9467
|
|
|
@@ -9405,14 +9475,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9405
9475
|
}
|
|
9406
9476
|
|
|
9407
9477
|
unmute(callSession , withEvent = true) {
|
|
9408
|
-
logger$
|
|
9478
|
+
logger$4.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
9409
9479
|
|
|
9410
9480
|
const sipSession = this.findSipSession(callSession);
|
|
9411
9481
|
if (!sipSession) {
|
|
9412
9482
|
return;
|
|
9413
9483
|
}
|
|
9414
9484
|
|
|
9415
|
-
logger$
|
|
9485
|
+
logger$4.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
9416
9486
|
this.client.unmute(sipSession);
|
|
9417
9487
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
9418
9488
|
|
|
@@ -9439,7 +9509,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9439
9509
|
if (!sipSession) {
|
|
9440
9510
|
return;
|
|
9441
9511
|
}
|
|
9442
|
-
logger$
|
|
9512
|
+
logger$4.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
9443
9513
|
|
|
9444
9514
|
this.client.toggleCameraOn(sipSession);
|
|
9445
9515
|
|
|
@@ -9451,7 +9521,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9451
9521
|
if (!sipSession) {
|
|
9452
9522
|
return;
|
|
9453
9523
|
}
|
|
9454
|
-
logger$
|
|
9524
|
+
logger$4.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
9455
9525
|
|
|
9456
9526
|
this.client.toggleCameraOff(sipSession);
|
|
9457
9527
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -9463,7 +9533,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9463
9533
|
return;
|
|
9464
9534
|
}
|
|
9465
9535
|
|
|
9466
|
-
logger$
|
|
9536
|
+
logger$4.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
9467
9537
|
this.client.sendDTMF(sipSession, tone);
|
|
9468
9538
|
}
|
|
9469
9539
|
|
|
@@ -9471,7 +9541,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9471
9541
|
// @TODO: line is not used here
|
|
9472
9542
|
async makeCall(number , line , cameraEnabled ,
|
|
9473
9543
|
audioOnly = false, conference = false) {
|
|
9474
|
-
logger$
|
|
9544
|
+
logger$4.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
9475
9545
|
if (!number) {
|
|
9476
9546
|
return Promise.resolve(null);
|
|
9477
9547
|
}
|
|
@@ -9481,7 +9551,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9481
9551
|
}
|
|
9482
9552
|
if (this.currentSipSession) {
|
|
9483
9553
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
9484
|
-
logger$
|
|
9554
|
+
logger$4.warn('Unable to hold current session when making another call', e);
|
|
9485
9555
|
});
|
|
9486
9556
|
}
|
|
9487
9557
|
|
|
@@ -9491,7 +9561,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9491
9561
|
this._bindEvents(sipSession);
|
|
9492
9562
|
} catch (error) {
|
|
9493
9563
|
console.warn(error);
|
|
9494
|
-
logger$
|
|
9564
|
+
logger$4.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
9495
9565
|
return Promise.resolve(null);
|
|
9496
9566
|
}
|
|
9497
9567
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -9519,7 +9589,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9519
9589
|
return;
|
|
9520
9590
|
}
|
|
9521
9591
|
|
|
9522
|
-
logger$
|
|
9592
|
+
logger$4.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
9523
9593
|
|
|
9524
9594
|
this.client.transfer(sipSession, target);
|
|
9525
9595
|
}
|
|
@@ -9528,7 +9598,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9528
9598
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
9529
9599
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
9530
9600
|
|
|
9531
|
-
logger$
|
|
9601
|
+
logger$4.info('WebRTC indirect transfer', {
|
|
9532
9602
|
sipId: sipSession ? sipSession.id : null,
|
|
9533
9603
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
9534
9604
|
});
|
|
@@ -9567,7 +9637,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9567
9637
|
return false;
|
|
9568
9638
|
}
|
|
9569
9639
|
|
|
9570
|
-
logger$
|
|
9640
|
+
logger$4.info('WebRTC hangup', { sipId: sipSession.id });
|
|
9571
9641
|
|
|
9572
9642
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9573
9643
|
|
|
@@ -9613,7 +9683,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9613
9683
|
endCurrentCall(callSession ) {
|
|
9614
9684
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
9615
9685
|
|
|
9616
|
-
logger$
|
|
9686
|
+
logger$4.info('Ending current call', {
|
|
9617
9687
|
id: callSession ? callSession.getId() : null,
|
|
9618
9688
|
isCurrent,
|
|
9619
9689
|
});
|
|
@@ -9637,7 +9707,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9637
9707
|
}
|
|
9638
9708
|
|
|
9639
9709
|
async close() {
|
|
9640
|
-
logger$
|
|
9710
|
+
logger$4.info('WebRTC close');
|
|
9641
9711
|
|
|
9642
9712
|
try {
|
|
9643
9713
|
await Promise.race([
|
|
@@ -9645,7 +9715,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9645
9715
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
9646
9716
|
]);
|
|
9647
9717
|
} catch (e) {
|
|
9648
|
-
logger$
|
|
9718
|
+
logger$4.error('WebRTC close, unregister error', e);
|
|
9649
9719
|
}
|
|
9650
9720
|
|
|
9651
9721
|
this.client.close();
|
|
@@ -9663,12 +9733,12 @@ class WebRTCPhone extends Emitter {
|
|
|
9663
9733
|
}
|
|
9664
9734
|
|
|
9665
9735
|
enableRinging() {
|
|
9666
|
-
logger$
|
|
9736
|
+
logger$4.info('WebRTC enable ringing');
|
|
9667
9737
|
this.ringingEnabled = true;
|
|
9668
9738
|
}
|
|
9669
9739
|
|
|
9670
9740
|
disableRinging() {
|
|
9671
|
-
logger$
|
|
9741
|
+
logger$4.info('WebRTC disable ringing');
|
|
9672
9742
|
this.ringingEnabled = false;
|
|
9673
9743
|
}
|
|
9674
9744
|
|
|
@@ -9708,7 +9778,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9708
9778
|
|
|
9709
9779
|
// Deprecated
|
|
9710
9780
|
getLocalMediaStream(callSession ) {
|
|
9711
|
-
logger$
|
|
9781
|
+
logger$4.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9712
9782
|
return this.getLocalStream(callSession);
|
|
9713
9783
|
}
|
|
9714
9784
|
|
|
@@ -9728,6 +9798,10 @@ class WebRTCPhone extends Emitter {
|
|
|
9728
9798
|
return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
|
|
9729
9799
|
}
|
|
9730
9800
|
|
|
9801
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
9802
|
+
return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
|
|
9803
|
+
}
|
|
9804
|
+
|
|
9731
9805
|
hasRemoteVideo(callSession ) {
|
|
9732
9806
|
return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
|
|
9733
9807
|
}
|
|
@@ -9746,7 +9820,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9746
9820
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
9747
9821
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
9748
9822
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
9749
|
-
logger$
|
|
9823
|
+
logger$4.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
9750
9824
|
|
|
9751
9825
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
9752
9826
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -9769,7 +9843,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9769
9843
|
});
|
|
9770
9844
|
|
|
9771
9845
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
9772
|
-
logger$
|
|
9846
|
+
logger$4.info('WebRTC on reinvite', {
|
|
9773
9847
|
sessionId: args[0].id,
|
|
9774
9848
|
inviteId: args[1].id,
|
|
9775
9849
|
updatedCalleeName: args[2],
|
|
@@ -9789,7 +9863,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9789
9863
|
});
|
|
9790
9864
|
|
|
9791
9865
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
9792
|
-
logger$
|
|
9866
|
+
logger$4.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
9793
9867
|
|
|
9794
9868
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
9795
9869
|
|
|
@@ -9800,22 +9874,22 @@ class WebRTCPhone extends Emitter {
|
|
|
9800
9874
|
this.client.on('ended', () => {});
|
|
9801
9875
|
|
|
9802
9876
|
this.client.on(this.client.ON_ERROR, e => {
|
|
9803
|
-
logger$
|
|
9877
|
+
logger$4.error('WebRTC error', e);
|
|
9804
9878
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
9805
9879
|
});
|
|
9806
9880
|
|
|
9807
9881
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
9808
|
-
logger$
|
|
9882
|
+
logger$4.info('WebRTC unregistered');
|
|
9809
9883
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
9810
9884
|
});
|
|
9811
9885
|
|
|
9812
9886
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
9813
|
-
logger$
|
|
9814
|
-
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
9887
|
+
logger$4.info('WebRTC disconnected');
|
|
9888
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
9815
9889
|
});
|
|
9816
9890
|
|
|
9817
9891
|
this.client.on(this.client.REGISTERED, () => {
|
|
9818
|
-
logger$
|
|
9892
|
+
logger$4.info('WebRTC registered', {
|
|
9819
9893
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
9820
9894
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
9821
9895
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -9828,23 +9902,27 @@ class WebRTCPhone extends Emitter {
|
|
|
9828
9902
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
9829
9903
|
&& this.currentSipSession.state === sessionState.SessionState.Established) {
|
|
9830
9904
|
this.shouldSendReinvite = false;
|
|
9905
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
9906
|
+
const isConference = pc ? pc.sfu : false;
|
|
9907
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
9908
|
+
|
|
9831
9909
|
try {
|
|
9832
9910
|
// Send reinvite with iceRestart
|
|
9833
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
9911
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
9834
9912
|
} catch (e) {
|
|
9835
|
-
logger$
|
|
9913
|
+
logger$4.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
9836
9914
|
}
|
|
9837
9915
|
}
|
|
9838
9916
|
});
|
|
9839
9917
|
|
|
9840
9918
|
this.client.on(this.client.CONNECTED, () => {
|
|
9841
|
-
logger$
|
|
9919
|
+
logger$4.info('WebRTC client connected');
|
|
9842
9920
|
|
|
9843
9921
|
this.stopHeartbeat();
|
|
9844
9922
|
});
|
|
9845
9923
|
|
|
9846
9924
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
9847
|
-
logger$
|
|
9925
|
+
logger$4.info('WebRTC client disconnected');
|
|
9848
9926
|
|
|
9849
9927
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
9850
9928
|
|
|
@@ -9858,7 +9936,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9858
9936
|
});
|
|
9859
9937
|
|
|
9860
9938
|
this.client.on(this.client.ON_TRACK, (session, event) => {
|
|
9861
|
-
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
9939
|
+
this.eventEmitter.emit(ON_TRACK$1, session, event);
|
|
9862
9940
|
});
|
|
9863
9941
|
|
|
9864
9942
|
this.client.on('onVideoInputChange', stream => {
|
|
@@ -9873,7 +9951,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9873
9951
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
9874
9952
|
const callSession = this.getCallSession(this.getSipSessionId(session));
|
|
9875
9953
|
|
|
9876
|
-
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
9954
|
+
this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
|
|
9877
9955
|
});
|
|
9878
9956
|
|
|
9879
9957
|
// Used when upgrading directly in screenshare mode
|
|
@@ -9882,7 +9960,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9882
9960
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
9883
9961
|
const callSession = this.callSessions[sipSessionId];
|
|
9884
9962
|
|
|
9885
|
-
logger$
|
|
9963
|
+
logger$4.info('Updrading directly in screensharing mode', {
|
|
9886
9964
|
sipSessionId,
|
|
9887
9965
|
tracks: localStream ? localStream.getTracks() : null,
|
|
9888
9966
|
});
|
|
@@ -9914,6 +9992,15 @@ class WebRTCPhone extends Emitter {
|
|
|
9914
9992
|
return this.client.getSipSessionId(sipSession);
|
|
9915
9993
|
}
|
|
9916
9994
|
|
|
9995
|
+
_updateCallSession(callSession ) {
|
|
9996
|
+
const sipSession = this.findSipSession(callSession);
|
|
9997
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
9998
|
+
|
|
9999
|
+
if (sipSessionId) {
|
|
10000
|
+
this.callSessions[sipSessionId] = callSession;
|
|
10001
|
+
}
|
|
10002
|
+
}
|
|
10003
|
+
|
|
9917
10004
|
_onMessage(message ) {
|
|
9918
10005
|
if (!message || message.method !== 'MESSAGE') {
|
|
9919
10006
|
return;
|
|
@@ -10051,8 +10138,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10051
10138
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10052
10139
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10053
10140
|
ON_MESSAGE: ON_MESSAGE,
|
|
10054
|
-
ON_REINVITE: ON_REINVITE,
|
|
10055
|
-
ON_TRACK: ON_TRACK,
|
|
10141
|
+
ON_REINVITE: ON_REINVITE$1,
|
|
10142
|
+
ON_TRACK: ON_TRACK$1,
|
|
10056
10143
|
ON_AUDIO_STREAM: ON_AUDIO_STREAM,
|
|
10057
10144
|
ON_VIDEO_STREAM: ON_VIDEO_STREAM,
|
|
10058
10145
|
ON_REMOVE_STREAM: ON_REMOVE_STREAM,
|
|
@@ -10067,13 +10154,13 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10067
10154
|
ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
|
|
10068
10155
|
ON_CALL_ERROR: ON_CALL_ERROR,
|
|
10069
10156
|
ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
|
|
10070
|
-
ON_NETWORK_STATS: ON_NETWORK_STATS,
|
|
10157
|
+
ON_NETWORK_STATS: ON_NETWORK_STATS$1,
|
|
10071
10158
|
ON_CHAT: ON_CHAT,
|
|
10072
10159
|
ON_SIGNAL: ON_SIGNAL,
|
|
10073
|
-
ON_DISCONNECTED: ON_DISCONNECTED,
|
|
10160
|
+
ON_DISCONNECTED: ON_DISCONNECTED$1,
|
|
10074
10161
|
MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
|
|
10075
10162
|
MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
|
|
10076
|
-
events: events,
|
|
10163
|
+
events: events$1,
|
|
10077
10164
|
'default': WebRTCPhone
|
|
10078
10165
|
});
|
|
10079
10166
|
|
|
@@ -10082,7 +10169,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10082
10169
|
class InvalidSubscription extends Error {}
|
|
10083
10170
|
class InvalidAuthorization extends Error {}
|
|
10084
10171
|
|
|
10085
|
-
const logger$
|
|
10172
|
+
const logger$5 = IssueReporter$1.loggerFor('simple-auth');
|
|
10086
10173
|
|
|
10087
10174
|
class Auth {
|
|
10088
10175
|
|
|
@@ -10117,7 +10204,7 @@ class Auth {
|
|
|
10117
10204
|
setApiClientId(this.clientId);
|
|
10118
10205
|
setRefreshExpiration(this.expiration);
|
|
10119
10206
|
setOnRefreshToken((token , session ) => {
|
|
10120
|
-
logger$
|
|
10207
|
+
logger$5.info('on refresh token done', { token });
|
|
10121
10208
|
setApiToken(token);
|
|
10122
10209
|
Wazo.Websocket.updateToken(token);
|
|
10123
10210
|
|
|
@@ -10162,7 +10249,7 @@ class Auth {
|
|
|
10162
10249
|
const rawSession = await getApiClient().auth.authenticate(token);
|
|
10163
10250
|
return this._onAuthenticated(rawSession);
|
|
10164
10251
|
} catch (e) {
|
|
10165
|
-
logger$
|
|
10252
|
+
logger$5.error('on validate token error', e);
|
|
10166
10253
|
console.warn(e);
|
|
10167
10254
|
return false;
|
|
10168
10255
|
}
|
|
@@ -10343,7 +10430,7 @@ var Auth$1 = global.wazoAuthInstance;
|
|
|
10343
10430
|
|
|
10344
10431
|
//
|
|
10345
10432
|
|
|
10346
|
-
const SOCKET_EVENTS
|
|
10433
|
+
const SOCKET_EVENTS = {
|
|
10347
10434
|
ON_OPEN: 'onopen',
|
|
10348
10435
|
ON_MESSAGE: 'onmessage',
|
|
10349
10436
|
ON_ERROR: 'onerror',
|
|
@@ -10429,6 +10516,7 @@ const AGENT_PAUSED = 'agent_paused';
|
|
|
10429
10516
|
const AGENT_UNPAUSED = 'agent_unpaused';
|
|
10430
10517
|
const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
|
|
10431
10518
|
const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
|
|
10519
|
+
const MEETING_USER_PROGRESS = 'meeting_user_progress';
|
|
10432
10520
|
|
|
10433
10521
|
const BLACKLIST_EVENTS = [
|
|
10434
10522
|
CHAT_MESSAGE_SENT,
|
|
@@ -10495,16 +10583,16 @@ class WebSocketClient extends Emitter {
|
|
|
10495
10583
|
|
|
10496
10584
|
this.socket.onopen = () => {
|
|
10497
10585
|
logger$6.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
10498
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10586
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
10499
10587
|
};
|
|
10500
10588
|
|
|
10501
10589
|
this.socket.onerror = event => {
|
|
10502
10590
|
logger$6.error('on Wazo WS error', event.target);
|
|
10503
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10591
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
10504
10592
|
};
|
|
10505
10593
|
|
|
10506
10594
|
this.socket.onmessage = (event ) => {
|
|
10507
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10595
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
|
|
10508
10596
|
|
|
10509
10597
|
const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
|
|
10510
10598
|
let { name } = message;
|
|
@@ -10537,11 +10625,11 @@ class WebSocketClient extends Emitter {
|
|
|
10537
10625
|
token: this.token,
|
|
10538
10626
|
});
|
|
10539
10627
|
this.initialized = false;
|
|
10540
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10628
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
|
|
10541
10629
|
|
|
10542
10630
|
switch (event.code) {
|
|
10543
10631
|
case 4002:
|
|
10544
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10632
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
|
|
10545
10633
|
break;
|
|
10546
10634
|
}
|
|
10547
10635
|
};
|
|
@@ -10657,7 +10745,7 @@ class WebSocketClient extends Emitter {
|
|
|
10657
10745
|
break;
|
|
10658
10746
|
case 'start':
|
|
10659
10747
|
this.initialized = true;
|
|
10660
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10748
|
+
this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
|
|
10661
10749
|
break;
|
|
10662
10750
|
default:
|
|
10663
10751
|
this.eventEmitter.emit('message', message);
|
|
@@ -10704,7 +10792,7 @@ class WebSocketClient extends Emitter {
|
|
|
10704
10792
|
logger$6.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
10705
10793
|
|
|
10706
10794
|
this.close();
|
|
10707
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10795
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
10708
10796
|
|
|
10709
10797
|
if (this.onHeartBeatTimeout) {
|
|
10710
10798
|
this.onHeartBeatTimeout();
|
|
@@ -10779,11 +10867,12 @@ WebSocketClient.eventLists = [
|
|
|
10779
10867
|
AGENT_UNPAUSED,
|
|
10780
10868
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
10781
10869
|
CONFERENCE_ADHOC_DELETED,
|
|
10870
|
+
MEETING_USER_PROGRESS,
|
|
10782
10871
|
];
|
|
10783
10872
|
|
|
10784
10873
|
var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
10785
10874
|
__proto__: null,
|
|
10786
|
-
SOCKET_EVENTS: SOCKET_EVENTS
|
|
10875
|
+
SOCKET_EVENTS: SOCKET_EVENTS,
|
|
10787
10876
|
AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
|
|
10788
10877
|
FAVORITE_ADDED: FAVORITE_ADDED,
|
|
10789
10878
|
FAVORITE_DELETED: FAVORITE_DELETED,
|
|
@@ -10849,16 +10938,17 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
10849
10938
|
AGENT_UNPAUSED: AGENT_UNPAUSED,
|
|
10850
10939
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
10851
10940
|
CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
|
|
10941
|
+
MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
|
|
10852
10942
|
HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
|
|
10853
10943
|
'default': WebSocketClient
|
|
10854
10944
|
});
|
|
10855
10945
|
|
|
10856
10946
|
//
|
|
10857
10947
|
|
|
10858
|
-
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
10859
|
-
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
10948
|
+
const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
10949
|
+
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
|
|
10860
10950
|
|
|
10861
|
-
const logger$
|
|
10951
|
+
const logger$7 = IssueReporter$1.loggerFor('simple-ws-client');
|
|
10862
10952
|
|
|
10863
10953
|
class Websocket extends Emitter {
|
|
10864
10954
|
|
|
@@ -10872,9 +10962,9 @@ class Websocket extends Emitter {
|
|
|
10872
10962
|
// $FlowFixMe
|
|
10873
10963
|
this[key] = OTHER_EVENTS[key];
|
|
10874
10964
|
});
|
|
10875
|
-
Object.keys(SOCKET_EVENTS).forEach(key => {
|
|
10965
|
+
Object.keys(SOCKET_EVENTS$1).forEach(key => {
|
|
10876
10966
|
// $FlowFixMe
|
|
10877
|
-
this[key] = SOCKET_EVENTS[key];
|
|
10967
|
+
this[key] = SOCKET_EVENTS$1[key];
|
|
10878
10968
|
});
|
|
10879
10969
|
this.eventLists = WebSocketClient.eventLists;
|
|
10880
10970
|
|
|
@@ -10882,7 +10972,7 @@ class Websocket extends Emitter {
|
|
|
10882
10972
|
}
|
|
10883
10973
|
|
|
10884
10974
|
open(host , session ) {
|
|
10885
|
-
logger$
|
|
10975
|
+
logger$7.info('open simple WebSocket', { host, token: session.token });
|
|
10886
10976
|
this.ws = new WebSocketClient(
|
|
10887
10977
|
{
|
|
10888
10978
|
host,
|
|
@@ -10910,7 +11000,7 @@ class Websocket extends Emitter {
|
|
|
10910
11000
|
}
|
|
10911
11001
|
|
|
10912
11002
|
updateToken(token ) {
|
|
10913
|
-
logger$
|
|
11003
|
+
logger$7.info('update token via simple Websocket', { token, ws: !!this.ws });
|
|
10914
11004
|
|
|
10915
11005
|
if (!this.ws) {
|
|
10916
11006
|
return;
|
|
@@ -10938,7 +11028,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
|
|
|
10938
11028
|
|
|
10939
11029
|
//
|
|
10940
11030
|
|
|
10941
|
-
const logger$
|
|
11031
|
+
const logger$8 = IssueReporter$1.loggerFor('room');
|
|
10942
11032
|
|
|
10943
11033
|
class Participant extends Emitter {
|
|
10944
11034
|
|
|
@@ -11060,7 +11150,7 @@ class Participant extends Emitter {
|
|
|
11060
11150
|
}
|
|
11061
11151
|
|
|
11062
11152
|
onTalking(isTalking ) {
|
|
11063
|
-
logger$
|
|
11153
|
+
logger$8.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
|
|
11064
11154
|
this.isTalking = isTalking;
|
|
11065
11155
|
// you may notice we're not broadcasting: since all participants are getting this info
|
|
11066
11156
|
// directly from asterisk, there's no need to do so
|
|
@@ -11163,7 +11253,7 @@ class Participant extends Emitter {
|
|
|
11163
11253
|
}
|
|
11164
11254
|
|
|
11165
11255
|
updateStatus(status , broadcast = true) {
|
|
11166
|
-
logger$
|
|
11256
|
+
logger$8.info('updating participant status', { name: this.name, status });
|
|
11167
11257
|
|
|
11168
11258
|
if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
|
|
11169
11259
|
if (status.audioMuted) {
|
|
@@ -11211,7 +11301,7 @@ class Participant extends Emitter {
|
|
|
11211
11301
|
|
|
11212
11302
|
broadcastStatus(inboundStatus = null) {
|
|
11213
11303
|
const status = inboundStatus || this.getStatus();
|
|
11214
|
-
logger$
|
|
11304
|
+
logger$8.info('broadcasting participant status', { callId: this.callId, status });
|
|
11215
11305
|
|
|
11216
11306
|
this.room.sendSignal({
|
|
11217
11307
|
type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
|
|
@@ -11247,9 +11337,9 @@ class LocalParticipant extends Participant {
|
|
|
11247
11337
|
const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
11248
11338
|
const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
11249
11339
|
|
|
11250
|
-
const logger$
|
|
11340
|
+
const logger$9 = IssueReporter$1.loggerFor('sdk-room');
|
|
11251
11341
|
|
|
11252
|
-
class Room
|
|
11342
|
+
class Room extends Emitter {
|
|
11253
11343
|
|
|
11254
11344
|
|
|
11255
11345
|
|
|
@@ -11307,7 +11397,7 @@ class Room$1 extends Emitter {
|
|
|
11307
11397
|
extra = {},
|
|
11308
11398
|
) {
|
|
11309
11399
|
super();
|
|
11310
|
-
logger$
|
|
11400
|
+
logger$9.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
11311
11401
|
|
|
11312
11402
|
// Represents the room callSession
|
|
11313
11403
|
this.callSession = callSession;
|
|
@@ -11373,7 +11463,7 @@ class Room$1 extends Emitter {
|
|
|
11373
11463
|
* @returns {Promise<Room>}
|
|
11374
11464
|
*/
|
|
11375
11465
|
static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
|
|
11376
|
-
logger$
|
|
11466
|
+
logger$9.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
11377
11467
|
|
|
11378
11468
|
if (!room) {
|
|
11379
11469
|
await Wazo.Phone.connect();
|
|
@@ -11386,7 +11476,7 @@ class Room$1 extends Emitter {
|
|
|
11386
11476
|
|
|
11387
11477
|
// Call_created is triggered before call_accepted, so we have to listen for it here.
|
|
11388
11478
|
Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
|
|
11389
|
-
logger$
|
|
11479
|
+
logger$9.info('room call received via WS', { callId: data.call_id });
|
|
11390
11480
|
if (room) {
|
|
11391
11481
|
room.setCallId(data.call_id);
|
|
11392
11482
|
}
|
|
@@ -11394,7 +11484,7 @@ class Room$1 extends Emitter {
|
|
|
11394
11484
|
|
|
11395
11485
|
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
11396
11486
|
// eslint-disable-next-line no-param-reassign
|
|
11397
|
-
room = new Room
|
|
11487
|
+
room = new Room(callSession, extension, null, null, extra);
|
|
11398
11488
|
|
|
11399
11489
|
// Wait for the call to be accepted
|
|
11400
11490
|
await new Promise((resolve, reject) => {
|
|
@@ -11415,7 +11505,7 @@ class Room$1 extends Emitter {
|
|
|
11415
11505
|
// Retrieve conference
|
|
11416
11506
|
const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
|
|
11417
11507
|
|
|
11418
|
-
logger$
|
|
11508
|
+
logger$9.info('connected to room', {
|
|
11419
11509
|
sourceId: conference ? conference.sourceId : null,
|
|
11420
11510
|
name: conference ? conference.name : null,
|
|
11421
11511
|
});
|
|
@@ -11425,7 +11515,7 @@ class Room$1 extends Emitter {
|
|
|
11425
11515
|
room.setName(conference.name);
|
|
11426
11516
|
}
|
|
11427
11517
|
} else if (meeting) {
|
|
11428
|
-
logger$
|
|
11518
|
+
logger$9.info('Already connected to meeting', {
|
|
11429
11519
|
uuid: meeting.uuid,
|
|
11430
11520
|
name: meeting.name,
|
|
11431
11521
|
});
|
|
@@ -11438,13 +11528,13 @@ class Room$1 extends Emitter {
|
|
|
11438
11528
|
}
|
|
11439
11529
|
|
|
11440
11530
|
static disconnect() {
|
|
11441
|
-
logger$
|
|
11531
|
+
logger$9.info('static disconnection to room');
|
|
11442
11532
|
|
|
11443
11533
|
Wazo.Phone.disconnect();
|
|
11444
11534
|
}
|
|
11445
11535
|
|
|
11446
11536
|
async disconnect() {
|
|
11447
|
-
logger$
|
|
11537
|
+
logger$9.info('disconnection to room called');
|
|
11448
11538
|
|
|
11449
11539
|
await Wazo.Phone.hangup(this.callSession);
|
|
11450
11540
|
this.callSession = null;
|
|
@@ -11464,19 +11554,19 @@ class Room$1 extends Emitter {
|
|
|
11464
11554
|
}
|
|
11465
11555
|
|
|
11466
11556
|
setSourceId(sourceId ) {
|
|
11467
|
-
logger$
|
|
11557
|
+
logger$9.info('set room source id', { sourceId });
|
|
11468
11558
|
|
|
11469
11559
|
this.sourceId = sourceId;
|
|
11470
11560
|
}
|
|
11471
11561
|
|
|
11472
11562
|
setMeetingUuid(meetingUuid ) {
|
|
11473
|
-
logger$
|
|
11563
|
+
logger$9.info('set meeting uuid', { meetingUuid });
|
|
11474
11564
|
|
|
11475
11565
|
this.meetingUuid = meetingUuid;
|
|
11476
11566
|
}
|
|
11477
11567
|
|
|
11478
11568
|
setCallId(callId ) {
|
|
11479
|
-
logger$
|
|
11569
|
+
logger$9.info('set room call id', { callId });
|
|
11480
11570
|
|
|
11481
11571
|
if (callId) {
|
|
11482
11572
|
this.callId = callId;
|
|
@@ -11484,7 +11574,7 @@ class Room$1 extends Emitter {
|
|
|
11484
11574
|
}
|
|
11485
11575
|
|
|
11486
11576
|
setName(name ) {
|
|
11487
|
-
logger$
|
|
11577
|
+
logger$9.info('set room name', { name });
|
|
11488
11578
|
|
|
11489
11579
|
this.name = name;
|
|
11490
11580
|
}
|
|
@@ -11503,7 +11593,7 @@ class Room$1 extends Emitter {
|
|
|
11503
11593
|
}
|
|
11504
11594
|
|
|
11505
11595
|
async startScreenSharing(constraints ) {
|
|
11506
|
-
logger$
|
|
11596
|
+
logger$9.info('start room screen sharing', { constraints });
|
|
11507
11597
|
|
|
11508
11598
|
const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
|
|
11509
11599
|
if (!screensharingStream) {
|
|
@@ -11517,7 +11607,7 @@ class Room$1 extends Emitter {
|
|
|
11517
11607
|
}
|
|
11518
11608
|
|
|
11519
11609
|
async stopScreenSharing(restoreLocalStream = true) {
|
|
11520
|
-
logger$
|
|
11610
|
+
logger$9.info('stop room screen sharing');
|
|
11521
11611
|
|
|
11522
11612
|
await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
11523
11613
|
|
|
@@ -11529,7 +11619,7 @@ class Room$1 extends Emitter {
|
|
|
11529
11619
|
}
|
|
11530
11620
|
|
|
11531
11621
|
turnCameraOff() {
|
|
11532
|
-
logger$
|
|
11622
|
+
logger$9.info('turn room camera off');
|
|
11533
11623
|
|
|
11534
11624
|
Wazo.Phone.turnCameraOff(this.callSession);
|
|
11535
11625
|
|
|
@@ -11539,7 +11629,7 @@ class Room$1 extends Emitter {
|
|
|
11539
11629
|
}
|
|
11540
11630
|
|
|
11541
11631
|
turnCameraOn() {
|
|
11542
|
-
logger$
|
|
11632
|
+
logger$9.info('turn room camera on');
|
|
11543
11633
|
|
|
11544
11634
|
Wazo.Phone.turnCameraOn(this.callSession);
|
|
11545
11635
|
|
|
@@ -11549,7 +11639,7 @@ class Room$1 extends Emitter {
|
|
|
11549
11639
|
}
|
|
11550
11640
|
|
|
11551
11641
|
mute() {
|
|
11552
|
-
logger$
|
|
11642
|
+
logger$9.info('mute room');
|
|
11553
11643
|
|
|
11554
11644
|
Wazo.Phone.mute(this.callSession);
|
|
11555
11645
|
|
|
@@ -11557,7 +11647,7 @@ class Room$1 extends Emitter {
|
|
|
11557
11647
|
}
|
|
11558
11648
|
|
|
11559
11649
|
unmute() {
|
|
11560
|
-
logger$
|
|
11650
|
+
logger$9.info('unmute room');
|
|
11561
11651
|
|
|
11562
11652
|
Wazo.Phone.unmute(this.callSession);
|
|
11563
11653
|
|
|
@@ -11577,7 +11667,7 @@ class Room$1 extends Emitter {
|
|
|
11577
11667
|
}
|
|
11578
11668
|
|
|
11579
11669
|
hold() {
|
|
11580
|
-
logger$
|
|
11670
|
+
logger$9.info('hold room');
|
|
11581
11671
|
|
|
11582
11672
|
Wazo.Phone.hold(this.callSession, true);
|
|
11583
11673
|
|
|
@@ -11587,7 +11677,7 @@ class Room$1 extends Emitter {
|
|
|
11587
11677
|
}
|
|
11588
11678
|
|
|
11589
11679
|
async resume() {
|
|
11590
|
-
logger$
|
|
11680
|
+
logger$9.info('resume room');
|
|
11591
11681
|
|
|
11592
11682
|
const newStream = await Wazo.Phone.resume(this.callSession, true);
|
|
11593
11683
|
|
|
@@ -11615,13 +11705,13 @@ class Room$1 extends Emitter {
|
|
|
11615
11705
|
}
|
|
11616
11706
|
|
|
11617
11707
|
sendDTMF(tone ) {
|
|
11618
|
-
logger$
|
|
11708
|
+
logger$9.info('send room DTMF', { tone });
|
|
11619
11709
|
|
|
11620
11710
|
Wazo.Phone.sendDTMF(tone, this.callSession);
|
|
11621
11711
|
}
|
|
11622
11712
|
|
|
11623
11713
|
async sendReinvite(newConstraints = null) {
|
|
11624
|
-
logger$
|
|
11714
|
+
logger$9.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
11625
11715
|
const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
|
|
11626
11716
|
|
|
11627
11717
|
Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
|
|
@@ -11680,7 +11770,7 @@ class Room$1 extends Emitter {
|
|
|
11680
11770
|
Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
11681
11771
|
|
|
11682
11772
|
this.on(this.ON_AUDIO_STREAM, stream => {
|
|
11683
|
-
logger$
|
|
11773
|
+
logger$9.info('on room audio stream');
|
|
11684
11774
|
|
|
11685
11775
|
this.audioStream = stream;
|
|
11686
11776
|
if (!this.roomAudioElement) {
|
|
@@ -11693,7 +11783,7 @@ class Room$1 extends Emitter {
|
|
|
11693
11783
|
});
|
|
11694
11784
|
|
|
11695
11785
|
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
11696
|
-
logger$
|
|
11786
|
+
logger$9.info('on room video stream', { streamId });
|
|
11697
11787
|
|
|
11698
11788
|
this._mapMsid(sipSession.body.body);
|
|
11699
11789
|
|
|
@@ -11708,7 +11798,7 @@ class Room$1 extends Emitter {
|
|
|
11708
11798
|
});
|
|
11709
11799
|
|
|
11710
11800
|
this.on(this.ON_REMOVE_STREAM, stream => {
|
|
11711
|
-
logger$
|
|
11801
|
+
logger$9.info('on room remove stream');
|
|
11712
11802
|
|
|
11713
11803
|
const participant = this.participants.find(someParticipant =>
|
|
11714
11804
|
someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
|
|
@@ -11840,7 +11930,7 @@ class Room$1 extends Emitter {
|
|
|
11840
11930
|
const requester = this._getParticipantFromCallId(origin.callId);
|
|
11841
11931
|
if (requester) {
|
|
11842
11932
|
// @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
|
|
11843
|
-
logger$
|
|
11933
|
+
logger$9.info('trigger room requester status', { origin });
|
|
11844
11934
|
requester.triggerUpdate('REQUESTER_UPDATE');
|
|
11845
11935
|
}
|
|
11846
11936
|
break;
|
|
@@ -11871,24 +11961,24 @@ class Room$1 extends Emitter {
|
|
|
11871
11961
|
|
|
11872
11962
|
// When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
|
|
11873
11963
|
if (participant.user_uuid === session.uuid) {
|
|
11874
|
-
logger$
|
|
11964
|
+
logger$9.info('room current user joined');
|
|
11875
11965
|
|
|
11876
11966
|
// Retrieve participants via an API calls
|
|
11877
11967
|
const conferenceId = this.sourceId || payload.data.conference_id;
|
|
11878
11968
|
let response;
|
|
11879
11969
|
try {
|
|
11880
11970
|
if (this.meetingUuid) {
|
|
11881
|
-
logger$
|
|
11971
|
+
logger$9.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
11882
11972
|
response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
|
|
11883
11973
|
} else {
|
|
11884
|
-
logger$
|
|
11974
|
+
logger$9.info('fetching conference participants', { conferenceId });
|
|
11885
11975
|
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
11886
11976
|
}
|
|
11887
11977
|
} catch (e) {
|
|
11888
|
-
logger$
|
|
11978
|
+
logger$9.error('room participants fetching, error', e);
|
|
11889
11979
|
}
|
|
11890
11980
|
if (response) {
|
|
11891
|
-
logger$
|
|
11981
|
+
logger$9.info('conference participants fetched', { nb: response.items.length });
|
|
11892
11982
|
participants = response.items.map(item => {
|
|
11893
11983
|
const isMe = item.call_id === this.callId;
|
|
11894
11984
|
|
|
@@ -11915,7 +12005,7 @@ class Room$1 extends Emitter {
|
|
|
11915
12005
|
? new Wazo.RemoteParticipant(this, participant)
|
|
11916
12006
|
: null;
|
|
11917
12007
|
|
|
11918
|
-
logger$
|
|
12008
|
+
logger$9.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
11919
12009
|
|
|
11920
12010
|
if (remoteParticipant) {
|
|
11921
12011
|
this.participants.push(remoteParticipant);
|
|
@@ -12080,12 +12170,12 @@ class Room$1 extends Emitter {
|
|
|
12080
12170
|
|
|
12081
12171
|
//
|
|
12082
12172
|
|
|
12083
|
-
const logger$
|
|
12173
|
+
const logger$a = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
12084
12174
|
|
|
12085
|
-
class SipRoom extends Room
|
|
12175
|
+
class SipRoom extends Room {
|
|
12086
12176
|
|
|
12087
12177
|
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
12088
|
-
logger$
|
|
12178
|
+
logger$a.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
12089
12179
|
|
|
12090
12180
|
if (!room) {
|
|
12091
12181
|
await Wazo.Phone.connect();
|
|
@@ -12101,7 +12191,7 @@ class SipRoom extends Room$1 {
|
|
|
12101
12191
|
room.setCallId(room.callSession.call.id);
|
|
12102
12192
|
}
|
|
12103
12193
|
|
|
12104
|
-
logger$
|
|
12194
|
+
logger$a.info('connected to room', {
|
|
12105
12195
|
extension: room.extension,
|
|
12106
12196
|
});
|
|
12107
12197
|
|
|
@@ -12109,7 +12199,7 @@ class SipRoom extends Room$1 {
|
|
|
12109
12199
|
}
|
|
12110
12200
|
|
|
12111
12201
|
mute() {
|
|
12112
|
-
logger$
|
|
12202
|
+
logger$a.info('mute sip room');
|
|
12113
12203
|
|
|
12114
12204
|
Wazo.Phone.mute(this.callSession, false);
|
|
12115
12205
|
|
|
@@ -12117,7 +12207,7 @@ class SipRoom extends Room$1 {
|
|
|
12117
12207
|
}
|
|
12118
12208
|
|
|
12119
12209
|
unmute() {
|
|
12120
|
-
logger$
|
|
12210
|
+
logger$a.info('unmute sip room');
|
|
12121
12211
|
|
|
12122
12212
|
Wazo.Phone.unmute(this.callSession, false);
|
|
12123
12213
|
|
|
@@ -12401,7 +12491,7 @@ class NotificationOptions {
|
|
|
12401
12491
|
|
|
12402
12492
|
|
|
12403
12493
|
// Represents a conference room, like `9000`.
|
|
12404
|
-
class Room {
|
|
12494
|
+
class Room$1 {
|
|
12405
12495
|
|
|
12406
12496
|
|
|
12407
12497
|
|
|
@@ -12422,7 +12512,7 @@ class Room {
|
|
|
12422
12512
|
}
|
|
12423
12513
|
|
|
12424
12514
|
connect(callSession ) {
|
|
12425
|
-
return new Room({ ...this, connectedCallSession: callSession });
|
|
12515
|
+
return new Room$1({ ...this, connectedCallSession: callSession });
|
|
12426
12516
|
}
|
|
12427
12517
|
|
|
12428
12518
|
has(callSession ) {
|
|
@@ -12431,7 +12521,7 @@ class Room {
|
|
|
12431
12521
|
|
|
12432
12522
|
addParticipant(uuid , extension , talking = null) {
|
|
12433
12523
|
if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
|
|
12434
|
-
return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
12524
|
+
return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
12435
12525
|
}
|
|
12436
12526
|
|
|
12437
12527
|
return this;
|
|
@@ -12450,7 +12540,7 @@ class Room {
|
|
|
12450
12540
|
updatedParticipants.push(participant);
|
|
12451
12541
|
}
|
|
12452
12542
|
|
|
12453
|
-
return new Room({ ...this, participants: updatedParticipants });
|
|
12543
|
+
return new Room$1({ ...this, participants: updatedParticipants });
|
|
12454
12544
|
}
|
|
12455
12545
|
|
|
12456
12546
|
updateParticipantByExtension(extension , participant , shouldAdd = false) {
|
|
@@ -12466,7 +12556,7 @@ class Room {
|
|
|
12466
12556
|
updatedParticipants.push(participant);
|
|
12467
12557
|
}
|
|
12468
12558
|
|
|
12469
|
-
return new Room({ ...this, participants: updatedParticipants });
|
|
12559
|
+
return new Room$1({ ...this, participants: updatedParticipants });
|
|
12470
12560
|
}
|
|
12471
12561
|
|
|
12472
12562
|
hasCallWithId(id ) {
|
|
@@ -12474,18 +12564,18 @@ class Room {
|
|
|
12474
12564
|
}
|
|
12475
12565
|
|
|
12476
12566
|
disconnect() {
|
|
12477
|
-
return new Room({ ...this, connectedCallSession: null });
|
|
12567
|
+
return new Room$1({ ...this, connectedCallSession: null });
|
|
12478
12568
|
}
|
|
12479
12569
|
|
|
12480
12570
|
removeParticipantWithUUID(uuid ) {
|
|
12481
|
-
return new Room({
|
|
12571
|
+
return new Room$1({
|
|
12482
12572
|
...this,
|
|
12483
12573
|
participants: this.participants.filter(participant => participant.uuid !== uuid),
|
|
12484
12574
|
});
|
|
12485
12575
|
}
|
|
12486
12576
|
|
|
12487
12577
|
removeParticipantWithExtension(extension ) {
|
|
12488
|
-
return new Room({
|
|
12578
|
+
return new Room$1({
|
|
12489
12579
|
...this,
|
|
12490
12580
|
participants: this.participants.filter(participant => participant.extension !== extension),
|
|
12491
12581
|
});
|
|
@@ -12496,7 +12586,7 @@ class Room {
|
|
|
12496
12586
|
}
|
|
12497
12587
|
|
|
12498
12588
|
static newFrom(room ) {
|
|
12499
|
-
return newFrom(room, Room);
|
|
12589
|
+
return newFrom(room, Room$1);
|
|
12500
12590
|
}
|
|
12501
12591
|
}
|
|
12502
12592
|
|
|
@@ -12803,11 +12893,11 @@ var wazoWebsocket = {
|
|
|
12803
12893
|
resolve();
|
|
12804
12894
|
};
|
|
12805
12895
|
|
|
12806
|
-
client.on(SOCKET_EVENTS
|
|
12896
|
+
client.on(SOCKET_EVENTS.ON_ERROR, error => {
|
|
12807
12897
|
handleError(`Connection error : ${error}`);
|
|
12808
12898
|
});
|
|
12809
12899
|
|
|
12810
|
-
client.on(SOCKET_EVENTS
|
|
12900
|
+
client.on(SOCKET_EVENTS.ON_OPEN, () => {
|
|
12811
12901
|
if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
|
|
12812
12902
|
client.setOnHeartbeatTimeout(() => {
|
|
12813
12903
|
handleError('No response to heartbeat');
|
|
@@ -12908,7 +12998,7 @@ var webrtc = {
|
|
|
12908
12998
|
}),
|
|
12909
12999
|
};
|
|
12910
13000
|
|
|
12911
|
-
const parseCandidate = line => {
|
|
13001
|
+
const parseCandidate$1 = line => {
|
|
12912
13002
|
let parts;
|
|
12913
13003
|
// Parse both variants.
|
|
12914
13004
|
if (line.indexOf('a=candidate:') === 0) {
|
|
@@ -12999,7 +13089,7 @@ var SymmetricNat = {
|
|
|
12999
13089
|
}
|
|
13000
13090
|
|
|
13001
13091
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
13002
|
-
const cand = parseCandidate(e.candidate.candidate);
|
|
13092
|
+
const cand = parseCandidate$1(e.candidate.candidate);
|
|
13003
13093
|
if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
|
|
13004
13094
|
candidates[cand.relatedPort].push(cand.port);
|
|
13005
13095
|
} else if (!e.candidate) {
|
|
@@ -13067,7 +13157,7 @@ var iceIpv4 = {
|
|
|
13067
13157
|
const rawCandidate = e.candidate.candidate;
|
|
13068
13158
|
if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
|
|
13069
13159
|
hasSrflxOrRelay = true;
|
|
13070
|
-
const candidate = parseCandidate(e.candidate.candidate);
|
|
13160
|
+
const candidate = parseCandidate$1(e.candidate.candidate);
|
|
13071
13161
|
ips.push(candidate.ip);
|
|
13072
13162
|
}
|
|
13073
13163
|
} else if (!e.candidate) {
|
|
@@ -13104,7 +13194,7 @@ var checks = [
|
|
|
13104
13194
|
|
|
13105
13195
|
//
|
|
13106
13196
|
|
|
13107
|
-
const logger$
|
|
13197
|
+
const logger$b = IssueReporter$1.loggerFor('engine-check');
|
|
13108
13198
|
|
|
13109
13199
|
class Checker {
|
|
13110
13200
|
|
|
@@ -13122,28 +13212,28 @@ class Checker {
|
|
|
13122
13212
|
async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
|
|
13123
13213
|
await this._addEngineVersion();
|
|
13124
13214
|
|
|
13125
|
-
logger$
|
|
13215
|
+
logger$b.info('Engine check starting');
|
|
13126
13216
|
|
|
13127
13217
|
for (let i = 0; i < this.checks.length; i++) {
|
|
13128
13218
|
const { name, check } = this.checks[i];
|
|
13129
13219
|
|
|
13130
|
-
logger$
|
|
13220
|
+
logger$b.info(`Checking ${name} ...`);
|
|
13131
13221
|
|
|
13132
13222
|
onCheckBegin(name);
|
|
13133
13223
|
try {
|
|
13134
13224
|
// eslint-disable-next-line no-await-in-loop
|
|
13135
13225
|
const result = await check(this.server, this.session, this.externalAppConfig);
|
|
13136
|
-
logger$
|
|
13226
|
+
logger$b.info(`Checking ${name} success.`, { result });
|
|
13137
13227
|
|
|
13138
13228
|
onCheckResult(name, result);
|
|
13139
13229
|
} catch (e) {
|
|
13140
|
-
logger$
|
|
13230
|
+
logger$b.info(`Checking ${name} failure`, { message: e.message });
|
|
13141
13231
|
|
|
13142
13232
|
onCheckResult(name, e);
|
|
13143
13233
|
}
|
|
13144
13234
|
}
|
|
13145
13235
|
|
|
13146
|
-
logger$
|
|
13236
|
+
logger$b.info('Engine check done.');
|
|
13147
13237
|
}
|
|
13148
13238
|
|
|
13149
13239
|
addCheck(check ) {
|
|
@@ -13167,7 +13257,7 @@ const Wazo = {
|
|
|
13167
13257
|
Auth: Auth$1,
|
|
13168
13258
|
Phone: Phone$1,
|
|
13169
13259
|
Websocket: Websocket$1,
|
|
13170
|
-
Room
|
|
13260
|
+
Room,
|
|
13171
13261
|
SipRoom,
|
|
13172
13262
|
RemoteParticipant,
|
|
13173
13263
|
LocalParticipant,
|
|
@@ -13200,7 +13290,7 @@ const Wazo = {
|
|
|
13200
13290
|
Session,
|
|
13201
13291
|
Voicemail,
|
|
13202
13292
|
Relocation,
|
|
13203
|
-
ConferenceRoom: Room,
|
|
13293
|
+
ConferenceRoom: Room$1,
|
|
13204
13294
|
CallSession,
|
|
13205
13295
|
IndirectTransfer,
|
|
13206
13296
|
SwitchboardCall,
|
|
@@ -13236,7 +13326,7 @@ if (global) {
|
|
|
13236
13326
|
|
|
13237
13327
|
//
|
|
13238
13328
|
|
|
13239
|
-
const logger = IssueReporter$1.loggerFor('simple-phone');
|
|
13329
|
+
const logger$c = IssueReporter$1.loggerFor('simple-phone');
|
|
13240
13330
|
const sipLogger = IssueReporter$1.loggerFor('sip.js');
|
|
13241
13331
|
const protocolLogger = IssueReporter$1.loggerFor('sip');
|
|
13242
13332
|
|
|
@@ -13343,7 +13433,7 @@ class Phone extends Emitter {
|
|
|
13343
13433
|
async disconnect() {
|
|
13344
13434
|
if (this.phone) {
|
|
13345
13435
|
if (this.phone.hasAnActiveCall()) {
|
|
13346
|
-
logger.info('hangup call on disconnect');
|
|
13436
|
+
logger$c.info('hangup call on disconnect');
|
|
13347
13437
|
// $FlowFixMe
|
|
13348
13438
|
await this.phone.hangup();
|
|
13349
13439
|
}
|
|
@@ -13366,13 +13456,13 @@ class Phone extends Emitter {
|
|
|
13366
13456
|
}
|
|
13367
13457
|
|
|
13368
13458
|
async hangup(callSession ) {
|
|
13369
|
-
logger.info('hangup via simple phone', { callId: callSession.getId() });
|
|
13459
|
+
logger$c.info('hangup via simple phone', { callId: callSession.getId() });
|
|
13370
13460
|
|
|
13371
13461
|
return this.phone && this.phone.hangup(callSession);
|
|
13372
13462
|
}
|
|
13373
13463
|
|
|
13374
13464
|
async accept(callSession , cameraEnabled ) {
|
|
13375
|
-
logger.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
|
|
13465
|
+
logger$c.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
|
|
13376
13466
|
|
|
13377
13467
|
return this.phone && this.phone.accept(callSession, cameraEnabled);
|
|
13378
13468
|
}
|
|
@@ -13411,7 +13501,7 @@ class Phone extends Emitter {
|
|
|
13411
13501
|
muteViaAPI(callSession ) {
|
|
13412
13502
|
if (callSession && callSession.callId) {
|
|
13413
13503
|
Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
|
|
13414
|
-
logger.error('Mute via API, error', e);
|
|
13504
|
+
logger$c.error('Mute via API, error', e);
|
|
13415
13505
|
});
|
|
13416
13506
|
}
|
|
13417
13507
|
}
|
|
@@ -13419,7 +13509,7 @@ class Phone extends Emitter {
|
|
|
13419
13509
|
unmuteViaAPI(callSession ) {
|
|
13420
13510
|
if (callSession && callSession.callId) {
|
|
13421
13511
|
Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
|
|
13422
|
-
logger.error('Unmute via API, error', e);
|
|
13512
|
+
logger$c.error('Unmute via API, error', e);
|
|
13423
13513
|
});
|
|
13424
13514
|
}
|
|
13425
13515
|
}
|
|
@@ -13527,7 +13617,7 @@ class Phone extends Emitter {
|
|
|
13527
13617
|
|
|
13528
13618
|
// @Deprecated
|
|
13529
13619
|
getLocalMediaStream(callSession ) {
|
|
13530
|
-
logger.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
|
|
13620
|
+
logger$c.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
|
|
13531
13621
|
|
|
13532
13622
|
return this.phone && this.phone.getLocalStream(callSession);
|
|
13533
13623
|
}
|
|
@@ -13550,24 +13640,29 @@ class Phone extends Emitter {
|
|
|
13550
13640
|
|
|
13551
13641
|
// @Deprecated
|
|
13552
13642
|
getRemoteStreamForCall(callSession ) {
|
|
13553
|
-
logger.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
|
|
13643
|
+
logger$c.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
|
|
13554
13644
|
return this.getRemoteStream(callSession);
|
|
13555
13645
|
}
|
|
13556
13646
|
|
|
13557
13647
|
// Returns remote streams directly from the peerConnection
|
|
13558
13648
|
// @Deprecated
|
|
13559
13649
|
getRemoteStreamsForCall(callSession ) {
|
|
13560
|
-
logger.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
|
|
13650
|
+
logger$c.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
|
|
13561
13651
|
return this.getLocalStream(callSession);
|
|
13562
13652
|
}
|
|
13563
13653
|
|
|
13564
13654
|
// @Deprecated
|
|
13565
13655
|
getRemoteVideoStreamForCall(callSession ) {
|
|
13566
|
-
logger.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
|
|
13656
|
+
logger$c.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
|
|
13567
13657
|
|
|
13568
13658
|
return this.getRemoteVideoStream(callSession);
|
|
13569
13659
|
}
|
|
13570
13660
|
|
|
13661
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
13662
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
13663
|
+
return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
|
|
13664
|
+
}
|
|
13665
|
+
|
|
13571
13666
|
hasVideo(callSession ) {
|
|
13572
13667
|
return this.phone ? this.phone.hasVideo(callSession) : false;
|
|
13573
13668
|
}
|
|
@@ -13619,7 +13714,7 @@ class Phone extends Emitter {
|
|
|
13619
13714
|
|
|
13620
13715
|
_transferEvents() {
|
|
13621
13716
|
this.unbind();
|
|
13622
|
-
[...events
|
|
13717
|
+
[...events, ...transportEvents].forEach(event => {
|
|
13623
13718
|
this.client.on(event, (...args) =>
|
|
13624
13719
|
this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
|
|
13625
13720
|
});
|