@wazo/sdk 0.37.23 → 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 +22 -17
- package/esm/__tests__/web-rtc-client.test.js +105 -100
- package/esm/api/amid.js +1 -1
- package/esm/api/call-logd.js +2 -2
- package/esm/api/confd.js +10 -5
- package/esm/api/ctid-ng.js +3 -3
- package/esm/api/dird.js +1 -1
- package/esm/api/webhookd.js +1 -1
- package/esm/api-client.js +22 -17
- package/esm/checker/Checker.js +130 -125
- package/esm/checker/checks/aor.js +22 -17
- package/esm/checker/checks/api.js +22 -17
- package/esm/checker/checks/index.js +120 -115
- package/esm/checker/checks/wazo-websocket.js +15 -15
- package/esm/checker/checks/webrtc-transport.js +105 -100
- package/esm/checker/checks/webrtc.js +105 -100
- package/esm/domain/AdHocAPIConference.js +22 -17
- package/esm/domain/CallLog.js +1 -1
- package/esm/domain/Contact.js +1 -1
- package/esm/domain/Features.js +22 -17
- package/esm/domain/Meeting.js +12 -5
- package/esm/domain/Phone/CTIPhone.js +36 -31
- package/esm/domain/Phone/WebRTCPhone.js +110 -87
- package/esm/domain/__tests__/CallLog.test.js +1 -1
- package/esm/domain/__tests__/Contact.test.js +1 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/index.js +365 -337
- package/esm/lib/WazoSessionDescriptionHandler.js +1 -1
- package/esm/service/CallApi.js +22 -17
- package/esm/service/IssueReporter.js +1 -1
- package/esm/service/__tests__/IssueReporter.test.js +1 -1
- package/esm/service/getApiClient.js +22 -17
- package/esm/simple/Auth.js +355 -327
- package/esm/simple/Configuration.js +355 -327
- package/esm/simple/Directory.js +22 -17
- package/esm/simple/Phone.js +355 -327
- package/esm/simple/Websocket.js +17 -17
- package/esm/simple/index.js +359 -331
- package/esm/simple/room/LocalParticipant.js +359 -331
- package/esm/simple/room/Participant.js +359 -331
- package/esm/simple/room/RemoteParticipant.js +359 -331
- package/esm/simple/room/Room.js +360 -332
- package/esm/simple/room/SipRoom.js +359 -331
- package/esm/simple/room/Stream.js +359 -331
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +359 -331
- package/esm/simple/utils.js +359 -331
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/web-rtc-client.js +105 -100
- package/esm/websocket-client.js +15 -15
- package/lib/__tests__/api-client.test.js +22 -17
- package/lib/__tests__/web-rtc-client.test.js +105 -100
- package/lib/api/amid.js +1 -1
- package/lib/api/call-logd.js +2 -2
- package/lib/api/confd.js +10 -5
- package/lib/api/ctid-ng.js +3 -3
- package/lib/api/dird.js +1 -1
- package/lib/api/webhookd.js +1 -1
- package/lib/api-client.js +22 -17
- package/lib/checker/Checker.js +130 -125
- package/lib/checker/checks/aor.js +22 -17
- package/lib/checker/checks/api.js +22 -17
- package/lib/checker/checks/index.js +120 -115
- package/lib/checker/checks/wazo-websocket.js +15 -15
- package/lib/checker/checks/webrtc-transport.js +105 -100
- package/lib/checker/checks/webrtc.js +105 -100
- package/lib/domain/AdHocAPIConference.js +22 -17
- package/lib/domain/CallLog.js +1 -1
- package/lib/domain/Contact.js +1 -1
- package/lib/domain/Features.js +22 -17
- package/lib/domain/Meeting.js +16 -5
- package/lib/domain/Phone/CTIPhone.js +36 -31
- package/lib/domain/Phone/WebRTCPhone.js +110 -87
- package/lib/domain/__tests__/CallLog.test.js +1 -1
- package/lib/domain/__tests__/Contact.test.js +1 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/index.js +365 -337
- package/lib/lib/WazoSessionDescriptionHandler.js +1 -1
- package/lib/service/CallApi.js +22 -17
- package/lib/service/IssueReporter.js +1 -1
- package/lib/service/__tests__/IssueReporter.test.js +1 -1
- package/lib/service/getApiClient.js +22 -17
- package/lib/simple/Auth.js +355 -327
- package/lib/simple/Configuration.js +355 -327
- package/lib/simple/Directory.js +22 -17
- package/lib/simple/Phone.js +355 -327
- package/lib/simple/Websocket.js +17 -17
- package/lib/simple/index.js +359 -331
- package/lib/simple/room/LocalParticipant.js +359 -331
- package/lib/simple/room/Participant.js +359 -331
- package/lib/simple/room/RemoteParticipant.js +359 -331
- package/lib/simple/room/Room.js +360 -332
- package/lib/simple/room/SipRoom.js +359 -331
- package/lib/simple/room/Stream.js +359 -331
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +359 -331
- package/lib/simple/utils.js +359 -331
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/web-rtc-client.js +105 -100
- package/lib/websocket-client.js +15 -15
- package/package.json +1 -1
- package/src/domain/Meeting.js +12 -5
- package/src/domain/Phone/WebRTCPhone.js +24 -1
- package/src/domain/__tests__/Meeting.test.js +50 -0
package/esm/index.js
CHANGED
|
@@ -460,7 +460,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
460
460
|
|
|
461
461
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
462
462
|
|
|
463
|
-
const logger
|
|
463
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
464
464
|
|
|
465
465
|
// Use a function here to be able to mock it in tests
|
|
466
466
|
const realFetch = () => {
|
|
@@ -599,7 +599,7 @@ class ApiRequester {
|
|
|
599
599
|
};
|
|
600
600
|
|
|
601
601
|
if (this.refreshTokenPromise) {
|
|
602
|
-
logger
|
|
602
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
603
603
|
await this.refreshTokenPromise;
|
|
604
604
|
}
|
|
605
605
|
|
|
@@ -619,7 +619,7 @@ class ApiRequester {
|
|
|
619
619
|
return promise.then(async (err ) => {
|
|
620
620
|
// Check if the token is still valid
|
|
621
621
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
622
|
-
logger
|
|
622
|
+
logger.warn('token expired', { error: err.reason });
|
|
623
623
|
// Replay the call after refreshing the token
|
|
624
624
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
625
625
|
}
|
|
@@ -629,7 +629,7 @@ class ApiRequester {
|
|
|
629
629
|
: exceptionClass.fromResponse(err, response.status);
|
|
630
630
|
|
|
631
631
|
if (this.shouldLogErrors) {
|
|
632
|
-
logger
|
|
632
|
+
logger.error('API error', error);
|
|
633
633
|
}
|
|
634
634
|
|
|
635
635
|
throw error;
|
|
@@ -639,7 +639,7 @@ class ApiRequester {
|
|
|
639
639
|
return newParse(response, isJson);
|
|
640
640
|
}).catch(error => {
|
|
641
641
|
if (this.shouldLogErrors) {
|
|
642
|
-
logger
|
|
642
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
643
643
|
}
|
|
644
644
|
|
|
645
645
|
throw error;
|
|
@@ -667,13 +667,13 @@ class ApiRequester {
|
|
|
667
667
|
) {
|
|
668
668
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
669
669
|
let newPath = path;
|
|
670
|
-
logger
|
|
670
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
671
671
|
|
|
672
672
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
673
673
|
|
|
674
674
|
return this.refreshTokenPromise.then(() => {
|
|
675
675
|
this.refreshTokenPromise = null;
|
|
676
|
-
logger
|
|
676
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
677
677
|
if (isTokenNotFound) {
|
|
678
678
|
const pathParts = path.split('/');
|
|
679
679
|
pathParts.pop();
|
|
@@ -2631,8 +2631,9 @@ class ExternalApp {
|
|
|
2631
2631
|
|
|
2632
2632
|
|
|
2633
2633
|
|
|
2634
|
-
|
|
2634
|
+
|
|
2635
2635
|
|
|
2636
|
+
|
|
2636
2637
|
|
|
2637
2638
|
|
|
2638
2639
|
class Meeting {
|
|
@@ -2643,9 +2644,10 @@ class Meeting {
|
|
|
2643
2644
|
|
|
2644
2645
|
|
|
2645
2646
|
|
|
2646
|
-
|
|
2647
|
+
|
|
2647
2648
|
|
|
2648
2649
|
|
|
2650
|
+
|
|
2649
2651
|
|
|
2650
2652
|
static parse(plain ) {
|
|
2651
2653
|
return new Meeting({
|
|
@@ -2655,8 +2657,9 @@ class Meeting {
|
|
|
2655
2657
|
ownerUuids: plain.owner_uuids,
|
|
2656
2658
|
port: plain.port,
|
|
2657
2659
|
uuid: plain.uuid,
|
|
2658
|
-
|
|
2660
|
+
extension: plain.exten,
|
|
2659
2661
|
persistent: plain.persistent,
|
|
2662
|
+
creationTime: moment(plain.creation_time).toDate(),
|
|
2660
2663
|
});
|
|
2661
2664
|
}
|
|
2662
2665
|
|
|
@@ -2678,8 +2681,9 @@ class Meeting {
|
|
|
2678
2681
|
ownerUuids,
|
|
2679
2682
|
port,
|
|
2680
2683
|
uri,
|
|
2681
|
-
|
|
2684
|
+
extension,
|
|
2682
2685
|
persistent,
|
|
2686
|
+
creationTime,
|
|
2683
2687
|
} = {}) {
|
|
2684
2688
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2685
2689
|
this.uri = uri;
|
|
@@ -2687,8 +2691,9 @@ class Meeting {
|
|
|
2687
2691
|
this.ownerUuids = ownerUuids;
|
|
2688
2692
|
this.port = port;
|
|
2689
2693
|
this.uuid = uuid;
|
|
2690
|
-
this.
|
|
2694
|
+
this.extension = extension;
|
|
2691
2695
|
this.persistent = persistent;
|
|
2696
|
+
this.creationTime = creationTime;
|
|
2692
2697
|
|
|
2693
2698
|
// Useful to compare instead of instanceof with minified code
|
|
2694
2699
|
this.type = 'Meeting';
|
|
@@ -4132,7 +4137,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
4132
4137
|
|
|
4133
4138
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
4134
4139
|
|
|
4135
|
-
const logger$
|
|
4140
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
4136
4141
|
|
|
4137
4142
|
class CTIPhone extends Emitter {
|
|
4138
4143
|
|
|
@@ -4145,7 +4150,7 @@ class CTIPhone extends Emitter {
|
|
|
4145
4150
|
|
|
4146
4151
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
4147
4152
|
super();
|
|
4148
|
-
logger$
|
|
4153
|
+
logger$1.info('CTI Phone created');
|
|
4149
4154
|
this.session = session;
|
|
4150
4155
|
this.isMobile = isMobile;
|
|
4151
4156
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -4206,7 +4211,7 @@ class CTIPhone extends Emitter {
|
|
|
4206
4211
|
}
|
|
4207
4212
|
|
|
4208
4213
|
async makeCall(number , line ) {
|
|
4209
|
-
logger$
|
|
4214
|
+
logger$1.info('make CTI call', { number });
|
|
4210
4215
|
|
|
4211
4216
|
if (!number) {
|
|
4212
4217
|
return null;
|
|
@@ -4229,7 +4234,7 @@ class CTIPhone extends Emitter {
|
|
|
4229
4234
|
if (!callSession) {
|
|
4230
4235
|
return Promise.resolve(null);
|
|
4231
4236
|
}
|
|
4232
|
-
logger$
|
|
4237
|
+
logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4233
4238
|
|
|
4234
4239
|
if (!this.currentCall) {
|
|
4235
4240
|
this.currentCall = callSession.call;
|
|
@@ -4242,7 +4247,7 @@ class CTIPhone extends Emitter {
|
|
|
4242
4247
|
if (!callSession) {
|
|
4243
4248
|
return;
|
|
4244
4249
|
}
|
|
4245
|
-
logger$
|
|
4250
|
+
logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4246
4251
|
|
|
4247
4252
|
this.currentCall = undefined;
|
|
4248
4253
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4252,7 +4257,7 @@ class CTIPhone extends Emitter {
|
|
|
4252
4257
|
if (!callSession) {
|
|
4253
4258
|
return Promise.resolve(false);
|
|
4254
4259
|
}
|
|
4255
|
-
logger$
|
|
4260
|
+
logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4256
4261
|
|
|
4257
4262
|
try {
|
|
4258
4263
|
await CallApi.cancelCall(callSession);
|
|
@@ -4263,7 +4268,7 @@ class CTIPhone extends Emitter {
|
|
|
4263
4268
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
4264
4269
|
return true;
|
|
4265
4270
|
} catch (e) {
|
|
4266
|
-
logger$
|
|
4271
|
+
logger$1.error('hangup CTI call, error', e);
|
|
4267
4272
|
|
|
4268
4273
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
4269
4274
|
return false;
|
|
@@ -4276,7 +4281,7 @@ class CTIPhone extends Emitter {
|
|
|
4276
4281
|
if (!callSession) {
|
|
4277
4282
|
return;
|
|
4278
4283
|
}
|
|
4279
|
-
logger$
|
|
4284
|
+
logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4280
4285
|
|
|
4281
4286
|
await CallApi.cancelCall(callSession);
|
|
4282
4287
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4286,7 +4291,7 @@ class CTIPhone extends Emitter {
|
|
|
4286
4291
|
if (!callSession) {
|
|
4287
4292
|
return;
|
|
4288
4293
|
}
|
|
4289
|
-
logger$
|
|
4294
|
+
logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4290
4295
|
|
|
4291
4296
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
4292
4297
|
}
|
|
@@ -4299,19 +4304,19 @@ class CTIPhone extends Emitter {
|
|
|
4299
4304
|
if (!callSession) {
|
|
4300
4305
|
return;
|
|
4301
4306
|
}
|
|
4302
|
-
logger$
|
|
4307
|
+
logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4303
4308
|
|
|
4304
4309
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
4305
4310
|
}
|
|
4306
4311
|
|
|
4307
4312
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
4308
|
-
logger$
|
|
4313
|
+
logger$1.info('cancel CTI transfer', { transferId });
|
|
4309
4314
|
|
|
4310
4315
|
return CallApi.cancelCallTransfer(transferId);
|
|
4311
4316
|
}
|
|
4312
4317
|
|
|
4313
4318
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
4314
|
-
logger$
|
|
4319
|
+
logger$1.info('confirm CTI transfer', { transferId });
|
|
4315
4320
|
|
|
4316
4321
|
return CallApi.confirmCallTransfer(transferId);
|
|
4317
4322
|
}
|
|
@@ -4320,19 +4325,19 @@ class CTIPhone extends Emitter {
|
|
|
4320
4325
|
if (!callSession) {
|
|
4321
4326
|
return;
|
|
4322
4327
|
}
|
|
4323
|
-
logger$
|
|
4328
|
+
logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4324
4329
|
|
|
4325
4330
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4326
4331
|
}
|
|
4327
4332
|
|
|
4328
4333
|
onConnectionMade() {
|
|
4329
|
-
logger$
|
|
4334
|
+
logger$1.info('on CTI connection made');
|
|
4330
4335
|
|
|
4331
4336
|
this.eventEmitter.emit('onCallAccepted');
|
|
4332
4337
|
}
|
|
4333
4338
|
|
|
4334
4339
|
async close() {
|
|
4335
|
-
logger$
|
|
4340
|
+
logger$1.info('CTI close');
|
|
4336
4341
|
|
|
4337
4342
|
return Promise.resolve();
|
|
4338
4343
|
}
|
|
@@ -4341,7 +4346,7 @@ class CTIPhone extends Emitter {
|
|
|
4341
4346
|
if (!callSession) {
|
|
4342
4347
|
return;
|
|
4343
4348
|
}
|
|
4344
|
-
logger$
|
|
4349
|
+
logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4345
4350
|
|
|
4346
4351
|
return CallApi.hold(callSession.callId);
|
|
4347
4352
|
}
|
|
@@ -4350,7 +4355,7 @@ class CTIPhone extends Emitter {
|
|
|
4350
4355
|
if (!callSession) {
|
|
4351
4356
|
return;
|
|
4352
4357
|
}
|
|
4353
|
-
logger$
|
|
4358
|
+
logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4354
4359
|
|
|
4355
4360
|
return CallApi.resume(callSession.callId);
|
|
4356
4361
|
}
|
|
@@ -4359,7 +4364,7 @@ class CTIPhone extends Emitter {
|
|
|
4359
4364
|
if (!callSession) {
|
|
4360
4365
|
return;
|
|
4361
4366
|
}
|
|
4362
|
-
logger$
|
|
4367
|
+
logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4363
4368
|
|
|
4364
4369
|
return CallApi.mute(callSession.callId);
|
|
4365
4370
|
}
|
|
@@ -4368,7 +4373,7 @@ class CTIPhone extends Emitter {
|
|
|
4368
4373
|
if (!callSession) {
|
|
4369
4374
|
return;
|
|
4370
4375
|
}
|
|
4371
|
-
logger$
|
|
4376
|
+
logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4372
4377
|
|
|
4373
4378
|
return CallApi.unmute(callSession.callId);
|
|
4374
4379
|
}
|
|
@@ -5377,7 +5382,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5377
5382
|
const WEBHOOKD_VERSION = '1.0';
|
|
5378
5383
|
const AMID_VERSION = '1.0';
|
|
5379
5384
|
|
|
5380
|
-
const logger$
|
|
5385
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5381
5386
|
|
|
5382
5387
|
class ApiClient {
|
|
5383
5388
|
|
|
@@ -5429,12 +5434,12 @@ class ApiClient {
|
|
|
5429
5434
|
}
|
|
5430
5435
|
|
|
5431
5436
|
async forceRefreshToken() {
|
|
5432
|
-
logger$
|
|
5437
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
5433
5438
|
return this.refreshTokenCallback();
|
|
5434
5439
|
}
|
|
5435
5440
|
|
|
5436
5441
|
async refreshTokenCallback() {
|
|
5437
|
-
logger$
|
|
5442
|
+
logger$2.info('refresh token callback called', {
|
|
5438
5443
|
refreshToken: this.refreshToken,
|
|
5439
5444
|
refreshBackend: this.refreshBackend,
|
|
5440
5445
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5452,7 +5457,7 @@ class ApiClient {
|
|
|
5452
5457
|
this.isMobile,
|
|
5453
5458
|
);
|
|
5454
5459
|
|
|
5455
|
-
logger$
|
|
5460
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
5456
5461
|
|
|
5457
5462
|
if (this.onRefreshToken) {
|
|
5458
5463
|
this.onRefreshToken(session.token, session);
|
|
@@ -5507,7 +5512,7 @@ class ApiClient {
|
|
|
5507
5512
|
|
|
5508
5513
|
/* */
|
|
5509
5514
|
|
|
5510
|
-
const parseCandidate
|
|
5515
|
+
const parseCandidate = (candidate ) => {
|
|
5511
5516
|
if (!candidate) {
|
|
5512
5517
|
return null;
|
|
5513
5518
|
}
|
|
@@ -5661,7 +5666,7 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5661
5666
|
this.peerConnectionDelegate.onicecandidate = event => {
|
|
5662
5667
|
wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
|
|
5663
5668
|
if (event.candidate) {
|
|
5664
|
-
this.gatheredCandidates.push(parseCandidate
|
|
5669
|
+
this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
|
|
5665
5670
|
}
|
|
5666
5671
|
};
|
|
5667
5672
|
|
|
@@ -6125,7 +6130,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
6125
6130
|
const SEND_STATS_DELAY = 5000;
|
|
6126
6131
|
|
|
6127
6132
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
6128
|
-
const logger$
|
|
6133
|
+
const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
6129
6134
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
6130
6135
|
|
|
6131
6136
|
// events
|
|
@@ -6139,14 +6144,14 @@ const TRANSPORT_ERROR = 'transportError';
|
|
|
6139
6144
|
const MESSAGE = 'message';
|
|
6140
6145
|
const ACCEPTED = 'accepted';
|
|
6141
6146
|
const REJECTED = 'rejected';
|
|
6142
|
-
const ON_TRACK
|
|
6143
|
-
const ON_REINVITE
|
|
6147
|
+
const ON_TRACK = 'onTrack';
|
|
6148
|
+
const ON_REINVITE = 'reinvite';
|
|
6144
6149
|
const ON_ERROR = 'onError';
|
|
6145
6150
|
const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
|
|
6146
|
-
const ON_NETWORK_STATS
|
|
6147
|
-
const ON_DISCONNECTED
|
|
6151
|
+
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
6152
|
+
const ON_DISCONNECTED = 'onDisconnected';
|
|
6148
6153
|
|
|
6149
|
-
const events
|
|
6154
|
+
const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
6150
6155
|
const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
6151
6156
|
class CanceledCallError extends Error {}
|
|
6152
6157
|
|
|
@@ -6282,12 +6287,12 @@ class WebRTCClient extends Emitter {
|
|
|
6282
6287
|
this.MESSAGE = MESSAGE;
|
|
6283
6288
|
this.ACCEPTED = ACCEPTED;
|
|
6284
6289
|
this.REJECTED = REJECTED;
|
|
6285
|
-
this.ON_TRACK = ON_TRACK
|
|
6286
|
-
this.ON_REINVITE = ON_REINVITE
|
|
6290
|
+
this.ON_TRACK = ON_TRACK;
|
|
6291
|
+
this.ON_REINVITE = ON_REINVITE;
|
|
6287
6292
|
this.ON_ERROR = ON_ERROR;
|
|
6288
6293
|
this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
|
|
6289
|
-
this.ON_NETWORK_STATS = ON_NETWORK_STATS
|
|
6290
|
-
this.ON_DISCONNECTED = ON_DISCONNECTED
|
|
6294
|
+
this.ON_NETWORK_STATS = ON_NETWORK_STATS;
|
|
6295
|
+
this.ON_DISCONNECTED = ON_DISCONNECTED;
|
|
6291
6296
|
}
|
|
6292
6297
|
|
|
6293
6298
|
configureMedia(media ) {
|
|
@@ -6304,13 +6309,13 @@ class WebRTCClient extends Emitter {
|
|
|
6304
6309
|
|
|
6305
6310
|
createUserAgent(configOverrides ) {
|
|
6306
6311
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6307
|
-
logger$
|
|
6312
|
+
logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6308
6313
|
|
|
6309
6314
|
webRTCConfiguration.delegate = {
|
|
6310
6315
|
onConnect: this.onConnect.bind(this),
|
|
6311
6316
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6312
6317
|
onInvite: (invitation ) => {
|
|
6313
|
-
logger$
|
|
6318
|
+
logger$3.info('sdk webrtc on invite', {
|
|
6314
6319
|
method: 'delegate.onInvite',
|
|
6315
6320
|
id: invitation.id,
|
|
6316
6321
|
remoteURI: invitation.remoteURI,
|
|
@@ -6353,7 +6358,7 @@ class WebRTCClient extends Emitter {
|
|
|
6353
6358
|
}
|
|
6354
6359
|
|
|
6355
6360
|
onConnect() {
|
|
6356
|
-
logger$
|
|
6361
|
+
logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6357
6362
|
this.eventEmitter.emit(CONNECTED);
|
|
6358
6363
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6359
6364
|
this.registerer.waitingToggle(false);
|
|
@@ -6362,7 +6367,7 @@ class WebRTCClient extends Emitter {
|
|
|
6362
6367
|
}
|
|
6363
6368
|
|
|
6364
6369
|
async onDisconnect(error ) {
|
|
6365
|
-
logger$
|
|
6370
|
+
logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6366
6371
|
this.connectionPromise = null;
|
|
6367
6372
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6368
6373
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6387,37 +6392,37 @@ class WebRTCClient extends Emitter {
|
|
|
6387
6392
|
};
|
|
6388
6393
|
|
|
6389
6394
|
if (this.skipRegister) {
|
|
6390
|
-
logger$
|
|
6395
|
+
logger$3.info('sdk webrtc skip register...', logInfo);
|
|
6391
6396
|
return Promise.resolve();
|
|
6392
6397
|
}
|
|
6393
6398
|
|
|
6394
|
-
logger$
|
|
6399
|
+
logger$3.info('sdk webrtc registering...', logInfo);
|
|
6395
6400
|
|
|
6396
6401
|
if (!this.userAgent) {
|
|
6397
|
-
logger$
|
|
6402
|
+
logger$3.info('sdk webrtc recreating User Agent');
|
|
6398
6403
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6399
6404
|
}
|
|
6400
6405
|
if (!this.userAgent || this.isRegistered()) {
|
|
6401
|
-
logger$
|
|
6406
|
+
logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6402
6407
|
return Promise.resolve();
|
|
6403
6408
|
}
|
|
6404
6409
|
|
|
6405
6410
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6406
|
-
logger$
|
|
6411
|
+
logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6407
6412
|
return Promise.resolve();
|
|
6408
6413
|
}
|
|
6409
6414
|
|
|
6410
6415
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6411
6416
|
|
|
6412
6417
|
const onRegisterFailed = () => {
|
|
6413
|
-
logger$
|
|
6418
|
+
logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6414
6419
|
this.connectionPromise = null;
|
|
6415
6420
|
if (this.registerer && this.registerer.waiting) {
|
|
6416
6421
|
this.registerer.waitingToggle(false);
|
|
6417
6422
|
}
|
|
6418
6423
|
|
|
6419
6424
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6420
|
-
logger$
|
|
6425
|
+
logger$3.info('sdk webrtc registering, retrying...', { tries });
|
|
6421
6426
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6422
6427
|
}
|
|
6423
6428
|
};
|
|
@@ -6426,18 +6431,18 @@ class WebRTCClient extends Emitter {
|
|
|
6426
6431
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6427
6432
|
// during the resolution of the primise.
|
|
6428
6433
|
if (!this.userAgent) {
|
|
6429
|
-
logger$
|
|
6434
|
+
logger$3.info('sdk webrtc recreating User Agent after connection');
|
|
6430
6435
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6431
6436
|
}
|
|
6432
6437
|
|
|
6433
|
-
logger$
|
|
6438
|
+
logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6434
6439
|
this.registerer = new Registerer(this.userAgent, registerOptions);
|
|
6435
6440
|
this.connectionPromise = null;
|
|
6436
6441
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6437
6442
|
|
|
6438
6443
|
// Bind registerer events
|
|
6439
6444
|
this.registerer.stateChange.addListener(newState => {
|
|
6440
|
-
logger$
|
|
6445
|
+
logger$3.info('sdk webrtc registering, state changed', { newState });
|
|
6441
6446
|
|
|
6442
6447
|
if (newState === RegistererState.Registered && this.registerer
|
|
6443
6448
|
&& this.registerer.state === RegistererState.Registered) {
|
|
@@ -6450,7 +6455,7 @@ class WebRTCClient extends Emitter {
|
|
|
6450
6455
|
const options = {
|
|
6451
6456
|
requestDelegate: {
|
|
6452
6457
|
onReject: response => {
|
|
6453
|
-
logger$
|
|
6458
|
+
logger$3.error('sdk webrtc registering, rejected', { response });
|
|
6454
6459
|
|
|
6455
6460
|
onRegisterFailed();
|
|
6456
6461
|
},
|
|
@@ -6458,13 +6463,13 @@ class WebRTCClient extends Emitter {
|
|
|
6458
6463
|
};
|
|
6459
6464
|
|
|
6460
6465
|
return this.registerer.register(options).catch((e) => {
|
|
6461
|
-
logger$
|
|
6466
|
+
logger$3.error('sdk webrtc registering, error', e);
|
|
6462
6467
|
|
|
6463
6468
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6464
6469
|
return e;
|
|
6465
6470
|
});
|
|
6466
6471
|
}).catch(error => {
|
|
6467
|
-
logger$
|
|
6472
|
+
logger$3.error('sdk webrtc registering, transport error', error);
|
|
6468
6473
|
onRegisterFailed();
|
|
6469
6474
|
});
|
|
6470
6475
|
}
|
|
@@ -6493,21 +6498,21 @@ class WebRTCClient extends Emitter {
|
|
|
6493
6498
|
}
|
|
6494
6499
|
|
|
6495
6500
|
unregister() {
|
|
6496
|
-
logger$
|
|
6501
|
+
logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6497
6502
|
if (!this.registerer) {
|
|
6498
6503
|
return Promise.resolve();
|
|
6499
6504
|
}
|
|
6500
6505
|
|
|
6501
6506
|
try {
|
|
6502
6507
|
return this.registerer.unregister().then(() => {
|
|
6503
|
-
logger$
|
|
6508
|
+
logger$3.info('sdk webrtc unregistered');
|
|
6504
6509
|
this._cleanupRegister();
|
|
6505
6510
|
}).catch(e => {
|
|
6506
|
-
logger$
|
|
6511
|
+
logger$3.error('sdk webrtc unregistering, promise error', e);
|
|
6507
6512
|
this._cleanupRegister();
|
|
6508
6513
|
});
|
|
6509
6514
|
} catch (e) {
|
|
6510
|
-
logger$
|
|
6515
|
+
logger$3.error('sdk webrtc unregistering, error', e);
|
|
6511
6516
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6512
6517
|
// error when the registerer is in a bad state
|
|
6513
6518
|
this._cleanupRegister();
|
|
@@ -6515,7 +6520,7 @@ class WebRTCClient extends Emitter {
|
|
|
6515
6520
|
}
|
|
6516
6521
|
|
|
6517
6522
|
stop() {
|
|
6518
|
-
logger$
|
|
6523
|
+
logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6519
6524
|
if (!this.userAgent) {
|
|
6520
6525
|
return Promise.resolve();
|
|
6521
6526
|
}
|
|
@@ -6523,12 +6528,12 @@ class WebRTCClient extends Emitter {
|
|
|
6523
6528
|
return this.userAgent.stop().then(() => {
|
|
6524
6529
|
return this._cleanupRegister();
|
|
6525
6530
|
}).catch(e => {
|
|
6526
|
-
logger$
|
|
6531
|
+
logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6527
6532
|
});
|
|
6528
6533
|
}
|
|
6529
6534
|
|
|
6530
6535
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6531
|
-
logger$
|
|
6536
|
+
logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6532
6537
|
const inviterOptions = {
|
|
6533
6538
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6534
6539
|
conference,
|
|
@@ -6559,7 +6564,7 @@ class WebRTCClient extends Emitter {
|
|
|
6559
6564
|
this._onAccepted(session, response.session, true);
|
|
6560
6565
|
},
|
|
6561
6566
|
onReject: (response ) => {
|
|
6562
|
-
logger$
|
|
6567
|
+
logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6563
6568
|
this._stopSendingStats(session);
|
|
6564
6569
|
this.stopNetworkMonitoring(session);
|
|
6565
6570
|
|
|
@@ -6582,11 +6587,11 @@ class WebRTCClient extends Emitter {
|
|
|
6582
6587
|
}
|
|
6583
6588
|
|
|
6584
6589
|
answer(session , enableVideo ) {
|
|
6585
|
-
logger$
|
|
6590
|
+
logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
6586
6591
|
|
|
6587
6592
|
if (!session || !session.accept) {
|
|
6588
6593
|
const error = 'No session to answer, or not an invitation';
|
|
6589
|
-
logger$
|
|
6594
|
+
logger$3.warn(error);
|
|
6590
6595
|
return Promise.reject(new Error(error));
|
|
6591
6596
|
}
|
|
6592
6597
|
const options = {
|
|
@@ -6596,15 +6601,15 @@ class WebRTCClient extends Emitter {
|
|
|
6596
6601
|
return session.accept(options).then(() => {
|
|
6597
6602
|
if (session.isCanceled) {
|
|
6598
6603
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
6599
|
-
logger$
|
|
6604
|
+
logger$3.error(message, { id: session.id });
|
|
6600
6605
|
this.onCallEnded(session);
|
|
6601
6606
|
|
|
6602
6607
|
throw new CanceledCallError(message);
|
|
6603
6608
|
}
|
|
6604
|
-
logger$
|
|
6609
|
+
logger$3.info('sdk webrtc answer, accepted.');
|
|
6605
6610
|
this._onAccepted(session);
|
|
6606
6611
|
}).catch(e => {
|
|
6607
|
-
logger$
|
|
6612
|
+
logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
6608
6613
|
|
|
6609
6614
|
throw e;
|
|
6610
6615
|
});
|
|
@@ -6612,7 +6617,7 @@ class WebRTCClient extends Emitter {
|
|
|
6612
6617
|
|
|
6613
6618
|
hangup(session ) {
|
|
6614
6619
|
const { state, id } = session;
|
|
6615
|
-
logger$
|
|
6620
|
+
logger$3.info('sdk webrtc hangup call', { id, state });
|
|
6616
6621
|
|
|
6617
6622
|
try {
|
|
6618
6623
|
this._stopSendingStats(session);
|
|
@@ -6641,7 +6646,7 @@ class WebRTCClient extends Emitter {
|
|
|
6641
6646
|
|
|
6642
6647
|
return bye();
|
|
6643
6648
|
} catch (error) {
|
|
6644
|
-
logger$
|
|
6649
|
+
logger$3.warn('sdk webrtc hangup, error', error);
|
|
6645
6650
|
}
|
|
6646
6651
|
|
|
6647
6652
|
return null;
|
|
@@ -6659,7 +6664,7 @@ class WebRTCClient extends Emitter {
|
|
|
6659
6664
|
// Fetch and emit an event at `interval` with session network stats
|
|
6660
6665
|
startNetworkMonitoring(session , interval = 1000) {
|
|
6661
6666
|
const sessionId = this.getSipSessionId(session);
|
|
6662
|
-
logger$
|
|
6667
|
+
logger$3.info('starting network inspection', { id: sessionId });
|
|
6663
6668
|
|
|
6664
6669
|
this.sessionNetworkStats[sessionId] = [];
|
|
6665
6670
|
|
|
@@ -6669,7 +6674,7 @@ class WebRTCClient extends Emitter {
|
|
|
6669
6674
|
stopNetworkMonitoring(session ) {
|
|
6670
6675
|
const sessionId = this.getSipSessionId(session);
|
|
6671
6676
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
6672
|
-
logger$
|
|
6677
|
+
logger$3.info('stopping network inspection', { id: sessionId, exists });
|
|
6673
6678
|
|
|
6674
6679
|
if (exists) {
|
|
6675
6680
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -6679,17 +6684,17 @@ class WebRTCClient extends Emitter {
|
|
|
6679
6684
|
}
|
|
6680
6685
|
|
|
6681
6686
|
reject(session ) {
|
|
6682
|
-
logger$
|
|
6687
|
+
logger$3.info('sdk webrtc reject call', { id: session.id });
|
|
6683
6688
|
|
|
6684
6689
|
try {
|
|
6685
6690
|
return session.reject ? session.reject() : session.cancel();
|
|
6686
6691
|
} catch (e) {
|
|
6687
|
-
logger$
|
|
6692
|
+
logger$3.warn('Error when rejecting call', e.message, e.stack);
|
|
6688
6693
|
}
|
|
6689
6694
|
}
|
|
6690
6695
|
|
|
6691
6696
|
async close() {
|
|
6692
|
-
logger$
|
|
6697
|
+
logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
6693
6698
|
this._cleanupMedia();
|
|
6694
6699
|
this.connectionPromise = null;
|
|
6695
6700
|
|
|
@@ -6720,7 +6725,7 @@ class WebRTCClient extends Emitter {
|
|
|
6720
6725
|
// eg: "INVITE not rejectable in state Completed"
|
|
6721
6726
|
}
|
|
6722
6727
|
this.userAgent = null;
|
|
6723
|
-
logger$
|
|
6728
|
+
logger$3.info('sdk webrtc client closed');
|
|
6724
6729
|
}
|
|
6725
6730
|
|
|
6726
6731
|
getNumber(session ) {
|
|
@@ -6733,13 +6738,13 @@ class WebRTCClient extends Emitter {
|
|
|
6733
6738
|
}
|
|
6734
6739
|
|
|
6735
6740
|
mute(session ) {
|
|
6736
|
-
logger$
|
|
6741
|
+
logger$3.info('sdk webrtc mute', { id: session.id });
|
|
6737
6742
|
|
|
6738
6743
|
this._toggleAudio(session, true);
|
|
6739
6744
|
}
|
|
6740
6745
|
|
|
6741
6746
|
unmute(session ) {
|
|
6742
|
-
logger$
|
|
6747
|
+
logger$3.info('sdk webrtc unmute', { id: session.id });
|
|
6743
6748
|
|
|
6744
6749
|
this._toggleAudio(session, false);
|
|
6745
6750
|
}
|
|
@@ -6779,13 +6784,13 @@ class WebRTCClient extends Emitter {
|
|
|
6779
6784
|
}
|
|
6780
6785
|
|
|
6781
6786
|
toggleCameraOn(session ) {
|
|
6782
|
-
logger$
|
|
6787
|
+
logger$3.info('sdk webrtc toggle camera on', { id: session.id });
|
|
6783
6788
|
|
|
6784
6789
|
this._toggleVideo(session, false);
|
|
6785
6790
|
}
|
|
6786
6791
|
|
|
6787
6792
|
toggleCameraOff(session ) {
|
|
6788
|
-
logger$
|
|
6793
|
+
logger$3.info('sdk webrtc toggle camera off', { id: session.id });
|
|
6789
6794
|
|
|
6790
6795
|
this._toggleVideo(session, true);
|
|
6791
6796
|
}
|
|
@@ -6794,7 +6799,7 @@ class WebRTCClient extends Emitter {
|
|
|
6794
6799
|
const sessionId = this.getSipSessionId(session);
|
|
6795
6800
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
6796
6801
|
|
|
6797
|
-
logger$
|
|
6802
|
+
logger$3.info('sdk webrtc hold', {
|
|
6798
6803
|
sessionId,
|
|
6799
6804
|
keys: Object.keys(this.heldSessions),
|
|
6800
6805
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6843,7 +6848,7 @@ class WebRTCClient extends Emitter {
|
|
|
6843
6848
|
const sessionId = this.getSipSessionId(session);
|
|
6844
6849
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
6845
6850
|
|
|
6846
|
-
logger$
|
|
6851
|
+
logger$3.info('sdk webrtc unhold', {
|
|
6847
6852
|
sessionId,
|
|
6848
6853
|
keys: Object.keys(this.heldSessions),
|
|
6849
6854
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6991,7 +6996,7 @@ class WebRTCClient extends Emitter {
|
|
|
6991
6996
|
if (!session.sessionDescriptionHandler) {
|
|
6992
6997
|
return;
|
|
6993
6998
|
}
|
|
6994
|
-
logger$
|
|
6999
|
+
logger$3.info('Sending DTMF', {
|
|
6995
7000
|
id: this.getSipSessionId(session),
|
|
6996
7001
|
tone,
|
|
6997
7002
|
});
|
|
@@ -7007,7 +7012,7 @@ class WebRTCClient extends Emitter {
|
|
|
7007
7012
|
transfer(session , target ) {
|
|
7008
7013
|
this.hold(session);
|
|
7009
7014
|
|
|
7010
|
-
logger$
|
|
7015
|
+
logger$3.info('Transfering a session', {
|
|
7011
7016
|
id: this.getSipSessionId(session),
|
|
7012
7017
|
target,
|
|
7013
7018
|
});
|
|
@@ -7029,17 +7034,17 @@ class WebRTCClient extends Emitter {
|
|
|
7029
7034
|
atxfer(session ) {
|
|
7030
7035
|
this.hold(session);
|
|
7031
7036
|
|
|
7032
|
-
logger$
|
|
7037
|
+
logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
7033
7038
|
|
|
7034
7039
|
const result = {
|
|
7035
7040
|
newSession: null,
|
|
7036
7041
|
init: async (target ) => {
|
|
7037
|
-
logger$
|
|
7042
|
+
logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
7038
7043
|
|
|
7039
7044
|
result.newSession = await this.call(target);
|
|
7040
7045
|
},
|
|
7041
7046
|
complete: () => {
|
|
7042
|
-
logger$
|
|
7047
|
+
logger$3.info('webrtc transfer completed', {
|
|
7043
7048
|
id: this.getSipSessionId(session),
|
|
7044
7049
|
referId: this.getSipSessionId(result.newSession),
|
|
7045
7050
|
});
|
|
@@ -7060,7 +7065,7 @@ class WebRTCClient extends Emitter {
|
|
|
7060
7065
|
return;
|
|
7061
7066
|
}
|
|
7062
7067
|
|
|
7063
|
-
logger$
|
|
7068
|
+
logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
7064
7069
|
|
|
7065
7070
|
try {
|
|
7066
7071
|
sipSession.message({
|
|
@@ -7102,7 +7107,7 @@ class WebRTCClient extends Emitter {
|
|
|
7102
7107
|
}
|
|
7103
7108
|
|
|
7104
7109
|
changeAudioOutputVolume(volume ) {
|
|
7105
|
-
logger$
|
|
7110
|
+
logger$3.info('Changing audio output volume', { volume });
|
|
7106
7111
|
|
|
7107
7112
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7108
7113
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -7114,7 +7119,7 @@ class WebRTCClient extends Emitter {
|
|
|
7114
7119
|
}
|
|
7115
7120
|
|
|
7116
7121
|
changeAudioOutputDevice(id ) {
|
|
7117
|
-
logger$
|
|
7122
|
+
logger$3.info('Changing audio output device', { id });
|
|
7118
7123
|
|
|
7119
7124
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7120
7125
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -7131,7 +7136,7 @@ class WebRTCClient extends Emitter {
|
|
|
7131
7136
|
|
|
7132
7137
|
changeAudioInputDevice(id , session ) {
|
|
7133
7138
|
const currentId = this.getAudioDeviceId();
|
|
7134
|
-
logger$
|
|
7139
|
+
logger$3.info('setting audio input device', { id, currentId, session: !!session });
|
|
7135
7140
|
|
|
7136
7141
|
if (id === currentId) {
|
|
7137
7142
|
return null;
|
|
@@ -7177,7 +7182,7 @@ class WebRTCClient extends Emitter {
|
|
|
7177
7182
|
|
|
7178
7183
|
setVideoInputDevice(id ) {
|
|
7179
7184
|
const currentId = this.getVideoDeviceId();
|
|
7180
|
-
logger$
|
|
7185
|
+
logger$3.info('setting video input device', { id, currentId });
|
|
7181
7186
|
|
|
7182
7187
|
if (id === currentId) {
|
|
7183
7188
|
return null;
|
|
@@ -7202,7 +7207,7 @@ class WebRTCClient extends Emitter {
|
|
|
7202
7207
|
const sessionId = this.getSipSessionId(session);
|
|
7203
7208
|
const localStream = this.getLocalStream(sessionId);
|
|
7204
7209
|
|
|
7205
|
-
logger$
|
|
7210
|
+
logger$3.info('changing video input device', { id, sessionId });
|
|
7206
7211
|
|
|
7207
7212
|
// Release old video stream
|
|
7208
7213
|
if (localStream) {
|
|
@@ -7270,7 +7275,7 @@ class WebRTCClient extends Emitter {
|
|
|
7270
7275
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
7271
7276
|
const desktop = newConstraints && newConstraints.desktop;
|
|
7272
7277
|
|
|
7273
|
-
logger$
|
|
7278
|
+
logger$3.info('Sending reinvite', {
|
|
7274
7279
|
id: this.getSipSessionId(sipSession),
|
|
7275
7280
|
newConstraints,
|
|
7276
7281
|
conference,
|
|
@@ -7308,7 +7313,7 @@ class WebRTCClient extends Emitter {
|
|
|
7308
7313
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
7309
7314
|
}
|
|
7310
7315
|
|
|
7311
|
-
logger$
|
|
7316
|
+
logger$3.info('on re-INVITE accepted', {
|
|
7312
7317
|
id: this.getSipSessionId(sipSession),
|
|
7313
7318
|
wasMuted,
|
|
7314
7319
|
shouldDoScreenSharing,
|
|
@@ -7326,7 +7331,7 @@ class WebRTCClient extends Emitter {
|
|
|
7326
7331
|
this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
|
|
7327
7332
|
}
|
|
7328
7333
|
|
|
7329
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
7334
|
+
return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
|
|
7330
7335
|
},
|
|
7331
7336
|
},
|
|
7332
7337
|
sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
|
|
@@ -7483,7 +7488,7 @@ class WebRTCClient extends Emitter {
|
|
|
7483
7488
|
}
|
|
7484
7489
|
|
|
7485
7490
|
startHeartbeat() {
|
|
7486
|
-
logger$
|
|
7491
|
+
logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7487
7492
|
if (!this.userAgent) {
|
|
7488
7493
|
this.heartbeat.stop();
|
|
7489
7494
|
return;
|
|
@@ -7496,7 +7501,7 @@ class WebRTCClient extends Emitter {
|
|
|
7496
7501
|
}
|
|
7497
7502
|
|
|
7498
7503
|
stopHeartbeat() {
|
|
7499
|
-
logger$
|
|
7504
|
+
logger$3.info('sdk webrtc stop heartbeat');
|
|
7500
7505
|
this.heartbeat.stop();
|
|
7501
7506
|
}
|
|
7502
7507
|
|
|
@@ -7517,7 +7522,7 @@ class WebRTCClient extends Emitter {
|
|
|
7517
7522
|
}
|
|
7518
7523
|
|
|
7519
7524
|
attemptReconnection() {
|
|
7520
|
-
logger$
|
|
7525
|
+
logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7521
7526
|
if (!this.userAgent) {
|
|
7522
7527
|
return;
|
|
7523
7528
|
}
|
|
@@ -7542,7 +7547,7 @@ class WebRTCClient extends Emitter {
|
|
|
7542
7547
|
return;
|
|
7543
7548
|
}
|
|
7544
7549
|
|
|
7545
|
-
logger$
|
|
7550
|
+
logger$3.info('setting local media stream', {
|
|
7546
7551
|
sipSessionId,
|
|
7547
7552
|
tracks: newStream ? newStream.getTracks() : null,
|
|
7548
7553
|
});
|
|
@@ -7559,7 +7564,7 @@ class WebRTCClient extends Emitter {
|
|
|
7559
7564
|
|
|
7560
7565
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
7561
7566
|
|
|
7562
|
-
logger$
|
|
7567
|
+
logger$3.info('updating local stream', {
|
|
7563
7568
|
sipSessionId,
|
|
7564
7569
|
oldStream: !!oldStream,
|
|
7565
7570
|
tracks: newStream.getTracks(),
|
|
@@ -7579,7 +7584,7 @@ class WebRTCClient extends Emitter {
|
|
|
7579
7584
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
7580
7585
|
const pc = this.getPeerConnection(sessionId);
|
|
7581
7586
|
|
|
7582
|
-
logger$
|
|
7587
|
+
logger$3.info('Updating remote stream', {
|
|
7583
7588
|
sessionId,
|
|
7584
7589
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
7585
7590
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -7605,7 +7610,7 @@ class WebRTCClient extends Emitter {
|
|
|
7605
7610
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
7606
7611
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
7607
7612
|
|
|
7608
|
-
logger$
|
|
7613
|
+
logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
7609
7614
|
|
|
7610
7615
|
return {
|
|
7611
7616
|
constraints: {
|
|
@@ -7654,7 +7659,7 @@ class WebRTCClient extends Emitter {
|
|
|
7654
7659
|
}
|
|
7655
7660
|
|
|
7656
7661
|
_onTransportError() {
|
|
7657
|
-
logger$
|
|
7662
|
+
logger$3.error('on transport error');
|
|
7658
7663
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
7659
7664
|
this.attemptReconnection();
|
|
7660
7665
|
}
|
|
@@ -7663,7 +7668,7 @@ class WebRTCClient extends Emitter {
|
|
|
7663
7668
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
7664
7669
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
7665
7670
|
if (this.hasHeartbeat()) {
|
|
7666
|
-
logger$
|
|
7671
|
+
logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
7667
7672
|
|
|
7668
7673
|
this.heartbeat.onHeartbeat();
|
|
7669
7674
|
if (this.heartbeatCb) {
|
|
@@ -7674,7 +7679,7 @@ class WebRTCClient extends Emitter {
|
|
|
7674
7679
|
}
|
|
7675
7680
|
|
|
7676
7681
|
async _onHeartbeatTimeout() {
|
|
7677
|
-
logger$
|
|
7682
|
+
logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
7678
7683
|
|
|
7679
7684
|
if (this.heartbeatTimeoutCb) {
|
|
7680
7685
|
this.heartbeatTimeoutCb();
|
|
@@ -7686,7 +7691,7 @@ class WebRTCClient extends Emitter {
|
|
|
7686
7691
|
try {
|
|
7687
7692
|
await this.userAgent.transport.disconnect();
|
|
7688
7693
|
} catch (e) {
|
|
7689
|
-
logger$
|
|
7694
|
+
logger$3.error('Transport disconnection after heartbeat timeout, error', e);
|
|
7690
7695
|
}
|
|
7691
7696
|
}
|
|
7692
7697
|
|
|
@@ -7719,31 +7724,31 @@ class WebRTCClient extends Emitter {
|
|
|
7719
7724
|
}
|
|
7720
7725
|
|
|
7721
7726
|
_connectIfNeeded() {
|
|
7722
|
-
logger$
|
|
7727
|
+
logger$3.info('connect if needed, checking', { connected: this.isConnected() });
|
|
7723
7728
|
if (!this.userAgent) {
|
|
7724
|
-
logger$
|
|
7729
|
+
logger$3.info('need to recreate User Agent');
|
|
7725
7730
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
7726
7731
|
}
|
|
7727
7732
|
|
|
7728
7733
|
if (this.isConnected()) {
|
|
7729
|
-
logger$
|
|
7734
|
+
logger$3.info('webrtc sdk, already connected');
|
|
7730
7735
|
return Promise.resolve();
|
|
7731
7736
|
}
|
|
7732
7737
|
|
|
7733
7738
|
if (this.isConnecting()) {
|
|
7734
|
-
logger$
|
|
7739
|
+
logger$3.info('webrtc sdk, already connecting...');
|
|
7735
7740
|
|
|
7736
7741
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
7737
7742
|
return this.connectionPromise;
|
|
7738
7743
|
}
|
|
7739
7744
|
|
|
7740
7745
|
if (this.connectionPromise) {
|
|
7741
|
-
logger$
|
|
7746
|
+
logger$3.info('webrtc sdk, connection promise connecting...');
|
|
7742
7747
|
// $FlowFixMe
|
|
7743
7748
|
return this.connectionPromise;
|
|
7744
7749
|
}
|
|
7745
7750
|
|
|
7746
|
-
logger$
|
|
7751
|
+
logger$3.info('WebRTC UA needs to connect');
|
|
7747
7752
|
|
|
7748
7753
|
// Force UA to reconnect
|
|
7749
7754
|
if (this.userAgent && this.userAgent.state !== UserAgentState.Stopped) {
|
|
@@ -7868,7 +7873,7 @@ class WebRTCClient extends Emitter {
|
|
|
7868
7873
|
|
|
7869
7874
|
sdh.peerConnectionDelegate = {
|
|
7870
7875
|
onicecandidateerror: (error ) => {
|
|
7871
|
-
logger$
|
|
7876
|
+
logger$3.error('on icecandidate error', {
|
|
7872
7877
|
address: error.address,
|
|
7873
7878
|
port: error.port,
|
|
7874
7879
|
errorCode: error.errorCode,
|
|
@@ -7897,7 +7902,7 @@ class WebRTCClient extends Emitter {
|
|
|
7897
7902
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
7898
7903
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
7899
7904
|
}
|
|
7900
|
-
logger$
|
|
7905
|
+
logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
7901
7906
|
|
|
7902
7907
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
7903
7908
|
|
|
@@ -7913,12 +7918,12 @@ class WebRTCClient extends Emitter {
|
|
|
7913
7918
|
|
|
7914
7919
|
this._setupMedias(session);
|
|
7915
7920
|
|
|
7916
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
7921
|
+
return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
|
|
7917
7922
|
};
|
|
7918
7923
|
}
|
|
7919
7924
|
|
|
7920
7925
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
7921
|
-
logger$
|
|
7926
|
+
logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7922
7927
|
|
|
7923
7928
|
this.storeSipSession(session);
|
|
7924
7929
|
|
|
@@ -7930,14 +7935,14 @@ class WebRTCClient extends Emitter {
|
|
|
7930
7935
|
const onTrack = (event ) => {
|
|
7931
7936
|
const isAudioOnly = this._isAudioOnly(session);
|
|
7932
7937
|
const { kind, label, readyState, id, muted } = event.track;
|
|
7933
|
-
logger$
|
|
7938
|
+
logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
7934
7939
|
|
|
7935
7940
|
// Stop video track in audio only mode
|
|
7936
7941
|
if (isAudioOnly && kind === 'video') {
|
|
7937
7942
|
event.track.stop();
|
|
7938
7943
|
}
|
|
7939
7944
|
|
|
7940
|
-
this.eventEmitter.emit(ON_TRACK
|
|
7945
|
+
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
7941
7946
|
};
|
|
7942
7947
|
|
|
7943
7948
|
if (session.sessionDescriptionHandler.peerConnection) {
|
|
@@ -7947,9 +7952,9 @@ class WebRTCClient extends Emitter {
|
|
|
7947
7952
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
7948
7953
|
|
|
7949
7954
|
pc.oniceconnectionstatechange = () => {
|
|
7950
|
-
logger$
|
|
7955
|
+
logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
7951
7956
|
if (pc.iceConnectionState === 'disconnected') {
|
|
7952
|
-
this.eventEmitter.emit(ON_DISCONNECTED
|
|
7957
|
+
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
7953
7958
|
}
|
|
7954
7959
|
};
|
|
7955
7960
|
|
|
@@ -8120,10 +8125,10 @@ class WebRTCClient extends Emitter {
|
|
|
8120
8125
|
|
|
8121
8126
|
_stopSendingStats(session ) {
|
|
8122
8127
|
const sessionId = this.getSipSessionId(session);
|
|
8123
|
-
logger$
|
|
8128
|
+
logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
8124
8129
|
|
|
8125
8130
|
if (sessionId in this.statsIntervals) {
|
|
8126
|
-
logger$
|
|
8131
|
+
logger$3.trace('Stop sending stats for call', { sessionId });
|
|
8127
8132
|
this.statsIntervals[sessionId]();
|
|
8128
8133
|
delete this.statsIntervals[sessionId];
|
|
8129
8134
|
}
|
|
@@ -8139,7 +8144,7 @@ class WebRTCClient extends Emitter {
|
|
|
8139
8144
|
try {
|
|
8140
8145
|
await this.userAgent.transport.disconnect();
|
|
8141
8146
|
} catch (e) {
|
|
8142
|
-
logger$
|
|
8147
|
+
logger$3.error('WebRTC transport disconnect, error', e);
|
|
8143
8148
|
}
|
|
8144
8149
|
}
|
|
8145
8150
|
}
|
|
@@ -8233,7 +8238,7 @@ class WebRTCClient extends Emitter {
|
|
|
8233
8238
|
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
8234
8239
|
+ networkStats.transportSent;
|
|
8235
8240
|
|
|
8236
|
-
this.eventEmitter.emit(ON_NETWORK_STATS
|
|
8241
|
+
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
8237
8242
|
this.sessionNetworkStats[sessionId].push(networkStats);
|
|
8238
8243
|
}
|
|
8239
8244
|
|
|
@@ -8241,7 +8246,7 @@ class WebRTCClient extends Emitter {
|
|
|
8241
8246
|
|
|
8242
8247
|
//
|
|
8243
8248
|
|
|
8244
|
-
const SOCKET_EVENTS
|
|
8249
|
+
const SOCKET_EVENTS = {
|
|
8245
8250
|
ON_OPEN: 'onopen',
|
|
8246
8251
|
ON_MESSAGE: 'onmessage',
|
|
8247
8252
|
ON_ERROR: 'onerror',
|
|
@@ -8337,7 +8342,7 @@ const BLACKLIST_EVENTS = [
|
|
|
8337
8342
|
];
|
|
8338
8343
|
|
|
8339
8344
|
const HEARTBEAT_ENGINE_VERSION = '20.09';
|
|
8340
|
-
const logger$
|
|
8345
|
+
const logger$4 = IssueReporter$1.loggerFor('wazo-ws');
|
|
8341
8346
|
const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
|
|
8342
8347
|
|
|
8343
8348
|
class WebSocketClient extends Emitter {
|
|
@@ -8386,24 +8391,24 @@ class WebSocketClient extends Emitter {
|
|
|
8386
8391
|
}
|
|
8387
8392
|
|
|
8388
8393
|
connect() {
|
|
8389
|
-
logger$
|
|
8394
|
+
logger$4.info('connect method started', { host: this.host, token: this.token });
|
|
8390
8395
|
this.socket = new ReconnectingWebSocket(this._getUrl.bind(this), [], this.options);
|
|
8391
8396
|
if (this.options.binaryType) {
|
|
8392
8397
|
this.socket.binaryType = this.options.binaryType;
|
|
8393
8398
|
}
|
|
8394
8399
|
|
|
8395
8400
|
this.socket.onopen = () => {
|
|
8396
|
-
logger$
|
|
8397
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
8401
|
+
logger$4.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
8402
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
8398
8403
|
};
|
|
8399
8404
|
|
|
8400
8405
|
this.socket.onerror = event => {
|
|
8401
|
-
logger$
|
|
8402
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
8406
|
+
logger$4.error('on Wazo WS error', event.target);
|
|
8407
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
8403
8408
|
};
|
|
8404
8409
|
|
|
8405
8410
|
this.socket.onmessage = (event ) => {
|
|
8406
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
8411
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
|
|
8407
8412
|
|
|
8408
8413
|
const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
|
|
8409
8414
|
let { name } = message;
|
|
@@ -8428,7 +8433,7 @@ class WebSocketClient extends Emitter {
|
|
|
8428
8433
|
|
|
8429
8434
|
this.socket.onclose = event => {
|
|
8430
8435
|
// Can't be converted to JSON (circular structure)
|
|
8431
|
-
logger$
|
|
8436
|
+
logger$4.info('on Wazo WS close', {
|
|
8432
8437
|
reason: event.reason,
|
|
8433
8438
|
code: event.code,
|
|
8434
8439
|
readyState: event.target.readyState,
|
|
@@ -8436,22 +8441,22 @@ class WebSocketClient extends Emitter {
|
|
|
8436
8441
|
token: this.token,
|
|
8437
8442
|
});
|
|
8438
8443
|
this.initialized = false;
|
|
8439
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
8444
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
|
|
8440
8445
|
|
|
8441
8446
|
switch (event.code) {
|
|
8442
8447
|
case 4002:
|
|
8443
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
8448
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
|
|
8444
8449
|
break;
|
|
8445
8450
|
}
|
|
8446
8451
|
};
|
|
8447
8452
|
|
|
8448
8453
|
this.socket.onerror = event => {
|
|
8449
|
-
logger$
|
|
8454
|
+
logger$4.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
8450
8455
|
};
|
|
8451
8456
|
}
|
|
8452
8457
|
|
|
8453
8458
|
close(force = false) {
|
|
8454
|
-
logger$
|
|
8459
|
+
logger$4.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
8455
8460
|
|
|
8456
8461
|
if (!this.socket) {
|
|
8457
8462
|
return;
|
|
@@ -8469,7 +8474,7 @@ class WebSocketClient extends Emitter {
|
|
|
8469
8474
|
|
|
8470
8475
|
updateToken(token ) {
|
|
8471
8476
|
this.token = token;
|
|
8472
|
-
logger$
|
|
8477
|
+
logger$4.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
8473
8478
|
|
|
8474
8479
|
if (this.socket) {
|
|
8475
8480
|
// If still connected, send the token to the WS
|
|
@@ -8487,7 +8492,7 @@ class WebSocketClient extends Emitter {
|
|
|
8487
8492
|
}
|
|
8488
8493
|
|
|
8489
8494
|
startHeartbeat() {
|
|
8490
|
-
logger$
|
|
8495
|
+
logger$4.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
8491
8496
|
|
|
8492
8497
|
if (!this.socket) {
|
|
8493
8498
|
this.heartbeat.stop();
|
|
@@ -8501,7 +8506,7 @@ class WebSocketClient extends Emitter {
|
|
|
8501
8506
|
}
|
|
8502
8507
|
|
|
8503
8508
|
stopHeartbeat() {
|
|
8504
|
-
logger$
|
|
8509
|
+
logger$4.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
8505
8510
|
|
|
8506
8511
|
this.heartbeat.stop();
|
|
8507
8512
|
}
|
|
@@ -8531,7 +8536,7 @@ class WebSocketClient extends Emitter {
|
|
|
8531
8536
|
}
|
|
8532
8537
|
|
|
8533
8538
|
reconnect(reason ) {
|
|
8534
|
-
logger$
|
|
8539
|
+
logger$4.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
8535
8540
|
if (!this.socket) {
|
|
8536
8541
|
return;
|
|
8537
8542
|
}
|
|
@@ -8556,7 +8561,7 @@ class WebSocketClient extends Emitter {
|
|
|
8556
8561
|
break;
|
|
8557
8562
|
case 'start':
|
|
8558
8563
|
this.initialized = true;
|
|
8559
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
8564
|
+
this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
|
|
8560
8565
|
break;
|
|
8561
8566
|
default:
|
|
8562
8567
|
this.eventEmitter.emit('message', message);
|
|
@@ -8587,7 +8592,7 @@ class WebSocketClient extends Emitter {
|
|
|
8587
8592
|
this.close();
|
|
8588
8593
|
}
|
|
8589
8594
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
8590
|
-
logger$
|
|
8595
|
+
logger$4.log('Wazo WS url computed to reconnect', { url });
|
|
8591
8596
|
|
|
8592
8597
|
return url;
|
|
8593
8598
|
}
|
|
@@ -8595,15 +8600,15 @@ class WebSocketClient extends Emitter {
|
|
|
8595
8600
|
_onHeartbeat(message ) {
|
|
8596
8601
|
if (message.payload === 'pong') {
|
|
8597
8602
|
this.heartbeat.onHeartbeat();
|
|
8598
|
-
logger$
|
|
8603
|
+
logger$4.log('on heartbeat received from Wazo WS');
|
|
8599
8604
|
}
|
|
8600
8605
|
}
|
|
8601
8606
|
|
|
8602
8607
|
async _onHeartbeatTimeout() {
|
|
8603
|
-
logger$
|
|
8608
|
+
logger$4.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
8604
8609
|
|
|
8605
8610
|
this.close();
|
|
8606
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
8611
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
8607
8612
|
|
|
8608
8613
|
if (this.onHeartBeatTimeout) {
|
|
8609
8614
|
this.onHeartBeatTimeout();
|
|
@@ -8683,7 +8688,7 @@ WebSocketClient.eventLists = [
|
|
|
8683
8688
|
|
|
8684
8689
|
var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
8685
8690
|
__proto__: null,
|
|
8686
|
-
SOCKET_EVENTS: SOCKET_EVENTS
|
|
8691
|
+
SOCKET_EVENTS: SOCKET_EVENTS,
|
|
8687
8692
|
AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
|
|
8688
8693
|
FAVORITE_ADDED: FAVORITE_ADDED,
|
|
8689
8694
|
FAVORITE_DELETED: FAVORITE_DELETED,
|
|
@@ -8916,7 +8921,7 @@ class NotificationOptions {
|
|
|
8916
8921
|
|
|
8917
8922
|
|
|
8918
8923
|
// Represents a conference room, like `9000`.
|
|
8919
|
-
class Room
|
|
8924
|
+
class Room {
|
|
8920
8925
|
|
|
8921
8926
|
|
|
8922
8927
|
|
|
@@ -8937,7 +8942,7 @@ class Room$1 {
|
|
|
8937
8942
|
}
|
|
8938
8943
|
|
|
8939
8944
|
connect(callSession ) {
|
|
8940
|
-
return new Room
|
|
8945
|
+
return new Room({ ...this, connectedCallSession: callSession });
|
|
8941
8946
|
}
|
|
8942
8947
|
|
|
8943
8948
|
has(callSession ) {
|
|
@@ -8946,7 +8951,7 @@ class Room$1 {
|
|
|
8946
8951
|
|
|
8947
8952
|
addParticipant(uuid , extension , talking = null) {
|
|
8948
8953
|
if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
|
|
8949
|
-
return new Room
|
|
8954
|
+
return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
8950
8955
|
}
|
|
8951
8956
|
|
|
8952
8957
|
return this;
|
|
@@ -8965,7 +8970,7 @@ class Room$1 {
|
|
|
8965
8970
|
updatedParticipants.push(participant);
|
|
8966
8971
|
}
|
|
8967
8972
|
|
|
8968
|
-
return new Room
|
|
8973
|
+
return new Room({ ...this, participants: updatedParticipants });
|
|
8969
8974
|
}
|
|
8970
8975
|
|
|
8971
8976
|
updateParticipantByExtension(extension , participant , shouldAdd = false) {
|
|
@@ -8981,7 +8986,7 @@ class Room$1 {
|
|
|
8981
8986
|
updatedParticipants.push(participant);
|
|
8982
8987
|
}
|
|
8983
8988
|
|
|
8984
|
-
return new Room
|
|
8989
|
+
return new Room({ ...this, participants: updatedParticipants });
|
|
8985
8990
|
}
|
|
8986
8991
|
|
|
8987
8992
|
hasCallWithId(id ) {
|
|
@@ -8989,18 +8994,18 @@ class Room$1 {
|
|
|
8989
8994
|
}
|
|
8990
8995
|
|
|
8991
8996
|
disconnect() {
|
|
8992
|
-
return new Room
|
|
8997
|
+
return new Room({ ...this, connectedCallSession: null });
|
|
8993
8998
|
}
|
|
8994
8999
|
|
|
8995
9000
|
removeParticipantWithUUID(uuid ) {
|
|
8996
|
-
return new Room
|
|
9001
|
+
return new Room({
|
|
8997
9002
|
...this,
|
|
8998
9003
|
participants: this.participants.filter(participant => participant.uuid !== uuid),
|
|
8999
9004
|
});
|
|
9000
9005
|
}
|
|
9001
9006
|
|
|
9002
9007
|
removeParticipantWithExtension(extension ) {
|
|
9003
|
-
return new Room
|
|
9008
|
+
return new Room({
|
|
9004
9009
|
...this,
|
|
9005
9010
|
participants: this.participants.filter(participant => participant.extension !== extension),
|
|
9006
9011
|
});
|
|
@@ -9011,7 +9016,7 @@ class Room$1 {
|
|
|
9011
9016
|
}
|
|
9012
9017
|
|
|
9013
9018
|
static newFrom(room ) {
|
|
9014
|
-
return newFrom(room, Room
|
|
9019
|
+
return newFrom(room, Room);
|
|
9015
9020
|
}
|
|
9016
9021
|
}
|
|
9017
9022
|
|
|
@@ -9154,8 +9159,8 @@ const ON_CALL_FAILED = 'onCallFailed';
|
|
|
9154
9159
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
9155
9160
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
9156
9161
|
const ON_MESSAGE = 'onMessage';
|
|
9157
|
-
const ON_REINVITE = 'reinvite';
|
|
9158
|
-
const ON_TRACK = 'onTrack';
|
|
9162
|
+
const ON_REINVITE$1 = 'reinvite';
|
|
9163
|
+
const ON_TRACK$1 = 'onTrack';
|
|
9159
9164
|
const ON_AUDIO_STREAM = 'onAudioStream';
|
|
9160
9165
|
const ON_VIDEO_STREAM = 'onVideoStream';
|
|
9161
9166
|
const ON_REMOVE_STREAM = 'onRemoveStream';
|
|
@@ -9170,15 +9175,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
|
|
|
9170
9175
|
const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
|
|
9171
9176
|
const ON_CALL_ERROR = 'onCallError';
|
|
9172
9177
|
const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
|
|
9173
|
-
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
9178
|
+
const ON_NETWORK_STATS$1 = 'onNetworkStats';
|
|
9174
9179
|
const ON_CHAT = 'phone/ON_CHAT';
|
|
9175
9180
|
const ON_SIGNAL = 'phone/ON_SIGNAL';
|
|
9176
|
-
const ON_DISCONNECTED = 'onDisconnected';
|
|
9181
|
+
const ON_DISCONNECTED$1 = 'onDisconnected';
|
|
9177
9182
|
|
|
9178
9183
|
const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
9179
9184
|
const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
9180
9185
|
|
|
9181
|
-
const events = [
|
|
9186
|
+
const events$1 = [
|
|
9182
9187
|
ON_USER_AGENT,
|
|
9183
9188
|
ON_REGISTERED,
|
|
9184
9189
|
ON_UNREGISTERED,
|
|
@@ -9196,8 +9201,8 @@ const events = [
|
|
|
9196
9201
|
ON_CALL_FAILED,
|
|
9197
9202
|
ON_CALL_ENDED,
|
|
9198
9203
|
ON_MESSAGE,
|
|
9199
|
-
ON_REINVITE,
|
|
9200
|
-
ON_TRACK,
|
|
9204
|
+
ON_REINVITE$1,
|
|
9205
|
+
ON_TRACK$1,
|
|
9201
9206
|
ON_AUDIO_STREAM,
|
|
9202
9207
|
ON_VIDEO_STREAM,
|
|
9203
9208
|
ON_REMOVE_STREAM,
|
|
@@ -9212,11 +9217,11 @@ const events = [
|
|
|
9212
9217
|
ON_CALL_ERROR,
|
|
9213
9218
|
ON_CHAT,
|
|
9214
9219
|
ON_SIGNAL,
|
|
9215
|
-
ON_NETWORK_STATS,
|
|
9216
|
-
ON_DISCONNECTED,
|
|
9220
|
+
ON_NETWORK_STATS$1,
|
|
9221
|
+
ON_DISCONNECTED$1,
|
|
9217
9222
|
];
|
|
9218
9223
|
|
|
9219
|
-
const logger$
|
|
9224
|
+
const logger$5 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
9220
9225
|
|
|
9221
9226
|
class WebRTCPhone extends Emitter {
|
|
9222
9227
|
|
|
@@ -9289,7 +9294,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9289
9294
|
}).catch(error => {
|
|
9290
9295
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
9291
9296
|
console.error('register error', error, error.message, error.stack);
|
|
9292
|
-
logger$
|
|
9297
|
+
logger$5.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
9293
9298
|
});
|
|
9294
9299
|
}
|
|
9295
9300
|
|
|
@@ -9304,7 +9309,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9304
9309
|
if (!this.client) {
|
|
9305
9310
|
return;
|
|
9306
9311
|
}
|
|
9307
|
-
logger$
|
|
9312
|
+
logger$5.info('WebRTC phone stop');
|
|
9308
9313
|
this.client.stop();
|
|
9309
9314
|
}
|
|
9310
9315
|
|
|
@@ -9319,7 +9324,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9319
9324
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
9320
9325
|
audioOnly = false, iceRestart = false) {
|
|
9321
9326
|
const sipSession = this.findSipSession(callSession);
|
|
9322
|
-
logger$
|
|
9327
|
+
logger$5.info('WebRTC phone - send reinvite', {
|
|
9323
9328
|
sessionId: sipSession ? sipSession.id : null,
|
|
9324
9329
|
constraints,
|
|
9325
9330
|
audioOnly,
|
|
@@ -9356,7 +9361,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9356
9361
|
}
|
|
9357
9362
|
|
|
9358
9363
|
startHeartbeat() {
|
|
9359
|
-
logger$
|
|
9364
|
+
logger$5.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
9360
9365
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
9361
9366
|
return;
|
|
9362
9367
|
}
|
|
@@ -9365,7 +9370,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9365
9370
|
}
|
|
9366
9371
|
|
|
9367
9372
|
stopHeartbeat() {
|
|
9368
|
-
logger$
|
|
9373
|
+
logger$5.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
9369
9374
|
if (!this.client) {
|
|
9370
9375
|
return;
|
|
9371
9376
|
}
|
|
@@ -9382,7 +9387,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9382
9387
|
}
|
|
9383
9388
|
|
|
9384
9389
|
reconnect() {
|
|
9385
|
-
logger$
|
|
9390
|
+
logger$5.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
9386
9391
|
if (!this.client) {
|
|
9387
9392
|
return;
|
|
9388
9393
|
}
|
|
@@ -9423,10 +9428,15 @@ class WebRTCPhone extends Emitter {
|
|
|
9423
9428
|
return false;
|
|
9424
9429
|
}
|
|
9425
9430
|
|
|
9426
|
-
logger$
|
|
9431
|
+
logger$5.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
9427
9432
|
|
|
9428
9433
|
this.client.downgradeToAudio(sipSession);
|
|
9429
9434
|
|
|
9435
|
+
if (callSession) {
|
|
9436
|
+
callSession.cameraEnabled = false;
|
|
9437
|
+
this._updateCallSession(callSession);
|
|
9438
|
+
}
|
|
9439
|
+
|
|
9430
9440
|
if (withMessage) {
|
|
9431
9441
|
this._sendReinviteMessage(callSession, false);
|
|
9432
9442
|
}
|
|
@@ -9441,7 +9451,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9441
9451
|
return Promise.resolve(false);
|
|
9442
9452
|
}
|
|
9443
9453
|
|
|
9444
|
-
logger$
|
|
9454
|
+
logger$5.info('Upgrade to video', {
|
|
9445
9455
|
id: callSession ? callSession.getId() : null,
|
|
9446
9456
|
constraints,
|
|
9447
9457
|
isConference,
|
|
@@ -9454,6 +9464,11 @@ class WebRTCPhone extends Emitter {
|
|
|
9454
9464
|
|
|
9455
9465
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
9456
9466
|
|
|
9467
|
+
if (callSession) {
|
|
9468
|
+
callSession.cameraEnabled = true;
|
|
9469
|
+
this._updateCallSession(callSession);
|
|
9470
|
+
}
|
|
9471
|
+
|
|
9457
9472
|
// If no stream is returned, it means we have to reinvite
|
|
9458
9473
|
if (!newStream) {
|
|
9459
9474
|
return true;
|
|
@@ -9476,7 +9491,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9476
9491
|
|
|
9477
9492
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
9478
9493
|
const sipSession = this.findSipSession(callSession);
|
|
9479
|
-
logger$
|
|
9494
|
+
logger$5.info('Sending reinvite message', {
|
|
9480
9495
|
id: callSession ? callSession.getId() : null,
|
|
9481
9496
|
isUpgrade,
|
|
9482
9497
|
});
|
|
@@ -9502,7 +9517,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9502
9517
|
// Monkey patch to know when canceled with the CANCEL message
|
|
9503
9518
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
9504
9519
|
sipSession._onCancel = (message ) => {
|
|
9505
|
-
logger$
|
|
9520
|
+
logger$5.trace('on sip session canceled', { callId: message.callId });
|
|
9506
9521
|
|
|
9507
9522
|
onCancel(message);
|
|
9508
9523
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
@@ -9530,13 +9545,13 @@ class WebRTCPhone extends Emitter {
|
|
|
9530
9545
|
this.audioOutputVolume,
|
|
9531
9546
|
);
|
|
9532
9547
|
case SessionState.Terminating:
|
|
9533
|
-
logger$
|
|
9548
|
+
logger$5.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
9534
9549
|
|
|
9535
9550
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
9536
9551
|
|
|
9537
9552
|
break;
|
|
9538
9553
|
case SessionState.Terminated: {
|
|
9539
|
-
logger$
|
|
9554
|
+
logger$5.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
9540
9555
|
|
|
9541
9556
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
9542
9557
|
const callSession = this._createCallSession(sipSession);
|
|
@@ -9558,7 +9573,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9558
9573
|
const [stream] = event.streams;
|
|
9559
9574
|
const kind = event && event.track && event.track.kind;
|
|
9560
9575
|
|
|
9561
|
-
logger$
|
|
9576
|
+
logger$5.info('on track stream called on the peer connection', {
|
|
9562
9577
|
callId: this.getSipSessionId(sipSession),
|
|
9563
9578
|
streamId: stream ? stream.id : null,
|
|
9564
9579
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -9578,7 +9593,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9578
9593
|
};
|
|
9579
9594
|
|
|
9580
9595
|
peerConnection.onremovestream = event => {
|
|
9581
|
-
logger$
|
|
9596
|
+
logger$5.info('on remove stream called on the peer connection', {
|
|
9582
9597
|
id: event.stream.id,
|
|
9583
9598
|
tracks: event.stream.getTracks(),
|
|
9584
9599
|
});
|
|
@@ -9588,7 +9603,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9588
9603
|
}
|
|
9589
9604
|
|
|
9590
9605
|
async startScreenSharing(constraints , callSession ) {
|
|
9591
|
-
logger$
|
|
9606
|
+
logger$5.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
9592
9607
|
|
|
9593
9608
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
9594
9609
|
if (!screenShareStream) {
|
|
@@ -9628,7 +9643,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9628
9643
|
return;
|
|
9629
9644
|
}
|
|
9630
9645
|
|
|
9631
|
-
logger$
|
|
9646
|
+
logger$5.info('WebRTC phone - stop screen sharing', {
|
|
9632
9647
|
restoreLocalStream,
|
|
9633
9648
|
});
|
|
9634
9649
|
|
|
@@ -9684,7 +9699,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9684
9699
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
9685
9700
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
9686
9701
|
|
|
9687
|
-
logger$
|
|
9702
|
+
logger$5.info('WebRTC phone - on screensharing', {
|
|
9688
9703
|
hadVideo,
|
|
9689
9704
|
id: this.getSipSessionId(sipSession),
|
|
9690
9705
|
screenTrack,
|
|
@@ -9692,7 +9707,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9692
9707
|
|
|
9693
9708
|
if (screenTrack) {
|
|
9694
9709
|
screenTrack.onended = () => {
|
|
9695
|
-
logger$
|
|
9710
|
+
logger$5.info('WebRTC phone - on screenshare ended', {
|
|
9696
9711
|
hadVideo,
|
|
9697
9712
|
id: this.getSipSessionId(sipSession),
|
|
9698
9713
|
screenTrack,
|
|
@@ -9723,7 +9738,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9723
9738
|
}
|
|
9724
9739
|
|
|
9725
9740
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
9726
|
-
logger$
|
|
9741
|
+
logger$5.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
9727
9742
|
|
|
9728
9743
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
9729
9744
|
this.currentSipSession = sipSession;
|
|
@@ -9741,7 +9756,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9741
9756
|
}
|
|
9742
9757
|
|
|
9743
9758
|
changeAudioDevice(id ) {
|
|
9744
|
-
logger$
|
|
9759
|
+
logger$5.info('WebRTC phone - change audio device', { deviceId: id });
|
|
9745
9760
|
this.audioOutputDeviceId = id;
|
|
9746
9761
|
this.client.changeAudioOutputDevice(id);
|
|
9747
9762
|
}
|
|
@@ -9751,14 +9766,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9751
9766
|
}
|
|
9752
9767
|
|
|
9753
9768
|
changeRingDevice(id ) {
|
|
9754
|
-
logger$
|
|
9769
|
+
logger$5.info('WebRTC phone - changing ring device', { id });
|
|
9755
9770
|
|
|
9756
9771
|
this.audioRingDeviceId = id;
|
|
9757
9772
|
}
|
|
9758
9773
|
|
|
9759
9774
|
// volume is a value between 0 and 1
|
|
9760
9775
|
changeAudioVolume(volume ) {
|
|
9761
|
-
logger$
|
|
9776
|
+
logger$5.info('WebRTC phone - changing audio volume', { volume });
|
|
9762
9777
|
|
|
9763
9778
|
this.audioOutputVolume = volume;
|
|
9764
9779
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -9766,31 +9781,31 @@ class WebRTCPhone extends Emitter {
|
|
|
9766
9781
|
|
|
9767
9782
|
// volume is a value between 0 and 1
|
|
9768
9783
|
changeRingVolume(volume ) {
|
|
9769
|
-
logger$
|
|
9784
|
+
logger$5.info('WebRTC phone - changing ring volume', { volume });
|
|
9770
9785
|
|
|
9771
9786
|
this.audioRingVolume = volume;
|
|
9772
9787
|
}
|
|
9773
9788
|
|
|
9774
9789
|
changeAudioInputDevice(id ) {
|
|
9775
|
-
logger$
|
|
9790
|
+
logger$5.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
9776
9791
|
|
|
9777
9792
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
9778
9793
|
}
|
|
9779
9794
|
|
|
9780
9795
|
changeVideoInputDevice(id ) {
|
|
9781
|
-
logger$
|
|
9796
|
+
logger$5.info('WebRTC phone - change video input device', { deviceId: id });
|
|
9782
9797
|
|
|
9783
9798
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
9784
9799
|
}
|
|
9785
9800
|
|
|
9786
9801
|
changeSessionVideoInputDevice(id ) {
|
|
9787
|
-
logger$
|
|
9802
|
+
logger$5.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
9788
9803
|
|
|
9789
9804
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
9790
9805
|
}
|
|
9791
9806
|
|
|
9792
9807
|
_onCallTerminated(sipSession ) {
|
|
9793
|
-
logger$
|
|
9808
|
+
logger$5.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9794
9809
|
|
|
9795
9810
|
const callSession = this._createCallSession(sipSession);
|
|
9796
9811
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -9824,7 +9839,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9824
9839
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
9825
9840
|
|
|
9826
9841
|
// Re-trigger incoming call event for remaining incoming calls
|
|
9827
|
-
logger$
|
|
9842
|
+
logger$5.info('WebRTC phone - check to re-trigger incoming call', {
|
|
9828
9843
|
sipId: sipSession.id,
|
|
9829
9844
|
shouldRetrigger,
|
|
9830
9845
|
hasIncomingCallSession,
|
|
@@ -9915,37 +9930,37 @@ class WebRTCPhone extends Emitter {
|
|
|
9915
9930
|
|
|
9916
9931
|
// Deprecated
|
|
9917
9932
|
getLocalStreamForCall(callSession ) {
|
|
9918
|
-
logger$
|
|
9933
|
+
logger$5.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9919
9934
|
|
|
9920
9935
|
return this.getLocalStream(callSession);
|
|
9921
9936
|
}
|
|
9922
9937
|
|
|
9923
9938
|
// Deprecated
|
|
9924
9939
|
getRemoteStreamForCall(callSession ) {
|
|
9925
|
-
logger$
|
|
9940
|
+
logger$5.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
9926
9941
|
|
|
9927
9942
|
return this.getRemoteVideoStream(callSession);
|
|
9928
9943
|
}
|
|
9929
9944
|
|
|
9930
9945
|
getRemoteStreamsForCall(callSession ) {
|
|
9931
|
-
logger$
|
|
9946
|
+
logger$5.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
9932
9947
|
|
|
9933
9948
|
return this.getRemoteStream(callSession);
|
|
9934
9949
|
}
|
|
9935
9950
|
|
|
9936
9951
|
accept(callSession , cameraEnabled ) {
|
|
9937
|
-
logger$
|
|
9952
|
+
logger$5.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
9938
9953
|
if (this.currentSipSession) {
|
|
9939
9954
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
9940
9955
|
}
|
|
9941
9956
|
|
|
9942
9957
|
if (!callSession) {
|
|
9943
|
-
logger$
|
|
9958
|
+
logger$5.warn('no CallSession to accept.');
|
|
9944
9959
|
return Promise.resolve(null);
|
|
9945
9960
|
}
|
|
9946
9961
|
|
|
9947
9962
|
if (callSession.getId() in this.acceptedSessions) {
|
|
9948
|
-
logger$
|
|
9963
|
+
logger$5.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9949
9964
|
return Promise.resolve(callSession.sipCallId);
|
|
9950
9965
|
}
|
|
9951
9966
|
|
|
@@ -9957,24 +9972,24 @@ class WebRTCPhone extends Emitter {
|
|
|
9957
9972
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
9958
9973
|
if (sipSession) {
|
|
9959
9974
|
if (sipSession.state === SessionState.Terminated || sipSession.state === SessionState.Terminating) {
|
|
9960
|
-
logger$
|
|
9975
|
+
logger$5.warn('Trying to answer a terminated sipSession.');
|
|
9961
9976
|
|
|
9962
9977
|
return Promise.resolve(null);
|
|
9963
9978
|
}
|
|
9964
9979
|
|
|
9965
|
-
logger$
|
|
9980
|
+
logger$5.info('accept call, session found', { sipId: sipSession.id });
|
|
9966
9981
|
|
|
9967
9982
|
// $FlowFixMe
|
|
9968
9983
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
9969
9984
|
return callSession.sipCallId;
|
|
9970
9985
|
}).catch(e => {
|
|
9971
|
-
logger$
|
|
9986
|
+
logger$5.error(e);
|
|
9972
9987
|
this.endCurrentCall(callSession);
|
|
9973
9988
|
throw e;
|
|
9974
9989
|
});
|
|
9975
9990
|
}
|
|
9976
9991
|
|
|
9977
|
-
logger$
|
|
9992
|
+
logger$5.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9978
9993
|
|
|
9979
9994
|
return Promise.resolve(null);
|
|
9980
9995
|
}
|
|
@@ -9984,7 +9999,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9984
9999
|
}
|
|
9985
10000
|
|
|
9986
10001
|
async reject(callSession ) {
|
|
9987
|
-
logger$
|
|
10002
|
+
logger$5.info('reject WebRTC called', { id: callSession.getId() });
|
|
9988
10003
|
|
|
9989
10004
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
9990
10005
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -9996,14 +10011,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9996
10011
|
|
|
9997
10012
|
const sipSession = this.findSipSession(callSession);
|
|
9998
10013
|
if (sipSession) {
|
|
9999
|
-
logger$
|
|
10014
|
+
logger$5.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
10000
10015
|
|
|
10001
10016
|
this.client.hangup(sipSession);
|
|
10002
10017
|
}
|
|
10003
10018
|
}
|
|
10004
10019
|
|
|
10005
10020
|
async ignore(callSession ) {
|
|
10006
|
-
logger$
|
|
10021
|
+
logger$5.info('WebRTC ignore', { id: callSession.getId() });
|
|
10007
10022
|
|
|
10008
10023
|
// kill the ring
|
|
10009
10024
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -10015,14 +10030,14 @@ class WebRTCPhone extends Emitter {
|
|
|
10015
10030
|
const sipSession = this.findSipSession(callSession);
|
|
10016
10031
|
|
|
10017
10032
|
if (sipSession) {
|
|
10018
|
-
logger$
|
|
10033
|
+
logger$5.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
10019
10034
|
|
|
10020
10035
|
return this.client.atxfer(sipSession);
|
|
10021
10036
|
}
|
|
10022
10037
|
}
|
|
10023
10038
|
|
|
10024
10039
|
hold(callSession , withEvent = true, isConference = false) {
|
|
10025
|
-
logger$
|
|
10040
|
+
logger$5.info('WebRTC hold', { id: callSession.getId() });
|
|
10026
10041
|
|
|
10027
10042
|
const sipSession = this.findSipSession(callSession);
|
|
10028
10043
|
|
|
@@ -10037,18 +10052,18 @@ class WebRTCPhone extends Emitter {
|
|
|
10037
10052
|
}
|
|
10038
10053
|
|
|
10039
10054
|
resume(callSession , isConference = false, withEvent = true) {
|
|
10040
|
-
logger$
|
|
10055
|
+
logger$5.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
10041
10056
|
|
|
10042
10057
|
const sipSession = this.findSipSession(callSession);
|
|
10043
10058
|
if (!sipSession) {
|
|
10044
10059
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
10045
10060
|
}
|
|
10046
10061
|
|
|
10047
|
-
logger$
|
|
10062
|
+
logger$5.info('WebRTC resuming', { sipId: sipSession.id });
|
|
10048
10063
|
|
|
10049
10064
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
10050
10065
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
10051
|
-
logger$
|
|
10066
|
+
logger$5.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
10052
10067
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
10053
10068
|
}
|
|
10054
10069
|
|
|
@@ -10073,7 +10088,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10073
10088
|
const sessionId = this.getSipSessionId(sipSession);
|
|
10074
10089
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
10075
10090
|
|
|
10076
|
-
logger$
|
|
10091
|
+
logger$5.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
10077
10092
|
|
|
10078
10093
|
// Stop screenshre if needed
|
|
10079
10094
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -10104,7 +10119,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10104
10119
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
10105
10120
|
}
|
|
10106
10121
|
const sessionId = this.getSipSessionId(sipSession);
|
|
10107
|
-
logger$
|
|
10122
|
+
logger$5.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
10108
10123
|
|
|
10109
10124
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
10110
10125
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -10148,14 +10163,14 @@ class WebRTCPhone extends Emitter {
|
|
|
10148
10163
|
}
|
|
10149
10164
|
|
|
10150
10165
|
mute(callSession , withEvent = true) {
|
|
10151
|
-
logger$
|
|
10166
|
+
logger$5.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
10152
10167
|
|
|
10153
10168
|
const sipSession = this.findSipSession(callSession);
|
|
10154
10169
|
if (!sipSession) {
|
|
10155
10170
|
return;
|
|
10156
10171
|
}
|
|
10157
10172
|
|
|
10158
|
-
logger$
|
|
10173
|
+
logger$5.info('WebRTC muting', { sipId: sipSession.id });
|
|
10159
10174
|
this.client.mute(sipSession);
|
|
10160
10175
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
10161
10176
|
|
|
@@ -10169,14 +10184,14 @@ class WebRTCPhone extends Emitter {
|
|
|
10169
10184
|
}
|
|
10170
10185
|
|
|
10171
10186
|
unmute(callSession , withEvent = true) {
|
|
10172
|
-
logger$
|
|
10187
|
+
logger$5.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
10173
10188
|
|
|
10174
10189
|
const sipSession = this.findSipSession(callSession);
|
|
10175
10190
|
if (!sipSession) {
|
|
10176
10191
|
return;
|
|
10177
10192
|
}
|
|
10178
10193
|
|
|
10179
|
-
logger$
|
|
10194
|
+
logger$5.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
10180
10195
|
this.client.unmute(sipSession);
|
|
10181
10196
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
10182
10197
|
|
|
@@ -10203,7 +10218,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10203
10218
|
if (!sipSession) {
|
|
10204
10219
|
return;
|
|
10205
10220
|
}
|
|
10206
|
-
logger$
|
|
10221
|
+
logger$5.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
10207
10222
|
|
|
10208
10223
|
this.client.toggleCameraOn(sipSession);
|
|
10209
10224
|
|
|
@@ -10215,7 +10230,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10215
10230
|
if (!sipSession) {
|
|
10216
10231
|
return;
|
|
10217
10232
|
}
|
|
10218
|
-
logger$
|
|
10233
|
+
logger$5.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
10219
10234
|
|
|
10220
10235
|
this.client.toggleCameraOff(sipSession);
|
|
10221
10236
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -10227,7 +10242,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10227
10242
|
return;
|
|
10228
10243
|
}
|
|
10229
10244
|
|
|
10230
|
-
logger$
|
|
10245
|
+
logger$5.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
10231
10246
|
this.client.sendDTMF(sipSession, tone);
|
|
10232
10247
|
}
|
|
10233
10248
|
|
|
@@ -10235,7 +10250,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10235
10250
|
// @TODO: line is not used here
|
|
10236
10251
|
async makeCall(number , line , cameraEnabled ,
|
|
10237
10252
|
audioOnly = false, conference = false) {
|
|
10238
|
-
logger$
|
|
10253
|
+
logger$5.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
10239
10254
|
if (!number) {
|
|
10240
10255
|
return Promise.resolve(null);
|
|
10241
10256
|
}
|
|
@@ -10245,7 +10260,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10245
10260
|
}
|
|
10246
10261
|
if (this.currentSipSession) {
|
|
10247
10262
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
10248
|
-
logger$
|
|
10263
|
+
logger$5.warn('Unable to hold current session when making another call', e);
|
|
10249
10264
|
});
|
|
10250
10265
|
}
|
|
10251
10266
|
|
|
@@ -10255,7 +10270,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10255
10270
|
this._bindEvents(sipSession);
|
|
10256
10271
|
} catch (error) {
|
|
10257
10272
|
console.warn(error);
|
|
10258
|
-
logger$
|
|
10273
|
+
logger$5.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
10259
10274
|
return Promise.resolve(null);
|
|
10260
10275
|
}
|
|
10261
10276
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -10283,7 +10298,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10283
10298
|
return;
|
|
10284
10299
|
}
|
|
10285
10300
|
|
|
10286
|
-
logger$
|
|
10301
|
+
logger$5.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
10287
10302
|
|
|
10288
10303
|
this.client.transfer(sipSession, target);
|
|
10289
10304
|
}
|
|
@@ -10292,7 +10307,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10292
10307
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
10293
10308
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
10294
10309
|
|
|
10295
|
-
logger$
|
|
10310
|
+
logger$5.info('WebRTC indirect transfer', {
|
|
10296
10311
|
sipId: sipSession ? sipSession.id : null,
|
|
10297
10312
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
10298
10313
|
});
|
|
@@ -10331,7 +10346,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10331
10346
|
return false;
|
|
10332
10347
|
}
|
|
10333
10348
|
|
|
10334
|
-
logger$
|
|
10349
|
+
logger$5.info('WebRTC hangup', { sipId: sipSession.id });
|
|
10335
10350
|
|
|
10336
10351
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
10337
10352
|
|
|
@@ -10377,7 +10392,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10377
10392
|
endCurrentCall(callSession ) {
|
|
10378
10393
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
10379
10394
|
|
|
10380
|
-
logger$
|
|
10395
|
+
logger$5.info('Ending current call', {
|
|
10381
10396
|
id: callSession ? callSession.getId() : null,
|
|
10382
10397
|
isCurrent,
|
|
10383
10398
|
});
|
|
@@ -10401,7 +10416,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10401
10416
|
}
|
|
10402
10417
|
|
|
10403
10418
|
async close() {
|
|
10404
|
-
logger$
|
|
10419
|
+
logger$5.info('WebRTC close');
|
|
10405
10420
|
|
|
10406
10421
|
try {
|
|
10407
10422
|
await Promise.race([
|
|
@@ -10409,7 +10424,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10409
10424
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
10410
10425
|
]);
|
|
10411
10426
|
} catch (e) {
|
|
10412
|
-
logger$
|
|
10427
|
+
logger$5.error('WebRTC close, unregister error', e);
|
|
10413
10428
|
}
|
|
10414
10429
|
|
|
10415
10430
|
this.client.close();
|
|
@@ -10427,12 +10442,12 @@ class WebRTCPhone extends Emitter {
|
|
|
10427
10442
|
}
|
|
10428
10443
|
|
|
10429
10444
|
enableRinging() {
|
|
10430
|
-
logger$
|
|
10445
|
+
logger$5.info('WebRTC enable ringing');
|
|
10431
10446
|
this.ringingEnabled = true;
|
|
10432
10447
|
}
|
|
10433
10448
|
|
|
10434
10449
|
disableRinging() {
|
|
10435
|
-
logger$
|
|
10450
|
+
logger$5.info('WebRTC disable ringing');
|
|
10436
10451
|
this.ringingEnabled = false;
|
|
10437
10452
|
}
|
|
10438
10453
|
|
|
@@ -10472,7 +10487,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10472
10487
|
|
|
10473
10488
|
// Deprecated
|
|
10474
10489
|
getLocalMediaStream(callSession ) {
|
|
10475
|
-
logger$
|
|
10490
|
+
logger$5.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
10476
10491
|
return this.getLocalStream(callSession);
|
|
10477
10492
|
}
|
|
10478
10493
|
|
|
@@ -10514,7 +10529,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10514
10529
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
10515
10530
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
10516
10531
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
10517
|
-
logger$
|
|
10532
|
+
logger$5.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
10518
10533
|
|
|
10519
10534
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
10520
10535
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -10537,7 +10552,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10537
10552
|
});
|
|
10538
10553
|
|
|
10539
10554
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
10540
|
-
logger$
|
|
10555
|
+
logger$5.info('WebRTC on reinvite', {
|
|
10541
10556
|
sessionId: args[0].id,
|
|
10542
10557
|
inviteId: args[1].id,
|
|
10543
10558
|
updatedCalleeName: args[2],
|
|
@@ -10557,7 +10572,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10557
10572
|
});
|
|
10558
10573
|
|
|
10559
10574
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
10560
|
-
logger$
|
|
10575
|
+
logger$5.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
10561
10576
|
|
|
10562
10577
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
10563
10578
|
|
|
@@ -10568,22 +10583,22 @@ class WebRTCPhone extends Emitter {
|
|
|
10568
10583
|
this.client.on('ended', () => {});
|
|
10569
10584
|
|
|
10570
10585
|
this.client.on(this.client.ON_ERROR, e => {
|
|
10571
|
-
logger$
|
|
10586
|
+
logger$5.error('WebRTC error', e);
|
|
10572
10587
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
10573
10588
|
});
|
|
10574
10589
|
|
|
10575
10590
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
10576
|
-
logger$
|
|
10591
|
+
logger$5.info('WebRTC unregistered');
|
|
10577
10592
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10578
10593
|
});
|
|
10579
10594
|
|
|
10580
10595
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
10581
|
-
logger$
|
|
10582
|
-
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
10596
|
+
logger$5.info('WebRTC disconnected');
|
|
10597
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
10583
10598
|
});
|
|
10584
10599
|
|
|
10585
10600
|
this.client.on(this.client.REGISTERED, () => {
|
|
10586
|
-
logger$
|
|
10601
|
+
logger$5.info('WebRTC registered', {
|
|
10587
10602
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
10588
10603
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
10589
10604
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -10596,23 +10611,27 @@ class WebRTCPhone extends Emitter {
|
|
|
10596
10611
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
10597
10612
|
&& this.currentSipSession.state === SessionState.Established) {
|
|
10598
10613
|
this.shouldSendReinvite = false;
|
|
10614
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
10615
|
+
const isConference = pc ? pc.sfu : false;
|
|
10616
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
10617
|
+
|
|
10599
10618
|
try {
|
|
10600
10619
|
// Send reinvite with iceRestart
|
|
10601
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
10620
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
10602
10621
|
} catch (e) {
|
|
10603
|
-
logger$
|
|
10622
|
+
logger$5.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
10604
10623
|
}
|
|
10605
10624
|
}
|
|
10606
10625
|
});
|
|
10607
10626
|
|
|
10608
10627
|
this.client.on(this.client.CONNECTED, () => {
|
|
10609
|
-
logger$
|
|
10628
|
+
logger$5.info('WebRTC client connected');
|
|
10610
10629
|
|
|
10611
10630
|
this.stopHeartbeat();
|
|
10612
10631
|
});
|
|
10613
10632
|
|
|
10614
10633
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10615
|
-
logger$
|
|
10634
|
+
logger$5.info('WebRTC client disconnected');
|
|
10616
10635
|
|
|
10617
10636
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10618
10637
|
|
|
@@ -10626,7 +10645,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10626
10645
|
});
|
|
10627
10646
|
|
|
10628
10647
|
this.client.on(this.client.ON_TRACK, (session, event) => {
|
|
10629
|
-
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
10648
|
+
this.eventEmitter.emit(ON_TRACK$1, session, event);
|
|
10630
10649
|
});
|
|
10631
10650
|
|
|
10632
10651
|
this.client.on('onVideoInputChange', stream => {
|
|
@@ -10641,7 +10660,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10641
10660
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
10642
10661
|
const callSession = this.getCallSession(this.getSipSessionId(session));
|
|
10643
10662
|
|
|
10644
|
-
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
10663
|
+
this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
|
|
10645
10664
|
});
|
|
10646
10665
|
|
|
10647
10666
|
// Used when upgrading directly in screenshare mode
|
|
@@ -10650,7 +10669,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10650
10669
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
10651
10670
|
const callSession = this.callSessions[sipSessionId];
|
|
10652
10671
|
|
|
10653
|
-
logger$
|
|
10672
|
+
logger$5.info('Updrading directly in screensharing mode', {
|
|
10654
10673
|
sipSessionId,
|
|
10655
10674
|
tracks: localStream ? localStream.getTracks() : null,
|
|
10656
10675
|
});
|
|
@@ -10682,6 +10701,15 @@ class WebRTCPhone extends Emitter {
|
|
|
10682
10701
|
return this.client.getSipSessionId(sipSession);
|
|
10683
10702
|
}
|
|
10684
10703
|
|
|
10704
|
+
_updateCallSession(callSession ) {
|
|
10705
|
+
const sipSession = this.findSipSession(callSession);
|
|
10706
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
10707
|
+
|
|
10708
|
+
if (sipSessionId) {
|
|
10709
|
+
this.callSessions[sipSessionId] = callSession;
|
|
10710
|
+
}
|
|
10711
|
+
}
|
|
10712
|
+
|
|
10685
10713
|
_onMessage(message ) {
|
|
10686
10714
|
if (!message || message.method !== 'MESSAGE') {
|
|
10687
10715
|
return;
|
|
@@ -10819,8 +10847,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10819
10847
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10820
10848
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10821
10849
|
ON_MESSAGE: ON_MESSAGE,
|
|
10822
|
-
ON_REINVITE: ON_REINVITE,
|
|
10823
|
-
ON_TRACK: ON_TRACK,
|
|
10850
|
+
ON_REINVITE: ON_REINVITE$1,
|
|
10851
|
+
ON_TRACK: ON_TRACK$1,
|
|
10824
10852
|
ON_AUDIO_STREAM: ON_AUDIO_STREAM,
|
|
10825
10853
|
ON_VIDEO_STREAM: ON_VIDEO_STREAM,
|
|
10826
10854
|
ON_REMOVE_STREAM: ON_REMOVE_STREAM,
|
|
@@ -10835,13 +10863,13 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10835
10863
|
ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
|
|
10836
10864
|
ON_CALL_ERROR: ON_CALL_ERROR,
|
|
10837
10865
|
ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
|
|
10838
|
-
ON_NETWORK_STATS: ON_NETWORK_STATS,
|
|
10866
|
+
ON_NETWORK_STATS: ON_NETWORK_STATS$1,
|
|
10839
10867
|
ON_CHAT: ON_CHAT,
|
|
10840
10868
|
ON_SIGNAL: ON_SIGNAL,
|
|
10841
|
-
ON_DISCONNECTED: ON_DISCONNECTED,
|
|
10869
|
+
ON_DISCONNECTED: ON_DISCONNECTED$1,
|
|
10842
10870
|
MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
|
|
10843
10871
|
MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
|
|
10844
|
-
events: events,
|
|
10872
|
+
events: events$1,
|
|
10845
10873
|
'default': WebRTCPhone
|
|
10846
10874
|
});
|
|
10847
10875
|
|
|
@@ -11012,11 +11040,11 @@ var wazoWebsocket = {
|
|
|
11012
11040
|
resolve();
|
|
11013
11041
|
};
|
|
11014
11042
|
|
|
11015
|
-
client.on(SOCKET_EVENTS
|
|
11043
|
+
client.on(SOCKET_EVENTS.ON_ERROR, error => {
|
|
11016
11044
|
handleError(`Connection error : ${error}`);
|
|
11017
11045
|
});
|
|
11018
11046
|
|
|
11019
|
-
client.on(SOCKET_EVENTS
|
|
11047
|
+
client.on(SOCKET_EVENTS.ON_OPEN, () => {
|
|
11020
11048
|
if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
|
|
11021
11049
|
client.setOnHeartbeatTimeout(() => {
|
|
11022
11050
|
handleError('No response to heartbeat');
|
|
@@ -11117,7 +11145,7 @@ var webrtc = {
|
|
|
11117
11145
|
}),
|
|
11118
11146
|
};
|
|
11119
11147
|
|
|
11120
|
-
const parseCandidate = line => {
|
|
11148
|
+
const parseCandidate$1 = line => {
|
|
11121
11149
|
let parts;
|
|
11122
11150
|
// Parse both variants.
|
|
11123
11151
|
if (line.indexOf('a=candidate:') === 0) {
|
|
@@ -11208,7 +11236,7 @@ var SymmetricNat = {
|
|
|
11208
11236
|
}
|
|
11209
11237
|
|
|
11210
11238
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
11211
|
-
const cand = parseCandidate(e.candidate.candidate);
|
|
11239
|
+
const cand = parseCandidate$1(e.candidate.candidate);
|
|
11212
11240
|
if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
|
|
11213
11241
|
candidates[cand.relatedPort].push(cand.port);
|
|
11214
11242
|
} else if (!e.candidate) {
|
|
@@ -11276,7 +11304,7 @@ var iceIpv4 = {
|
|
|
11276
11304
|
const rawCandidate = e.candidate.candidate;
|
|
11277
11305
|
if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
|
|
11278
11306
|
hasSrflxOrRelay = true;
|
|
11279
|
-
const candidate = parseCandidate(e.candidate.candidate);
|
|
11307
|
+
const candidate = parseCandidate$1(e.candidate.candidate);
|
|
11280
11308
|
ips.push(candidate.ip);
|
|
11281
11309
|
}
|
|
11282
11310
|
} else if (!e.candidate) {
|
|
@@ -11446,7 +11474,7 @@ const getCallableNumber = (number , country ) => {
|
|
|
11446
11474
|
class InvalidSubscription extends Error {}
|
|
11447
11475
|
class InvalidAuthorization extends Error {}
|
|
11448
11476
|
|
|
11449
|
-
const logger$
|
|
11477
|
+
const logger$7 = IssueReporter$1.loggerFor('simple-auth');
|
|
11450
11478
|
|
|
11451
11479
|
class Auth {
|
|
11452
11480
|
|
|
@@ -11481,7 +11509,7 @@ class Auth {
|
|
|
11481
11509
|
setApiClientId(this.clientId);
|
|
11482
11510
|
setRefreshExpiration(this.expiration);
|
|
11483
11511
|
setOnRefreshToken((token , session ) => {
|
|
11484
|
-
logger$
|
|
11512
|
+
logger$7.info('on refresh token done', { token });
|
|
11485
11513
|
setApiToken(token);
|
|
11486
11514
|
Wazo.Websocket.updateToken(token);
|
|
11487
11515
|
|
|
@@ -11526,7 +11554,7 @@ class Auth {
|
|
|
11526
11554
|
const rawSession = await getApiClient().auth.authenticate(token);
|
|
11527
11555
|
return this._onAuthenticated(rawSession);
|
|
11528
11556
|
} catch (e) {
|
|
11529
|
-
logger$
|
|
11557
|
+
logger$7.error('on validate token error', e);
|
|
11530
11558
|
console.warn(e);
|
|
11531
11559
|
return false;
|
|
11532
11560
|
}
|
|
@@ -11882,7 +11910,7 @@ class AdHocAPIConference {
|
|
|
11882
11910
|
|
|
11883
11911
|
//
|
|
11884
11912
|
|
|
11885
|
-
const logger$
|
|
11913
|
+
const logger$8 = IssueReporter$1.loggerFor('simple-phone');
|
|
11886
11914
|
const sipLogger = IssueReporter$1.loggerFor('sip.js');
|
|
11887
11915
|
const protocolLogger = IssueReporter$1.loggerFor('sip');
|
|
11888
11916
|
|
|
@@ -11989,7 +12017,7 @@ class Phone extends Emitter {
|
|
|
11989
12017
|
async disconnect() {
|
|
11990
12018
|
if (this.phone) {
|
|
11991
12019
|
if (this.phone.hasAnActiveCall()) {
|
|
11992
|
-
logger$
|
|
12020
|
+
logger$8.info('hangup call on disconnect');
|
|
11993
12021
|
// $FlowFixMe
|
|
11994
12022
|
await this.phone.hangup();
|
|
11995
12023
|
}
|
|
@@ -12012,13 +12040,13 @@ class Phone extends Emitter {
|
|
|
12012
12040
|
}
|
|
12013
12041
|
|
|
12014
12042
|
async hangup(callSession ) {
|
|
12015
|
-
logger$
|
|
12043
|
+
logger$8.info('hangup via simple phone', { callId: callSession.getId() });
|
|
12016
12044
|
|
|
12017
12045
|
return this.phone && this.phone.hangup(callSession);
|
|
12018
12046
|
}
|
|
12019
12047
|
|
|
12020
12048
|
async accept(callSession , cameraEnabled ) {
|
|
12021
|
-
logger$
|
|
12049
|
+
logger$8.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
|
|
12022
12050
|
|
|
12023
12051
|
return this.phone && this.phone.accept(callSession, cameraEnabled);
|
|
12024
12052
|
}
|
|
@@ -12057,7 +12085,7 @@ class Phone extends Emitter {
|
|
|
12057
12085
|
muteViaAPI(callSession ) {
|
|
12058
12086
|
if (callSession && callSession.callId) {
|
|
12059
12087
|
Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
|
|
12060
|
-
logger$
|
|
12088
|
+
logger$8.error('Mute via API, error', e);
|
|
12061
12089
|
});
|
|
12062
12090
|
}
|
|
12063
12091
|
}
|
|
@@ -12065,7 +12093,7 @@ class Phone extends Emitter {
|
|
|
12065
12093
|
unmuteViaAPI(callSession ) {
|
|
12066
12094
|
if (callSession && callSession.callId) {
|
|
12067
12095
|
Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
|
|
12068
|
-
logger$
|
|
12096
|
+
logger$8.error('Unmute via API, error', e);
|
|
12069
12097
|
});
|
|
12070
12098
|
}
|
|
12071
12099
|
}
|
|
@@ -12173,7 +12201,7 @@ class Phone extends Emitter {
|
|
|
12173
12201
|
|
|
12174
12202
|
// @Deprecated
|
|
12175
12203
|
getLocalMediaStream(callSession ) {
|
|
12176
|
-
logger$
|
|
12204
|
+
logger$8.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
|
|
12177
12205
|
|
|
12178
12206
|
return this.phone && this.phone.getLocalStream(callSession);
|
|
12179
12207
|
}
|
|
@@ -12196,20 +12224,20 @@ class Phone extends Emitter {
|
|
|
12196
12224
|
|
|
12197
12225
|
// @Deprecated
|
|
12198
12226
|
getRemoteStreamForCall(callSession ) {
|
|
12199
|
-
logger$
|
|
12227
|
+
logger$8.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
|
|
12200
12228
|
return this.getRemoteStream(callSession);
|
|
12201
12229
|
}
|
|
12202
12230
|
|
|
12203
12231
|
// Returns remote streams directly from the peerConnection
|
|
12204
12232
|
// @Deprecated
|
|
12205
12233
|
getRemoteStreamsForCall(callSession ) {
|
|
12206
|
-
logger$
|
|
12234
|
+
logger$8.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
|
|
12207
12235
|
return this.getLocalStream(callSession);
|
|
12208
12236
|
}
|
|
12209
12237
|
|
|
12210
12238
|
// @Deprecated
|
|
12211
12239
|
getRemoteVideoStreamForCall(callSession ) {
|
|
12212
|
-
logger$
|
|
12240
|
+
logger$8.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
|
|
12213
12241
|
|
|
12214
12242
|
return this.getRemoteVideoStream(callSession);
|
|
12215
12243
|
}
|
|
@@ -12270,7 +12298,7 @@ class Phone extends Emitter {
|
|
|
12270
12298
|
|
|
12271
12299
|
_transferEvents() {
|
|
12272
12300
|
this.unbind();
|
|
12273
|
-
[...events
|
|
12301
|
+
[...events, ...transportEvents].forEach(event => {
|
|
12274
12302
|
this.client.on(event, (...args) =>
|
|
12275
12303
|
this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
|
|
12276
12304
|
});
|
|
@@ -12292,10 +12320,10 @@ var Phone$1 = global.wazoTelephonyInstance;
|
|
|
12292
12320
|
|
|
12293
12321
|
//
|
|
12294
12322
|
|
|
12295
|
-
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
12296
|
-
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
12323
|
+
const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
12324
|
+
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
|
|
12297
12325
|
|
|
12298
|
-
const logger$
|
|
12326
|
+
const logger$9 = IssueReporter$1.loggerFor('simple-ws-client');
|
|
12299
12327
|
|
|
12300
12328
|
class Websocket extends Emitter {
|
|
12301
12329
|
|
|
@@ -12309,9 +12337,9 @@ class Websocket extends Emitter {
|
|
|
12309
12337
|
// $FlowFixMe
|
|
12310
12338
|
this[key] = OTHER_EVENTS[key];
|
|
12311
12339
|
});
|
|
12312
|
-
Object.keys(SOCKET_EVENTS).forEach(key => {
|
|
12340
|
+
Object.keys(SOCKET_EVENTS$1).forEach(key => {
|
|
12313
12341
|
// $FlowFixMe
|
|
12314
|
-
this[key] = SOCKET_EVENTS[key];
|
|
12342
|
+
this[key] = SOCKET_EVENTS$1[key];
|
|
12315
12343
|
});
|
|
12316
12344
|
this.eventLists = WebSocketClient.eventLists;
|
|
12317
12345
|
|
|
@@ -12319,7 +12347,7 @@ class Websocket extends Emitter {
|
|
|
12319
12347
|
}
|
|
12320
12348
|
|
|
12321
12349
|
open(host , session ) {
|
|
12322
|
-
logger$
|
|
12350
|
+
logger$9.info('open simple WebSocket', { host, token: session.token });
|
|
12323
12351
|
this.ws = new WebSocketClient(
|
|
12324
12352
|
{
|
|
12325
12353
|
host,
|
|
@@ -12347,7 +12375,7 @@ class Websocket extends Emitter {
|
|
|
12347
12375
|
}
|
|
12348
12376
|
|
|
12349
12377
|
updateToken(token ) {
|
|
12350
|
-
logger$
|
|
12378
|
+
logger$9.info('update token via simple Websocket', { token, ws: !!this.ws });
|
|
12351
12379
|
|
|
12352
12380
|
if (!this.ws) {
|
|
12353
12381
|
return;
|
|
@@ -12375,7 +12403,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
|
|
|
12375
12403
|
|
|
12376
12404
|
//
|
|
12377
12405
|
|
|
12378
|
-
const logger$
|
|
12406
|
+
const logger$a = IssueReporter$1.loggerFor('room');
|
|
12379
12407
|
|
|
12380
12408
|
class Participant extends Emitter {
|
|
12381
12409
|
|
|
@@ -12497,7 +12525,7 @@ class Participant extends Emitter {
|
|
|
12497
12525
|
}
|
|
12498
12526
|
|
|
12499
12527
|
onTalking(isTalking ) {
|
|
12500
|
-
logger$
|
|
12528
|
+
logger$a.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
|
|
12501
12529
|
this.isTalking = isTalking;
|
|
12502
12530
|
// you may notice we're not broadcasting: since all participants are getting this info
|
|
12503
12531
|
// directly from asterisk, there's no need to do so
|
|
@@ -12600,7 +12628,7 @@ class Participant extends Emitter {
|
|
|
12600
12628
|
}
|
|
12601
12629
|
|
|
12602
12630
|
updateStatus(status , broadcast = true) {
|
|
12603
|
-
logger$
|
|
12631
|
+
logger$a.info('updating participant status', { name: this.name, status });
|
|
12604
12632
|
|
|
12605
12633
|
if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
|
|
12606
12634
|
if (status.audioMuted) {
|
|
@@ -12648,7 +12676,7 @@ class Participant extends Emitter {
|
|
|
12648
12676
|
|
|
12649
12677
|
broadcastStatus(inboundStatus = null) {
|
|
12650
12678
|
const status = inboundStatus || this.getStatus();
|
|
12651
|
-
logger$
|
|
12679
|
+
logger$a.info('broadcasting participant status', { callId: this.callId, status });
|
|
12652
12680
|
|
|
12653
12681
|
this.room.sendSignal({
|
|
12654
12682
|
type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
|
|
@@ -12684,9 +12712,9 @@ class LocalParticipant extends Participant {
|
|
|
12684
12712
|
const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
12685
12713
|
const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
12686
12714
|
|
|
12687
|
-
const logger$
|
|
12715
|
+
const logger$b = IssueReporter$1.loggerFor('sdk-room');
|
|
12688
12716
|
|
|
12689
|
-
class Room extends Emitter {
|
|
12717
|
+
class Room$1 extends Emitter {
|
|
12690
12718
|
|
|
12691
12719
|
|
|
12692
12720
|
|
|
@@ -12744,7 +12772,7 @@ class Room extends Emitter {
|
|
|
12744
12772
|
extra = {},
|
|
12745
12773
|
) {
|
|
12746
12774
|
super();
|
|
12747
|
-
logger$
|
|
12775
|
+
logger$b.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
12748
12776
|
|
|
12749
12777
|
// Represents the room callSession
|
|
12750
12778
|
this.callSession = callSession;
|
|
@@ -12810,7 +12838,7 @@ class Room extends Emitter {
|
|
|
12810
12838
|
* @returns {Promise<Room>}
|
|
12811
12839
|
*/
|
|
12812
12840
|
static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
|
|
12813
|
-
logger$
|
|
12841
|
+
logger$b.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
12814
12842
|
|
|
12815
12843
|
if (!room) {
|
|
12816
12844
|
await Wazo.Phone.connect();
|
|
@@ -12823,7 +12851,7 @@ class Room extends Emitter {
|
|
|
12823
12851
|
|
|
12824
12852
|
// Call_created is triggered before call_accepted, so we have to listen for it here.
|
|
12825
12853
|
Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
|
|
12826
|
-
logger$
|
|
12854
|
+
logger$b.info('room call received via WS', { callId: data.call_id });
|
|
12827
12855
|
if (room) {
|
|
12828
12856
|
room.setCallId(data.call_id);
|
|
12829
12857
|
}
|
|
@@ -12831,7 +12859,7 @@ class Room extends Emitter {
|
|
|
12831
12859
|
|
|
12832
12860
|
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
12833
12861
|
// eslint-disable-next-line no-param-reassign
|
|
12834
|
-
room = new Room(callSession, extension, null, null, extra);
|
|
12862
|
+
room = new Room$1(callSession, extension, null, null, extra);
|
|
12835
12863
|
|
|
12836
12864
|
// Wait for the call to be accepted
|
|
12837
12865
|
await new Promise((resolve, reject) => {
|
|
@@ -12852,7 +12880,7 @@ class Room extends Emitter {
|
|
|
12852
12880
|
// Retrieve conference
|
|
12853
12881
|
const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
|
|
12854
12882
|
|
|
12855
|
-
logger$
|
|
12883
|
+
logger$b.info('connected to room', {
|
|
12856
12884
|
sourceId: conference ? conference.sourceId : null,
|
|
12857
12885
|
name: conference ? conference.name : null,
|
|
12858
12886
|
});
|
|
@@ -12862,7 +12890,7 @@ class Room extends Emitter {
|
|
|
12862
12890
|
room.setName(conference.name);
|
|
12863
12891
|
}
|
|
12864
12892
|
} else if (meeting) {
|
|
12865
|
-
logger$
|
|
12893
|
+
logger$b.info('Already connected to meeting', {
|
|
12866
12894
|
uuid: meeting.uuid,
|
|
12867
12895
|
name: meeting.name,
|
|
12868
12896
|
});
|
|
@@ -12875,13 +12903,13 @@ class Room extends Emitter {
|
|
|
12875
12903
|
}
|
|
12876
12904
|
|
|
12877
12905
|
static disconnect() {
|
|
12878
|
-
logger$
|
|
12906
|
+
logger$b.info('static disconnection to room');
|
|
12879
12907
|
|
|
12880
12908
|
Wazo.Phone.disconnect();
|
|
12881
12909
|
}
|
|
12882
12910
|
|
|
12883
12911
|
async disconnect() {
|
|
12884
|
-
logger$
|
|
12912
|
+
logger$b.info('disconnection to room called');
|
|
12885
12913
|
|
|
12886
12914
|
await Wazo.Phone.hangup(this.callSession);
|
|
12887
12915
|
this.callSession = null;
|
|
@@ -12901,19 +12929,19 @@ class Room extends Emitter {
|
|
|
12901
12929
|
}
|
|
12902
12930
|
|
|
12903
12931
|
setSourceId(sourceId ) {
|
|
12904
|
-
logger$
|
|
12932
|
+
logger$b.info('set room source id', { sourceId });
|
|
12905
12933
|
|
|
12906
12934
|
this.sourceId = sourceId;
|
|
12907
12935
|
}
|
|
12908
12936
|
|
|
12909
12937
|
setMeetingUuid(meetingUuid ) {
|
|
12910
|
-
logger$
|
|
12938
|
+
logger$b.info('set meeting uuid', { meetingUuid });
|
|
12911
12939
|
|
|
12912
12940
|
this.meetingUuid = meetingUuid;
|
|
12913
12941
|
}
|
|
12914
12942
|
|
|
12915
12943
|
setCallId(callId ) {
|
|
12916
|
-
logger$
|
|
12944
|
+
logger$b.info('set room call id', { callId });
|
|
12917
12945
|
|
|
12918
12946
|
if (callId) {
|
|
12919
12947
|
this.callId = callId;
|
|
@@ -12921,7 +12949,7 @@ class Room extends Emitter {
|
|
|
12921
12949
|
}
|
|
12922
12950
|
|
|
12923
12951
|
setName(name ) {
|
|
12924
|
-
logger$
|
|
12952
|
+
logger$b.info('set room name', { name });
|
|
12925
12953
|
|
|
12926
12954
|
this.name = name;
|
|
12927
12955
|
}
|
|
@@ -12940,7 +12968,7 @@ class Room extends Emitter {
|
|
|
12940
12968
|
}
|
|
12941
12969
|
|
|
12942
12970
|
async startScreenSharing(constraints ) {
|
|
12943
|
-
logger$
|
|
12971
|
+
logger$b.info('start room screen sharing', { constraints });
|
|
12944
12972
|
|
|
12945
12973
|
const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
|
|
12946
12974
|
if (!screensharingStream) {
|
|
@@ -12954,7 +12982,7 @@ class Room extends Emitter {
|
|
|
12954
12982
|
}
|
|
12955
12983
|
|
|
12956
12984
|
async stopScreenSharing(restoreLocalStream = true) {
|
|
12957
|
-
logger$
|
|
12985
|
+
logger$b.info('stop room screen sharing');
|
|
12958
12986
|
|
|
12959
12987
|
await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
12960
12988
|
|
|
@@ -12966,7 +12994,7 @@ class Room extends Emitter {
|
|
|
12966
12994
|
}
|
|
12967
12995
|
|
|
12968
12996
|
turnCameraOff() {
|
|
12969
|
-
logger$
|
|
12997
|
+
logger$b.info('turn room camera off');
|
|
12970
12998
|
|
|
12971
12999
|
Wazo.Phone.turnCameraOff(this.callSession);
|
|
12972
13000
|
|
|
@@ -12976,7 +13004,7 @@ class Room extends Emitter {
|
|
|
12976
13004
|
}
|
|
12977
13005
|
|
|
12978
13006
|
turnCameraOn() {
|
|
12979
|
-
logger$
|
|
13007
|
+
logger$b.info('turn room camera on');
|
|
12980
13008
|
|
|
12981
13009
|
Wazo.Phone.turnCameraOn(this.callSession);
|
|
12982
13010
|
|
|
@@ -12986,7 +13014,7 @@ class Room extends Emitter {
|
|
|
12986
13014
|
}
|
|
12987
13015
|
|
|
12988
13016
|
mute() {
|
|
12989
|
-
logger$
|
|
13017
|
+
logger$b.info('mute room');
|
|
12990
13018
|
|
|
12991
13019
|
Wazo.Phone.mute(this.callSession);
|
|
12992
13020
|
|
|
@@ -12994,7 +13022,7 @@ class Room extends Emitter {
|
|
|
12994
13022
|
}
|
|
12995
13023
|
|
|
12996
13024
|
unmute() {
|
|
12997
|
-
logger$
|
|
13025
|
+
logger$b.info('unmute room');
|
|
12998
13026
|
|
|
12999
13027
|
Wazo.Phone.unmute(this.callSession);
|
|
13000
13028
|
|
|
@@ -13014,7 +13042,7 @@ class Room extends Emitter {
|
|
|
13014
13042
|
}
|
|
13015
13043
|
|
|
13016
13044
|
hold() {
|
|
13017
|
-
logger$
|
|
13045
|
+
logger$b.info('hold room');
|
|
13018
13046
|
|
|
13019
13047
|
Wazo.Phone.hold(this.callSession, true);
|
|
13020
13048
|
|
|
@@ -13024,7 +13052,7 @@ class Room extends Emitter {
|
|
|
13024
13052
|
}
|
|
13025
13053
|
|
|
13026
13054
|
async resume() {
|
|
13027
|
-
logger$
|
|
13055
|
+
logger$b.info('resume room');
|
|
13028
13056
|
|
|
13029
13057
|
const newStream = await Wazo.Phone.resume(this.callSession, true);
|
|
13030
13058
|
|
|
@@ -13052,13 +13080,13 @@ class Room extends Emitter {
|
|
|
13052
13080
|
}
|
|
13053
13081
|
|
|
13054
13082
|
sendDTMF(tone ) {
|
|
13055
|
-
logger$
|
|
13083
|
+
logger$b.info('send room DTMF', { tone });
|
|
13056
13084
|
|
|
13057
13085
|
Wazo.Phone.sendDTMF(tone, this.callSession);
|
|
13058
13086
|
}
|
|
13059
13087
|
|
|
13060
13088
|
async sendReinvite(newConstraints = null) {
|
|
13061
|
-
logger$
|
|
13089
|
+
logger$b.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
13062
13090
|
const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
|
|
13063
13091
|
|
|
13064
13092
|
Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
|
|
@@ -13117,7 +13145,7 @@ class Room extends Emitter {
|
|
|
13117
13145
|
Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
13118
13146
|
|
|
13119
13147
|
this.on(this.ON_AUDIO_STREAM, stream => {
|
|
13120
|
-
logger$
|
|
13148
|
+
logger$b.info('on room audio stream');
|
|
13121
13149
|
|
|
13122
13150
|
this.audioStream = stream;
|
|
13123
13151
|
if (!this.roomAudioElement) {
|
|
@@ -13130,7 +13158,7 @@ class Room extends Emitter {
|
|
|
13130
13158
|
});
|
|
13131
13159
|
|
|
13132
13160
|
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
13133
|
-
logger$
|
|
13161
|
+
logger$b.info('on room video stream', { streamId });
|
|
13134
13162
|
|
|
13135
13163
|
this._mapMsid(sipSession.body.body);
|
|
13136
13164
|
|
|
@@ -13145,7 +13173,7 @@ class Room extends Emitter {
|
|
|
13145
13173
|
});
|
|
13146
13174
|
|
|
13147
13175
|
this.on(this.ON_REMOVE_STREAM, stream => {
|
|
13148
|
-
logger$
|
|
13176
|
+
logger$b.info('on room remove stream');
|
|
13149
13177
|
|
|
13150
13178
|
const participant = this.participants.find(someParticipant =>
|
|
13151
13179
|
someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
|
|
@@ -13277,7 +13305,7 @@ class Room extends Emitter {
|
|
|
13277
13305
|
const requester = this._getParticipantFromCallId(origin.callId);
|
|
13278
13306
|
if (requester) {
|
|
13279
13307
|
// @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
|
|
13280
|
-
logger$
|
|
13308
|
+
logger$b.info('trigger room requester status', { origin });
|
|
13281
13309
|
requester.triggerUpdate('REQUESTER_UPDATE');
|
|
13282
13310
|
}
|
|
13283
13311
|
break;
|
|
@@ -13308,24 +13336,24 @@ class Room extends Emitter {
|
|
|
13308
13336
|
|
|
13309
13337
|
// When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
|
|
13310
13338
|
if (participant.user_uuid === session.uuid) {
|
|
13311
|
-
logger$
|
|
13339
|
+
logger$b.info('room current user joined');
|
|
13312
13340
|
|
|
13313
13341
|
// Retrieve participants via an API calls
|
|
13314
13342
|
const conferenceId = this.sourceId || payload.data.conference_id;
|
|
13315
13343
|
let response;
|
|
13316
13344
|
try {
|
|
13317
13345
|
if (this.meetingUuid) {
|
|
13318
|
-
logger$
|
|
13346
|
+
logger$b.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
13319
13347
|
response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
|
|
13320
13348
|
} else {
|
|
13321
|
-
logger$
|
|
13349
|
+
logger$b.info('fetching conference participants', { conferenceId });
|
|
13322
13350
|
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
13323
13351
|
}
|
|
13324
13352
|
} catch (e) {
|
|
13325
|
-
logger$
|
|
13353
|
+
logger$b.error('room participants fetching, error', e);
|
|
13326
13354
|
}
|
|
13327
13355
|
if (response) {
|
|
13328
|
-
logger$
|
|
13356
|
+
logger$b.info('conference participants fetched', { nb: response.items.length });
|
|
13329
13357
|
participants = response.items.map(item => {
|
|
13330
13358
|
const isMe = item.call_id === this.callId;
|
|
13331
13359
|
|
|
@@ -13352,7 +13380,7 @@ class Room extends Emitter {
|
|
|
13352
13380
|
? new Wazo.RemoteParticipant(this, participant)
|
|
13353
13381
|
: null;
|
|
13354
13382
|
|
|
13355
|
-
logger$
|
|
13383
|
+
logger$b.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
13356
13384
|
|
|
13357
13385
|
if (remoteParticipant) {
|
|
13358
13386
|
this.participants.push(remoteParticipant);
|
|
@@ -13517,12 +13545,12 @@ class Room extends Emitter {
|
|
|
13517
13545
|
|
|
13518
13546
|
//
|
|
13519
13547
|
|
|
13520
|
-
const logger = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
13548
|
+
const logger$c = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
13521
13549
|
|
|
13522
|
-
class SipRoom extends Room {
|
|
13550
|
+
class SipRoom extends Room$1 {
|
|
13523
13551
|
|
|
13524
13552
|
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
13525
|
-
logger.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
13553
|
+
logger$c.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
13526
13554
|
|
|
13527
13555
|
if (!room) {
|
|
13528
13556
|
await Wazo.Phone.connect();
|
|
@@ -13538,7 +13566,7 @@ class SipRoom extends Room {
|
|
|
13538
13566
|
room.setCallId(room.callSession.call.id);
|
|
13539
13567
|
}
|
|
13540
13568
|
|
|
13541
|
-
logger.info('connected to room', {
|
|
13569
|
+
logger$c.info('connected to room', {
|
|
13542
13570
|
extension: room.extension,
|
|
13543
13571
|
});
|
|
13544
13572
|
|
|
@@ -13546,7 +13574,7 @@ class SipRoom extends Room {
|
|
|
13546
13574
|
}
|
|
13547
13575
|
|
|
13548
13576
|
mute() {
|
|
13549
|
-
logger.info('mute sip room');
|
|
13577
|
+
logger$c.info('mute sip room');
|
|
13550
13578
|
|
|
13551
13579
|
Wazo.Phone.mute(this.callSession, false);
|
|
13552
13580
|
|
|
@@ -13554,7 +13582,7 @@ class SipRoom extends Room {
|
|
|
13554
13582
|
}
|
|
13555
13583
|
|
|
13556
13584
|
unmute() {
|
|
13557
|
-
logger.info('unmute sip room');
|
|
13585
|
+
logger$c.info('unmute sip room');
|
|
13558
13586
|
|
|
13559
13587
|
Wazo.Phone.unmute(this.callSession, false);
|
|
13560
13588
|
|
|
@@ -13767,7 +13795,7 @@ const Wazo = {
|
|
|
13767
13795
|
Auth: Auth$1,
|
|
13768
13796
|
Phone: Phone$1,
|
|
13769
13797
|
Websocket: Websocket$1,
|
|
13770
|
-
Room,
|
|
13798
|
+
Room: Room$1,
|
|
13771
13799
|
SipRoom,
|
|
13772
13800
|
RemoteParticipant,
|
|
13773
13801
|
LocalParticipant,
|
|
@@ -13800,7 +13828,7 @@ const Wazo = {
|
|
|
13800
13828
|
Session,
|
|
13801
13829
|
Voicemail,
|
|
13802
13830
|
Relocation,
|
|
13803
|
-
ConferenceRoom: Room
|
|
13831
|
+
ConferenceRoom: Room,
|
|
13804
13832
|
CallSession,
|
|
13805
13833
|
IndirectTransfer,
|
|
13806
13834
|
SwitchboardCall,
|
|
@@ -13886,13 +13914,13 @@ var index = {
|
|
|
13886
13914
|
Session,
|
|
13887
13915
|
Voicemail,
|
|
13888
13916
|
Relocation,
|
|
13889
|
-
Room
|
|
13917
|
+
Room,
|
|
13890
13918
|
IssueReporter: IssueReporter$1,
|
|
13891
13919
|
DebugDevice,
|
|
13892
13920
|
PROFILE_STATE: STATE,
|
|
13893
13921
|
FORWARD_KEYS,
|
|
13894
13922
|
LINE_STATE,
|
|
13895
|
-
SOCKET_EVENTS
|
|
13923
|
+
SOCKET_EVENTS,
|
|
13896
13924
|
Wazo,
|
|
13897
13925
|
WebRTCPhone,
|
|
13898
13926
|
Meeting,
|