@wazo/sdk 0.37.24 → 0.37.25
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 +12 -12
- package/esm/__tests__/web-rtc-client.test.js +120 -103
- package/esm/api/amid.js +1 -1
- package/esm/api/call-logd.js +2 -2
- 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 +12 -12
- package/esm/checker/Checker.js +145 -128
- package/esm/checker/checks/aor.js +12 -12
- package/esm/checker/checks/api.js +12 -12
- package/esm/checker/checks/index.js +135 -118
- package/esm/checker/checks/wazo-websocket.js +15 -15
- package/esm/checker/checks/webrtc-transport.js +120 -103
- package/esm/checker/checks/webrtc.js +120 -103
- package/esm/domain/AdHocAPIConference.js +12 -12
- package/esm/domain/CallLog.js +1 -1
- package/esm/domain/Contact.js +1 -1
- package/esm/domain/Features.js +12 -12
- package/esm/domain/Phone/CTIPhone.js +26 -26
- package/esm/domain/Phone/WebRTCPhone.js +87 -86
- package/esm/domain/__tests__/CallLog.test.js +1 -1
- package/esm/domain/__tests__/Contact.test.js +1 -1
- package/esm/index.js +356 -338
- package/esm/lib/WazoSessionDescriptionHandler.js +1 -1
- package/esm/service/CallApi.js +12 -12
- package/esm/service/IssueReporter.js +1 -1
- package/esm/service/__tests__/IssueReporter.test.js +1 -1
- package/esm/service/getApiClient.js +12 -12
- package/esm/simple/Auth.js +346 -328
- package/esm/simple/Configuration.js +346 -328
- package/esm/simple/Directory.js +12 -12
- package/esm/simple/Phone.js +346 -328
- package/esm/simple/Websocket.js +17 -17
- package/esm/simple/index.js +350 -332
- package/esm/simple/room/LocalParticipant.js +350 -332
- package/esm/simple/room/Participant.js +350 -332
- package/esm/simple/room/RemoteParticipant.js +350 -332
- package/esm/simple/room/Room.js +351 -333
- package/esm/simple/room/SipRoom.js +350 -332
- package/esm/simple/room/Stream.js +350 -332
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +350 -332
- package/esm/simple/utils.js +350 -332
- package/esm/web-rtc-client.js +120 -103
- package/esm/websocket-client.js +15 -15
- package/lib/__tests__/api-client.test.js +12 -12
- package/lib/__tests__/web-rtc-client.test.js +120 -103
- package/lib/api/amid.js +1 -1
- package/lib/api/call-logd.js +2 -2
- 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 +12 -12
- package/lib/checker/Checker.js +145 -128
- package/lib/checker/checks/aor.js +12 -12
- package/lib/checker/checks/api.js +12 -12
- package/lib/checker/checks/index.js +135 -118
- package/lib/checker/checks/wazo-websocket.js +15 -15
- package/lib/checker/checks/webrtc-transport.js +120 -103
- package/lib/checker/checks/webrtc.js +120 -103
- package/lib/domain/AdHocAPIConference.js +12 -12
- package/lib/domain/CallLog.js +1 -1
- package/lib/domain/Contact.js +1 -1
- package/lib/domain/Features.js +12 -12
- package/lib/domain/Phone/CTIPhone.js +26 -26
- package/lib/domain/Phone/WebRTCPhone.js +87 -86
- package/lib/domain/__tests__/CallLog.test.js +1 -1
- package/lib/domain/__tests__/Contact.test.js +1 -1
- package/lib/index.js +356 -338
- package/lib/lib/WazoSessionDescriptionHandler.js +1 -1
- package/lib/service/CallApi.js +12 -12
- package/lib/service/IssueReporter.js +1 -1
- package/lib/service/__tests__/IssueReporter.test.js +1 -1
- package/lib/service/getApiClient.js +12 -12
- package/lib/simple/Auth.js +346 -328
- package/lib/simple/Configuration.js +346 -328
- package/lib/simple/Directory.js +12 -12
- package/lib/simple/Phone.js +346 -328
- package/lib/simple/Websocket.js +17 -17
- package/lib/simple/index.js +350 -332
- package/lib/simple/room/LocalParticipant.js +350 -332
- package/lib/simple/room/Participant.js +350 -332
- package/lib/simple/room/RemoteParticipant.js +350 -332
- package/lib/simple/room/Room.js +351 -333
- package/lib/simple/room/SipRoom.js +350 -332
- package/lib/simple/room/Stream.js +350 -332
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +350 -332
- package/lib/simple/utils.js +350 -332
- package/lib/web-rtc-client.js +120 -103
- package/lib/websocket-client.js +15 -15
- package/package.json +1 -1
- package/src/domain/Phone/WebRTCPhone.js +3 -2
- package/src/web-rtc-client.js +27 -10
package/lib/simple/room/Room.js
CHANGED
|
@@ -471,7 +471,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
471
471
|
|
|
472
472
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
473
473
|
|
|
474
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
474
|
+
const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
475
475
|
|
|
476
476
|
// Use a function here to be able to mock it in tests
|
|
477
477
|
const realFetch = () => {
|
|
@@ -610,7 +610,7 @@ class ApiRequester {
|
|
|
610
610
|
};
|
|
611
611
|
|
|
612
612
|
if (this.refreshTokenPromise) {
|
|
613
|
-
logger.info('A token is already refreshing, waiting ...', { url });
|
|
613
|
+
logger$c.info('A token is already refreshing, waiting ...', { url });
|
|
614
614
|
await this.refreshTokenPromise;
|
|
615
615
|
}
|
|
616
616
|
|
|
@@ -630,7 +630,7 @@ class ApiRequester {
|
|
|
630
630
|
return promise.then(async (err ) => {
|
|
631
631
|
// Check if the token is still valid
|
|
632
632
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
633
|
-
logger.warn('token expired', { error: err.reason });
|
|
633
|
+
logger$c.warn('token expired', { error: err.reason });
|
|
634
634
|
// Replay the call after refreshing the token
|
|
635
635
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
636
636
|
}
|
|
@@ -640,7 +640,7 @@ class ApiRequester {
|
|
|
640
640
|
: exceptionClass.fromResponse(err, response.status);
|
|
641
641
|
|
|
642
642
|
if (this.shouldLogErrors) {
|
|
643
|
-
logger.error('API error', error);
|
|
643
|
+
logger$c.error('API error', error);
|
|
644
644
|
}
|
|
645
645
|
|
|
646
646
|
throw error;
|
|
@@ -650,7 +650,7 @@ class ApiRequester {
|
|
|
650
650
|
return newParse(response, isJson);
|
|
651
651
|
}).catch(error => {
|
|
652
652
|
if (this.shouldLogErrors) {
|
|
653
|
-
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
653
|
+
logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
654
654
|
}
|
|
655
655
|
|
|
656
656
|
throw error;
|
|
@@ -678,13 +678,13 @@ class ApiRequester {
|
|
|
678
678
|
) {
|
|
679
679
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
680
680
|
let newPath = path;
|
|
681
|
-
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
681
|
+
logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
682
682
|
|
|
683
683
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
684
684
|
|
|
685
685
|
return this.refreshTokenPromise.then(() => {
|
|
686
686
|
this.refreshTokenPromise = null;
|
|
687
|
-
logger.info('token refreshed', { isTokenNotFound });
|
|
687
|
+
logger$c.info('token refreshed', { isTokenNotFound });
|
|
688
688
|
if (isTokenNotFound) {
|
|
689
689
|
const pathParts = path.split('/');
|
|
690
690
|
pathParts.pop();
|
|
@@ -4065,7 +4065,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
4065
4065
|
|
|
4066
4066
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
4067
4067
|
|
|
4068
|
-
const logger$
|
|
4068
|
+
const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
4069
4069
|
|
|
4070
4070
|
class CTIPhone extends Emitter {
|
|
4071
4071
|
|
|
@@ -4078,7 +4078,7 @@ class CTIPhone extends Emitter {
|
|
|
4078
4078
|
|
|
4079
4079
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
4080
4080
|
super();
|
|
4081
|
-
logger$
|
|
4081
|
+
logger$b.info('CTI Phone created');
|
|
4082
4082
|
this.session = session;
|
|
4083
4083
|
this.isMobile = isMobile;
|
|
4084
4084
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -4139,7 +4139,7 @@ class CTIPhone extends Emitter {
|
|
|
4139
4139
|
}
|
|
4140
4140
|
|
|
4141
4141
|
async makeCall(number , line ) {
|
|
4142
|
-
logger$
|
|
4142
|
+
logger$b.info('make CTI call', { number });
|
|
4143
4143
|
|
|
4144
4144
|
if (!number) {
|
|
4145
4145
|
return null;
|
|
@@ -4162,7 +4162,7 @@ class CTIPhone extends Emitter {
|
|
|
4162
4162
|
if (!callSession) {
|
|
4163
4163
|
return Promise.resolve(null);
|
|
4164
4164
|
}
|
|
4165
|
-
logger$
|
|
4165
|
+
logger$b.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4166
4166
|
|
|
4167
4167
|
if (!this.currentCall) {
|
|
4168
4168
|
this.currentCall = callSession.call;
|
|
@@ -4175,7 +4175,7 @@ class CTIPhone extends Emitter {
|
|
|
4175
4175
|
if (!callSession) {
|
|
4176
4176
|
return;
|
|
4177
4177
|
}
|
|
4178
|
-
logger$
|
|
4178
|
+
logger$b.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4179
4179
|
|
|
4180
4180
|
this.currentCall = undefined;
|
|
4181
4181
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4185,7 +4185,7 @@ class CTIPhone extends Emitter {
|
|
|
4185
4185
|
if (!callSession) {
|
|
4186
4186
|
return Promise.resolve(false);
|
|
4187
4187
|
}
|
|
4188
|
-
logger$
|
|
4188
|
+
logger$b.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4189
4189
|
|
|
4190
4190
|
try {
|
|
4191
4191
|
await CallApi.cancelCall(callSession);
|
|
@@ -4196,7 +4196,7 @@ class CTIPhone extends Emitter {
|
|
|
4196
4196
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
4197
4197
|
return true;
|
|
4198
4198
|
} catch (e) {
|
|
4199
|
-
logger$
|
|
4199
|
+
logger$b.error('hangup CTI call, error', e);
|
|
4200
4200
|
|
|
4201
4201
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
4202
4202
|
return false;
|
|
@@ -4209,7 +4209,7 @@ class CTIPhone extends Emitter {
|
|
|
4209
4209
|
if (!callSession) {
|
|
4210
4210
|
return;
|
|
4211
4211
|
}
|
|
4212
|
-
logger$
|
|
4212
|
+
logger$b.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4213
4213
|
|
|
4214
4214
|
await CallApi.cancelCall(callSession);
|
|
4215
4215
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4219,7 +4219,7 @@ class CTIPhone extends Emitter {
|
|
|
4219
4219
|
if (!callSession) {
|
|
4220
4220
|
return;
|
|
4221
4221
|
}
|
|
4222
|
-
logger$
|
|
4222
|
+
logger$b.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4223
4223
|
|
|
4224
4224
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
4225
4225
|
}
|
|
@@ -4232,19 +4232,19 @@ class CTIPhone extends Emitter {
|
|
|
4232
4232
|
if (!callSession) {
|
|
4233
4233
|
return;
|
|
4234
4234
|
}
|
|
4235
|
-
logger$
|
|
4235
|
+
logger$b.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4236
4236
|
|
|
4237
4237
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
4238
4238
|
}
|
|
4239
4239
|
|
|
4240
4240
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
4241
|
-
logger$
|
|
4241
|
+
logger$b.info('cancel CTI transfer', { transferId });
|
|
4242
4242
|
|
|
4243
4243
|
return CallApi.cancelCallTransfer(transferId);
|
|
4244
4244
|
}
|
|
4245
4245
|
|
|
4246
4246
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
4247
|
-
logger$
|
|
4247
|
+
logger$b.info('confirm CTI transfer', { transferId });
|
|
4248
4248
|
|
|
4249
4249
|
return CallApi.confirmCallTransfer(transferId);
|
|
4250
4250
|
}
|
|
@@ -4253,19 +4253,19 @@ class CTIPhone extends Emitter {
|
|
|
4253
4253
|
if (!callSession) {
|
|
4254
4254
|
return;
|
|
4255
4255
|
}
|
|
4256
|
-
logger$
|
|
4256
|
+
logger$b.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4257
4257
|
|
|
4258
4258
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4259
4259
|
}
|
|
4260
4260
|
|
|
4261
4261
|
onConnectionMade() {
|
|
4262
|
-
logger$
|
|
4262
|
+
logger$b.info('on CTI connection made');
|
|
4263
4263
|
|
|
4264
4264
|
this.eventEmitter.emit('onCallAccepted');
|
|
4265
4265
|
}
|
|
4266
4266
|
|
|
4267
4267
|
async close() {
|
|
4268
|
-
logger$
|
|
4268
|
+
logger$b.info('CTI close');
|
|
4269
4269
|
|
|
4270
4270
|
return Promise.resolve();
|
|
4271
4271
|
}
|
|
@@ -4274,7 +4274,7 @@ class CTIPhone extends Emitter {
|
|
|
4274
4274
|
if (!callSession) {
|
|
4275
4275
|
return;
|
|
4276
4276
|
}
|
|
4277
|
-
logger$
|
|
4277
|
+
logger$b.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4278
4278
|
|
|
4279
4279
|
return CallApi.hold(callSession.callId);
|
|
4280
4280
|
}
|
|
@@ -4283,7 +4283,7 @@ class CTIPhone extends Emitter {
|
|
|
4283
4283
|
if (!callSession) {
|
|
4284
4284
|
return;
|
|
4285
4285
|
}
|
|
4286
|
-
logger$
|
|
4286
|
+
logger$b.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4287
4287
|
|
|
4288
4288
|
return CallApi.resume(callSession.callId);
|
|
4289
4289
|
}
|
|
@@ -4292,7 +4292,7 @@ class CTIPhone extends Emitter {
|
|
|
4292
4292
|
if (!callSession) {
|
|
4293
4293
|
return;
|
|
4294
4294
|
}
|
|
4295
|
-
logger$
|
|
4295
|
+
logger$b.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4296
4296
|
|
|
4297
4297
|
return CallApi.mute(callSession.callId);
|
|
4298
4298
|
}
|
|
@@ -4301,7 +4301,7 @@ class CTIPhone extends Emitter {
|
|
|
4301
4301
|
if (!callSession) {
|
|
4302
4302
|
return;
|
|
4303
4303
|
}
|
|
4304
|
-
logger$
|
|
4304
|
+
logger$b.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4305
4305
|
|
|
4306
4306
|
return CallApi.unmute(callSession.callId);
|
|
4307
4307
|
}
|
|
@@ -5310,7 +5310,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5310
5310
|
const WEBHOOKD_VERSION = '1.0';
|
|
5311
5311
|
const AMID_VERSION = '1.0';
|
|
5312
5312
|
|
|
5313
|
-
const logger$
|
|
5313
|
+
const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5314
5314
|
|
|
5315
5315
|
class ApiClient {
|
|
5316
5316
|
|
|
@@ -5362,12 +5362,12 @@ class ApiClient {
|
|
|
5362
5362
|
}
|
|
5363
5363
|
|
|
5364
5364
|
async forceRefreshToken() {
|
|
5365
|
-
logger$
|
|
5365
|
+
logger$a.info('forcing refresh token, calling callback');
|
|
5366
5366
|
return this.refreshTokenCallback();
|
|
5367
5367
|
}
|
|
5368
5368
|
|
|
5369
5369
|
async refreshTokenCallback() {
|
|
5370
|
-
logger$
|
|
5370
|
+
logger$a.info('refresh token callback called', {
|
|
5371
5371
|
refreshToken: this.refreshToken,
|
|
5372
5372
|
refreshBackend: this.refreshBackend,
|
|
5373
5373
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5385,7 +5385,7 @@ class ApiClient {
|
|
|
5385
5385
|
this.isMobile,
|
|
5386
5386
|
);
|
|
5387
5387
|
|
|
5388
|
-
logger$
|
|
5388
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5389
5389
|
|
|
5390
5390
|
if (this.onRefreshToken) {
|
|
5391
5391
|
this.onRefreshToken(session.token, session);
|
|
@@ -5526,7 +5526,7 @@ var getApiClient = (forServer ) => {
|
|
|
5526
5526
|
class InvalidSubscription extends Error {}
|
|
5527
5527
|
class InvalidAuthorization extends Error {}
|
|
5528
5528
|
|
|
5529
|
-
const logger$
|
|
5529
|
+
const logger$9 = IssueReporter$1.loggerFor('simple-auth');
|
|
5530
5530
|
|
|
5531
5531
|
class Auth {
|
|
5532
5532
|
|
|
@@ -5561,7 +5561,7 @@ class Auth {
|
|
|
5561
5561
|
setApiClientId(this.clientId);
|
|
5562
5562
|
setRefreshExpiration(this.expiration);
|
|
5563
5563
|
setOnRefreshToken((token , session ) => {
|
|
5564
|
-
logger$
|
|
5564
|
+
logger$9.info('on refresh token done', { token });
|
|
5565
5565
|
setApiToken(token);
|
|
5566
5566
|
Wazo.Websocket.updateToken(token);
|
|
5567
5567
|
|
|
@@ -5606,7 +5606,7 @@ class Auth {
|
|
|
5606
5606
|
const rawSession = await getApiClient().auth.authenticate(token);
|
|
5607
5607
|
return this._onAuthenticated(rawSession);
|
|
5608
5608
|
} catch (e) {
|
|
5609
|
-
logger$
|
|
5609
|
+
logger$9.error('on validate token error', e);
|
|
5610
5610
|
console.warn(e);
|
|
5611
5611
|
return false;
|
|
5612
5612
|
}
|
|
@@ -5962,7 +5962,7 @@ class AdHocAPIConference {
|
|
|
5962
5962
|
|
|
5963
5963
|
/* */
|
|
5964
5964
|
|
|
5965
|
-
const parseCandidate = (candidate ) => {
|
|
5965
|
+
const parseCandidate$1 = (candidate ) => {
|
|
5966
5966
|
if (!candidate) {
|
|
5967
5967
|
return null;
|
|
5968
5968
|
}
|
|
@@ -6116,7 +6116,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6116
6116
|
this.peerConnectionDelegate.onicecandidate = event => {
|
|
6117
6117
|
wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
|
|
6118
6118
|
if (event.candidate) {
|
|
6119
|
-
this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
|
|
6119
|
+
this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
|
|
6120
6120
|
}
|
|
6121
6121
|
};
|
|
6122
6122
|
|
|
@@ -6580,7 +6580,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
6580
6580
|
const SEND_STATS_DELAY = 5000;
|
|
6581
6581
|
|
|
6582
6582
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
6583
|
-
const logger$
|
|
6583
|
+
const logger$8 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
6584
6584
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
6585
6585
|
|
|
6586
6586
|
// events
|
|
@@ -6594,14 +6594,14 @@ const TRANSPORT_ERROR = 'transportError';
|
|
|
6594
6594
|
const MESSAGE = 'message';
|
|
6595
6595
|
const ACCEPTED = 'accepted';
|
|
6596
6596
|
const REJECTED = 'rejected';
|
|
6597
|
-
const ON_TRACK = 'onTrack';
|
|
6598
|
-
const ON_REINVITE = 'reinvite';
|
|
6597
|
+
const ON_TRACK$1 = 'onTrack';
|
|
6598
|
+
const ON_REINVITE$1 = 'reinvite';
|
|
6599
6599
|
const ON_ERROR = 'onError';
|
|
6600
6600
|
const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
|
|
6601
|
-
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
6602
|
-
const ON_DISCONNECTED = 'onDisconnected';
|
|
6601
|
+
const ON_NETWORK_STATS$1 = 'onNetworkStats';
|
|
6602
|
+
const ON_DISCONNECTED$1 = 'onDisconnected';
|
|
6603
6603
|
|
|
6604
|
-
const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
6604
|
+
const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
6605
6605
|
const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
6606
6606
|
class CanceledCallError extends Error {}
|
|
6607
6607
|
|
|
@@ -6737,12 +6737,12 @@ class WebRTCClient extends Emitter {
|
|
|
6737
6737
|
this.MESSAGE = MESSAGE;
|
|
6738
6738
|
this.ACCEPTED = ACCEPTED;
|
|
6739
6739
|
this.REJECTED = REJECTED;
|
|
6740
|
-
this.ON_TRACK = ON_TRACK;
|
|
6741
|
-
this.ON_REINVITE = ON_REINVITE;
|
|
6740
|
+
this.ON_TRACK = ON_TRACK$1;
|
|
6741
|
+
this.ON_REINVITE = ON_REINVITE$1;
|
|
6742
6742
|
this.ON_ERROR = ON_ERROR;
|
|
6743
6743
|
this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
|
|
6744
|
-
this.ON_NETWORK_STATS = ON_NETWORK_STATS;
|
|
6745
|
-
this.ON_DISCONNECTED = ON_DISCONNECTED;
|
|
6744
|
+
this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
|
|
6745
|
+
this.ON_DISCONNECTED = ON_DISCONNECTED$1;
|
|
6746
6746
|
}
|
|
6747
6747
|
|
|
6748
6748
|
configureMedia(media ) {
|
|
@@ -6759,13 +6759,13 @@ class WebRTCClient extends Emitter {
|
|
|
6759
6759
|
|
|
6760
6760
|
createUserAgent(configOverrides ) {
|
|
6761
6761
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6762
|
-
logger$
|
|
6762
|
+
logger$8.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6763
6763
|
|
|
6764
6764
|
webRTCConfiguration.delegate = {
|
|
6765
6765
|
onConnect: this.onConnect.bind(this),
|
|
6766
6766
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6767
6767
|
onInvite: (invitation ) => {
|
|
6768
|
-
logger$
|
|
6768
|
+
logger$8.info('sdk webrtc on invite', {
|
|
6769
6769
|
method: 'delegate.onInvite',
|
|
6770
6770
|
id: invitation.id,
|
|
6771
6771
|
remoteURI: invitation.remoteURI,
|
|
@@ -6808,7 +6808,7 @@ class WebRTCClient extends Emitter {
|
|
|
6808
6808
|
}
|
|
6809
6809
|
|
|
6810
6810
|
onConnect() {
|
|
6811
|
-
logger$
|
|
6811
|
+
logger$8.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6812
6812
|
this.eventEmitter.emit(CONNECTED);
|
|
6813
6813
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6814
6814
|
this.registerer.waitingToggle(false);
|
|
@@ -6817,7 +6817,7 @@ class WebRTCClient extends Emitter {
|
|
|
6817
6817
|
}
|
|
6818
6818
|
|
|
6819
6819
|
async onDisconnect(error ) {
|
|
6820
|
-
logger$
|
|
6820
|
+
logger$8.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6821
6821
|
this.connectionPromise = null;
|
|
6822
6822
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6823
6823
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6842,37 +6842,37 @@ class WebRTCClient extends Emitter {
|
|
|
6842
6842
|
};
|
|
6843
6843
|
|
|
6844
6844
|
if (this.skipRegister) {
|
|
6845
|
-
logger$
|
|
6845
|
+
logger$8.info('sdk webrtc skip register...', logInfo);
|
|
6846
6846
|
return Promise.resolve();
|
|
6847
6847
|
}
|
|
6848
6848
|
|
|
6849
|
-
logger$
|
|
6849
|
+
logger$8.info('sdk webrtc registering...', logInfo);
|
|
6850
6850
|
|
|
6851
6851
|
if (!this.userAgent) {
|
|
6852
|
-
logger$
|
|
6852
|
+
logger$8.info('sdk webrtc recreating User Agent');
|
|
6853
6853
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6854
6854
|
}
|
|
6855
6855
|
if (!this.userAgent || this.isRegistered()) {
|
|
6856
|
-
logger$
|
|
6856
|
+
logger$8.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6857
6857
|
return Promise.resolve();
|
|
6858
6858
|
}
|
|
6859
6859
|
|
|
6860
6860
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6861
|
-
logger$
|
|
6861
|
+
logger$8.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6862
6862
|
return Promise.resolve();
|
|
6863
6863
|
}
|
|
6864
6864
|
|
|
6865
6865
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6866
6866
|
|
|
6867
6867
|
const onRegisterFailed = () => {
|
|
6868
|
-
logger$
|
|
6868
|
+
logger$8.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6869
6869
|
this.connectionPromise = null;
|
|
6870
6870
|
if (this.registerer && this.registerer.waiting) {
|
|
6871
6871
|
this.registerer.waitingToggle(false);
|
|
6872
6872
|
}
|
|
6873
6873
|
|
|
6874
6874
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6875
|
-
logger$
|
|
6875
|
+
logger$8.info('sdk webrtc registering, retrying...', { tries });
|
|
6876
6876
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6877
6877
|
}
|
|
6878
6878
|
};
|
|
@@ -6881,18 +6881,18 @@ class WebRTCClient extends Emitter {
|
|
|
6881
6881
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6882
6882
|
// during the resolution of the primise.
|
|
6883
6883
|
if (!this.userAgent) {
|
|
6884
|
-
logger$
|
|
6884
|
+
logger$8.info('sdk webrtc recreating User Agent after connection');
|
|
6885
6885
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6886
6886
|
}
|
|
6887
6887
|
|
|
6888
|
-
logger$
|
|
6888
|
+
logger$8.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6889
6889
|
this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
|
|
6890
6890
|
this.connectionPromise = null;
|
|
6891
6891
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6892
6892
|
|
|
6893
6893
|
// Bind registerer events
|
|
6894
6894
|
this.registerer.stateChange.addListener(newState => {
|
|
6895
|
-
logger$
|
|
6895
|
+
logger$8.info('sdk webrtc registering, state changed', { newState });
|
|
6896
6896
|
|
|
6897
6897
|
if (newState === registererState.RegistererState.Registered && this.registerer
|
|
6898
6898
|
&& this.registerer.state === registererState.RegistererState.Registered) {
|
|
@@ -6905,7 +6905,7 @@ class WebRTCClient extends Emitter {
|
|
|
6905
6905
|
const options = {
|
|
6906
6906
|
requestDelegate: {
|
|
6907
6907
|
onReject: response => {
|
|
6908
|
-
logger$
|
|
6908
|
+
logger$8.error('sdk webrtc registering, rejected', { response });
|
|
6909
6909
|
|
|
6910
6910
|
onRegisterFailed();
|
|
6911
6911
|
},
|
|
@@ -6913,13 +6913,13 @@ class WebRTCClient extends Emitter {
|
|
|
6913
6913
|
};
|
|
6914
6914
|
|
|
6915
6915
|
return this.registerer.register(options).catch((e) => {
|
|
6916
|
-
logger$
|
|
6916
|
+
logger$8.error('sdk webrtc registering, error', e);
|
|
6917
6917
|
|
|
6918
6918
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6919
6919
|
return e;
|
|
6920
6920
|
});
|
|
6921
6921
|
}).catch(error => {
|
|
6922
|
-
logger$
|
|
6922
|
+
logger$8.error('sdk webrtc registering, transport error', error);
|
|
6923
6923
|
onRegisterFailed();
|
|
6924
6924
|
});
|
|
6925
6925
|
}
|
|
@@ -6948,21 +6948,21 @@ class WebRTCClient extends Emitter {
|
|
|
6948
6948
|
}
|
|
6949
6949
|
|
|
6950
6950
|
unregister() {
|
|
6951
|
-
logger$
|
|
6951
|
+
logger$8.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6952
6952
|
if (!this.registerer) {
|
|
6953
6953
|
return Promise.resolve();
|
|
6954
6954
|
}
|
|
6955
6955
|
|
|
6956
6956
|
try {
|
|
6957
6957
|
return this.registerer.unregister().then(() => {
|
|
6958
|
-
logger$
|
|
6958
|
+
logger$8.info('sdk webrtc unregistered');
|
|
6959
6959
|
this._cleanupRegister();
|
|
6960
6960
|
}).catch(e => {
|
|
6961
|
-
logger$
|
|
6961
|
+
logger$8.error('sdk webrtc unregistering, promise error', e);
|
|
6962
6962
|
this._cleanupRegister();
|
|
6963
6963
|
});
|
|
6964
6964
|
} catch (e) {
|
|
6965
|
-
logger$
|
|
6965
|
+
logger$8.error('sdk webrtc unregistering, error', e);
|
|
6966
6966
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6967
6967
|
// error when the registerer is in a bad state
|
|
6968
6968
|
this._cleanupRegister();
|
|
@@ -6970,7 +6970,7 @@ class WebRTCClient extends Emitter {
|
|
|
6970
6970
|
}
|
|
6971
6971
|
|
|
6972
6972
|
stop() {
|
|
6973
|
-
logger$
|
|
6973
|
+
logger$8.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6974
6974
|
if (!this.userAgent) {
|
|
6975
6975
|
return Promise.resolve();
|
|
6976
6976
|
}
|
|
@@ -6978,12 +6978,12 @@ class WebRTCClient extends Emitter {
|
|
|
6978
6978
|
return this.userAgent.stop().then(() => {
|
|
6979
6979
|
return this._cleanupRegister();
|
|
6980
6980
|
}).catch(e => {
|
|
6981
|
-
logger$
|
|
6981
|
+
logger$8.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6982
6982
|
});
|
|
6983
6983
|
}
|
|
6984
6984
|
|
|
6985
6985
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6986
|
-
logger$
|
|
6986
|
+
logger$8.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
|
|
6987
6987
|
const inviterOptions = {
|
|
6988
6988
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6989
6989
|
conference,
|
|
@@ -7014,7 +7014,7 @@ class WebRTCClient extends Emitter {
|
|
|
7014
7014
|
this._onAccepted(session, response.session, true);
|
|
7015
7015
|
},
|
|
7016
7016
|
onReject: (response ) => {
|
|
7017
|
-
logger$
|
|
7017
|
+
logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
7018
7018
|
this._stopSendingStats(session);
|
|
7019
7019
|
this.stopNetworkMonitoring(session);
|
|
7020
7020
|
|
|
@@ -7037,11 +7037,11 @@ class WebRTCClient extends Emitter {
|
|
|
7037
7037
|
}
|
|
7038
7038
|
|
|
7039
7039
|
answer(session , enableVideo ) {
|
|
7040
|
-
logger$
|
|
7040
|
+
logger$8.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
7041
7041
|
|
|
7042
7042
|
if (!session || !session.accept) {
|
|
7043
7043
|
const error = 'No session to answer, or not an invitation';
|
|
7044
|
-
logger$
|
|
7044
|
+
logger$8.warn(error);
|
|
7045
7045
|
return Promise.reject(new Error(error));
|
|
7046
7046
|
}
|
|
7047
7047
|
const options = {
|
|
@@ -7051,15 +7051,15 @@ class WebRTCClient extends Emitter {
|
|
|
7051
7051
|
return session.accept(options).then(() => {
|
|
7052
7052
|
if (session.isCanceled) {
|
|
7053
7053
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
7054
|
-
logger$
|
|
7054
|
+
logger$8.error(message, { id: session.id });
|
|
7055
7055
|
this.onCallEnded(session);
|
|
7056
7056
|
|
|
7057
7057
|
throw new CanceledCallError(message);
|
|
7058
7058
|
}
|
|
7059
|
-
logger$
|
|
7059
|
+
logger$8.info('sdk webrtc answer, accepted.');
|
|
7060
7060
|
this._onAccepted(session);
|
|
7061
7061
|
}).catch(e => {
|
|
7062
|
-
logger$
|
|
7062
|
+
logger$8.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
7063
7063
|
|
|
7064
7064
|
throw e;
|
|
7065
7065
|
});
|
|
@@ -7067,7 +7067,7 @@ class WebRTCClient extends Emitter {
|
|
|
7067
7067
|
|
|
7068
7068
|
hangup(session ) {
|
|
7069
7069
|
const { state, id } = session;
|
|
7070
|
-
logger$
|
|
7070
|
+
logger$8.info('sdk webrtc hangup call', { id, state });
|
|
7071
7071
|
|
|
7072
7072
|
try {
|
|
7073
7073
|
this._stopSendingStats(session);
|
|
@@ -7096,7 +7096,7 @@ class WebRTCClient extends Emitter {
|
|
|
7096
7096
|
|
|
7097
7097
|
return bye();
|
|
7098
7098
|
} catch (error) {
|
|
7099
|
-
logger$
|
|
7099
|
+
logger$8.warn('sdk webrtc hangup, error', error);
|
|
7100
7100
|
}
|
|
7101
7101
|
|
|
7102
7102
|
return null;
|
|
@@ -7114,7 +7114,7 @@ class WebRTCClient extends Emitter {
|
|
|
7114
7114
|
// Fetch and emit an event at `interval` with session network stats
|
|
7115
7115
|
startNetworkMonitoring(session , interval = 1000) {
|
|
7116
7116
|
const sessionId = this.getSipSessionId(session);
|
|
7117
|
-
logger$
|
|
7117
|
+
logger$8.info('starting network inspection', { id: sessionId });
|
|
7118
7118
|
|
|
7119
7119
|
this.sessionNetworkStats[sessionId] = [];
|
|
7120
7120
|
|
|
@@ -7124,7 +7124,7 @@ class WebRTCClient extends Emitter {
|
|
|
7124
7124
|
stopNetworkMonitoring(session ) {
|
|
7125
7125
|
const sessionId = this.getSipSessionId(session);
|
|
7126
7126
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
7127
|
-
logger$
|
|
7127
|
+
logger$8.info('stopping network inspection', { id: sessionId, exists });
|
|
7128
7128
|
|
|
7129
7129
|
if (exists) {
|
|
7130
7130
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -7134,17 +7134,17 @@ class WebRTCClient extends Emitter {
|
|
|
7134
7134
|
}
|
|
7135
7135
|
|
|
7136
7136
|
reject(session ) {
|
|
7137
|
-
logger$
|
|
7137
|
+
logger$8.info('sdk webrtc reject call', { id: session.id });
|
|
7138
7138
|
|
|
7139
7139
|
try {
|
|
7140
7140
|
return session.reject ? session.reject() : session.cancel();
|
|
7141
7141
|
} catch (e) {
|
|
7142
|
-
logger$
|
|
7142
|
+
logger$8.warn('Error when rejecting call', e.message, e.stack);
|
|
7143
7143
|
}
|
|
7144
7144
|
}
|
|
7145
7145
|
|
|
7146
7146
|
async close() {
|
|
7147
|
-
logger$
|
|
7147
|
+
logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
7148
7148
|
this._cleanupMedia();
|
|
7149
7149
|
this.connectionPromise = null;
|
|
7150
7150
|
|
|
@@ -7175,7 +7175,7 @@ class WebRTCClient extends Emitter {
|
|
|
7175
7175
|
// eg: "INVITE not rejectable in state Completed"
|
|
7176
7176
|
}
|
|
7177
7177
|
this.userAgent = null;
|
|
7178
|
-
logger$
|
|
7178
|
+
logger$8.info('sdk webrtc client closed');
|
|
7179
7179
|
}
|
|
7180
7180
|
|
|
7181
7181
|
getNumber(session ) {
|
|
@@ -7188,13 +7188,13 @@ class WebRTCClient extends Emitter {
|
|
|
7188
7188
|
}
|
|
7189
7189
|
|
|
7190
7190
|
mute(session ) {
|
|
7191
|
-
logger$
|
|
7191
|
+
logger$8.info('sdk webrtc mute', { id: session.id });
|
|
7192
7192
|
|
|
7193
7193
|
this._toggleAudio(session, true);
|
|
7194
7194
|
}
|
|
7195
7195
|
|
|
7196
7196
|
unmute(session ) {
|
|
7197
|
-
logger$
|
|
7197
|
+
logger$8.info('sdk webrtc unmute', { id: session.id });
|
|
7198
7198
|
|
|
7199
7199
|
this._toggleAudio(session, false);
|
|
7200
7200
|
}
|
|
@@ -7234,13 +7234,13 @@ class WebRTCClient extends Emitter {
|
|
|
7234
7234
|
}
|
|
7235
7235
|
|
|
7236
7236
|
toggleCameraOn(session ) {
|
|
7237
|
-
logger$
|
|
7237
|
+
logger$8.info('sdk webrtc toggle camera on', { id: session.id });
|
|
7238
7238
|
|
|
7239
7239
|
this._toggleVideo(session, false);
|
|
7240
7240
|
}
|
|
7241
7241
|
|
|
7242
7242
|
toggleCameraOff(session ) {
|
|
7243
|
-
logger$
|
|
7243
|
+
logger$8.info('sdk webrtc toggle camera off', { id: session.id });
|
|
7244
7244
|
|
|
7245
7245
|
this._toggleVideo(session, true);
|
|
7246
7246
|
}
|
|
@@ -7249,7 +7249,7 @@ class WebRTCClient extends Emitter {
|
|
|
7249
7249
|
const sessionId = this.getSipSessionId(session);
|
|
7250
7250
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
7251
7251
|
|
|
7252
|
-
logger$
|
|
7252
|
+
logger$8.info('sdk webrtc hold', {
|
|
7253
7253
|
sessionId,
|
|
7254
7254
|
keys: Object.keys(this.heldSessions),
|
|
7255
7255
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7298,7 +7298,7 @@ class WebRTCClient extends Emitter {
|
|
|
7298
7298
|
const sessionId = this.getSipSessionId(session);
|
|
7299
7299
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
7300
7300
|
|
|
7301
|
-
logger$
|
|
7301
|
+
logger$8.info('sdk webrtc unhold', {
|
|
7302
7302
|
sessionId,
|
|
7303
7303
|
keys: Object.keys(this.heldSessions),
|
|
7304
7304
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7446,7 +7446,7 @@ class WebRTCClient extends Emitter {
|
|
|
7446
7446
|
if (!session.sessionDescriptionHandler) {
|
|
7447
7447
|
return;
|
|
7448
7448
|
}
|
|
7449
|
-
logger$
|
|
7449
|
+
logger$8.info('Sending DTMF', {
|
|
7450
7450
|
id: this.getSipSessionId(session),
|
|
7451
7451
|
tone,
|
|
7452
7452
|
});
|
|
@@ -7462,7 +7462,7 @@ class WebRTCClient extends Emitter {
|
|
|
7462
7462
|
transfer(session , target ) {
|
|
7463
7463
|
this.hold(session);
|
|
7464
7464
|
|
|
7465
|
-
logger$
|
|
7465
|
+
logger$8.info('Transfering a session', {
|
|
7466
7466
|
id: this.getSipSessionId(session),
|
|
7467
7467
|
target,
|
|
7468
7468
|
});
|
|
@@ -7484,17 +7484,17 @@ class WebRTCClient extends Emitter {
|
|
|
7484
7484
|
atxfer(session ) {
|
|
7485
7485
|
this.hold(session);
|
|
7486
7486
|
|
|
7487
|
-
logger$
|
|
7487
|
+
logger$8.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
7488
7488
|
|
|
7489
7489
|
const result = {
|
|
7490
7490
|
newSession: null,
|
|
7491
7491
|
init: async (target ) => {
|
|
7492
|
-
logger$
|
|
7492
|
+
logger$8.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
7493
7493
|
|
|
7494
7494
|
result.newSession = await this.call(target);
|
|
7495
7495
|
},
|
|
7496
7496
|
complete: () => {
|
|
7497
|
-
logger$
|
|
7497
|
+
logger$8.info('webrtc transfer completed', {
|
|
7498
7498
|
id: this.getSipSessionId(session),
|
|
7499
7499
|
referId: this.getSipSessionId(result.newSession),
|
|
7500
7500
|
});
|
|
@@ -7515,7 +7515,7 @@ class WebRTCClient extends Emitter {
|
|
|
7515
7515
|
return;
|
|
7516
7516
|
}
|
|
7517
7517
|
|
|
7518
|
-
logger$
|
|
7518
|
+
logger$8.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
7519
7519
|
|
|
7520
7520
|
try {
|
|
7521
7521
|
sipSession.message({
|
|
@@ -7557,7 +7557,7 @@ class WebRTCClient extends Emitter {
|
|
|
7557
7557
|
}
|
|
7558
7558
|
|
|
7559
7559
|
changeAudioOutputVolume(volume ) {
|
|
7560
|
-
logger$
|
|
7560
|
+
logger$8.info('Changing audio output volume', { volume });
|
|
7561
7561
|
|
|
7562
7562
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7563
7563
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -7569,7 +7569,7 @@ class WebRTCClient extends Emitter {
|
|
|
7569
7569
|
}
|
|
7570
7570
|
|
|
7571
7571
|
changeAudioOutputDevice(id ) {
|
|
7572
|
-
logger$
|
|
7572
|
+
logger$8.info('Changing audio output device', { id });
|
|
7573
7573
|
|
|
7574
7574
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7575
7575
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -7586,7 +7586,7 @@ class WebRTCClient extends Emitter {
|
|
|
7586
7586
|
|
|
7587
7587
|
changeAudioInputDevice(id , session ) {
|
|
7588
7588
|
const currentId = this.getAudioDeviceId();
|
|
7589
|
-
logger$
|
|
7589
|
+
logger$8.info('setting audio input device', { id, currentId, session: !!session });
|
|
7590
7590
|
|
|
7591
7591
|
if (id === currentId) {
|
|
7592
7592
|
return null;
|
|
@@ -7632,7 +7632,7 @@ class WebRTCClient extends Emitter {
|
|
|
7632
7632
|
|
|
7633
7633
|
setVideoInputDevice(id ) {
|
|
7634
7634
|
const currentId = this.getVideoDeviceId();
|
|
7635
|
-
logger$
|
|
7635
|
+
logger$8.info('setting video input device', { id, currentId });
|
|
7636
7636
|
|
|
7637
7637
|
if (id === currentId) {
|
|
7638
7638
|
return null;
|
|
@@ -7657,7 +7657,7 @@ class WebRTCClient extends Emitter {
|
|
|
7657
7657
|
const sessionId = this.getSipSessionId(session);
|
|
7658
7658
|
const localStream = this.getLocalStream(sessionId);
|
|
7659
7659
|
|
|
7660
|
-
logger$
|
|
7660
|
+
logger$8.info('changing video input device', { id, sessionId });
|
|
7661
7661
|
|
|
7662
7662
|
// Release old video stream
|
|
7663
7663
|
if (localStream) {
|
|
@@ -7725,7 +7725,7 @@ class WebRTCClient extends Emitter {
|
|
|
7725
7725
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
7726
7726
|
const desktop = newConstraints && newConstraints.desktop;
|
|
7727
7727
|
|
|
7728
|
-
logger$
|
|
7728
|
+
logger$8.info('Sending reinvite', {
|
|
7729
7729
|
id: this.getSipSessionId(sipSession),
|
|
7730
7730
|
newConstraints,
|
|
7731
7731
|
conference,
|
|
@@ -7763,7 +7763,7 @@ class WebRTCClient extends Emitter {
|
|
|
7763
7763
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
7764
7764
|
}
|
|
7765
7765
|
|
|
7766
|
-
logger$
|
|
7766
|
+
logger$8.info('on re-INVITE accepted', {
|
|
7767
7767
|
id: this.getSipSessionId(sipSession),
|
|
7768
7768
|
wasMuted,
|
|
7769
7769
|
shouldDoScreenSharing,
|
|
@@ -7781,7 +7781,7 @@ class WebRTCClient extends Emitter {
|
|
|
7781
7781
|
this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
|
|
7782
7782
|
}
|
|
7783
7783
|
|
|
7784
|
-
return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
|
|
7784
|
+
return this.eventEmitter.emit(ON_REINVITE$1, sipSession, response);
|
|
7785
7785
|
},
|
|
7786
7786
|
},
|
|
7787
7787
|
sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
|
|
@@ -7938,7 +7938,7 @@ class WebRTCClient extends Emitter {
|
|
|
7938
7938
|
}
|
|
7939
7939
|
|
|
7940
7940
|
startHeartbeat() {
|
|
7941
|
-
logger$
|
|
7941
|
+
logger$8.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7942
7942
|
if (!this.userAgent) {
|
|
7943
7943
|
this.heartbeat.stop();
|
|
7944
7944
|
return;
|
|
@@ -7951,7 +7951,7 @@ class WebRTCClient extends Emitter {
|
|
|
7951
7951
|
}
|
|
7952
7952
|
|
|
7953
7953
|
stopHeartbeat() {
|
|
7954
|
-
logger$
|
|
7954
|
+
logger$8.info('sdk webrtc stop heartbeat');
|
|
7955
7955
|
this.heartbeat.stop();
|
|
7956
7956
|
}
|
|
7957
7957
|
|
|
@@ -7972,7 +7972,7 @@ class WebRTCClient extends Emitter {
|
|
|
7972
7972
|
}
|
|
7973
7973
|
|
|
7974
7974
|
attemptReconnection() {
|
|
7975
|
-
logger$
|
|
7975
|
+
logger$8.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7976
7976
|
if (!this.userAgent) {
|
|
7977
7977
|
return;
|
|
7978
7978
|
}
|
|
@@ -7997,7 +7997,7 @@ class WebRTCClient extends Emitter {
|
|
|
7997
7997
|
return;
|
|
7998
7998
|
}
|
|
7999
7999
|
|
|
8000
|
-
logger$
|
|
8000
|
+
logger$8.info('setting local media stream', {
|
|
8001
8001
|
sipSessionId,
|
|
8002
8002
|
tracks: newStream ? newStream.getTracks() : null,
|
|
8003
8003
|
});
|
|
@@ -8014,7 +8014,7 @@ class WebRTCClient extends Emitter {
|
|
|
8014
8014
|
|
|
8015
8015
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
8016
8016
|
|
|
8017
|
-
logger$
|
|
8017
|
+
logger$8.info('updating local stream', {
|
|
8018
8018
|
sipSessionId,
|
|
8019
8019
|
oldStream: !!oldStream,
|
|
8020
8020
|
tracks: newStream.getTracks(),
|
|
@@ -8034,7 +8034,7 @@ class WebRTCClient extends Emitter {
|
|
|
8034
8034
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
8035
8035
|
const pc = this.getPeerConnection(sessionId);
|
|
8036
8036
|
|
|
8037
|
-
logger$
|
|
8037
|
+
logger$8.info('Updating remote stream', {
|
|
8038
8038
|
sessionId,
|
|
8039
8039
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
8040
8040
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -8059,14 +8059,16 @@ class WebRTCClient extends Emitter {
|
|
|
8059
8059
|
const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
|
|
8060
8060
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
8061
8061
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
8062
|
+
const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
|
|
8062
8063
|
|
|
8063
|
-
logger$
|
|
8064
|
+
logger$8.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
8064
8065
|
|
|
8065
8066
|
return {
|
|
8066
8067
|
constraints: {
|
|
8067
8068
|
// Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
|
|
8068
8069
|
audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
|
|
8069
|
-
video: screenSharing ? (isDesktop
|
|
8070
|
+
video: screenSharing ? (isDesktop
|
|
8071
|
+
? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
|
|
8070
8072
|
: this._getVideoConstraints(enableVideo),
|
|
8071
8073
|
screen: screenSharing,
|
|
8072
8074
|
desktop: isDesktop,
|
|
@@ -8109,7 +8111,7 @@ class WebRTCClient extends Emitter {
|
|
|
8109
8111
|
}
|
|
8110
8112
|
|
|
8111
8113
|
_onTransportError() {
|
|
8112
|
-
logger$
|
|
8114
|
+
logger$8.error('on transport error');
|
|
8113
8115
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
8114
8116
|
this.attemptReconnection();
|
|
8115
8117
|
}
|
|
@@ -8118,7 +8120,7 @@ class WebRTCClient extends Emitter {
|
|
|
8118
8120
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
8119
8121
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
8120
8122
|
if (this.hasHeartbeat()) {
|
|
8121
|
-
logger$
|
|
8123
|
+
logger$8.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
8122
8124
|
|
|
8123
8125
|
this.heartbeat.onHeartbeat();
|
|
8124
8126
|
if (this.heartbeatCb) {
|
|
@@ -8129,7 +8131,7 @@ class WebRTCClient extends Emitter {
|
|
|
8129
8131
|
}
|
|
8130
8132
|
|
|
8131
8133
|
async _onHeartbeatTimeout() {
|
|
8132
|
-
logger$
|
|
8134
|
+
logger$8.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
8133
8135
|
|
|
8134
8136
|
if (this.heartbeatTimeoutCb) {
|
|
8135
8137
|
this.heartbeatTimeoutCb();
|
|
@@ -8141,7 +8143,7 @@ class WebRTCClient extends Emitter {
|
|
|
8141
8143
|
try {
|
|
8142
8144
|
await this.userAgent.transport.disconnect();
|
|
8143
8145
|
} catch (e) {
|
|
8144
|
-
logger$
|
|
8146
|
+
logger$8.error('Transport disconnection after heartbeat timeout, error', e);
|
|
8145
8147
|
}
|
|
8146
8148
|
}
|
|
8147
8149
|
|
|
@@ -8174,31 +8176,31 @@ class WebRTCClient extends Emitter {
|
|
|
8174
8176
|
}
|
|
8175
8177
|
|
|
8176
8178
|
_connectIfNeeded() {
|
|
8177
|
-
logger$
|
|
8179
|
+
logger$8.info('connect if needed, checking', { connected: this.isConnected() });
|
|
8178
8180
|
if (!this.userAgent) {
|
|
8179
|
-
logger$
|
|
8181
|
+
logger$8.info('need to recreate User Agent');
|
|
8180
8182
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
8181
8183
|
}
|
|
8182
8184
|
|
|
8183
8185
|
if (this.isConnected()) {
|
|
8184
|
-
logger$
|
|
8186
|
+
logger$8.info('webrtc sdk, already connected');
|
|
8185
8187
|
return Promise.resolve();
|
|
8186
8188
|
}
|
|
8187
8189
|
|
|
8188
8190
|
if (this.isConnecting()) {
|
|
8189
|
-
logger$
|
|
8191
|
+
logger$8.info('webrtc sdk, already connecting...');
|
|
8190
8192
|
|
|
8191
8193
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
8192
8194
|
return this.connectionPromise;
|
|
8193
8195
|
}
|
|
8194
8196
|
|
|
8195
8197
|
if (this.connectionPromise) {
|
|
8196
|
-
logger$
|
|
8198
|
+
logger$8.info('webrtc sdk, connection promise connecting...');
|
|
8197
8199
|
// $FlowFixMe
|
|
8198
8200
|
return this.connectionPromise;
|
|
8199
8201
|
}
|
|
8200
8202
|
|
|
8201
|
-
logger$
|
|
8203
|
+
logger$8.info('WebRTC UA needs to connect');
|
|
8202
8204
|
|
|
8203
8205
|
// Force UA to reconnect
|
|
8204
8206
|
if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
|
|
@@ -8323,7 +8325,7 @@ class WebRTCClient extends Emitter {
|
|
|
8323
8325
|
|
|
8324
8326
|
sdh.peerConnectionDelegate = {
|
|
8325
8327
|
onicecandidateerror: (error ) => {
|
|
8326
|
-
logger$
|
|
8328
|
+
logger$8.error('on icecandidate error', {
|
|
8327
8329
|
address: error.address,
|
|
8328
8330
|
port: error.port,
|
|
8329
8331
|
errorCode: error.errorCode,
|
|
@@ -8352,7 +8354,7 @@ class WebRTCClient extends Emitter {
|
|
|
8352
8354
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
8353
8355
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
8354
8356
|
}
|
|
8355
|
-
logger$
|
|
8357
|
+
logger$8.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
8356
8358
|
|
|
8357
8359
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
8358
8360
|
|
|
@@ -8368,12 +8370,12 @@ class WebRTCClient extends Emitter {
|
|
|
8368
8370
|
|
|
8369
8371
|
this._setupMedias(session);
|
|
8370
8372
|
|
|
8371
|
-
return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
|
|
8373
|
+
return this.eventEmitter.emit(ON_REINVITE$1, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
|
|
8372
8374
|
};
|
|
8373
8375
|
}
|
|
8374
8376
|
|
|
8375
8377
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
8376
|
-
logger$
|
|
8378
|
+
logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
8377
8379
|
|
|
8378
8380
|
this.storeSipSession(session);
|
|
8379
8381
|
|
|
@@ -8385,14 +8387,14 @@ class WebRTCClient extends Emitter {
|
|
|
8385
8387
|
const onTrack = (event ) => {
|
|
8386
8388
|
const isAudioOnly = this._isAudioOnly(session);
|
|
8387
8389
|
const { kind, label, readyState, id, muted } = event.track;
|
|
8388
|
-
logger$
|
|
8390
|
+
logger$8.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
8389
8391
|
|
|
8390
8392
|
// Stop video track in audio only mode
|
|
8391
8393
|
if (isAudioOnly && kind === 'video') {
|
|
8392
8394
|
event.track.stop();
|
|
8393
8395
|
}
|
|
8394
8396
|
|
|
8395
|
-
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
8397
|
+
this.eventEmitter.emit(ON_TRACK$1, session, event);
|
|
8396
8398
|
};
|
|
8397
8399
|
|
|
8398
8400
|
if (session.sessionDescriptionHandler.peerConnection) {
|
|
@@ -8401,12 +8403,14 @@ class WebRTCClient extends Emitter {
|
|
|
8401
8403
|
|
|
8402
8404
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
8403
8405
|
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8409
|
-
|
|
8406
|
+
if (pc) {
|
|
8407
|
+
pc.oniceconnectionstatechange = () => {
|
|
8408
|
+
logger$8.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
8409
|
+
if (pc.iceConnectionState === 'disconnected') {
|
|
8410
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
8411
|
+
}
|
|
8412
|
+
};
|
|
8413
|
+
}
|
|
8410
8414
|
|
|
8411
8415
|
if (withEvent) {
|
|
8412
8416
|
this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
|
|
@@ -8575,10 +8579,10 @@ class WebRTCClient extends Emitter {
|
|
|
8575
8579
|
|
|
8576
8580
|
_stopSendingStats(session ) {
|
|
8577
8581
|
const sessionId = this.getSipSessionId(session);
|
|
8578
|
-
logger$
|
|
8582
|
+
logger$8.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
8579
8583
|
|
|
8580
8584
|
if (sessionId in this.statsIntervals) {
|
|
8581
|
-
logger$
|
|
8585
|
+
logger$8.trace('Stop sending stats for call', { sessionId });
|
|
8582
8586
|
this.statsIntervals[sessionId]();
|
|
8583
8587
|
delete this.statsIntervals[sessionId];
|
|
8584
8588
|
}
|
|
@@ -8594,7 +8598,7 @@ class WebRTCClient extends Emitter {
|
|
|
8594
8598
|
try {
|
|
8595
8599
|
await this.userAgent.transport.disconnect();
|
|
8596
8600
|
} catch (e) {
|
|
8597
|
-
logger$
|
|
8601
|
+
logger$8.error('WebRTC transport disconnect, error', e);
|
|
8598
8602
|
}
|
|
8599
8603
|
}
|
|
8600
8604
|
}
|
|
@@ -8616,13 +8620,17 @@ class WebRTCClient extends Emitter {
|
|
|
8616
8620
|
const nbStats = this.sessionNetworkStats[sessionId].length;
|
|
8617
8621
|
const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
|
|
8618
8622
|
const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
|
|
8623
|
+
const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
|
|
8619
8624
|
const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
|
|
8620
8625
|
const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
|
|
8626
|
+
const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
|
|
8621
8627
|
const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
|
|
8622
8628
|
const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
|
|
8623
8629
|
const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
|
|
8624
|
-
let audioBytesSent = 0;
|
|
8625
|
-
let audioBytesReceived = 0;
|
|
8630
|
+
let audioBytesSent = 0; // content + header
|
|
8631
|
+
let audioBytesReceived = 0; // content + header
|
|
8632
|
+
let audioContentSent = 0; // useful to detect blank call
|
|
8633
|
+
let audioContentReceived = 0;
|
|
8626
8634
|
let videoBytesSent = 0;
|
|
8627
8635
|
let videoBytesReceived = 0;
|
|
8628
8636
|
let transportSent = 0;
|
|
@@ -8632,6 +8640,7 @@ class WebRTCClient extends Emitter {
|
|
|
8632
8640
|
stats.forEach(report => {
|
|
8633
8641
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
8634
8642
|
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8643
|
+
audioContentSent += Number(report.bytesSent);
|
|
8635
8644
|
}
|
|
8636
8645
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
8637
8646
|
audioBytesSent += Number(report.bytesSent);
|
|
@@ -8643,6 +8652,7 @@ class WebRTCClient extends Emitter {
|
|
|
8643
8652
|
packetsLost += Number(report.packetsLost);
|
|
8644
8653
|
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
8645
8654
|
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8655
|
+
audioContentReceived += Number(report.bytesReceived);
|
|
8646
8656
|
}
|
|
8647
8657
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
8648
8658
|
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
@@ -8671,10 +8681,17 @@ class WebRTCClient extends Emitter {
|
|
|
8671
8681
|
});
|
|
8672
8682
|
|
|
8673
8683
|
networkStats.packetsLost = packetsLost;
|
|
8684
|
+
|
|
8674
8685
|
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
8675
8686
|
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
8676
8687
|
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
8677
8688
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
8689
|
+
|
|
8690
|
+
networkStats.totalAudioContentSent = audioContentSent;
|
|
8691
|
+
networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
|
|
8692
|
+
networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
|
|
8693
|
+
networkStats.audioContentReceived = audioContentReceived;
|
|
8694
|
+
|
|
8678
8695
|
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
8679
8696
|
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
8680
8697
|
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
@@ -8688,7 +8705,7 @@ class WebRTCClient extends Emitter {
|
|
|
8688
8705
|
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
8689
8706
|
+ networkStats.transportSent;
|
|
8690
8707
|
|
|
8691
|
-
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
8708
|
+
this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
8692
8709
|
this.sessionNetworkStats[sessionId].push(networkStats);
|
|
8693
8710
|
}
|
|
8694
8711
|
|
|
@@ -8716,8 +8733,8 @@ const ON_CALL_FAILED = 'onCallFailed';
|
|
|
8716
8733
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
8717
8734
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
8718
8735
|
const ON_MESSAGE = 'onMessage';
|
|
8719
|
-
const ON_REINVITE
|
|
8720
|
-
const ON_TRACK
|
|
8736
|
+
const ON_REINVITE = 'reinvite';
|
|
8737
|
+
const ON_TRACK = 'onTrack';
|
|
8721
8738
|
const ON_AUDIO_STREAM = 'onAudioStream';
|
|
8722
8739
|
const ON_VIDEO_STREAM = 'onVideoStream';
|
|
8723
8740
|
const ON_REMOVE_STREAM = 'onRemoveStream';
|
|
@@ -8732,15 +8749,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
|
|
|
8732
8749
|
const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
|
|
8733
8750
|
const ON_CALL_ERROR = 'onCallError';
|
|
8734
8751
|
const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
|
|
8735
|
-
const ON_NETWORK_STATS
|
|
8752
|
+
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
8736
8753
|
const ON_CHAT = 'phone/ON_CHAT';
|
|
8737
8754
|
const ON_SIGNAL = 'phone/ON_SIGNAL';
|
|
8738
|
-
const ON_DISCONNECTED
|
|
8755
|
+
const ON_DISCONNECTED = 'onDisconnected';
|
|
8739
8756
|
|
|
8740
8757
|
const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
8741
8758
|
const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
8742
8759
|
|
|
8743
|
-
const events
|
|
8760
|
+
const events = [
|
|
8744
8761
|
ON_USER_AGENT,
|
|
8745
8762
|
ON_REGISTERED,
|
|
8746
8763
|
ON_UNREGISTERED,
|
|
@@ -8758,8 +8775,8 @@ const events$1 = [
|
|
|
8758
8775
|
ON_CALL_FAILED,
|
|
8759
8776
|
ON_CALL_ENDED,
|
|
8760
8777
|
ON_MESSAGE,
|
|
8761
|
-
ON_REINVITE
|
|
8762
|
-
ON_TRACK
|
|
8778
|
+
ON_REINVITE,
|
|
8779
|
+
ON_TRACK,
|
|
8763
8780
|
ON_AUDIO_STREAM,
|
|
8764
8781
|
ON_VIDEO_STREAM,
|
|
8765
8782
|
ON_REMOVE_STREAM,
|
|
@@ -8774,11 +8791,11 @@ const events$1 = [
|
|
|
8774
8791
|
ON_CALL_ERROR,
|
|
8775
8792
|
ON_CHAT,
|
|
8776
8793
|
ON_SIGNAL,
|
|
8777
|
-
ON_NETWORK_STATS
|
|
8778
|
-
ON_DISCONNECTED
|
|
8794
|
+
ON_NETWORK_STATS,
|
|
8795
|
+
ON_DISCONNECTED,
|
|
8779
8796
|
];
|
|
8780
8797
|
|
|
8781
|
-
const logger$
|
|
8798
|
+
const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
8782
8799
|
|
|
8783
8800
|
class WebRTCPhone extends Emitter {
|
|
8784
8801
|
|
|
@@ -8851,7 +8868,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8851
8868
|
}).catch(error => {
|
|
8852
8869
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
8853
8870
|
console.error('register error', error, error.message, error.stack);
|
|
8854
|
-
logger$
|
|
8871
|
+
logger$7.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
8855
8872
|
});
|
|
8856
8873
|
}
|
|
8857
8874
|
|
|
@@ -8866,7 +8883,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8866
8883
|
if (!this.client) {
|
|
8867
8884
|
return;
|
|
8868
8885
|
}
|
|
8869
|
-
logger$
|
|
8886
|
+
logger$7.info('WebRTC phone stop');
|
|
8870
8887
|
this.client.stop();
|
|
8871
8888
|
}
|
|
8872
8889
|
|
|
@@ -8881,11 +8898,12 @@ class WebRTCPhone extends Emitter {
|
|
|
8881
8898
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
8882
8899
|
audioOnly = false, iceRestart = false) {
|
|
8883
8900
|
const sipSession = this.findSipSession(callSession);
|
|
8884
|
-
logger$
|
|
8901
|
+
logger$7.info('WebRTC phone - send reinvite', {
|
|
8885
8902
|
sessionId: sipSession ? sipSession.id : null,
|
|
8886
8903
|
constraints,
|
|
8887
8904
|
audioOnly,
|
|
8888
8905
|
conference,
|
|
8906
|
+
iceRestart,
|
|
8889
8907
|
});
|
|
8890
8908
|
|
|
8891
8909
|
if (!sipSession) {
|
|
@@ -8918,7 +8936,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8918
8936
|
}
|
|
8919
8937
|
|
|
8920
8938
|
startHeartbeat() {
|
|
8921
|
-
logger$
|
|
8939
|
+
logger$7.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
8922
8940
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
8923
8941
|
return;
|
|
8924
8942
|
}
|
|
@@ -8927,7 +8945,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8927
8945
|
}
|
|
8928
8946
|
|
|
8929
8947
|
stopHeartbeat() {
|
|
8930
|
-
logger$
|
|
8948
|
+
logger$7.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
8931
8949
|
if (!this.client) {
|
|
8932
8950
|
return;
|
|
8933
8951
|
}
|
|
@@ -8944,7 +8962,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8944
8962
|
}
|
|
8945
8963
|
|
|
8946
8964
|
reconnect() {
|
|
8947
|
-
logger$
|
|
8965
|
+
logger$7.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
8948
8966
|
if (!this.client) {
|
|
8949
8967
|
return;
|
|
8950
8968
|
}
|
|
@@ -8985,7 +9003,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8985
9003
|
return false;
|
|
8986
9004
|
}
|
|
8987
9005
|
|
|
8988
|
-
logger$
|
|
9006
|
+
logger$7.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
8989
9007
|
|
|
8990
9008
|
this.client.downgradeToAudio(sipSession);
|
|
8991
9009
|
|
|
@@ -9008,7 +9026,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9008
9026
|
return Promise.resolve(false);
|
|
9009
9027
|
}
|
|
9010
9028
|
|
|
9011
|
-
logger$
|
|
9029
|
+
logger$7.info('Upgrade to video', {
|
|
9012
9030
|
id: callSession ? callSession.getId() : null,
|
|
9013
9031
|
constraints,
|
|
9014
9032
|
isConference,
|
|
@@ -9048,7 +9066,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9048
9066
|
|
|
9049
9067
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
9050
9068
|
const sipSession = this.findSipSession(callSession);
|
|
9051
|
-
logger$
|
|
9069
|
+
logger$7.info('Sending reinvite message', {
|
|
9052
9070
|
id: callSession ? callSession.getId() : null,
|
|
9053
9071
|
isUpgrade,
|
|
9054
9072
|
});
|
|
@@ -9074,7 +9092,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9074
9092
|
// Monkey patch to know when canceled with the CANCEL message
|
|
9075
9093
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
9076
9094
|
sipSession._onCancel = (message ) => {
|
|
9077
|
-
logger$
|
|
9095
|
+
logger$7.trace('on sip session canceled', { callId: message.callId });
|
|
9078
9096
|
|
|
9079
9097
|
onCancel(message);
|
|
9080
9098
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
@@ -9102,13 +9120,13 @@ class WebRTCPhone extends Emitter {
|
|
|
9102
9120
|
this.audioOutputVolume,
|
|
9103
9121
|
);
|
|
9104
9122
|
case sessionState.SessionState.Terminating:
|
|
9105
|
-
logger$
|
|
9123
|
+
logger$7.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
9106
9124
|
|
|
9107
9125
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
9108
9126
|
|
|
9109
9127
|
break;
|
|
9110
9128
|
case sessionState.SessionState.Terminated: {
|
|
9111
|
-
logger$
|
|
9129
|
+
logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
9112
9130
|
|
|
9113
9131
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
9114
9132
|
const callSession = this._createCallSession(sipSession);
|
|
@@ -9130,7 +9148,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9130
9148
|
const [stream] = event.streams;
|
|
9131
9149
|
const kind = event && event.track && event.track.kind;
|
|
9132
9150
|
|
|
9133
|
-
logger$
|
|
9151
|
+
logger$7.info('on track stream called on the peer connection', {
|
|
9134
9152
|
callId: this.getSipSessionId(sipSession),
|
|
9135
9153
|
streamId: stream ? stream.id : null,
|
|
9136
9154
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -9150,7 +9168,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9150
9168
|
};
|
|
9151
9169
|
|
|
9152
9170
|
peerConnection.onremovestream = event => {
|
|
9153
|
-
logger$
|
|
9171
|
+
logger$7.info('on remove stream called on the peer connection', {
|
|
9154
9172
|
id: event.stream.id,
|
|
9155
9173
|
tracks: event.stream.getTracks(),
|
|
9156
9174
|
});
|
|
@@ -9160,7 +9178,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9160
9178
|
}
|
|
9161
9179
|
|
|
9162
9180
|
async startScreenSharing(constraints , callSession ) {
|
|
9163
|
-
logger$
|
|
9181
|
+
logger$7.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
9164
9182
|
|
|
9165
9183
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
9166
9184
|
if (!screenShareStream) {
|
|
@@ -9200,7 +9218,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9200
9218
|
return;
|
|
9201
9219
|
}
|
|
9202
9220
|
|
|
9203
|
-
logger$
|
|
9221
|
+
logger$7.info('WebRTC phone - stop screen sharing', {
|
|
9204
9222
|
restoreLocalStream,
|
|
9205
9223
|
});
|
|
9206
9224
|
|
|
@@ -9256,7 +9274,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9256
9274
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
9257
9275
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
9258
9276
|
|
|
9259
|
-
logger$
|
|
9277
|
+
logger$7.info('WebRTC phone - on screensharing', {
|
|
9260
9278
|
hadVideo,
|
|
9261
9279
|
id: this.getSipSessionId(sipSession),
|
|
9262
9280
|
screenTrack,
|
|
@@ -9264,7 +9282,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9264
9282
|
|
|
9265
9283
|
if (screenTrack) {
|
|
9266
9284
|
screenTrack.onended = () => {
|
|
9267
|
-
logger$
|
|
9285
|
+
logger$7.info('WebRTC phone - on screenshare ended', {
|
|
9268
9286
|
hadVideo,
|
|
9269
9287
|
id: this.getSipSessionId(sipSession),
|
|
9270
9288
|
screenTrack,
|
|
@@ -9295,7 +9313,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9295
9313
|
}
|
|
9296
9314
|
|
|
9297
9315
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
9298
|
-
logger$
|
|
9316
|
+
logger$7.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
9299
9317
|
|
|
9300
9318
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
9301
9319
|
this.currentSipSession = sipSession;
|
|
@@ -9313,7 +9331,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9313
9331
|
}
|
|
9314
9332
|
|
|
9315
9333
|
changeAudioDevice(id ) {
|
|
9316
|
-
logger$
|
|
9334
|
+
logger$7.info('WebRTC phone - change audio device', { deviceId: id });
|
|
9317
9335
|
this.audioOutputDeviceId = id;
|
|
9318
9336
|
this.client.changeAudioOutputDevice(id);
|
|
9319
9337
|
}
|
|
@@ -9323,14 +9341,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9323
9341
|
}
|
|
9324
9342
|
|
|
9325
9343
|
changeRingDevice(id ) {
|
|
9326
|
-
logger$
|
|
9344
|
+
logger$7.info('WebRTC phone - changing ring device', { id });
|
|
9327
9345
|
|
|
9328
9346
|
this.audioRingDeviceId = id;
|
|
9329
9347
|
}
|
|
9330
9348
|
|
|
9331
9349
|
// volume is a value between 0 and 1
|
|
9332
9350
|
changeAudioVolume(volume ) {
|
|
9333
|
-
logger$
|
|
9351
|
+
logger$7.info('WebRTC phone - changing audio volume', { volume });
|
|
9334
9352
|
|
|
9335
9353
|
this.audioOutputVolume = volume;
|
|
9336
9354
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -9338,31 +9356,31 @@ class WebRTCPhone extends Emitter {
|
|
|
9338
9356
|
|
|
9339
9357
|
// volume is a value between 0 and 1
|
|
9340
9358
|
changeRingVolume(volume ) {
|
|
9341
|
-
logger$
|
|
9359
|
+
logger$7.info('WebRTC phone - changing ring volume', { volume });
|
|
9342
9360
|
|
|
9343
9361
|
this.audioRingVolume = volume;
|
|
9344
9362
|
}
|
|
9345
9363
|
|
|
9346
9364
|
changeAudioInputDevice(id ) {
|
|
9347
|
-
logger$
|
|
9365
|
+
logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
9348
9366
|
|
|
9349
9367
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
9350
9368
|
}
|
|
9351
9369
|
|
|
9352
9370
|
changeVideoInputDevice(id ) {
|
|
9353
|
-
logger$
|
|
9371
|
+
logger$7.info('WebRTC phone - change video input device', { deviceId: id });
|
|
9354
9372
|
|
|
9355
9373
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
9356
9374
|
}
|
|
9357
9375
|
|
|
9358
9376
|
changeSessionVideoInputDevice(id ) {
|
|
9359
|
-
logger$
|
|
9377
|
+
logger$7.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
9360
9378
|
|
|
9361
9379
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
9362
9380
|
}
|
|
9363
9381
|
|
|
9364
9382
|
_onCallTerminated(sipSession ) {
|
|
9365
|
-
logger$
|
|
9383
|
+
logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9366
9384
|
|
|
9367
9385
|
const callSession = this._createCallSession(sipSession);
|
|
9368
9386
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -9396,7 +9414,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9396
9414
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
9397
9415
|
|
|
9398
9416
|
// Re-trigger incoming call event for remaining incoming calls
|
|
9399
|
-
logger$
|
|
9417
|
+
logger$7.info('WebRTC phone - check to re-trigger incoming call', {
|
|
9400
9418
|
sipId: sipSession.id,
|
|
9401
9419
|
shouldRetrigger,
|
|
9402
9420
|
hasIncomingCallSession,
|
|
@@ -9487,37 +9505,37 @@ class WebRTCPhone extends Emitter {
|
|
|
9487
9505
|
|
|
9488
9506
|
// Deprecated
|
|
9489
9507
|
getLocalStreamForCall(callSession ) {
|
|
9490
|
-
logger$
|
|
9508
|
+
logger$7.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9491
9509
|
|
|
9492
9510
|
return this.getLocalStream(callSession);
|
|
9493
9511
|
}
|
|
9494
9512
|
|
|
9495
9513
|
// Deprecated
|
|
9496
9514
|
getRemoteStreamForCall(callSession ) {
|
|
9497
|
-
logger$
|
|
9515
|
+
logger$7.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
9498
9516
|
|
|
9499
9517
|
return this.getRemoteVideoStream(callSession);
|
|
9500
9518
|
}
|
|
9501
9519
|
|
|
9502
9520
|
getRemoteStreamsForCall(callSession ) {
|
|
9503
|
-
logger$
|
|
9521
|
+
logger$7.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
9504
9522
|
|
|
9505
9523
|
return this.getRemoteStream(callSession);
|
|
9506
9524
|
}
|
|
9507
9525
|
|
|
9508
9526
|
accept(callSession , cameraEnabled ) {
|
|
9509
|
-
logger$
|
|
9527
|
+
logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
9510
9528
|
if (this.currentSipSession) {
|
|
9511
9529
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
9512
9530
|
}
|
|
9513
9531
|
|
|
9514
9532
|
if (!callSession) {
|
|
9515
|
-
logger$
|
|
9533
|
+
logger$7.warn('no CallSession to accept.');
|
|
9516
9534
|
return Promise.resolve(null);
|
|
9517
9535
|
}
|
|
9518
9536
|
|
|
9519
9537
|
if (callSession.getId() in this.acceptedSessions) {
|
|
9520
|
-
logger$
|
|
9538
|
+
logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9521
9539
|
return Promise.resolve(callSession.sipCallId);
|
|
9522
9540
|
}
|
|
9523
9541
|
|
|
@@ -9529,24 +9547,24 @@ class WebRTCPhone extends Emitter {
|
|
|
9529
9547
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
9530
9548
|
if (sipSession) {
|
|
9531
9549
|
if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
|
|
9532
|
-
logger$
|
|
9550
|
+
logger$7.warn('Trying to answer a terminated sipSession.');
|
|
9533
9551
|
|
|
9534
9552
|
return Promise.resolve(null);
|
|
9535
9553
|
}
|
|
9536
9554
|
|
|
9537
|
-
logger$
|
|
9555
|
+
logger$7.info('accept call, session found', { sipId: sipSession.id });
|
|
9538
9556
|
|
|
9539
9557
|
// $FlowFixMe
|
|
9540
9558
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
9541
9559
|
return callSession.sipCallId;
|
|
9542
9560
|
}).catch(e => {
|
|
9543
|
-
logger$
|
|
9561
|
+
logger$7.error(e);
|
|
9544
9562
|
this.endCurrentCall(callSession);
|
|
9545
9563
|
throw e;
|
|
9546
9564
|
});
|
|
9547
9565
|
}
|
|
9548
9566
|
|
|
9549
|
-
logger$
|
|
9567
|
+
logger$7.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9550
9568
|
|
|
9551
9569
|
return Promise.resolve(null);
|
|
9552
9570
|
}
|
|
@@ -9556,7 +9574,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9556
9574
|
}
|
|
9557
9575
|
|
|
9558
9576
|
async reject(callSession ) {
|
|
9559
|
-
logger$
|
|
9577
|
+
logger$7.info('reject WebRTC called', { id: callSession.getId() });
|
|
9560
9578
|
|
|
9561
9579
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
9562
9580
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -9568,14 +9586,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9568
9586
|
|
|
9569
9587
|
const sipSession = this.findSipSession(callSession);
|
|
9570
9588
|
if (sipSession) {
|
|
9571
|
-
logger$
|
|
9589
|
+
logger$7.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
9572
9590
|
|
|
9573
9591
|
this.client.hangup(sipSession);
|
|
9574
9592
|
}
|
|
9575
9593
|
}
|
|
9576
9594
|
|
|
9577
9595
|
async ignore(callSession ) {
|
|
9578
|
-
logger$
|
|
9596
|
+
logger$7.info('WebRTC ignore', { id: callSession.getId() });
|
|
9579
9597
|
|
|
9580
9598
|
// kill the ring
|
|
9581
9599
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -9587,14 +9605,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9587
9605
|
const sipSession = this.findSipSession(callSession);
|
|
9588
9606
|
|
|
9589
9607
|
if (sipSession) {
|
|
9590
|
-
logger$
|
|
9608
|
+
logger$7.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
9591
9609
|
|
|
9592
9610
|
return this.client.atxfer(sipSession);
|
|
9593
9611
|
}
|
|
9594
9612
|
}
|
|
9595
9613
|
|
|
9596
9614
|
hold(callSession , withEvent = true, isConference = false) {
|
|
9597
|
-
logger$
|
|
9615
|
+
logger$7.info('WebRTC hold', { id: callSession.getId() });
|
|
9598
9616
|
|
|
9599
9617
|
const sipSession = this.findSipSession(callSession);
|
|
9600
9618
|
|
|
@@ -9609,18 +9627,18 @@ class WebRTCPhone extends Emitter {
|
|
|
9609
9627
|
}
|
|
9610
9628
|
|
|
9611
9629
|
resume(callSession , isConference = false, withEvent = true) {
|
|
9612
|
-
logger$
|
|
9630
|
+
logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
9613
9631
|
|
|
9614
9632
|
const sipSession = this.findSipSession(callSession);
|
|
9615
9633
|
if (!sipSession) {
|
|
9616
9634
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
9617
9635
|
}
|
|
9618
9636
|
|
|
9619
|
-
logger$
|
|
9637
|
+
logger$7.info('WebRTC resuming', { sipId: sipSession.id });
|
|
9620
9638
|
|
|
9621
9639
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
9622
9640
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
9623
|
-
logger$
|
|
9641
|
+
logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
9624
9642
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
9625
9643
|
}
|
|
9626
9644
|
|
|
@@ -9645,7 +9663,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9645
9663
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9646
9664
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
9647
9665
|
|
|
9648
|
-
logger$
|
|
9666
|
+
logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9649
9667
|
|
|
9650
9668
|
// Stop screenshre if needed
|
|
9651
9669
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -9676,7 +9694,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9676
9694
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
9677
9695
|
}
|
|
9678
9696
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9679
|
-
logger$
|
|
9697
|
+
logger$7.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
9680
9698
|
|
|
9681
9699
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
9682
9700
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -9720,14 +9738,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9720
9738
|
}
|
|
9721
9739
|
|
|
9722
9740
|
mute(callSession , withEvent = true) {
|
|
9723
|
-
logger$
|
|
9741
|
+
logger$7.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
9724
9742
|
|
|
9725
9743
|
const sipSession = this.findSipSession(callSession);
|
|
9726
9744
|
if (!sipSession) {
|
|
9727
9745
|
return;
|
|
9728
9746
|
}
|
|
9729
9747
|
|
|
9730
|
-
logger$
|
|
9748
|
+
logger$7.info('WebRTC muting', { sipId: sipSession.id });
|
|
9731
9749
|
this.client.mute(sipSession);
|
|
9732
9750
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
9733
9751
|
|
|
@@ -9741,14 +9759,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9741
9759
|
}
|
|
9742
9760
|
|
|
9743
9761
|
unmute(callSession , withEvent = true) {
|
|
9744
|
-
logger$
|
|
9762
|
+
logger$7.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
9745
9763
|
|
|
9746
9764
|
const sipSession = this.findSipSession(callSession);
|
|
9747
9765
|
if (!sipSession) {
|
|
9748
9766
|
return;
|
|
9749
9767
|
}
|
|
9750
9768
|
|
|
9751
|
-
logger$
|
|
9769
|
+
logger$7.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
9752
9770
|
this.client.unmute(sipSession);
|
|
9753
9771
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
9754
9772
|
|
|
@@ -9775,7 +9793,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9775
9793
|
if (!sipSession) {
|
|
9776
9794
|
return;
|
|
9777
9795
|
}
|
|
9778
|
-
logger$
|
|
9796
|
+
logger$7.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
9779
9797
|
|
|
9780
9798
|
this.client.toggleCameraOn(sipSession);
|
|
9781
9799
|
|
|
@@ -9787,7 +9805,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9787
9805
|
if (!sipSession) {
|
|
9788
9806
|
return;
|
|
9789
9807
|
}
|
|
9790
|
-
logger$
|
|
9808
|
+
logger$7.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
9791
9809
|
|
|
9792
9810
|
this.client.toggleCameraOff(sipSession);
|
|
9793
9811
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -9799,7 +9817,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9799
9817
|
return;
|
|
9800
9818
|
}
|
|
9801
9819
|
|
|
9802
|
-
logger$
|
|
9820
|
+
logger$7.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
9803
9821
|
this.client.sendDTMF(sipSession, tone);
|
|
9804
9822
|
}
|
|
9805
9823
|
|
|
@@ -9807,7 +9825,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9807
9825
|
// @TODO: line is not used here
|
|
9808
9826
|
async makeCall(number , line , cameraEnabled ,
|
|
9809
9827
|
audioOnly = false, conference = false) {
|
|
9810
|
-
logger$
|
|
9828
|
+
logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled, audioOnly, conference });
|
|
9811
9829
|
if (!number) {
|
|
9812
9830
|
return Promise.resolve(null);
|
|
9813
9831
|
}
|
|
@@ -9817,7 +9835,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9817
9835
|
}
|
|
9818
9836
|
if (this.currentSipSession) {
|
|
9819
9837
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
9820
|
-
logger$
|
|
9838
|
+
logger$7.warn('Unable to hold current session when making another call', e);
|
|
9821
9839
|
});
|
|
9822
9840
|
}
|
|
9823
9841
|
|
|
@@ -9827,7 +9845,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9827
9845
|
this._bindEvents(sipSession);
|
|
9828
9846
|
} catch (error) {
|
|
9829
9847
|
console.warn(error);
|
|
9830
|
-
logger$
|
|
9848
|
+
logger$7.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
9831
9849
|
return Promise.resolve(null);
|
|
9832
9850
|
}
|
|
9833
9851
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -9855,7 +9873,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9855
9873
|
return;
|
|
9856
9874
|
}
|
|
9857
9875
|
|
|
9858
|
-
logger$
|
|
9876
|
+
logger$7.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
9859
9877
|
|
|
9860
9878
|
this.client.transfer(sipSession, target);
|
|
9861
9879
|
}
|
|
@@ -9864,7 +9882,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9864
9882
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
9865
9883
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
9866
9884
|
|
|
9867
|
-
logger$
|
|
9885
|
+
logger$7.info('WebRTC indirect transfer', {
|
|
9868
9886
|
sipId: sipSession ? sipSession.id : null,
|
|
9869
9887
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
9870
9888
|
});
|
|
@@ -9903,7 +9921,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9903
9921
|
return false;
|
|
9904
9922
|
}
|
|
9905
9923
|
|
|
9906
|
-
logger$
|
|
9924
|
+
logger$7.info('WebRTC hangup', { sipId: sipSession.id });
|
|
9907
9925
|
|
|
9908
9926
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9909
9927
|
|
|
@@ -9949,7 +9967,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9949
9967
|
endCurrentCall(callSession ) {
|
|
9950
9968
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
9951
9969
|
|
|
9952
|
-
logger$
|
|
9970
|
+
logger$7.info('Ending current call', {
|
|
9953
9971
|
id: callSession ? callSession.getId() : null,
|
|
9954
9972
|
isCurrent,
|
|
9955
9973
|
});
|
|
@@ -9973,7 +9991,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9973
9991
|
}
|
|
9974
9992
|
|
|
9975
9993
|
async close() {
|
|
9976
|
-
logger$
|
|
9994
|
+
logger$7.info('WebRTC close');
|
|
9977
9995
|
|
|
9978
9996
|
try {
|
|
9979
9997
|
await Promise.race([
|
|
@@ -9981,7 +9999,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9981
9999
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
9982
10000
|
]);
|
|
9983
10001
|
} catch (e) {
|
|
9984
|
-
logger$
|
|
10002
|
+
logger$7.error('WebRTC close, unregister error', e);
|
|
9985
10003
|
}
|
|
9986
10004
|
|
|
9987
10005
|
this.client.close();
|
|
@@ -9999,12 +10017,12 @@ class WebRTCPhone extends Emitter {
|
|
|
9999
10017
|
}
|
|
10000
10018
|
|
|
10001
10019
|
enableRinging() {
|
|
10002
|
-
logger$
|
|
10020
|
+
logger$7.info('WebRTC enable ringing');
|
|
10003
10021
|
this.ringingEnabled = true;
|
|
10004
10022
|
}
|
|
10005
10023
|
|
|
10006
10024
|
disableRinging() {
|
|
10007
|
-
logger$
|
|
10025
|
+
logger$7.info('WebRTC disable ringing');
|
|
10008
10026
|
this.ringingEnabled = false;
|
|
10009
10027
|
}
|
|
10010
10028
|
|
|
@@ -10044,7 +10062,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10044
10062
|
|
|
10045
10063
|
// Deprecated
|
|
10046
10064
|
getLocalMediaStream(callSession ) {
|
|
10047
|
-
logger$
|
|
10065
|
+
logger$7.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
10048
10066
|
return this.getLocalStream(callSession);
|
|
10049
10067
|
}
|
|
10050
10068
|
|
|
@@ -10086,7 +10104,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10086
10104
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
10087
10105
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
10088
10106
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
10089
|
-
logger$
|
|
10107
|
+
logger$7.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
10090
10108
|
|
|
10091
10109
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
10092
10110
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -10109,7 +10127,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10109
10127
|
});
|
|
10110
10128
|
|
|
10111
10129
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
10112
|
-
logger$
|
|
10130
|
+
logger$7.info('WebRTC on reinvite', {
|
|
10113
10131
|
sessionId: args[0].id,
|
|
10114
10132
|
inviteId: args[1].id,
|
|
10115
10133
|
updatedCalleeName: args[2],
|
|
@@ -10129,7 +10147,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10129
10147
|
});
|
|
10130
10148
|
|
|
10131
10149
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
10132
|
-
logger$
|
|
10150
|
+
logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
10133
10151
|
|
|
10134
10152
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
10135
10153
|
|
|
@@ -10140,22 +10158,22 @@ class WebRTCPhone extends Emitter {
|
|
|
10140
10158
|
this.client.on('ended', () => {});
|
|
10141
10159
|
|
|
10142
10160
|
this.client.on(this.client.ON_ERROR, e => {
|
|
10143
|
-
logger$
|
|
10161
|
+
logger$7.error('WebRTC error', e);
|
|
10144
10162
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
10145
10163
|
});
|
|
10146
10164
|
|
|
10147
10165
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
10148
|
-
logger$
|
|
10166
|
+
logger$7.info('WebRTC unregistered');
|
|
10149
10167
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10150
10168
|
});
|
|
10151
10169
|
|
|
10152
10170
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
10153
|
-
logger$
|
|
10154
|
-
this.eventEmitter.emit(ON_DISCONNECTED
|
|
10171
|
+
logger$7.info('WebRTC disconnected');
|
|
10172
|
+
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
10155
10173
|
});
|
|
10156
10174
|
|
|
10157
10175
|
this.client.on(this.client.REGISTERED, () => {
|
|
10158
|
-
logger$
|
|
10176
|
+
logger$7.info('WebRTC registered', {
|
|
10159
10177
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
10160
10178
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
10161
10179
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -10176,19 +10194,19 @@ class WebRTCPhone extends Emitter {
|
|
|
10176
10194
|
// Send reinvite with iceRestart
|
|
10177
10195
|
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
10178
10196
|
} catch (e) {
|
|
10179
|
-
logger$
|
|
10197
|
+
logger$7.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
10180
10198
|
}
|
|
10181
10199
|
}
|
|
10182
10200
|
});
|
|
10183
10201
|
|
|
10184
10202
|
this.client.on(this.client.CONNECTED, () => {
|
|
10185
|
-
logger$
|
|
10203
|
+
logger$7.info('WebRTC client connected');
|
|
10186
10204
|
|
|
10187
10205
|
this.stopHeartbeat();
|
|
10188
10206
|
});
|
|
10189
10207
|
|
|
10190
10208
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10191
|
-
logger$
|
|
10209
|
+
logger$7.info('WebRTC client disconnected');
|
|
10192
10210
|
|
|
10193
10211
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10194
10212
|
|
|
@@ -10202,7 +10220,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10202
10220
|
});
|
|
10203
10221
|
|
|
10204
10222
|
this.client.on(this.client.ON_TRACK, (session, event) => {
|
|
10205
|
-
this.eventEmitter.emit(ON_TRACK
|
|
10223
|
+
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
10206
10224
|
});
|
|
10207
10225
|
|
|
10208
10226
|
this.client.on('onVideoInputChange', stream => {
|
|
@@ -10217,7 +10235,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10217
10235
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
10218
10236
|
const callSession = this.getCallSession(this.getSipSessionId(session));
|
|
10219
10237
|
|
|
10220
|
-
this.eventEmitter.emit(ON_NETWORK_STATS
|
|
10238
|
+
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
10221
10239
|
});
|
|
10222
10240
|
|
|
10223
10241
|
// Used when upgrading directly in screenshare mode
|
|
@@ -10226,7 +10244,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10226
10244
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
10227
10245
|
const callSession = this.callSessions[sipSessionId];
|
|
10228
10246
|
|
|
10229
|
-
logger$
|
|
10247
|
+
logger$7.info('Updrading directly in screensharing mode', {
|
|
10230
10248
|
sipSessionId,
|
|
10231
10249
|
tracks: localStream ? localStream.getTracks() : null,
|
|
10232
10250
|
});
|
|
@@ -10404,8 +10422,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10404
10422
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10405
10423
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10406
10424
|
ON_MESSAGE: ON_MESSAGE,
|
|
10407
|
-
ON_REINVITE: ON_REINVITE
|
|
10408
|
-
ON_TRACK: ON_TRACK
|
|
10425
|
+
ON_REINVITE: ON_REINVITE,
|
|
10426
|
+
ON_TRACK: ON_TRACK,
|
|
10409
10427
|
ON_AUDIO_STREAM: ON_AUDIO_STREAM,
|
|
10410
10428
|
ON_VIDEO_STREAM: ON_VIDEO_STREAM,
|
|
10411
10429
|
ON_REMOVE_STREAM: ON_REMOVE_STREAM,
|
|
@@ -10420,13 +10438,13 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10420
10438
|
ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
|
|
10421
10439
|
ON_CALL_ERROR: ON_CALL_ERROR,
|
|
10422
10440
|
ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
|
|
10423
|
-
ON_NETWORK_STATS: ON_NETWORK_STATS
|
|
10441
|
+
ON_NETWORK_STATS: ON_NETWORK_STATS,
|
|
10424
10442
|
ON_CHAT: ON_CHAT,
|
|
10425
10443
|
ON_SIGNAL: ON_SIGNAL,
|
|
10426
|
-
ON_DISCONNECTED: ON_DISCONNECTED
|
|
10444
|
+
ON_DISCONNECTED: ON_DISCONNECTED,
|
|
10427
10445
|
MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
|
|
10428
10446
|
MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
|
|
10429
|
-
events: events
|
|
10447
|
+
events: events,
|
|
10430
10448
|
'default': WebRTCPhone
|
|
10431
10449
|
});
|
|
10432
10450
|
|
|
@@ -10820,7 +10838,7 @@ class Phone extends Emitter {
|
|
|
10820
10838
|
|
|
10821
10839
|
_transferEvents() {
|
|
10822
10840
|
this.unbind();
|
|
10823
|
-
[...events, ...transportEvents].forEach(event => {
|
|
10841
|
+
[...events$1, ...transportEvents].forEach(event => {
|
|
10824
10842
|
this.client.on(event, (...args) =>
|
|
10825
10843
|
this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
|
|
10826
10844
|
});
|
|
@@ -10842,7 +10860,7 @@ var Phone$1 = global.wazoTelephonyInstance;
|
|
|
10842
10860
|
|
|
10843
10861
|
//
|
|
10844
10862
|
|
|
10845
|
-
const SOCKET_EVENTS = {
|
|
10863
|
+
const SOCKET_EVENTS$1 = {
|
|
10846
10864
|
ON_OPEN: 'onopen',
|
|
10847
10865
|
ON_MESSAGE: 'onmessage',
|
|
10848
10866
|
ON_ERROR: 'onerror',
|
|
@@ -10938,7 +10956,7 @@ const BLACKLIST_EVENTS = [
|
|
|
10938
10956
|
];
|
|
10939
10957
|
|
|
10940
10958
|
const HEARTBEAT_ENGINE_VERSION = '20.09';
|
|
10941
|
-
const logger$
|
|
10959
|
+
const logger$5 = IssueReporter$1.loggerFor('wazo-ws');
|
|
10942
10960
|
const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
|
|
10943
10961
|
|
|
10944
10962
|
class WebSocketClient extends Emitter {
|
|
@@ -10987,24 +11005,24 @@ class WebSocketClient extends Emitter {
|
|
|
10987
11005
|
}
|
|
10988
11006
|
|
|
10989
11007
|
connect() {
|
|
10990
|
-
logger$
|
|
11008
|
+
logger$5.info('connect method started', { host: this.host, token: this.token });
|
|
10991
11009
|
this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
|
|
10992
11010
|
if (this.options.binaryType) {
|
|
10993
11011
|
this.socket.binaryType = this.options.binaryType;
|
|
10994
11012
|
}
|
|
10995
11013
|
|
|
10996
11014
|
this.socket.onopen = () => {
|
|
10997
|
-
logger$
|
|
10998
|
-
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
11015
|
+
logger$5.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
11016
|
+
this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
|
|
10999
11017
|
};
|
|
11000
11018
|
|
|
11001
11019
|
this.socket.onerror = event => {
|
|
11002
|
-
logger$
|
|
11003
|
-
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
11020
|
+
logger$5.error('on Wazo WS error', event.target);
|
|
11021
|
+
this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
|
|
11004
11022
|
};
|
|
11005
11023
|
|
|
11006
11024
|
this.socket.onmessage = (event ) => {
|
|
11007
|
-
this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
|
|
11025
|
+
this.eventEmitter.emit(SOCKET_EVENTS$1.ON_MESSAGE, event.data);
|
|
11008
11026
|
|
|
11009
11027
|
const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
|
|
11010
11028
|
let { name } = message;
|
|
@@ -11029,7 +11047,7 @@ class WebSocketClient extends Emitter {
|
|
|
11029
11047
|
|
|
11030
11048
|
this.socket.onclose = event => {
|
|
11031
11049
|
// Can't be converted to JSON (circular structure)
|
|
11032
|
-
logger$
|
|
11050
|
+
logger$5.info('on Wazo WS close', {
|
|
11033
11051
|
reason: event.reason,
|
|
11034
11052
|
code: event.code,
|
|
11035
11053
|
readyState: event.target.readyState,
|
|
@@ -11037,22 +11055,22 @@ class WebSocketClient extends Emitter {
|
|
|
11037
11055
|
token: this.token,
|
|
11038
11056
|
});
|
|
11039
11057
|
this.initialized = false;
|
|
11040
|
-
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
|
|
11058
|
+
this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, event);
|
|
11041
11059
|
|
|
11042
11060
|
switch (event.code) {
|
|
11043
11061
|
case 4002:
|
|
11044
|
-
this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
|
|
11062
|
+
this.eventEmitter.emit(SOCKET_EVENTS$1.ON_AUTH_FAILED);
|
|
11045
11063
|
break;
|
|
11046
11064
|
}
|
|
11047
11065
|
};
|
|
11048
11066
|
|
|
11049
11067
|
this.socket.onerror = event => {
|
|
11050
|
-
logger$
|
|
11068
|
+
logger$5.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
11051
11069
|
};
|
|
11052
11070
|
}
|
|
11053
11071
|
|
|
11054
11072
|
close(force = false) {
|
|
11055
|
-
logger$
|
|
11073
|
+
logger$5.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
11056
11074
|
|
|
11057
11075
|
if (!this.socket) {
|
|
11058
11076
|
return;
|
|
@@ -11070,7 +11088,7 @@ class WebSocketClient extends Emitter {
|
|
|
11070
11088
|
|
|
11071
11089
|
updateToken(token ) {
|
|
11072
11090
|
this.token = token;
|
|
11073
|
-
logger$
|
|
11091
|
+
logger$5.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
11074
11092
|
|
|
11075
11093
|
if (this.socket) {
|
|
11076
11094
|
// If still connected, send the token to the WS
|
|
@@ -11088,7 +11106,7 @@ class WebSocketClient extends Emitter {
|
|
|
11088
11106
|
}
|
|
11089
11107
|
|
|
11090
11108
|
startHeartbeat() {
|
|
11091
|
-
logger$
|
|
11109
|
+
logger$5.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
11092
11110
|
|
|
11093
11111
|
if (!this.socket) {
|
|
11094
11112
|
this.heartbeat.stop();
|
|
@@ -11102,7 +11120,7 @@ class WebSocketClient extends Emitter {
|
|
|
11102
11120
|
}
|
|
11103
11121
|
|
|
11104
11122
|
stopHeartbeat() {
|
|
11105
|
-
logger$
|
|
11123
|
+
logger$5.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
11106
11124
|
|
|
11107
11125
|
this.heartbeat.stop();
|
|
11108
11126
|
}
|
|
@@ -11132,7 +11150,7 @@ class WebSocketClient extends Emitter {
|
|
|
11132
11150
|
}
|
|
11133
11151
|
|
|
11134
11152
|
reconnect(reason ) {
|
|
11135
|
-
logger$
|
|
11153
|
+
logger$5.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
11136
11154
|
if (!this.socket) {
|
|
11137
11155
|
return;
|
|
11138
11156
|
}
|
|
@@ -11157,7 +11175,7 @@ class WebSocketClient extends Emitter {
|
|
|
11157
11175
|
break;
|
|
11158
11176
|
case 'start':
|
|
11159
11177
|
this.initialized = true;
|
|
11160
|
-
this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
|
|
11178
|
+
this.eventEmitter.emit(SOCKET_EVENTS$1.INITIALIZED);
|
|
11161
11179
|
break;
|
|
11162
11180
|
default:
|
|
11163
11181
|
this.eventEmitter.emit('message', message);
|
|
@@ -11188,7 +11206,7 @@ class WebSocketClient extends Emitter {
|
|
|
11188
11206
|
this.close();
|
|
11189
11207
|
}
|
|
11190
11208
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
11191
|
-
logger$
|
|
11209
|
+
logger$5.log('Wazo WS url computed to reconnect', { url });
|
|
11192
11210
|
|
|
11193
11211
|
return url;
|
|
11194
11212
|
}
|
|
@@ -11196,15 +11214,15 @@ class WebSocketClient extends Emitter {
|
|
|
11196
11214
|
_onHeartbeat(message ) {
|
|
11197
11215
|
if (message.payload === 'pong') {
|
|
11198
11216
|
this.heartbeat.onHeartbeat();
|
|
11199
|
-
logger$
|
|
11217
|
+
logger$5.log('on heartbeat received from Wazo WS');
|
|
11200
11218
|
}
|
|
11201
11219
|
}
|
|
11202
11220
|
|
|
11203
11221
|
async _onHeartbeatTimeout() {
|
|
11204
|
-
logger$
|
|
11222
|
+
logger$5.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
11205
11223
|
|
|
11206
11224
|
this.close();
|
|
11207
|
-
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
11225
|
+
this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
11208
11226
|
|
|
11209
11227
|
if (this.onHeartBeatTimeout) {
|
|
11210
11228
|
this.onHeartBeatTimeout();
|
|
@@ -11284,7 +11302,7 @@ WebSocketClient.eventLists = [
|
|
|
11284
11302
|
|
|
11285
11303
|
var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
11286
11304
|
__proto__: null,
|
|
11287
|
-
SOCKET_EVENTS: SOCKET_EVENTS,
|
|
11305
|
+
SOCKET_EVENTS: SOCKET_EVENTS$1,
|
|
11288
11306
|
AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
|
|
11289
11307
|
FAVORITE_ADDED: FAVORITE_ADDED,
|
|
11290
11308
|
FAVORITE_DELETED: FAVORITE_DELETED,
|
|
@@ -11357,10 +11375,10 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
11357
11375
|
|
|
11358
11376
|
//
|
|
11359
11377
|
|
|
11360
|
-
const { SOCKET_EVENTS
|
|
11361
|
-
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS
|
|
11378
|
+
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
11379
|
+
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
11362
11380
|
|
|
11363
|
-
const logger$
|
|
11381
|
+
const logger$4 = IssueReporter$1.loggerFor('simple-ws-client');
|
|
11364
11382
|
|
|
11365
11383
|
class Websocket extends Emitter {
|
|
11366
11384
|
|
|
@@ -11374,9 +11392,9 @@ class Websocket extends Emitter {
|
|
|
11374
11392
|
// $FlowFixMe
|
|
11375
11393
|
this[key] = OTHER_EVENTS[key];
|
|
11376
11394
|
});
|
|
11377
|
-
Object.keys(SOCKET_EVENTS
|
|
11395
|
+
Object.keys(SOCKET_EVENTS).forEach(key => {
|
|
11378
11396
|
// $FlowFixMe
|
|
11379
|
-
this[key] = SOCKET_EVENTS
|
|
11397
|
+
this[key] = SOCKET_EVENTS[key];
|
|
11380
11398
|
});
|
|
11381
11399
|
this.eventLists = WebSocketClient.eventLists;
|
|
11382
11400
|
|
|
@@ -11384,7 +11402,7 @@ class Websocket extends Emitter {
|
|
|
11384
11402
|
}
|
|
11385
11403
|
|
|
11386
11404
|
open(host , session ) {
|
|
11387
|
-
logger$
|
|
11405
|
+
logger$4.info('open simple WebSocket', { host, token: session.token });
|
|
11388
11406
|
this.ws = new WebSocketClient(
|
|
11389
11407
|
{
|
|
11390
11408
|
host,
|
|
@@ -11412,7 +11430,7 @@ class Websocket extends Emitter {
|
|
|
11412
11430
|
}
|
|
11413
11431
|
|
|
11414
11432
|
updateToken(token ) {
|
|
11415
|
-
logger$
|
|
11433
|
+
logger$4.info('update token via simple Websocket', { token, ws: !!this.ws });
|
|
11416
11434
|
|
|
11417
11435
|
if (!this.ws) {
|
|
11418
11436
|
return;
|
|
@@ -11440,12 +11458,12 @@ var Websocket$1 = global.wazoWebsocketInstance;
|
|
|
11440
11458
|
|
|
11441
11459
|
//
|
|
11442
11460
|
|
|
11443
|
-
const logger$
|
|
11461
|
+
const logger$3 = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
11444
11462
|
|
|
11445
|
-
class SipRoom extends Room
|
|
11463
|
+
class SipRoom extends Room {
|
|
11446
11464
|
|
|
11447
11465
|
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
11448
|
-
logger$
|
|
11466
|
+
logger$3.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
11449
11467
|
|
|
11450
11468
|
if (!room) {
|
|
11451
11469
|
await Wazo.Phone.connect();
|
|
@@ -11461,7 +11479,7 @@ class SipRoom extends Room$1 {
|
|
|
11461
11479
|
room.setCallId(room.callSession.call.id);
|
|
11462
11480
|
}
|
|
11463
11481
|
|
|
11464
|
-
logger$
|
|
11482
|
+
logger$3.info('connected to room', {
|
|
11465
11483
|
extension: room.extension,
|
|
11466
11484
|
});
|
|
11467
11485
|
|
|
@@ -11469,7 +11487,7 @@ class SipRoom extends Room$1 {
|
|
|
11469
11487
|
}
|
|
11470
11488
|
|
|
11471
11489
|
mute() {
|
|
11472
|
-
logger$
|
|
11490
|
+
logger$3.info('mute sip room');
|
|
11473
11491
|
|
|
11474
11492
|
Wazo.Phone.mute(this.callSession, false);
|
|
11475
11493
|
|
|
@@ -11477,7 +11495,7 @@ class SipRoom extends Room$1 {
|
|
|
11477
11495
|
}
|
|
11478
11496
|
|
|
11479
11497
|
unmute() {
|
|
11480
|
-
logger$
|
|
11498
|
+
logger$3.info('unmute sip room');
|
|
11481
11499
|
|
|
11482
11500
|
Wazo.Phone.unmute(this.callSession, false);
|
|
11483
11501
|
|
|
@@ -11579,7 +11597,7 @@ class SipRoom extends Room$1 {
|
|
|
11579
11597
|
|
|
11580
11598
|
//
|
|
11581
11599
|
|
|
11582
|
-
const logger$
|
|
11600
|
+
const logger$2 = IssueReporter$1.loggerFor('room');
|
|
11583
11601
|
|
|
11584
11602
|
class Participant extends Emitter {
|
|
11585
11603
|
|
|
@@ -11701,7 +11719,7 @@ class Participant extends Emitter {
|
|
|
11701
11719
|
}
|
|
11702
11720
|
|
|
11703
11721
|
onTalking(isTalking ) {
|
|
11704
|
-
logger$
|
|
11722
|
+
logger$2.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
|
|
11705
11723
|
this.isTalking = isTalking;
|
|
11706
11724
|
// you may notice we're not broadcasting: since all participants are getting this info
|
|
11707
11725
|
// directly from asterisk, there's no need to do so
|
|
@@ -11804,7 +11822,7 @@ class Participant extends Emitter {
|
|
|
11804
11822
|
}
|
|
11805
11823
|
|
|
11806
11824
|
updateStatus(status , broadcast = true) {
|
|
11807
|
-
logger$
|
|
11825
|
+
logger$2.info('updating participant status', { name: this.name, status });
|
|
11808
11826
|
|
|
11809
11827
|
if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
|
|
11810
11828
|
if (status.audioMuted) {
|
|
@@ -11852,7 +11870,7 @@ class Participant extends Emitter {
|
|
|
11852
11870
|
|
|
11853
11871
|
broadcastStatus(inboundStatus = null) {
|
|
11854
11872
|
const status = inboundStatus || this.getStatus();
|
|
11855
|
-
logger$
|
|
11873
|
+
logger$2.info('broadcasting participant status', { callId: this.callId, status });
|
|
11856
11874
|
|
|
11857
11875
|
this.room.sendSignal({
|
|
11858
11876
|
type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
|
|
@@ -12067,7 +12085,7 @@ class NotificationOptions {
|
|
|
12067
12085
|
|
|
12068
12086
|
|
|
12069
12087
|
// Represents a conference room, like `9000`.
|
|
12070
|
-
class Room {
|
|
12088
|
+
class Room$1 {
|
|
12071
12089
|
|
|
12072
12090
|
|
|
12073
12091
|
|
|
@@ -12088,7 +12106,7 @@ class Room {
|
|
|
12088
12106
|
}
|
|
12089
12107
|
|
|
12090
12108
|
connect(callSession ) {
|
|
12091
|
-
return new Room({ ...this, connectedCallSession: callSession });
|
|
12109
|
+
return new Room$1({ ...this, connectedCallSession: callSession });
|
|
12092
12110
|
}
|
|
12093
12111
|
|
|
12094
12112
|
has(callSession ) {
|
|
@@ -12097,7 +12115,7 @@ class Room {
|
|
|
12097
12115
|
|
|
12098
12116
|
addParticipant(uuid , extension , talking = null) {
|
|
12099
12117
|
if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
|
|
12100
|
-
return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
12118
|
+
return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
12101
12119
|
}
|
|
12102
12120
|
|
|
12103
12121
|
return this;
|
|
@@ -12116,7 +12134,7 @@ class Room {
|
|
|
12116
12134
|
updatedParticipants.push(participant);
|
|
12117
12135
|
}
|
|
12118
12136
|
|
|
12119
|
-
return new Room({ ...this, participants: updatedParticipants });
|
|
12137
|
+
return new Room$1({ ...this, participants: updatedParticipants });
|
|
12120
12138
|
}
|
|
12121
12139
|
|
|
12122
12140
|
updateParticipantByExtension(extension , participant , shouldAdd = false) {
|
|
@@ -12132,7 +12150,7 @@ class Room {
|
|
|
12132
12150
|
updatedParticipants.push(participant);
|
|
12133
12151
|
}
|
|
12134
12152
|
|
|
12135
|
-
return new Room({ ...this, participants: updatedParticipants });
|
|
12153
|
+
return new Room$1({ ...this, participants: updatedParticipants });
|
|
12136
12154
|
}
|
|
12137
12155
|
|
|
12138
12156
|
hasCallWithId(id ) {
|
|
@@ -12140,18 +12158,18 @@ class Room {
|
|
|
12140
12158
|
}
|
|
12141
12159
|
|
|
12142
12160
|
disconnect() {
|
|
12143
|
-
return new Room({ ...this, connectedCallSession: null });
|
|
12161
|
+
return new Room$1({ ...this, connectedCallSession: null });
|
|
12144
12162
|
}
|
|
12145
12163
|
|
|
12146
12164
|
removeParticipantWithUUID(uuid ) {
|
|
12147
|
-
return new Room({
|
|
12165
|
+
return new Room$1({
|
|
12148
12166
|
...this,
|
|
12149
12167
|
participants: this.participants.filter(participant => participant.uuid !== uuid),
|
|
12150
12168
|
});
|
|
12151
12169
|
}
|
|
12152
12170
|
|
|
12153
12171
|
removeParticipantWithExtension(extension ) {
|
|
12154
|
-
return new Room({
|
|
12172
|
+
return new Room$1({
|
|
12155
12173
|
...this,
|
|
12156
12174
|
participants: this.participants.filter(participant => participant.extension !== extension),
|
|
12157
12175
|
});
|
|
@@ -12162,7 +12180,7 @@ class Room {
|
|
|
12162
12180
|
}
|
|
12163
12181
|
|
|
12164
12182
|
static newFrom(room ) {
|
|
12165
|
-
return newFrom(room, Room);
|
|
12183
|
+
return newFrom(room, Room$1);
|
|
12166
12184
|
}
|
|
12167
12185
|
}
|
|
12168
12186
|
|
|
@@ -12469,11 +12487,11 @@ var wazoWebsocket = {
|
|
|
12469
12487
|
resolve();
|
|
12470
12488
|
};
|
|
12471
12489
|
|
|
12472
|
-
client.on(SOCKET_EVENTS.ON_ERROR, error => {
|
|
12490
|
+
client.on(SOCKET_EVENTS$1.ON_ERROR, error => {
|
|
12473
12491
|
handleError(`Connection error : ${error}`);
|
|
12474
12492
|
});
|
|
12475
12493
|
|
|
12476
|
-
client.on(SOCKET_EVENTS.ON_OPEN, () => {
|
|
12494
|
+
client.on(SOCKET_EVENTS$1.ON_OPEN, () => {
|
|
12477
12495
|
if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
|
|
12478
12496
|
client.setOnHeartbeatTimeout(() => {
|
|
12479
12497
|
handleError('No response to heartbeat');
|
|
@@ -12574,7 +12592,7 @@ var webrtc = {
|
|
|
12574
12592
|
}),
|
|
12575
12593
|
};
|
|
12576
12594
|
|
|
12577
|
-
const parseCandidate
|
|
12595
|
+
const parseCandidate = line => {
|
|
12578
12596
|
let parts;
|
|
12579
12597
|
// Parse both variants.
|
|
12580
12598
|
if (line.indexOf('a=candidate:') === 0) {
|
|
@@ -12665,7 +12683,7 @@ var SymmetricNat = {
|
|
|
12665
12683
|
}
|
|
12666
12684
|
|
|
12667
12685
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
12668
|
-
const cand = parseCandidate
|
|
12686
|
+
const cand = parseCandidate(e.candidate.candidate);
|
|
12669
12687
|
if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
|
|
12670
12688
|
candidates[cand.relatedPort].push(cand.port);
|
|
12671
12689
|
} else if (!e.candidate) {
|
|
@@ -12733,7 +12751,7 @@ var iceIpv4 = {
|
|
|
12733
12751
|
const rawCandidate = e.candidate.candidate;
|
|
12734
12752
|
if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
|
|
12735
12753
|
hasSrflxOrRelay = true;
|
|
12736
|
-
const candidate = parseCandidate
|
|
12754
|
+
const candidate = parseCandidate(e.candidate.candidate);
|
|
12737
12755
|
ips.push(candidate.ip);
|
|
12738
12756
|
}
|
|
12739
12757
|
} else if (!e.candidate) {
|
|
@@ -12770,7 +12788,7 @@ var checks = [
|
|
|
12770
12788
|
|
|
12771
12789
|
//
|
|
12772
12790
|
|
|
12773
|
-
const logger$
|
|
12791
|
+
const logger$1 = IssueReporter$1.loggerFor('engine-check');
|
|
12774
12792
|
|
|
12775
12793
|
class Checker {
|
|
12776
12794
|
|
|
@@ -12788,28 +12806,28 @@ class Checker {
|
|
|
12788
12806
|
async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
|
|
12789
12807
|
await this._addEngineVersion();
|
|
12790
12808
|
|
|
12791
|
-
logger$
|
|
12809
|
+
logger$1.info('Engine check starting');
|
|
12792
12810
|
|
|
12793
12811
|
for (let i = 0; i < this.checks.length; i++) {
|
|
12794
12812
|
const { name, check } = this.checks[i];
|
|
12795
12813
|
|
|
12796
|
-
logger$
|
|
12814
|
+
logger$1.info(`Checking ${name} ...`);
|
|
12797
12815
|
|
|
12798
12816
|
onCheckBegin(name);
|
|
12799
12817
|
try {
|
|
12800
12818
|
// eslint-disable-next-line no-await-in-loop
|
|
12801
12819
|
const result = await check(this.server, this.session, this.externalAppConfig);
|
|
12802
|
-
logger$
|
|
12820
|
+
logger$1.info(`Checking ${name} success.`, { result });
|
|
12803
12821
|
|
|
12804
12822
|
onCheckResult(name, result);
|
|
12805
12823
|
} catch (e) {
|
|
12806
|
-
logger$
|
|
12824
|
+
logger$1.info(`Checking ${name} failure`, { message: e.message });
|
|
12807
12825
|
|
|
12808
12826
|
onCheckResult(name, e);
|
|
12809
12827
|
}
|
|
12810
12828
|
}
|
|
12811
12829
|
|
|
12812
|
-
logger$
|
|
12830
|
+
logger$1.info('Engine check done.');
|
|
12813
12831
|
}
|
|
12814
12832
|
|
|
12815
12833
|
addCheck(check ) {
|
|
@@ -12833,7 +12851,7 @@ const Wazo = {
|
|
|
12833
12851
|
Auth: Auth$1,
|
|
12834
12852
|
Phone: Phone$1,
|
|
12835
12853
|
Websocket: Websocket$1,
|
|
12836
|
-
Room
|
|
12854
|
+
Room,
|
|
12837
12855
|
SipRoom,
|
|
12838
12856
|
RemoteParticipant,
|
|
12839
12857
|
LocalParticipant,
|
|
@@ -12866,7 +12884,7 @@ const Wazo = {
|
|
|
12866
12884
|
Session,
|
|
12867
12885
|
Voicemail,
|
|
12868
12886
|
Relocation,
|
|
12869
|
-
ConferenceRoom: Room,
|
|
12887
|
+
ConferenceRoom: Room$1,
|
|
12870
12888
|
CallSession,
|
|
12871
12889
|
IndirectTransfer,
|
|
12872
12890
|
SwitchboardCall,
|
|
@@ -12905,9 +12923,9 @@ if (global) {
|
|
|
12905
12923
|
const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
12906
12924
|
const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
12907
12925
|
|
|
12908
|
-
const logger
|
|
12926
|
+
const logger = IssueReporter$1.loggerFor('sdk-room');
|
|
12909
12927
|
|
|
12910
|
-
class Room
|
|
12928
|
+
class Room extends Emitter {
|
|
12911
12929
|
|
|
12912
12930
|
|
|
12913
12931
|
|
|
@@ -12965,7 +12983,7 @@ class Room$1 extends Emitter {
|
|
|
12965
12983
|
extra = {},
|
|
12966
12984
|
) {
|
|
12967
12985
|
super();
|
|
12968
|
-
logger
|
|
12986
|
+
logger.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
12969
12987
|
|
|
12970
12988
|
// Represents the room callSession
|
|
12971
12989
|
this.callSession = callSession;
|
|
@@ -13031,7 +13049,7 @@ class Room$1 extends Emitter {
|
|
|
13031
13049
|
* @returns {Promise<Room>}
|
|
13032
13050
|
*/
|
|
13033
13051
|
static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
|
|
13034
|
-
logger
|
|
13052
|
+
logger.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
13035
13053
|
|
|
13036
13054
|
if (!room) {
|
|
13037
13055
|
await Wazo.Phone.connect();
|
|
@@ -13044,7 +13062,7 @@ class Room$1 extends Emitter {
|
|
|
13044
13062
|
|
|
13045
13063
|
// Call_created is triggered before call_accepted, so we have to listen for it here.
|
|
13046
13064
|
Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
|
|
13047
|
-
logger
|
|
13065
|
+
logger.info('room call received via WS', { callId: data.call_id });
|
|
13048
13066
|
if (room) {
|
|
13049
13067
|
room.setCallId(data.call_id);
|
|
13050
13068
|
}
|
|
@@ -13052,7 +13070,7 @@ class Room$1 extends Emitter {
|
|
|
13052
13070
|
|
|
13053
13071
|
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
13054
13072
|
// eslint-disable-next-line no-param-reassign
|
|
13055
|
-
room = new Room
|
|
13073
|
+
room = new Room(callSession, extension, null, null, extra);
|
|
13056
13074
|
|
|
13057
13075
|
// Wait for the call to be accepted
|
|
13058
13076
|
await new Promise((resolve, reject) => {
|
|
@@ -13073,7 +13091,7 @@ class Room$1 extends Emitter {
|
|
|
13073
13091
|
// Retrieve conference
|
|
13074
13092
|
const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
|
|
13075
13093
|
|
|
13076
|
-
logger
|
|
13094
|
+
logger.info('connected to room', {
|
|
13077
13095
|
sourceId: conference ? conference.sourceId : null,
|
|
13078
13096
|
name: conference ? conference.name : null,
|
|
13079
13097
|
});
|
|
@@ -13083,7 +13101,7 @@ class Room$1 extends Emitter {
|
|
|
13083
13101
|
room.setName(conference.name);
|
|
13084
13102
|
}
|
|
13085
13103
|
} else if (meeting) {
|
|
13086
|
-
logger
|
|
13104
|
+
logger.info('Already connected to meeting', {
|
|
13087
13105
|
uuid: meeting.uuid,
|
|
13088
13106
|
name: meeting.name,
|
|
13089
13107
|
});
|
|
@@ -13096,13 +13114,13 @@ class Room$1 extends Emitter {
|
|
|
13096
13114
|
}
|
|
13097
13115
|
|
|
13098
13116
|
static disconnect() {
|
|
13099
|
-
logger
|
|
13117
|
+
logger.info('static disconnection to room');
|
|
13100
13118
|
|
|
13101
13119
|
Wazo.Phone.disconnect();
|
|
13102
13120
|
}
|
|
13103
13121
|
|
|
13104
13122
|
async disconnect() {
|
|
13105
|
-
logger
|
|
13123
|
+
logger.info('disconnection to room called');
|
|
13106
13124
|
|
|
13107
13125
|
await Wazo.Phone.hangup(this.callSession);
|
|
13108
13126
|
this.callSession = null;
|
|
@@ -13122,19 +13140,19 @@ class Room$1 extends Emitter {
|
|
|
13122
13140
|
}
|
|
13123
13141
|
|
|
13124
13142
|
setSourceId(sourceId ) {
|
|
13125
|
-
logger
|
|
13143
|
+
logger.info('set room source id', { sourceId });
|
|
13126
13144
|
|
|
13127
13145
|
this.sourceId = sourceId;
|
|
13128
13146
|
}
|
|
13129
13147
|
|
|
13130
13148
|
setMeetingUuid(meetingUuid ) {
|
|
13131
|
-
logger
|
|
13149
|
+
logger.info('set meeting uuid', { meetingUuid });
|
|
13132
13150
|
|
|
13133
13151
|
this.meetingUuid = meetingUuid;
|
|
13134
13152
|
}
|
|
13135
13153
|
|
|
13136
13154
|
setCallId(callId ) {
|
|
13137
|
-
logger
|
|
13155
|
+
logger.info('set room call id', { callId });
|
|
13138
13156
|
|
|
13139
13157
|
if (callId) {
|
|
13140
13158
|
this.callId = callId;
|
|
@@ -13142,7 +13160,7 @@ class Room$1 extends Emitter {
|
|
|
13142
13160
|
}
|
|
13143
13161
|
|
|
13144
13162
|
setName(name ) {
|
|
13145
|
-
logger
|
|
13163
|
+
logger.info('set room name', { name });
|
|
13146
13164
|
|
|
13147
13165
|
this.name = name;
|
|
13148
13166
|
}
|
|
@@ -13161,7 +13179,7 @@ class Room$1 extends Emitter {
|
|
|
13161
13179
|
}
|
|
13162
13180
|
|
|
13163
13181
|
async startScreenSharing(constraints ) {
|
|
13164
|
-
logger
|
|
13182
|
+
logger.info('start room screen sharing', { constraints });
|
|
13165
13183
|
|
|
13166
13184
|
const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
|
|
13167
13185
|
if (!screensharingStream) {
|
|
@@ -13175,7 +13193,7 @@ class Room$1 extends Emitter {
|
|
|
13175
13193
|
}
|
|
13176
13194
|
|
|
13177
13195
|
async stopScreenSharing(restoreLocalStream = true) {
|
|
13178
|
-
logger
|
|
13196
|
+
logger.info('stop room screen sharing');
|
|
13179
13197
|
|
|
13180
13198
|
await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
13181
13199
|
|
|
@@ -13187,7 +13205,7 @@ class Room$1 extends Emitter {
|
|
|
13187
13205
|
}
|
|
13188
13206
|
|
|
13189
13207
|
turnCameraOff() {
|
|
13190
|
-
logger
|
|
13208
|
+
logger.info('turn room camera off');
|
|
13191
13209
|
|
|
13192
13210
|
Wazo.Phone.turnCameraOff(this.callSession);
|
|
13193
13211
|
|
|
@@ -13197,7 +13215,7 @@ class Room$1 extends Emitter {
|
|
|
13197
13215
|
}
|
|
13198
13216
|
|
|
13199
13217
|
turnCameraOn() {
|
|
13200
|
-
logger
|
|
13218
|
+
logger.info('turn room camera on');
|
|
13201
13219
|
|
|
13202
13220
|
Wazo.Phone.turnCameraOn(this.callSession);
|
|
13203
13221
|
|
|
@@ -13207,7 +13225,7 @@ class Room$1 extends Emitter {
|
|
|
13207
13225
|
}
|
|
13208
13226
|
|
|
13209
13227
|
mute() {
|
|
13210
|
-
logger
|
|
13228
|
+
logger.info('mute room');
|
|
13211
13229
|
|
|
13212
13230
|
Wazo.Phone.mute(this.callSession);
|
|
13213
13231
|
|
|
@@ -13215,7 +13233,7 @@ class Room$1 extends Emitter {
|
|
|
13215
13233
|
}
|
|
13216
13234
|
|
|
13217
13235
|
unmute() {
|
|
13218
|
-
logger
|
|
13236
|
+
logger.info('unmute room');
|
|
13219
13237
|
|
|
13220
13238
|
Wazo.Phone.unmute(this.callSession);
|
|
13221
13239
|
|
|
@@ -13235,7 +13253,7 @@ class Room$1 extends Emitter {
|
|
|
13235
13253
|
}
|
|
13236
13254
|
|
|
13237
13255
|
hold() {
|
|
13238
|
-
logger
|
|
13256
|
+
logger.info('hold room');
|
|
13239
13257
|
|
|
13240
13258
|
Wazo.Phone.hold(this.callSession, true);
|
|
13241
13259
|
|
|
@@ -13245,7 +13263,7 @@ class Room$1 extends Emitter {
|
|
|
13245
13263
|
}
|
|
13246
13264
|
|
|
13247
13265
|
async resume() {
|
|
13248
|
-
logger
|
|
13266
|
+
logger.info('resume room');
|
|
13249
13267
|
|
|
13250
13268
|
const newStream = await Wazo.Phone.resume(this.callSession, true);
|
|
13251
13269
|
|
|
@@ -13273,13 +13291,13 @@ class Room$1 extends Emitter {
|
|
|
13273
13291
|
}
|
|
13274
13292
|
|
|
13275
13293
|
sendDTMF(tone ) {
|
|
13276
|
-
logger
|
|
13294
|
+
logger.info('send room DTMF', { tone });
|
|
13277
13295
|
|
|
13278
13296
|
Wazo.Phone.sendDTMF(tone, this.callSession);
|
|
13279
13297
|
}
|
|
13280
13298
|
|
|
13281
13299
|
async sendReinvite(newConstraints = null) {
|
|
13282
|
-
logger
|
|
13300
|
+
logger.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
13283
13301
|
const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
|
|
13284
13302
|
|
|
13285
13303
|
Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
|
|
@@ -13338,7 +13356,7 @@ class Room$1 extends Emitter {
|
|
|
13338
13356
|
Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
13339
13357
|
|
|
13340
13358
|
this.on(this.ON_AUDIO_STREAM, stream => {
|
|
13341
|
-
logger
|
|
13359
|
+
logger.info('on room audio stream');
|
|
13342
13360
|
|
|
13343
13361
|
this.audioStream = stream;
|
|
13344
13362
|
if (!this.roomAudioElement) {
|
|
@@ -13351,7 +13369,7 @@ class Room$1 extends Emitter {
|
|
|
13351
13369
|
});
|
|
13352
13370
|
|
|
13353
13371
|
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
13354
|
-
logger
|
|
13372
|
+
logger.info('on room video stream', { streamId });
|
|
13355
13373
|
|
|
13356
13374
|
this._mapMsid(sipSession.body.body);
|
|
13357
13375
|
|
|
@@ -13366,7 +13384,7 @@ class Room$1 extends Emitter {
|
|
|
13366
13384
|
});
|
|
13367
13385
|
|
|
13368
13386
|
this.on(this.ON_REMOVE_STREAM, stream => {
|
|
13369
|
-
logger
|
|
13387
|
+
logger.info('on room remove stream');
|
|
13370
13388
|
|
|
13371
13389
|
const participant = this.participants.find(someParticipant =>
|
|
13372
13390
|
someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
|
|
@@ -13498,7 +13516,7 @@ class Room$1 extends Emitter {
|
|
|
13498
13516
|
const requester = this._getParticipantFromCallId(origin.callId);
|
|
13499
13517
|
if (requester) {
|
|
13500
13518
|
// @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
|
|
13501
|
-
logger
|
|
13519
|
+
logger.info('trigger room requester status', { origin });
|
|
13502
13520
|
requester.triggerUpdate('REQUESTER_UPDATE');
|
|
13503
13521
|
}
|
|
13504
13522
|
break;
|
|
@@ -13529,24 +13547,24 @@ class Room$1 extends Emitter {
|
|
|
13529
13547
|
|
|
13530
13548
|
// When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
|
|
13531
13549
|
if (participant.user_uuid === session.uuid) {
|
|
13532
|
-
logger
|
|
13550
|
+
logger.info('room current user joined');
|
|
13533
13551
|
|
|
13534
13552
|
// Retrieve participants via an API calls
|
|
13535
13553
|
const conferenceId = this.sourceId || payload.data.conference_id;
|
|
13536
13554
|
let response;
|
|
13537
13555
|
try {
|
|
13538
13556
|
if (this.meetingUuid) {
|
|
13539
|
-
logger
|
|
13557
|
+
logger.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
13540
13558
|
response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
|
|
13541
13559
|
} else {
|
|
13542
|
-
logger
|
|
13560
|
+
logger.info('fetching conference participants', { conferenceId });
|
|
13543
13561
|
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
13544
13562
|
}
|
|
13545
13563
|
} catch (e) {
|
|
13546
|
-
logger
|
|
13564
|
+
logger.error('room participants fetching, error', e);
|
|
13547
13565
|
}
|
|
13548
13566
|
if (response) {
|
|
13549
|
-
logger
|
|
13567
|
+
logger.info('conference participants fetched', { nb: response.items.length });
|
|
13550
13568
|
participants = response.items.map(item => {
|
|
13551
13569
|
const isMe = item.call_id === this.callId;
|
|
13552
13570
|
|
|
@@ -13573,7 +13591,7 @@ class Room$1 extends Emitter {
|
|
|
13573
13591
|
? new Wazo.RemoteParticipant(this, participant)
|
|
13574
13592
|
: null;
|
|
13575
13593
|
|
|
13576
|
-
logger
|
|
13594
|
+
logger.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
13577
13595
|
|
|
13578
13596
|
if (remoteParticipant) {
|
|
13579
13597
|
this.participants.push(remoteParticipant);
|
|
@@ -13738,4 +13756,4 @@ class Room$1 extends Emitter {
|
|
|
13738
13756
|
|
|
13739
13757
|
exports.SIGNAL_TYPE_PARTICIPANT_REQUEST = SIGNAL_TYPE_PARTICIPANT_REQUEST;
|
|
13740
13758
|
exports.SIGNAL_TYPE_PARTICIPANT_UPDATE = SIGNAL_TYPE_PARTICIPANT_UPDATE;
|
|
13741
|
-
exports.default = Room
|
|
13759
|
+
exports.default = Room;
|