@wazo/sdk 0.37.23 → 0.37.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/api-client.test.js +22 -17
- package/esm/__tests__/web-rtc-client.test.js +105 -100
- package/esm/api/amid.js +1 -1
- package/esm/api/call-logd.js +2 -2
- package/esm/api/confd.js +10 -5
- package/esm/api/ctid-ng.js +3 -3
- package/esm/api/dird.js +1 -1
- package/esm/api/webhookd.js +1 -1
- package/esm/api-client.js +22 -17
- package/esm/checker/Checker.js +130 -125
- package/esm/checker/checks/aor.js +22 -17
- package/esm/checker/checks/api.js +22 -17
- package/esm/checker/checks/index.js +120 -115
- package/esm/checker/checks/wazo-websocket.js +15 -15
- package/esm/checker/checks/webrtc-transport.js +105 -100
- package/esm/checker/checks/webrtc.js +105 -100
- package/esm/domain/AdHocAPIConference.js +22 -17
- package/esm/domain/CallLog.js +1 -1
- package/esm/domain/Contact.js +1 -1
- package/esm/domain/Features.js +22 -17
- package/esm/domain/Meeting.js +12 -5
- package/esm/domain/Phone/CTIPhone.js +36 -31
- package/esm/domain/Phone/WebRTCPhone.js +110 -87
- package/esm/domain/__tests__/CallLog.test.js +1 -1
- package/esm/domain/__tests__/Contact.test.js +1 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/index.js +365 -337
- package/esm/lib/WazoSessionDescriptionHandler.js +1 -1
- package/esm/service/CallApi.js +22 -17
- package/esm/service/IssueReporter.js +1 -1
- package/esm/service/__tests__/IssueReporter.test.js +1 -1
- package/esm/service/getApiClient.js +22 -17
- package/esm/simple/Auth.js +355 -327
- package/esm/simple/Configuration.js +355 -327
- package/esm/simple/Directory.js +22 -17
- package/esm/simple/Phone.js +355 -327
- package/esm/simple/Websocket.js +17 -17
- package/esm/simple/index.js +359 -331
- package/esm/simple/room/LocalParticipant.js +359 -331
- package/esm/simple/room/Participant.js +359 -331
- package/esm/simple/room/RemoteParticipant.js +359 -331
- package/esm/simple/room/Room.js +360 -332
- package/esm/simple/room/SipRoom.js +359 -331
- package/esm/simple/room/Stream.js +359 -331
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +359 -331
- package/esm/simple/utils.js +359 -331
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/web-rtc-client.js +105 -100
- package/esm/websocket-client.js +15 -15
- package/lib/__tests__/api-client.test.js +22 -17
- package/lib/__tests__/web-rtc-client.test.js +105 -100
- package/lib/api/amid.js +1 -1
- package/lib/api/call-logd.js +2 -2
- package/lib/api/confd.js +10 -5
- package/lib/api/ctid-ng.js +3 -3
- package/lib/api/dird.js +1 -1
- package/lib/api/webhookd.js +1 -1
- package/lib/api-client.js +22 -17
- package/lib/checker/Checker.js +130 -125
- package/lib/checker/checks/aor.js +22 -17
- package/lib/checker/checks/api.js +22 -17
- package/lib/checker/checks/index.js +120 -115
- package/lib/checker/checks/wazo-websocket.js +15 -15
- package/lib/checker/checks/webrtc-transport.js +105 -100
- package/lib/checker/checks/webrtc.js +105 -100
- package/lib/domain/AdHocAPIConference.js +22 -17
- package/lib/domain/CallLog.js +1 -1
- package/lib/domain/Contact.js +1 -1
- package/lib/domain/Features.js +22 -17
- package/lib/domain/Meeting.js +16 -5
- package/lib/domain/Phone/CTIPhone.js +36 -31
- package/lib/domain/Phone/WebRTCPhone.js +110 -87
- package/lib/domain/__tests__/CallLog.test.js +1 -1
- package/lib/domain/__tests__/Contact.test.js +1 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/index.js +365 -337
- package/lib/lib/WazoSessionDescriptionHandler.js +1 -1
- package/lib/service/CallApi.js +22 -17
- package/lib/service/IssueReporter.js +1 -1
- package/lib/service/__tests__/IssueReporter.test.js +1 -1
- package/lib/service/getApiClient.js +22 -17
- package/lib/simple/Auth.js +355 -327
- package/lib/simple/Configuration.js +355 -327
- package/lib/simple/Directory.js +22 -17
- package/lib/simple/Phone.js +355 -327
- package/lib/simple/Websocket.js +17 -17
- package/lib/simple/index.js +359 -331
- package/lib/simple/room/LocalParticipant.js +359 -331
- package/lib/simple/room/Participant.js +359 -331
- package/lib/simple/room/RemoteParticipant.js +359 -331
- package/lib/simple/room/Room.js +360 -332
- package/lib/simple/room/SipRoom.js +359 -331
- package/lib/simple/room/Stream.js +359 -331
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +359 -331
- package/lib/simple/utils.js +359 -331
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/web-rtc-client.js +105 -100
- package/lib/websocket-client.js +15 -15
- package/package.json +1 -1
- package/src/domain/Meeting.js +12 -5
- package/src/domain/Phone/WebRTCPhone.js +24 -1
- package/src/domain/__tests__/Meeting.test.js +50 -0
|
@@ -1957,7 +1957,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
1957
1957
|
|
|
1958
1958
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
1959
1959
|
|
|
1960
|
-
const logger
|
|
1960
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
1961
1961
|
|
|
1962
1962
|
// Use a function here to be able to mock it in tests
|
|
1963
1963
|
const realFetch = () => {
|
|
@@ -2096,7 +2096,7 @@ class ApiRequester {
|
|
|
2096
2096
|
};
|
|
2097
2097
|
|
|
2098
2098
|
if (this.refreshTokenPromise) {
|
|
2099
|
-
logger
|
|
2099
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
2100
2100
|
await this.refreshTokenPromise;
|
|
2101
2101
|
}
|
|
2102
2102
|
|
|
@@ -2116,7 +2116,7 @@ class ApiRequester {
|
|
|
2116
2116
|
return promise.then(async (err ) => {
|
|
2117
2117
|
// Check if the token is still valid
|
|
2118
2118
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
2119
|
-
logger
|
|
2119
|
+
logger.warn('token expired', { error: err.reason });
|
|
2120
2120
|
// Replay the call after refreshing the token
|
|
2121
2121
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
2122
2122
|
}
|
|
@@ -2126,7 +2126,7 @@ class ApiRequester {
|
|
|
2126
2126
|
: exceptionClass.fromResponse(err, response.status);
|
|
2127
2127
|
|
|
2128
2128
|
if (this.shouldLogErrors) {
|
|
2129
|
-
logger
|
|
2129
|
+
logger.error('API error', error);
|
|
2130
2130
|
}
|
|
2131
2131
|
|
|
2132
2132
|
throw error;
|
|
@@ -2136,7 +2136,7 @@ class ApiRequester {
|
|
|
2136
2136
|
return newParse(response, isJson);
|
|
2137
2137
|
}).catch(error => {
|
|
2138
2138
|
if (this.shouldLogErrors) {
|
|
2139
|
-
logger
|
|
2139
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
2140
2140
|
}
|
|
2141
2141
|
|
|
2142
2142
|
throw error;
|
|
@@ -2164,13 +2164,13 @@ class ApiRequester {
|
|
|
2164
2164
|
) {
|
|
2165
2165
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
2166
2166
|
let newPath = path;
|
|
2167
|
-
logger
|
|
2167
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
2168
2168
|
|
|
2169
2169
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
2170
2170
|
|
|
2171
2171
|
return this.refreshTokenPromise.then(() => {
|
|
2172
2172
|
this.refreshTokenPromise = null;
|
|
2173
|
-
logger
|
|
2173
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
2174
2174
|
if (isTokenNotFound) {
|
|
2175
2175
|
const pathParts = path.split('/');
|
|
2176
2176
|
pathParts.pop();
|
|
@@ -2640,8 +2640,9 @@ class ExternalApp {
|
|
|
2640
2640
|
|
|
2641
2641
|
|
|
2642
2642
|
|
|
2643
|
-
|
|
2643
|
+
|
|
2644
2644
|
|
|
2645
|
+
|
|
2645
2646
|
|
|
2646
2647
|
|
|
2647
2648
|
class Meeting {
|
|
@@ -2652,9 +2653,10 @@ class Meeting {
|
|
|
2652
2653
|
|
|
2653
2654
|
|
|
2654
2655
|
|
|
2655
|
-
|
|
2656
|
+
|
|
2656
2657
|
|
|
2657
2658
|
|
|
2659
|
+
|
|
2658
2660
|
|
|
2659
2661
|
static parse(plain ) {
|
|
2660
2662
|
return new Meeting({
|
|
@@ -2664,8 +2666,9 @@ class Meeting {
|
|
|
2664
2666
|
ownerUuids: plain.owner_uuids,
|
|
2665
2667
|
port: plain.port,
|
|
2666
2668
|
uuid: plain.uuid,
|
|
2667
|
-
|
|
2669
|
+
extension: plain.exten,
|
|
2668
2670
|
persistent: plain.persistent,
|
|
2671
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
2669
2672
|
});
|
|
2670
2673
|
}
|
|
2671
2674
|
|
|
@@ -2687,8 +2690,9 @@ class Meeting {
|
|
|
2687
2690
|
ownerUuids,
|
|
2688
2691
|
port,
|
|
2689
2692
|
uri,
|
|
2690
|
-
|
|
2693
|
+
extension,
|
|
2691
2694
|
persistent,
|
|
2695
|
+
creationTime,
|
|
2692
2696
|
} = {}) {
|
|
2693
2697
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2694
2698
|
this.uri = uri;
|
|
@@ -2696,8 +2700,9 @@ class Meeting {
|
|
|
2696
2700
|
this.ownerUuids = ownerUuids;
|
|
2697
2701
|
this.port = port;
|
|
2698
2702
|
this.uuid = uuid;
|
|
2699
|
-
this.
|
|
2703
|
+
this.extension = extension;
|
|
2700
2704
|
this.persistent = persistent;
|
|
2705
|
+
this.creationTime = creationTime;
|
|
2701
2706
|
|
|
2702
2707
|
// Useful to compare instead of instanceof with minified code
|
|
2703
2708
|
this.type = 'Meeting';
|
|
@@ -4058,7 +4063,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
4058
4063
|
|
|
4059
4064
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
4060
4065
|
|
|
4061
|
-
const logger$
|
|
4066
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
4062
4067
|
|
|
4063
4068
|
class CTIPhone extends Emitter {
|
|
4064
4069
|
|
|
@@ -4071,7 +4076,7 @@ class CTIPhone extends Emitter {
|
|
|
4071
4076
|
|
|
4072
4077
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
4073
4078
|
super();
|
|
4074
|
-
logger$
|
|
4079
|
+
logger$1.info('CTI Phone created');
|
|
4075
4080
|
this.session = session;
|
|
4076
4081
|
this.isMobile = isMobile;
|
|
4077
4082
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -4132,7 +4137,7 @@ class CTIPhone extends Emitter {
|
|
|
4132
4137
|
}
|
|
4133
4138
|
|
|
4134
4139
|
async makeCall(number , line ) {
|
|
4135
|
-
logger$
|
|
4140
|
+
logger$1.info('make CTI call', { number });
|
|
4136
4141
|
|
|
4137
4142
|
if (!number) {
|
|
4138
4143
|
return null;
|
|
@@ -4155,7 +4160,7 @@ class CTIPhone extends Emitter {
|
|
|
4155
4160
|
if (!callSession) {
|
|
4156
4161
|
return Promise.resolve(null);
|
|
4157
4162
|
}
|
|
4158
|
-
logger$
|
|
4163
|
+
logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4159
4164
|
|
|
4160
4165
|
if (!this.currentCall) {
|
|
4161
4166
|
this.currentCall = callSession.call;
|
|
@@ -4168,7 +4173,7 @@ class CTIPhone extends Emitter {
|
|
|
4168
4173
|
if (!callSession) {
|
|
4169
4174
|
return;
|
|
4170
4175
|
}
|
|
4171
|
-
logger$
|
|
4176
|
+
logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4172
4177
|
|
|
4173
4178
|
this.currentCall = undefined;
|
|
4174
4179
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4178,7 +4183,7 @@ class CTIPhone extends Emitter {
|
|
|
4178
4183
|
if (!callSession) {
|
|
4179
4184
|
return Promise.resolve(false);
|
|
4180
4185
|
}
|
|
4181
|
-
logger$
|
|
4186
|
+
logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4182
4187
|
|
|
4183
4188
|
try {
|
|
4184
4189
|
await CallApi.cancelCall(callSession);
|
|
@@ -4189,7 +4194,7 @@ class CTIPhone extends Emitter {
|
|
|
4189
4194
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
4190
4195
|
return true;
|
|
4191
4196
|
} catch (e) {
|
|
4192
|
-
logger$
|
|
4197
|
+
logger$1.error('hangup CTI call, error', e);
|
|
4193
4198
|
|
|
4194
4199
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
4195
4200
|
return false;
|
|
@@ -4202,7 +4207,7 @@ class CTIPhone extends Emitter {
|
|
|
4202
4207
|
if (!callSession) {
|
|
4203
4208
|
return;
|
|
4204
4209
|
}
|
|
4205
|
-
logger$
|
|
4210
|
+
logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4206
4211
|
|
|
4207
4212
|
await CallApi.cancelCall(callSession);
|
|
4208
4213
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4212,7 +4217,7 @@ class CTIPhone extends Emitter {
|
|
|
4212
4217
|
if (!callSession) {
|
|
4213
4218
|
return;
|
|
4214
4219
|
}
|
|
4215
|
-
logger$
|
|
4220
|
+
logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4216
4221
|
|
|
4217
4222
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
4218
4223
|
}
|
|
@@ -4225,19 +4230,19 @@ class CTIPhone extends Emitter {
|
|
|
4225
4230
|
if (!callSession) {
|
|
4226
4231
|
return;
|
|
4227
4232
|
}
|
|
4228
|
-
logger$
|
|
4233
|
+
logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4229
4234
|
|
|
4230
4235
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
4231
4236
|
}
|
|
4232
4237
|
|
|
4233
4238
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
4234
|
-
logger$
|
|
4239
|
+
logger$1.info('cancel CTI transfer', { transferId });
|
|
4235
4240
|
|
|
4236
4241
|
return CallApi.cancelCallTransfer(transferId);
|
|
4237
4242
|
}
|
|
4238
4243
|
|
|
4239
4244
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
4240
|
-
logger$
|
|
4245
|
+
logger$1.info('confirm CTI transfer', { transferId });
|
|
4241
4246
|
|
|
4242
4247
|
return CallApi.confirmCallTransfer(transferId);
|
|
4243
4248
|
}
|
|
@@ -4246,19 +4251,19 @@ class CTIPhone extends Emitter {
|
|
|
4246
4251
|
if (!callSession) {
|
|
4247
4252
|
return;
|
|
4248
4253
|
}
|
|
4249
|
-
logger$
|
|
4254
|
+
logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4250
4255
|
|
|
4251
4256
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4252
4257
|
}
|
|
4253
4258
|
|
|
4254
4259
|
onConnectionMade() {
|
|
4255
|
-
logger$
|
|
4260
|
+
logger$1.info('on CTI connection made');
|
|
4256
4261
|
|
|
4257
4262
|
this.eventEmitter.emit('onCallAccepted');
|
|
4258
4263
|
}
|
|
4259
4264
|
|
|
4260
4265
|
async close() {
|
|
4261
|
-
logger$
|
|
4266
|
+
logger$1.info('CTI close');
|
|
4262
4267
|
|
|
4263
4268
|
return Promise.resolve();
|
|
4264
4269
|
}
|
|
@@ -4267,7 +4272,7 @@ class CTIPhone extends Emitter {
|
|
|
4267
4272
|
if (!callSession) {
|
|
4268
4273
|
return;
|
|
4269
4274
|
}
|
|
4270
|
-
logger$
|
|
4275
|
+
logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4271
4276
|
|
|
4272
4277
|
return CallApi.hold(callSession.callId);
|
|
4273
4278
|
}
|
|
@@ -4276,7 +4281,7 @@ class CTIPhone extends Emitter {
|
|
|
4276
4281
|
if (!callSession) {
|
|
4277
4282
|
return;
|
|
4278
4283
|
}
|
|
4279
|
-
logger$
|
|
4284
|
+
logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4280
4285
|
|
|
4281
4286
|
return CallApi.resume(callSession.callId);
|
|
4282
4287
|
}
|
|
@@ -4285,7 +4290,7 @@ class CTIPhone extends Emitter {
|
|
|
4285
4290
|
if (!callSession) {
|
|
4286
4291
|
return;
|
|
4287
4292
|
}
|
|
4288
|
-
logger$
|
|
4293
|
+
logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4289
4294
|
|
|
4290
4295
|
return CallApi.mute(callSession.callId);
|
|
4291
4296
|
}
|
|
@@ -4294,7 +4299,7 @@ class CTIPhone extends Emitter {
|
|
|
4294
4299
|
if (!callSession) {
|
|
4295
4300
|
return;
|
|
4296
4301
|
}
|
|
4297
|
-
logger$
|
|
4302
|
+
logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4298
4303
|
|
|
4299
4304
|
return CallApi.unmute(callSession.callId);
|
|
4300
4305
|
}
|
|
@@ -5303,7 +5308,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5303
5308
|
const WEBHOOKD_VERSION = '1.0';
|
|
5304
5309
|
const AMID_VERSION = '1.0';
|
|
5305
5310
|
|
|
5306
|
-
const logger$
|
|
5311
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5307
5312
|
|
|
5308
5313
|
class ApiClient {
|
|
5309
5314
|
|
|
@@ -5355,12 +5360,12 @@ class ApiClient {
|
|
|
5355
5360
|
}
|
|
5356
5361
|
|
|
5357
5362
|
async forceRefreshToken() {
|
|
5358
|
-
logger$
|
|
5363
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
5359
5364
|
return this.refreshTokenCallback();
|
|
5360
5365
|
}
|
|
5361
5366
|
|
|
5362
5367
|
async refreshTokenCallback() {
|
|
5363
|
-
logger$
|
|
5368
|
+
logger$2.info('refresh token callback called', {
|
|
5364
5369
|
refreshToken: this.refreshToken,
|
|
5365
5370
|
refreshBackend: this.refreshBackend,
|
|
5366
5371
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5378,7 +5383,7 @@ class ApiClient {
|
|
|
5378
5383
|
this.isMobile,
|
|
5379
5384
|
);
|
|
5380
5385
|
|
|
5381
|
-
logger$
|
|
5386
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
5382
5387
|
|
|
5383
5388
|
if (this.onRefreshToken) {
|
|
5384
5389
|
this.onRefreshToken(session.token, session);
|
|
@@ -5691,7 +5696,7 @@ class AdHocAPIConference {
|
|
|
5691
5696
|
|
|
5692
5697
|
/* */
|
|
5693
5698
|
|
|
5694
|
-
const parseCandidate
|
|
5699
|
+
const parseCandidate = (candidate ) => {
|
|
5695
5700
|
if (!candidate) {
|
|
5696
5701
|
return null;
|
|
5697
5702
|
}
|
|
@@ -5845,7 +5850,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5845
5850
|
this.peerConnectionDelegate.onicecandidate = event => {
|
|
5846
5851
|
wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
|
|
5847
5852
|
if (event.candidate) {
|
|
5848
|
-
this.gatheredCandidates.push(parseCandidate
|
|
5853
|
+
this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
|
|
5849
5854
|
}
|
|
5850
5855
|
};
|
|
5851
5856
|
|
|
@@ -6309,7 +6314,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
6309
6314
|
const SEND_STATS_DELAY = 5000;
|
|
6310
6315
|
|
|
6311
6316
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
6312
|
-
const logger$
|
|
6317
|
+
const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
6313
6318
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
6314
6319
|
|
|
6315
6320
|
// events
|
|
@@ -6323,14 +6328,14 @@ const TRANSPORT_ERROR = 'transportError';
|
|
|
6323
6328
|
const MESSAGE = 'message';
|
|
6324
6329
|
const ACCEPTED = 'accepted';
|
|
6325
6330
|
const REJECTED = 'rejected';
|
|
6326
|
-
const ON_TRACK
|
|
6327
|
-
const ON_REINVITE
|
|
6331
|
+
const ON_TRACK = 'onTrack';
|
|
6332
|
+
const ON_REINVITE = 'reinvite';
|
|
6328
6333
|
const ON_ERROR = 'onError';
|
|
6329
6334
|
const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
|
|
6330
|
-
const ON_NETWORK_STATS
|
|
6331
|
-
const ON_DISCONNECTED
|
|
6335
|
+
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
6336
|
+
const ON_DISCONNECTED = 'onDisconnected';
|
|
6332
6337
|
|
|
6333
|
-
const events
|
|
6338
|
+
const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
6334
6339
|
const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
6335
6340
|
class CanceledCallError extends Error {}
|
|
6336
6341
|
|
|
@@ -6466,12 +6471,12 @@ class WebRTCClient extends Emitter {
|
|
|
6466
6471
|
this.MESSAGE = MESSAGE;
|
|
6467
6472
|
this.ACCEPTED = ACCEPTED;
|
|
6468
6473
|
this.REJECTED = REJECTED;
|
|
6469
|
-
this.ON_TRACK = ON_TRACK
|
|
6470
|
-
this.ON_REINVITE = ON_REINVITE
|
|
6474
|
+
this.ON_TRACK = ON_TRACK;
|
|
6475
|
+
this.ON_REINVITE = ON_REINVITE;
|
|
6471
6476
|
this.ON_ERROR = ON_ERROR;
|
|
6472
6477
|
this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
|
|
6473
|
-
this.ON_NETWORK_STATS = ON_NETWORK_STATS
|
|
6474
|
-
this.ON_DISCONNECTED = ON_DISCONNECTED
|
|
6478
|
+
this.ON_NETWORK_STATS = ON_NETWORK_STATS;
|
|
6479
|
+
this.ON_DISCONNECTED = ON_DISCONNECTED;
|
|
6475
6480
|
}
|
|
6476
6481
|
|
|
6477
6482
|
configureMedia(media ) {
|
|
@@ -6488,13 +6493,13 @@ class WebRTCClient extends Emitter {
|
|
|
6488
6493
|
|
|
6489
6494
|
createUserAgent(configOverrides ) {
|
|
6490
6495
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6491
|
-
logger$
|
|
6496
|
+
logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6492
6497
|
|
|
6493
6498
|
webRTCConfiguration.delegate = {
|
|
6494
6499
|
onConnect: this.onConnect.bind(this),
|
|
6495
6500
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6496
6501
|
onInvite: (invitation ) => {
|
|
6497
|
-
logger$
|
|
6502
|
+
logger$3.info('sdk webrtc on invite', {
|
|
6498
6503
|
method: 'delegate.onInvite',
|
|
6499
6504
|
id: invitation.id,
|
|
6500
6505
|
remoteURI: invitation.remoteURI,
|
|
@@ -6537,7 +6542,7 @@ class WebRTCClient extends Emitter {
|
|
|
6537
6542
|
}
|
|
6538
6543
|
|
|
6539
6544
|
onConnect() {
|
|
6540
|
-
logger$
|
|
6545
|
+
logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6541
6546
|
this.eventEmitter.emit(CONNECTED);
|
|
6542
6547
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6543
6548
|
this.registerer.waitingToggle(false);
|
|
@@ -6546,7 +6551,7 @@ class WebRTCClient extends Emitter {
|
|
|
6546
6551
|
}
|
|
6547
6552
|
|
|
6548
6553
|
async onDisconnect(error ) {
|
|
6549
|
-
logger$
|
|
6554
|
+
logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6550
6555
|
this.connectionPromise = null;
|
|
6551
6556
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6552
6557
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6571,37 +6576,37 @@ class WebRTCClient extends Emitter {
|
|
|
6571
6576
|
};
|
|
6572
6577
|
|
|
6573
6578
|
if (this.skipRegister) {
|
|
6574
|
-
logger$
|
|
6579
|
+
logger$3.info('sdk webrtc skip register...', logInfo);
|
|
6575
6580
|
return Promise.resolve();
|
|
6576
6581
|
}
|
|
6577
6582
|
|
|
6578
|
-
logger$
|
|
6583
|
+
logger$3.info('sdk webrtc registering...', logInfo);
|
|
6579
6584
|
|
|
6580
6585
|
if (!this.userAgent) {
|
|
6581
|
-
logger$
|
|
6586
|
+
logger$3.info('sdk webrtc recreating User Agent');
|
|
6582
6587
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6583
6588
|
}
|
|
6584
6589
|
if (!this.userAgent || this.isRegistered()) {
|
|
6585
|
-
logger$
|
|
6590
|
+
logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6586
6591
|
return Promise.resolve();
|
|
6587
6592
|
}
|
|
6588
6593
|
|
|
6589
6594
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6590
|
-
logger$
|
|
6595
|
+
logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6591
6596
|
return Promise.resolve();
|
|
6592
6597
|
}
|
|
6593
6598
|
|
|
6594
6599
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6595
6600
|
|
|
6596
6601
|
const onRegisterFailed = () => {
|
|
6597
|
-
logger$
|
|
6602
|
+
logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6598
6603
|
this.connectionPromise = null;
|
|
6599
6604
|
if (this.registerer && this.registerer.waiting) {
|
|
6600
6605
|
this.registerer.waitingToggle(false);
|
|
6601
6606
|
}
|
|
6602
6607
|
|
|
6603
6608
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6604
|
-
logger$
|
|
6609
|
+
logger$3.info('sdk webrtc registering, retrying...', { tries });
|
|
6605
6610
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6606
6611
|
}
|
|
6607
6612
|
};
|
|
@@ -6610,18 +6615,18 @@ class WebRTCClient extends Emitter {
|
|
|
6610
6615
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6611
6616
|
// during the resolution of the primise.
|
|
6612
6617
|
if (!this.userAgent) {
|
|
6613
|
-
logger$
|
|
6618
|
+
logger$3.info('sdk webrtc recreating User Agent after connection');
|
|
6614
6619
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6615
6620
|
}
|
|
6616
6621
|
|
|
6617
|
-
logger$
|
|
6622
|
+
logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6618
6623
|
this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
|
|
6619
6624
|
this.connectionPromise = null;
|
|
6620
6625
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6621
6626
|
|
|
6622
6627
|
// Bind registerer events
|
|
6623
6628
|
this.registerer.stateChange.addListener(newState => {
|
|
6624
|
-
logger$
|
|
6629
|
+
logger$3.info('sdk webrtc registering, state changed', { newState });
|
|
6625
6630
|
|
|
6626
6631
|
if (newState === registererState.RegistererState.Registered && this.registerer
|
|
6627
6632
|
&& this.registerer.state === registererState.RegistererState.Registered) {
|
|
@@ -6634,7 +6639,7 @@ class WebRTCClient extends Emitter {
|
|
|
6634
6639
|
const options = {
|
|
6635
6640
|
requestDelegate: {
|
|
6636
6641
|
onReject: response => {
|
|
6637
|
-
logger$
|
|
6642
|
+
logger$3.error('sdk webrtc registering, rejected', { response });
|
|
6638
6643
|
|
|
6639
6644
|
onRegisterFailed();
|
|
6640
6645
|
},
|
|
@@ -6642,13 +6647,13 @@ class WebRTCClient extends Emitter {
|
|
|
6642
6647
|
};
|
|
6643
6648
|
|
|
6644
6649
|
return this.registerer.register(options).catch((e) => {
|
|
6645
|
-
logger$
|
|
6650
|
+
logger$3.error('sdk webrtc registering, error', e);
|
|
6646
6651
|
|
|
6647
6652
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6648
6653
|
return e;
|
|
6649
6654
|
});
|
|
6650
6655
|
}).catch(error => {
|
|
6651
|
-
logger$
|
|
6656
|
+
logger$3.error('sdk webrtc registering, transport error', error);
|
|
6652
6657
|
onRegisterFailed();
|
|
6653
6658
|
});
|
|
6654
6659
|
}
|
|
@@ -6677,21 +6682,21 @@ class WebRTCClient extends Emitter {
|
|
|
6677
6682
|
}
|
|
6678
6683
|
|
|
6679
6684
|
unregister() {
|
|
6680
|
-
logger$
|
|
6685
|
+
logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6681
6686
|
if (!this.registerer) {
|
|
6682
6687
|
return Promise.resolve();
|
|
6683
6688
|
}
|
|
6684
6689
|
|
|
6685
6690
|
try {
|
|
6686
6691
|
return this.registerer.unregister().then(() => {
|
|
6687
|
-
logger$
|
|
6692
|
+
logger$3.info('sdk webrtc unregistered');
|
|
6688
6693
|
this._cleanupRegister();
|
|
6689
6694
|
}).catch(e => {
|
|
6690
|
-
logger$
|
|
6695
|
+
logger$3.error('sdk webrtc unregistering, promise error', e);
|
|
6691
6696
|
this._cleanupRegister();
|
|
6692
6697
|
});
|
|
6693
6698
|
} catch (e) {
|
|
6694
|
-
logger$
|
|
6699
|
+
logger$3.error('sdk webrtc unregistering, error', e);
|
|
6695
6700
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6696
6701
|
// error when the registerer is in a bad state
|
|
6697
6702
|
this._cleanupRegister();
|
|
@@ -6699,7 +6704,7 @@ class WebRTCClient extends Emitter {
|
|
|
6699
6704
|
}
|
|
6700
6705
|
|
|
6701
6706
|
stop() {
|
|
6702
|
-
logger$
|
|
6707
|
+
logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6703
6708
|
if (!this.userAgent) {
|
|
6704
6709
|
return Promise.resolve();
|
|
6705
6710
|
}
|
|
@@ -6707,12 +6712,12 @@ class WebRTCClient extends Emitter {
|
|
|
6707
6712
|
return this.userAgent.stop().then(() => {
|
|
6708
6713
|
return this._cleanupRegister();
|
|
6709
6714
|
}).catch(e => {
|
|
6710
|
-
logger$
|
|
6715
|
+
logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6711
6716
|
});
|
|
6712
6717
|
}
|
|
6713
6718
|
|
|
6714
6719
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6715
|
-
logger$
|
|
6720
|
+
logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6716
6721
|
const inviterOptions = {
|
|
6717
6722
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6718
6723
|
conference,
|
|
@@ -6743,7 +6748,7 @@ class WebRTCClient extends Emitter {
|
|
|
6743
6748
|
this._onAccepted(session, response.session, true);
|
|
6744
6749
|
},
|
|
6745
6750
|
onReject: (response ) => {
|
|
6746
|
-
logger$
|
|
6751
|
+
logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6747
6752
|
this._stopSendingStats(session);
|
|
6748
6753
|
this.stopNetworkMonitoring(session);
|
|
6749
6754
|
|
|
@@ -6766,11 +6771,11 @@ class WebRTCClient extends Emitter {
|
|
|
6766
6771
|
}
|
|
6767
6772
|
|
|
6768
6773
|
answer(session , enableVideo ) {
|
|
6769
|
-
logger$
|
|
6774
|
+
logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
6770
6775
|
|
|
6771
6776
|
if (!session || !session.accept) {
|
|
6772
6777
|
const error = 'No session to answer, or not an invitation';
|
|
6773
|
-
logger$
|
|
6778
|
+
logger$3.warn(error);
|
|
6774
6779
|
return Promise.reject(new Error(error));
|
|
6775
6780
|
}
|
|
6776
6781
|
const options = {
|
|
@@ -6780,15 +6785,15 @@ class WebRTCClient extends Emitter {
|
|
|
6780
6785
|
return session.accept(options).then(() => {
|
|
6781
6786
|
if (session.isCanceled) {
|
|
6782
6787
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
6783
|
-
logger$
|
|
6788
|
+
logger$3.error(message, { id: session.id });
|
|
6784
6789
|
this.onCallEnded(session);
|
|
6785
6790
|
|
|
6786
6791
|
throw new CanceledCallError(message);
|
|
6787
6792
|
}
|
|
6788
|
-
logger$
|
|
6793
|
+
logger$3.info('sdk webrtc answer, accepted.');
|
|
6789
6794
|
this._onAccepted(session);
|
|
6790
6795
|
}).catch(e => {
|
|
6791
|
-
logger$
|
|
6796
|
+
logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
6792
6797
|
|
|
6793
6798
|
throw e;
|
|
6794
6799
|
});
|
|
@@ -6796,7 +6801,7 @@ class WebRTCClient extends Emitter {
|
|
|
6796
6801
|
|
|
6797
6802
|
hangup(session ) {
|
|
6798
6803
|
const { state, id } = session;
|
|
6799
|
-
logger$
|
|
6804
|
+
logger$3.info('sdk webrtc hangup call', { id, state });
|
|
6800
6805
|
|
|
6801
6806
|
try {
|
|
6802
6807
|
this._stopSendingStats(session);
|
|
@@ -6825,7 +6830,7 @@ class WebRTCClient extends Emitter {
|
|
|
6825
6830
|
|
|
6826
6831
|
return bye();
|
|
6827
6832
|
} catch (error) {
|
|
6828
|
-
logger$
|
|
6833
|
+
logger$3.warn('sdk webrtc hangup, error', error);
|
|
6829
6834
|
}
|
|
6830
6835
|
|
|
6831
6836
|
return null;
|
|
@@ -6843,7 +6848,7 @@ class WebRTCClient extends Emitter {
|
|
|
6843
6848
|
// Fetch and emit an event at `interval` with session network stats
|
|
6844
6849
|
startNetworkMonitoring(session , interval = 1000) {
|
|
6845
6850
|
const sessionId = this.getSipSessionId(session);
|
|
6846
|
-
logger$
|
|
6851
|
+
logger$3.info('starting network inspection', { id: sessionId });
|
|
6847
6852
|
|
|
6848
6853
|
this.sessionNetworkStats[sessionId] = [];
|
|
6849
6854
|
|
|
@@ -6853,7 +6858,7 @@ class WebRTCClient extends Emitter {
|
|
|
6853
6858
|
stopNetworkMonitoring(session ) {
|
|
6854
6859
|
const sessionId = this.getSipSessionId(session);
|
|
6855
6860
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
6856
|
-
logger$
|
|
6861
|
+
logger$3.info('stopping network inspection', { id: sessionId, exists });
|
|
6857
6862
|
|
|
6858
6863
|
if (exists) {
|
|
6859
6864
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -6863,17 +6868,17 @@ class WebRTCClient extends Emitter {
|
|
|
6863
6868
|
}
|
|
6864
6869
|
|
|
6865
6870
|
reject(session ) {
|
|
6866
|
-
logger$
|
|
6871
|
+
logger$3.info('sdk webrtc reject call', { id: session.id });
|
|
6867
6872
|
|
|
6868
6873
|
try {
|
|
6869
6874
|
return session.reject ? session.reject() : session.cancel();
|
|
6870
6875
|
} catch (e) {
|
|
6871
|
-
logger$
|
|
6876
|
+
logger$3.warn('Error when rejecting call', e.message, e.stack);
|
|
6872
6877
|
}
|
|
6873
6878
|
}
|
|
6874
6879
|
|
|
6875
6880
|
async close() {
|
|
6876
|
-
logger$
|
|
6881
|
+
logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
6877
6882
|
this._cleanupMedia();
|
|
6878
6883
|
this.connectionPromise = null;
|
|
6879
6884
|
|
|
@@ -6904,7 +6909,7 @@ class WebRTCClient extends Emitter {
|
|
|
6904
6909
|
// eg: "INVITE not rejectable in state Completed"
|
|
6905
6910
|
}
|
|
6906
6911
|
this.userAgent = null;
|
|
6907
|
-
logger$
|
|
6912
|
+
logger$3.info('sdk webrtc client closed');
|
|
6908
6913
|
}
|
|
6909
6914
|
|
|
6910
6915
|
getNumber(session ) {
|
|
@@ -6917,13 +6922,13 @@ class WebRTCClient extends Emitter {
|
|
|
6917
6922
|
}
|
|
6918
6923
|
|
|
6919
6924
|
mute(session ) {
|
|
6920
|
-
logger$
|
|
6925
|
+
logger$3.info('sdk webrtc mute', { id: session.id });
|
|
6921
6926
|
|
|
6922
6927
|
this._toggleAudio(session, true);
|
|
6923
6928
|
}
|
|
6924
6929
|
|
|
6925
6930
|
unmute(session ) {
|
|
6926
|
-
logger$
|
|
6931
|
+
logger$3.info('sdk webrtc unmute', { id: session.id });
|
|
6927
6932
|
|
|
6928
6933
|
this._toggleAudio(session, false);
|
|
6929
6934
|
}
|
|
@@ -6963,13 +6968,13 @@ class WebRTCClient extends Emitter {
|
|
|
6963
6968
|
}
|
|
6964
6969
|
|
|
6965
6970
|
toggleCameraOn(session ) {
|
|
6966
|
-
logger$
|
|
6971
|
+
logger$3.info('sdk webrtc toggle camera on', { id: session.id });
|
|
6967
6972
|
|
|
6968
6973
|
this._toggleVideo(session, false);
|
|
6969
6974
|
}
|
|
6970
6975
|
|
|
6971
6976
|
toggleCameraOff(session ) {
|
|
6972
|
-
logger$
|
|
6977
|
+
logger$3.info('sdk webrtc toggle camera off', { id: session.id });
|
|
6973
6978
|
|
|
6974
6979
|
this._toggleVideo(session, true);
|
|
6975
6980
|
}
|
|
@@ -6978,7 +6983,7 @@ class WebRTCClient extends Emitter {
|
|
|
6978
6983
|
const sessionId = this.getSipSessionId(session);
|
|
6979
6984
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
6980
6985
|
|
|
6981
|
-
logger$
|
|
6986
|
+
logger$3.info('sdk webrtc hold', {
|
|
6982
6987
|
sessionId,
|
|
6983
6988
|
keys: Object.keys(this.heldSessions),
|
|
6984
6989
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7027,7 +7032,7 @@ class WebRTCClient extends Emitter {
|
|
|
7027
7032
|
const sessionId = this.getSipSessionId(session);
|
|
7028
7033
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
7029
7034
|
|
|
7030
|
-
logger$
|
|
7035
|
+
logger$3.info('sdk webrtc unhold', {
|
|
7031
7036
|
sessionId,
|
|
7032
7037
|
keys: Object.keys(this.heldSessions),
|
|
7033
7038
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7175,7 +7180,7 @@ class WebRTCClient extends Emitter {
|
|
|
7175
7180
|
if (!session.sessionDescriptionHandler) {
|
|
7176
7181
|
return;
|
|
7177
7182
|
}
|
|
7178
|
-
logger$
|
|
7183
|
+
logger$3.info('Sending DTMF', {
|
|
7179
7184
|
id: this.getSipSessionId(session),
|
|
7180
7185
|
tone,
|
|
7181
7186
|
});
|
|
@@ -7191,7 +7196,7 @@ class WebRTCClient extends Emitter {
|
|
|
7191
7196
|
transfer(session , target ) {
|
|
7192
7197
|
this.hold(session);
|
|
7193
7198
|
|
|
7194
|
-
logger$
|
|
7199
|
+
logger$3.info('Transfering a session', {
|
|
7195
7200
|
id: this.getSipSessionId(session),
|
|
7196
7201
|
target,
|
|
7197
7202
|
});
|
|
@@ -7213,17 +7218,17 @@ class WebRTCClient extends Emitter {
|
|
|
7213
7218
|
atxfer(session ) {
|
|
7214
7219
|
this.hold(session);
|
|
7215
7220
|
|
|
7216
|
-
logger$
|
|
7221
|
+
logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
7217
7222
|
|
|
7218
7223
|
const result = {
|
|
7219
7224
|
newSession: null,
|
|
7220
7225
|
init: async (target ) => {
|
|
7221
|
-
logger$
|
|
7226
|
+
logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
7222
7227
|
|
|
7223
7228
|
result.newSession = await this.call(target);
|
|
7224
7229
|
},
|
|
7225
7230
|
complete: () => {
|
|
7226
|
-
logger$
|
|
7231
|
+
logger$3.info('webrtc transfer completed', {
|
|
7227
7232
|
id: this.getSipSessionId(session),
|
|
7228
7233
|
referId: this.getSipSessionId(result.newSession),
|
|
7229
7234
|
});
|
|
@@ -7244,7 +7249,7 @@ class WebRTCClient extends Emitter {
|
|
|
7244
7249
|
return;
|
|
7245
7250
|
}
|
|
7246
7251
|
|
|
7247
|
-
logger$
|
|
7252
|
+
logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
7248
7253
|
|
|
7249
7254
|
try {
|
|
7250
7255
|
sipSession.message({
|
|
@@ -7286,7 +7291,7 @@ class WebRTCClient extends Emitter {
|
|
|
7286
7291
|
}
|
|
7287
7292
|
|
|
7288
7293
|
changeAudioOutputVolume(volume ) {
|
|
7289
|
-
logger$
|
|
7294
|
+
logger$3.info('Changing audio output volume', { volume });
|
|
7290
7295
|
|
|
7291
7296
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7292
7297
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -7298,7 +7303,7 @@ class WebRTCClient extends Emitter {
|
|
|
7298
7303
|
}
|
|
7299
7304
|
|
|
7300
7305
|
changeAudioOutputDevice(id ) {
|
|
7301
|
-
logger$
|
|
7306
|
+
logger$3.info('Changing audio output device', { id });
|
|
7302
7307
|
|
|
7303
7308
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7304
7309
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -7315,7 +7320,7 @@ class WebRTCClient extends Emitter {
|
|
|
7315
7320
|
|
|
7316
7321
|
changeAudioInputDevice(id , session ) {
|
|
7317
7322
|
const currentId = this.getAudioDeviceId();
|
|
7318
|
-
logger$
|
|
7323
|
+
logger$3.info('setting audio input device', { id, currentId, session: !!session });
|
|
7319
7324
|
|
|
7320
7325
|
if (id === currentId) {
|
|
7321
7326
|
return null;
|
|
@@ -7361,7 +7366,7 @@ class WebRTCClient extends Emitter {
|
|
|
7361
7366
|
|
|
7362
7367
|
setVideoInputDevice(id ) {
|
|
7363
7368
|
const currentId = this.getVideoDeviceId();
|
|
7364
|
-
logger$
|
|
7369
|
+
logger$3.info('setting video input device', { id, currentId });
|
|
7365
7370
|
|
|
7366
7371
|
if (id === currentId) {
|
|
7367
7372
|
return null;
|
|
@@ -7386,7 +7391,7 @@ class WebRTCClient extends Emitter {
|
|
|
7386
7391
|
const sessionId = this.getSipSessionId(session);
|
|
7387
7392
|
const localStream = this.getLocalStream(sessionId);
|
|
7388
7393
|
|
|
7389
|
-
logger$
|
|
7394
|
+
logger$3.info('changing video input device', { id, sessionId });
|
|
7390
7395
|
|
|
7391
7396
|
// Release old video stream
|
|
7392
7397
|
if (localStream) {
|
|
@@ -7454,7 +7459,7 @@ class WebRTCClient extends Emitter {
|
|
|
7454
7459
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
7455
7460
|
const desktop = newConstraints && newConstraints.desktop;
|
|
7456
7461
|
|
|
7457
|
-
logger$
|
|
7462
|
+
logger$3.info('Sending reinvite', {
|
|
7458
7463
|
id: this.getSipSessionId(sipSession),
|
|
7459
7464
|
newConstraints,
|
|
7460
7465
|
conference,
|
|
@@ -7492,7 +7497,7 @@ class WebRTCClient extends Emitter {
|
|
|
7492
7497
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
7493
7498
|
}
|
|
7494
7499
|
|
|
7495
|
-
logger$
|
|
7500
|
+
logger$3.info('on re-INVITE accepted', {
|
|
7496
7501
|
id: this.getSipSessionId(sipSession),
|
|
7497
7502
|
wasMuted,
|
|
7498
7503
|
shouldDoScreenSharing,
|
|
@@ -7510,7 +7515,7 @@ class WebRTCClient extends Emitter {
|
|
|
7510
7515
|
this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
|
|
7511
7516
|
}
|
|
7512
7517
|
|
|
7513
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
7518
|
+
return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
|
|
7514
7519
|
},
|
|
7515
7520
|
},
|
|
7516
7521
|
sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
|
|
@@ -7667,7 +7672,7 @@ class WebRTCClient extends Emitter {
|
|
|
7667
7672
|
}
|
|
7668
7673
|
|
|
7669
7674
|
startHeartbeat() {
|
|
7670
|
-
logger$
|
|
7675
|
+
logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7671
7676
|
if (!this.userAgent) {
|
|
7672
7677
|
this.heartbeat.stop();
|
|
7673
7678
|
return;
|
|
@@ -7680,7 +7685,7 @@ class WebRTCClient extends Emitter {
|
|
|
7680
7685
|
}
|
|
7681
7686
|
|
|
7682
7687
|
stopHeartbeat() {
|
|
7683
|
-
logger$
|
|
7688
|
+
logger$3.info('sdk webrtc stop heartbeat');
|
|
7684
7689
|
this.heartbeat.stop();
|
|
7685
7690
|
}
|
|
7686
7691
|
|
|
@@ -7701,7 +7706,7 @@ class WebRTCClient extends Emitter {
|
|
|
7701
7706
|
}
|
|
7702
7707
|
|
|
7703
7708
|
attemptReconnection() {
|
|
7704
|
-
logger$
|
|
7709
|
+
logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7705
7710
|
if (!this.userAgent) {
|
|
7706
7711
|
return;
|
|
7707
7712
|
}
|
|
@@ -7726,7 +7731,7 @@ class WebRTCClient extends Emitter {
|
|
|
7726
7731
|
return;
|
|
7727
7732
|
}
|
|
7728
7733
|
|
|
7729
|
-
logger$
|
|
7734
|
+
logger$3.info('setting local media stream', {
|
|
7730
7735
|
sipSessionId,
|
|
7731
7736
|
tracks: newStream ? newStream.getTracks() : null,
|
|
7732
7737
|
});
|
|
@@ -7743,7 +7748,7 @@ class WebRTCClient extends Emitter {
|
|
|
7743
7748
|
|
|
7744
7749
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
7745
7750
|
|
|
7746
|
-
logger$
|
|
7751
|
+
logger$3.info('updating local stream', {
|
|
7747
7752
|
sipSessionId,
|
|
7748
7753
|
oldStream: !!oldStream,
|
|
7749
7754
|
tracks: newStream.getTracks(),
|
|
@@ -7763,7 +7768,7 @@ class WebRTCClient extends Emitter {
|
|
|
7763
7768
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
7764
7769
|
const pc = this.getPeerConnection(sessionId);
|
|
7765
7770
|
|
|
7766
|
-
logger$
|
|
7771
|
+
logger$3.info('Updating remote stream', {
|
|
7767
7772
|
sessionId,
|
|
7768
7773
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
7769
7774
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -7789,7 +7794,7 @@ class WebRTCClient extends Emitter {
|
|
|
7789
7794
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
7790
7795
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
7791
7796
|
|
|
7792
|
-
logger$
|
|
7797
|
+
logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
7793
7798
|
|
|
7794
7799
|
return {
|
|
7795
7800
|
constraints: {
|
|
@@ -7838,7 +7843,7 @@ class WebRTCClient extends Emitter {
|
|
|
7838
7843
|
}
|
|
7839
7844
|
|
|
7840
7845
|
_onTransportError() {
|
|
7841
|
-
logger$
|
|
7846
|
+
logger$3.error('on transport error');
|
|
7842
7847
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
7843
7848
|
this.attemptReconnection();
|
|
7844
7849
|
}
|
|
@@ -7847,7 +7852,7 @@ class WebRTCClient extends Emitter {
|
|
|
7847
7852
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
7848
7853
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
7849
7854
|
if (this.hasHeartbeat()) {
|
|
7850
|
-
logger$
|
|
7855
|
+
logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
7851
7856
|
|
|
7852
7857
|
this.heartbeat.onHeartbeat();
|
|
7853
7858
|
if (this.heartbeatCb) {
|
|
@@ -7858,7 +7863,7 @@ class WebRTCClient extends Emitter {
|
|
|
7858
7863
|
}
|
|
7859
7864
|
|
|
7860
7865
|
async _onHeartbeatTimeout() {
|
|
7861
|
-
logger$
|
|
7866
|
+
logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
7862
7867
|
|
|
7863
7868
|
if (this.heartbeatTimeoutCb) {
|
|
7864
7869
|
this.heartbeatTimeoutCb();
|
|
@@ -7870,7 +7875,7 @@ class WebRTCClient extends Emitter {
|
|
|
7870
7875
|
try {
|
|
7871
7876
|
await this.userAgent.transport.disconnect();
|
|
7872
7877
|
} catch (e) {
|
|
7873
|
-
logger$
|
|
7878
|
+
logger$3.error('Transport disconnection after heartbeat timeout, error', e);
|
|
7874
7879
|
}
|
|
7875
7880
|
}
|
|
7876
7881
|
|
|
@@ -7903,31 +7908,31 @@ class WebRTCClient extends Emitter {
|
|
|
7903
7908
|
}
|
|
7904
7909
|
|
|
7905
7910
|
_connectIfNeeded() {
|
|
7906
|
-
logger$
|
|
7911
|
+
logger$3.info('connect if needed, checking', { connected: this.isConnected() });
|
|
7907
7912
|
if (!this.userAgent) {
|
|
7908
|
-
logger$
|
|
7913
|
+
logger$3.info('need to recreate User Agent');
|
|
7909
7914
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
7910
7915
|
}
|
|
7911
7916
|
|
|
7912
7917
|
if (this.isConnected()) {
|
|
7913
|
-
logger$
|
|
7918
|
+
logger$3.info('webrtc sdk, already connected');
|
|
7914
7919
|
return Promise.resolve();
|
|
7915
7920
|
}
|
|
7916
7921
|
|
|
7917
7922
|
if (this.isConnecting()) {
|
|
7918
|
-
logger$
|
|
7923
|
+
logger$3.info('webrtc sdk, already connecting...');
|
|
7919
7924
|
|
|
7920
7925
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
7921
7926
|
return this.connectionPromise;
|
|
7922
7927
|
}
|
|
7923
7928
|
|
|
7924
7929
|
if (this.connectionPromise) {
|
|
7925
|
-
logger$
|
|
7930
|
+
logger$3.info('webrtc sdk, connection promise connecting...');
|
|
7926
7931
|
// $FlowFixMe
|
|
7927
7932
|
return this.connectionPromise;
|
|
7928
7933
|
}
|
|
7929
7934
|
|
|
7930
|
-
logger$
|
|
7935
|
+
logger$3.info('WebRTC UA needs to connect');
|
|
7931
7936
|
|
|
7932
7937
|
// Force UA to reconnect
|
|
7933
7938
|
if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
|
|
@@ -8052,7 +8057,7 @@ class WebRTCClient extends Emitter {
|
|
|
8052
8057
|
|
|
8053
8058
|
sdh.peerConnectionDelegate = {
|
|
8054
8059
|
onicecandidateerror: (error ) => {
|
|
8055
|
-
logger$
|
|
8060
|
+
logger$3.error('on icecandidate error', {
|
|
8056
8061
|
address: error.address,
|
|
8057
8062
|
port: error.port,
|
|
8058
8063
|
errorCode: error.errorCode,
|
|
@@ -8081,7 +8086,7 @@ class WebRTCClient extends Emitter {
|
|
|
8081
8086
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
8082
8087
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
8083
8088
|
}
|
|
8084
|
-
logger$
|
|
8089
|
+
logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
8085
8090
|
|
|
8086
8091
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
8087
8092
|
|
|
@@ -8097,12 +8102,12 @@ class WebRTCClient extends Emitter {
|
|
|
8097
8102
|
|
|
8098
8103
|
this._setupMedias(session);
|
|
8099
8104
|
|
|
8100
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
8105
|
+
return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
|
|
8101
8106
|
};
|
|
8102
8107
|
}
|
|
8103
8108
|
|
|
8104
8109
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
8105
|
-
logger$
|
|
8110
|
+
logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
8106
8111
|
|
|
8107
8112
|
this.storeSipSession(session);
|
|
8108
8113
|
|
|
@@ -8114,14 +8119,14 @@ class WebRTCClient extends Emitter {
|
|
|
8114
8119
|
const onTrack = (event ) => {
|
|
8115
8120
|
const isAudioOnly = this._isAudioOnly(session);
|
|
8116
8121
|
const { kind, label, readyState, id, muted } = event.track;
|
|
8117
|
-
logger$
|
|
8122
|
+
logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
8118
8123
|
|
|
8119
8124
|
// Stop video track in audio only mode
|
|
8120
8125
|
if (isAudioOnly && kind === 'video') {
|
|
8121
8126
|
event.track.stop();
|
|
8122
8127
|
}
|
|
8123
8128
|
|
|
8124
|
-
this.eventEmitter.emit(ON_TRACK
|
|
8129
|
+
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
8125
8130
|
};
|
|
8126
8131
|
|
|
8127
8132
|
if (session.sessionDescriptionHandler.peerConnection) {
|
|
@@ -8131,9 +8136,9 @@ class WebRTCClient extends Emitter {
|
|
|
8131
8136
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
8132
8137
|
|
|
8133
8138
|
pc.oniceconnectionstatechange = () => {
|
|
8134
|
-
logger$
|
|
8139
|
+
logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
8135
8140
|
if (pc.iceConnectionState === 'disconnected') {
|
|
8136
|
-
this.eventEmitter.emit(ON_DISCONNECTED
|
|
8141
|
+
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
8137
8142
|
}
|
|
8138
8143
|
};
|
|
8139
8144
|
|
|
@@ -8304,10 +8309,10 @@ class WebRTCClient extends Emitter {
|
|
|
8304
8309
|
|
|
8305
8310
|
_stopSendingStats(session ) {
|
|
8306
8311
|
const sessionId = this.getSipSessionId(session);
|
|
8307
|
-
logger$
|
|
8312
|
+
logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
8308
8313
|
|
|
8309
8314
|
if (sessionId in this.statsIntervals) {
|
|
8310
|
-
logger$
|
|
8315
|
+
logger$3.trace('Stop sending stats for call', { sessionId });
|
|
8311
8316
|
this.statsIntervals[sessionId]();
|
|
8312
8317
|
delete this.statsIntervals[sessionId];
|
|
8313
8318
|
}
|
|
@@ -8323,7 +8328,7 @@ class WebRTCClient extends Emitter {
|
|
|
8323
8328
|
try {
|
|
8324
8329
|
await this.userAgent.transport.disconnect();
|
|
8325
8330
|
} catch (e) {
|
|
8326
|
-
logger$
|
|
8331
|
+
logger$3.error('WebRTC transport disconnect, error', e);
|
|
8327
8332
|
}
|
|
8328
8333
|
}
|
|
8329
8334
|
}
|
|
@@ -8417,7 +8422,7 @@ class WebRTCClient extends Emitter {
|
|
|
8417
8422
|
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
8418
8423
|
+ networkStats.transportSent;
|
|
8419
8424
|
|
|
8420
|
-
this.eventEmitter.emit(ON_NETWORK_STATS
|
|
8425
|
+
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
8421
8426
|
this.sessionNetworkStats[sessionId].push(networkStats);
|
|
8422
8427
|
}
|
|
8423
8428
|
|
|
@@ -8445,8 +8450,8 @@ const ON_CALL_FAILED = 'onCallFailed';
|
|
|
8445
8450
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
8446
8451
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
8447
8452
|
const ON_MESSAGE = 'onMessage';
|
|
8448
|
-
const ON_REINVITE = 'reinvite';
|
|
8449
|
-
const ON_TRACK = 'onTrack';
|
|
8453
|
+
const ON_REINVITE$1 = 'reinvite';
|
|
8454
|
+
const ON_TRACK$1 = 'onTrack';
|
|
8450
8455
|
const ON_AUDIO_STREAM = 'onAudioStream';
|
|
8451
8456
|
const ON_VIDEO_STREAM = 'onVideoStream';
|
|
8452
8457
|
const ON_REMOVE_STREAM = 'onRemoveStream';
|
|
@@ -8461,15 +8466,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
|
|
|
8461
8466
|
const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
|
|
8462
8467
|
const ON_CALL_ERROR = 'onCallError';
|
|
8463
8468
|
const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
|
|
8464
|
-
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
8469
|
+
const ON_NETWORK_STATS$1 = 'onNetworkStats';
|
|
8465
8470
|
const ON_CHAT = 'phone/ON_CHAT';
|
|
8466
8471
|
const ON_SIGNAL = 'phone/ON_SIGNAL';
|
|
8467
|
-
const ON_DISCONNECTED = 'onDisconnected';
|
|
8472
|
+
const ON_DISCONNECTED$1 = 'onDisconnected';
|
|
8468
8473
|
|
|
8469
8474
|
const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
8470
8475
|
const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
8471
8476
|
|
|
8472
|
-
const events = [
|
|
8477
|
+
const events$1 = [
|
|
8473
8478
|
ON_USER_AGENT,
|
|
8474
8479
|
ON_REGISTERED,
|
|
8475
8480
|
ON_UNREGISTERED,
|
|
@@ -8487,8 +8492,8 @@ const events = [
|
|
|
8487
8492
|
ON_CALL_FAILED,
|
|
8488
8493
|
ON_CALL_ENDED,
|
|
8489
8494
|
ON_MESSAGE,
|
|
8490
|
-
ON_REINVITE,
|
|
8491
|
-
ON_TRACK,
|
|
8495
|
+
ON_REINVITE$1,
|
|
8496
|
+
ON_TRACK$1,
|
|
8492
8497
|
ON_AUDIO_STREAM,
|
|
8493
8498
|
ON_VIDEO_STREAM,
|
|
8494
8499
|
ON_REMOVE_STREAM,
|
|
@@ -8503,11 +8508,11 @@ const events = [
|
|
|
8503
8508
|
ON_CALL_ERROR,
|
|
8504
8509
|
ON_CHAT,
|
|
8505
8510
|
ON_SIGNAL,
|
|
8506
|
-
ON_NETWORK_STATS,
|
|
8507
|
-
ON_DISCONNECTED,
|
|
8511
|
+
ON_NETWORK_STATS$1,
|
|
8512
|
+
ON_DISCONNECTED$1,
|
|
8508
8513
|
];
|
|
8509
8514
|
|
|
8510
|
-
const logger$
|
|
8515
|
+
const logger$4 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
8511
8516
|
|
|
8512
8517
|
class WebRTCPhone extends Emitter {
|
|
8513
8518
|
|
|
@@ -8580,7 +8585,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8580
8585
|
}).catch(error => {
|
|
8581
8586
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
8582
8587
|
console.error('register error', error, error.message, error.stack);
|
|
8583
|
-
logger$
|
|
8588
|
+
logger$4.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
8584
8589
|
});
|
|
8585
8590
|
}
|
|
8586
8591
|
|
|
@@ -8595,7 +8600,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8595
8600
|
if (!this.client) {
|
|
8596
8601
|
return;
|
|
8597
8602
|
}
|
|
8598
|
-
logger$
|
|
8603
|
+
logger$4.info('WebRTC phone stop');
|
|
8599
8604
|
this.client.stop();
|
|
8600
8605
|
}
|
|
8601
8606
|
|
|
@@ -8610,7 +8615,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8610
8615
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
8611
8616
|
audioOnly = false, iceRestart = false) {
|
|
8612
8617
|
const sipSession = this.findSipSession(callSession);
|
|
8613
|
-
logger$
|
|
8618
|
+
logger$4.info('WebRTC phone - send reinvite', {
|
|
8614
8619
|
sessionId: sipSession ? sipSession.id : null,
|
|
8615
8620
|
constraints,
|
|
8616
8621
|
audioOnly,
|
|
@@ -8647,7 +8652,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8647
8652
|
}
|
|
8648
8653
|
|
|
8649
8654
|
startHeartbeat() {
|
|
8650
|
-
logger$
|
|
8655
|
+
logger$4.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
8651
8656
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
8652
8657
|
return;
|
|
8653
8658
|
}
|
|
@@ -8656,7 +8661,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8656
8661
|
}
|
|
8657
8662
|
|
|
8658
8663
|
stopHeartbeat() {
|
|
8659
|
-
logger$
|
|
8664
|
+
logger$4.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
8660
8665
|
if (!this.client) {
|
|
8661
8666
|
return;
|
|
8662
8667
|
}
|
|
@@ -8673,7 +8678,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8673
8678
|
}
|
|
8674
8679
|
|
|
8675
8680
|
reconnect() {
|
|
8676
|
-
logger$
|
|
8681
|
+
logger$4.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
8677
8682
|
if (!this.client) {
|
|
8678
8683
|
return;
|
|
8679
8684
|
}
|
|
@@ -8714,10 +8719,15 @@ class WebRTCPhone extends Emitter {
|
|
|
8714
8719
|
return false;
|
|
8715
8720
|
}
|
|
8716
8721
|
|
|
8717
|
-
logger$
|
|
8722
|
+
logger$4.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
8718
8723
|
|
|
8719
8724
|
this.client.downgradeToAudio(sipSession);
|
|
8720
8725
|
|
|
8726
|
+
if (callSession) {
|
|
8727
|
+
callSession.cameraEnabled = false;
|
|
8728
|
+
this._updateCallSession(callSession);
|
|
8729
|
+
}
|
|
8730
|
+
|
|
8721
8731
|
if (withMessage) {
|
|
8722
8732
|
this._sendReinviteMessage(callSession, false);
|
|
8723
8733
|
}
|
|
@@ -8732,7 +8742,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8732
8742
|
return Promise.resolve(false);
|
|
8733
8743
|
}
|
|
8734
8744
|
|
|
8735
|
-
logger$
|
|
8745
|
+
logger$4.info('Upgrade to video', {
|
|
8736
8746
|
id: callSession ? callSession.getId() : null,
|
|
8737
8747
|
constraints,
|
|
8738
8748
|
isConference,
|
|
@@ -8745,6 +8755,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8745
8755
|
|
|
8746
8756
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
8747
8757
|
|
|
8758
|
+
if (callSession) {
|
|
8759
|
+
callSession.cameraEnabled = true;
|
|
8760
|
+
this._updateCallSession(callSession);
|
|
8761
|
+
}
|
|
8762
|
+
|
|
8748
8763
|
// If no stream is returned, it means we have to reinvite
|
|
8749
8764
|
if (!newStream) {
|
|
8750
8765
|
return true;
|
|
@@ -8767,7 +8782,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8767
8782
|
|
|
8768
8783
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
8769
8784
|
const sipSession = this.findSipSession(callSession);
|
|
8770
|
-
logger$
|
|
8785
|
+
logger$4.info('Sending reinvite message', {
|
|
8771
8786
|
id: callSession ? callSession.getId() : null,
|
|
8772
8787
|
isUpgrade,
|
|
8773
8788
|
});
|
|
@@ -8793,7 +8808,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8793
8808
|
// Monkey patch to know when canceled with the CANCEL message
|
|
8794
8809
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
8795
8810
|
sipSession._onCancel = (message ) => {
|
|
8796
|
-
logger$
|
|
8811
|
+
logger$4.trace('on sip session canceled', { callId: message.callId });
|
|
8797
8812
|
|
|
8798
8813
|
onCancel(message);
|
|
8799
8814
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
@@ -8821,13 +8836,13 @@ class WebRTCPhone extends Emitter {
|
|
|
8821
8836
|
this.audioOutputVolume,
|
|
8822
8837
|
);
|
|
8823
8838
|
case sessionState.SessionState.Terminating:
|
|
8824
|
-
logger$
|
|
8839
|
+
logger$4.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
8825
8840
|
|
|
8826
8841
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
8827
8842
|
|
|
8828
8843
|
break;
|
|
8829
8844
|
case sessionState.SessionState.Terminated: {
|
|
8830
|
-
logger$
|
|
8845
|
+
logger$4.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
8831
8846
|
|
|
8832
8847
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
8833
8848
|
const callSession = this._createCallSession(sipSession);
|
|
@@ -8849,7 +8864,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8849
8864
|
const [stream] = event.streams;
|
|
8850
8865
|
const kind = event && event.track && event.track.kind;
|
|
8851
8866
|
|
|
8852
|
-
logger$
|
|
8867
|
+
logger$4.info('on track stream called on the peer connection', {
|
|
8853
8868
|
callId: this.getSipSessionId(sipSession),
|
|
8854
8869
|
streamId: stream ? stream.id : null,
|
|
8855
8870
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -8869,7 +8884,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8869
8884
|
};
|
|
8870
8885
|
|
|
8871
8886
|
peerConnection.onremovestream = event => {
|
|
8872
|
-
logger$
|
|
8887
|
+
logger$4.info('on remove stream called on the peer connection', {
|
|
8873
8888
|
id: event.stream.id,
|
|
8874
8889
|
tracks: event.stream.getTracks(),
|
|
8875
8890
|
});
|
|
@@ -8879,7 +8894,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8879
8894
|
}
|
|
8880
8895
|
|
|
8881
8896
|
async startScreenSharing(constraints , callSession ) {
|
|
8882
|
-
logger$
|
|
8897
|
+
logger$4.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
8883
8898
|
|
|
8884
8899
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
8885
8900
|
if (!screenShareStream) {
|
|
@@ -8919,7 +8934,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8919
8934
|
return;
|
|
8920
8935
|
}
|
|
8921
8936
|
|
|
8922
|
-
logger$
|
|
8937
|
+
logger$4.info('WebRTC phone - stop screen sharing', {
|
|
8923
8938
|
restoreLocalStream,
|
|
8924
8939
|
});
|
|
8925
8940
|
|
|
@@ -8975,7 +8990,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8975
8990
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
8976
8991
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
8977
8992
|
|
|
8978
|
-
logger$
|
|
8993
|
+
logger$4.info('WebRTC phone - on screensharing', {
|
|
8979
8994
|
hadVideo,
|
|
8980
8995
|
id: this.getSipSessionId(sipSession),
|
|
8981
8996
|
screenTrack,
|
|
@@ -8983,7 +8998,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8983
8998
|
|
|
8984
8999
|
if (screenTrack) {
|
|
8985
9000
|
screenTrack.onended = () => {
|
|
8986
|
-
logger$
|
|
9001
|
+
logger$4.info('WebRTC phone - on screenshare ended', {
|
|
8987
9002
|
hadVideo,
|
|
8988
9003
|
id: this.getSipSessionId(sipSession),
|
|
8989
9004
|
screenTrack,
|
|
@@ -9014,7 +9029,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9014
9029
|
}
|
|
9015
9030
|
|
|
9016
9031
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
9017
|
-
logger$
|
|
9032
|
+
logger$4.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
9018
9033
|
|
|
9019
9034
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
9020
9035
|
this.currentSipSession = sipSession;
|
|
@@ -9032,7 +9047,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9032
9047
|
}
|
|
9033
9048
|
|
|
9034
9049
|
changeAudioDevice(id ) {
|
|
9035
|
-
logger$
|
|
9050
|
+
logger$4.info('WebRTC phone - change audio device', { deviceId: id });
|
|
9036
9051
|
this.audioOutputDeviceId = id;
|
|
9037
9052
|
this.client.changeAudioOutputDevice(id);
|
|
9038
9053
|
}
|
|
@@ -9042,14 +9057,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9042
9057
|
}
|
|
9043
9058
|
|
|
9044
9059
|
changeRingDevice(id ) {
|
|
9045
|
-
logger$
|
|
9060
|
+
logger$4.info('WebRTC phone - changing ring device', { id });
|
|
9046
9061
|
|
|
9047
9062
|
this.audioRingDeviceId = id;
|
|
9048
9063
|
}
|
|
9049
9064
|
|
|
9050
9065
|
// volume is a value between 0 and 1
|
|
9051
9066
|
changeAudioVolume(volume ) {
|
|
9052
|
-
logger$
|
|
9067
|
+
logger$4.info('WebRTC phone - changing audio volume', { volume });
|
|
9053
9068
|
|
|
9054
9069
|
this.audioOutputVolume = volume;
|
|
9055
9070
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -9057,31 +9072,31 @@ class WebRTCPhone extends Emitter {
|
|
|
9057
9072
|
|
|
9058
9073
|
// volume is a value between 0 and 1
|
|
9059
9074
|
changeRingVolume(volume ) {
|
|
9060
|
-
logger$
|
|
9075
|
+
logger$4.info('WebRTC phone - changing ring volume', { volume });
|
|
9061
9076
|
|
|
9062
9077
|
this.audioRingVolume = volume;
|
|
9063
9078
|
}
|
|
9064
9079
|
|
|
9065
9080
|
changeAudioInputDevice(id ) {
|
|
9066
|
-
logger$
|
|
9081
|
+
logger$4.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
9067
9082
|
|
|
9068
9083
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
9069
9084
|
}
|
|
9070
9085
|
|
|
9071
9086
|
changeVideoInputDevice(id ) {
|
|
9072
|
-
logger$
|
|
9087
|
+
logger$4.info('WebRTC phone - change video input device', { deviceId: id });
|
|
9073
9088
|
|
|
9074
9089
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
9075
9090
|
}
|
|
9076
9091
|
|
|
9077
9092
|
changeSessionVideoInputDevice(id ) {
|
|
9078
|
-
logger$
|
|
9093
|
+
logger$4.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
9079
9094
|
|
|
9080
9095
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
9081
9096
|
}
|
|
9082
9097
|
|
|
9083
9098
|
_onCallTerminated(sipSession ) {
|
|
9084
|
-
logger$
|
|
9099
|
+
logger$4.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9085
9100
|
|
|
9086
9101
|
const callSession = this._createCallSession(sipSession);
|
|
9087
9102
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -9115,7 +9130,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9115
9130
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
9116
9131
|
|
|
9117
9132
|
// Re-trigger incoming call event for remaining incoming calls
|
|
9118
|
-
logger$
|
|
9133
|
+
logger$4.info('WebRTC phone - check to re-trigger incoming call', {
|
|
9119
9134
|
sipId: sipSession.id,
|
|
9120
9135
|
shouldRetrigger,
|
|
9121
9136
|
hasIncomingCallSession,
|
|
@@ -9206,37 +9221,37 @@ class WebRTCPhone extends Emitter {
|
|
|
9206
9221
|
|
|
9207
9222
|
// Deprecated
|
|
9208
9223
|
getLocalStreamForCall(callSession ) {
|
|
9209
|
-
logger$
|
|
9224
|
+
logger$4.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9210
9225
|
|
|
9211
9226
|
return this.getLocalStream(callSession);
|
|
9212
9227
|
}
|
|
9213
9228
|
|
|
9214
9229
|
// Deprecated
|
|
9215
9230
|
getRemoteStreamForCall(callSession ) {
|
|
9216
|
-
logger$
|
|
9231
|
+
logger$4.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
9217
9232
|
|
|
9218
9233
|
return this.getRemoteVideoStream(callSession);
|
|
9219
9234
|
}
|
|
9220
9235
|
|
|
9221
9236
|
getRemoteStreamsForCall(callSession ) {
|
|
9222
|
-
logger$
|
|
9237
|
+
logger$4.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
9223
9238
|
|
|
9224
9239
|
return this.getRemoteStream(callSession);
|
|
9225
9240
|
}
|
|
9226
9241
|
|
|
9227
9242
|
accept(callSession , cameraEnabled ) {
|
|
9228
|
-
logger$
|
|
9243
|
+
logger$4.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
9229
9244
|
if (this.currentSipSession) {
|
|
9230
9245
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
9231
9246
|
}
|
|
9232
9247
|
|
|
9233
9248
|
if (!callSession) {
|
|
9234
|
-
logger$
|
|
9249
|
+
logger$4.warn('no CallSession to accept.');
|
|
9235
9250
|
return Promise.resolve(null);
|
|
9236
9251
|
}
|
|
9237
9252
|
|
|
9238
9253
|
if (callSession.getId() in this.acceptedSessions) {
|
|
9239
|
-
logger$
|
|
9254
|
+
logger$4.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9240
9255
|
return Promise.resolve(callSession.sipCallId);
|
|
9241
9256
|
}
|
|
9242
9257
|
|
|
@@ -9248,24 +9263,24 @@ class WebRTCPhone extends Emitter {
|
|
|
9248
9263
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
9249
9264
|
if (sipSession) {
|
|
9250
9265
|
if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
|
|
9251
|
-
logger$
|
|
9266
|
+
logger$4.warn('Trying to answer a terminated sipSession.');
|
|
9252
9267
|
|
|
9253
9268
|
return Promise.resolve(null);
|
|
9254
9269
|
}
|
|
9255
9270
|
|
|
9256
|
-
logger$
|
|
9271
|
+
logger$4.info('accept call, session found', { sipId: sipSession.id });
|
|
9257
9272
|
|
|
9258
9273
|
// $FlowFixMe
|
|
9259
9274
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
9260
9275
|
return callSession.sipCallId;
|
|
9261
9276
|
}).catch(e => {
|
|
9262
|
-
logger$
|
|
9277
|
+
logger$4.error(e);
|
|
9263
9278
|
this.endCurrentCall(callSession);
|
|
9264
9279
|
throw e;
|
|
9265
9280
|
});
|
|
9266
9281
|
}
|
|
9267
9282
|
|
|
9268
|
-
logger$
|
|
9283
|
+
logger$4.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9269
9284
|
|
|
9270
9285
|
return Promise.resolve(null);
|
|
9271
9286
|
}
|
|
@@ -9275,7 +9290,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9275
9290
|
}
|
|
9276
9291
|
|
|
9277
9292
|
async reject(callSession ) {
|
|
9278
|
-
logger$
|
|
9293
|
+
logger$4.info('reject WebRTC called', { id: callSession.getId() });
|
|
9279
9294
|
|
|
9280
9295
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
9281
9296
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -9287,14 +9302,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9287
9302
|
|
|
9288
9303
|
const sipSession = this.findSipSession(callSession);
|
|
9289
9304
|
if (sipSession) {
|
|
9290
|
-
logger$
|
|
9305
|
+
logger$4.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
9291
9306
|
|
|
9292
9307
|
this.client.hangup(sipSession);
|
|
9293
9308
|
}
|
|
9294
9309
|
}
|
|
9295
9310
|
|
|
9296
9311
|
async ignore(callSession ) {
|
|
9297
|
-
logger$
|
|
9312
|
+
logger$4.info('WebRTC ignore', { id: callSession.getId() });
|
|
9298
9313
|
|
|
9299
9314
|
// kill the ring
|
|
9300
9315
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -9306,14 +9321,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9306
9321
|
const sipSession = this.findSipSession(callSession);
|
|
9307
9322
|
|
|
9308
9323
|
if (sipSession) {
|
|
9309
|
-
logger$
|
|
9324
|
+
logger$4.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
9310
9325
|
|
|
9311
9326
|
return this.client.atxfer(sipSession);
|
|
9312
9327
|
}
|
|
9313
9328
|
}
|
|
9314
9329
|
|
|
9315
9330
|
hold(callSession , withEvent = true, isConference = false) {
|
|
9316
|
-
logger$
|
|
9331
|
+
logger$4.info('WebRTC hold', { id: callSession.getId() });
|
|
9317
9332
|
|
|
9318
9333
|
const sipSession = this.findSipSession(callSession);
|
|
9319
9334
|
|
|
@@ -9328,18 +9343,18 @@ class WebRTCPhone extends Emitter {
|
|
|
9328
9343
|
}
|
|
9329
9344
|
|
|
9330
9345
|
resume(callSession , isConference = false, withEvent = true) {
|
|
9331
|
-
logger$
|
|
9346
|
+
logger$4.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
9332
9347
|
|
|
9333
9348
|
const sipSession = this.findSipSession(callSession);
|
|
9334
9349
|
if (!sipSession) {
|
|
9335
9350
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
9336
9351
|
}
|
|
9337
9352
|
|
|
9338
|
-
logger$
|
|
9353
|
+
logger$4.info('WebRTC resuming', { sipId: sipSession.id });
|
|
9339
9354
|
|
|
9340
9355
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
9341
9356
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
9342
|
-
logger$
|
|
9357
|
+
logger$4.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
9343
9358
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
9344
9359
|
}
|
|
9345
9360
|
|
|
@@ -9364,7 +9379,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9364
9379
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9365
9380
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
9366
9381
|
|
|
9367
|
-
logger$
|
|
9382
|
+
logger$4.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9368
9383
|
|
|
9369
9384
|
// Stop screenshre if needed
|
|
9370
9385
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -9395,7 +9410,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9395
9410
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
9396
9411
|
}
|
|
9397
9412
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9398
|
-
logger$
|
|
9413
|
+
logger$4.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
9399
9414
|
|
|
9400
9415
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
9401
9416
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -9439,14 +9454,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9439
9454
|
}
|
|
9440
9455
|
|
|
9441
9456
|
mute(callSession , withEvent = true) {
|
|
9442
|
-
logger$
|
|
9457
|
+
logger$4.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
9443
9458
|
|
|
9444
9459
|
const sipSession = this.findSipSession(callSession);
|
|
9445
9460
|
if (!sipSession) {
|
|
9446
9461
|
return;
|
|
9447
9462
|
}
|
|
9448
9463
|
|
|
9449
|
-
logger$
|
|
9464
|
+
logger$4.info('WebRTC muting', { sipId: sipSession.id });
|
|
9450
9465
|
this.client.mute(sipSession);
|
|
9451
9466
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
9452
9467
|
|
|
@@ -9460,14 +9475,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9460
9475
|
}
|
|
9461
9476
|
|
|
9462
9477
|
unmute(callSession , withEvent = true) {
|
|
9463
|
-
logger$
|
|
9478
|
+
logger$4.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
9464
9479
|
|
|
9465
9480
|
const sipSession = this.findSipSession(callSession);
|
|
9466
9481
|
if (!sipSession) {
|
|
9467
9482
|
return;
|
|
9468
9483
|
}
|
|
9469
9484
|
|
|
9470
|
-
logger$
|
|
9485
|
+
logger$4.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
9471
9486
|
this.client.unmute(sipSession);
|
|
9472
9487
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
9473
9488
|
|
|
@@ -9494,7 +9509,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9494
9509
|
if (!sipSession) {
|
|
9495
9510
|
return;
|
|
9496
9511
|
}
|
|
9497
|
-
logger$
|
|
9512
|
+
logger$4.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
9498
9513
|
|
|
9499
9514
|
this.client.toggleCameraOn(sipSession);
|
|
9500
9515
|
|
|
@@ -9506,7 +9521,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9506
9521
|
if (!sipSession) {
|
|
9507
9522
|
return;
|
|
9508
9523
|
}
|
|
9509
|
-
logger$
|
|
9524
|
+
logger$4.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
9510
9525
|
|
|
9511
9526
|
this.client.toggleCameraOff(sipSession);
|
|
9512
9527
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -9518,7 +9533,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9518
9533
|
return;
|
|
9519
9534
|
}
|
|
9520
9535
|
|
|
9521
|
-
logger$
|
|
9536
|
+
logger$4.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
9522
9537
|
this.client.sendDTMF(sipSession, tone);
|
|
9523
9538
|
}
|
|
9524
9539
|
|
|
@@ -9526,7 +9541,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9526
9541
|
// @TODO: line is not used here
|
|
9527
9542
|
async makeCall(number , line , cameraEnabled ,
|
|
9528
9543
|
audioOnly = false, conference = false) {
|
|
9529
|
-
logger$
|
|
9544
|
+
logger$4.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
9530
9545
|
if (!number) {
|
|
9531
9546
|
return Promise.resolve(null);
|
|
9532
9547
|
}
|
|
@@ -9536,7 +9551,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9536
9551
|
}
|
|
9537
9552
|
if (this.currentSipSession) {
|
|
9538
9553
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
9539
|
-
logger$
|
|
9554
|
+
logger$4.warn('Unable to hold current session when making another call', e);
|
|
9540
9555
|
});
|
|
9541
9556
|
}
|
|
9542
9557
|
|
|
@@ -9546,7 +9561,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9546
9561
|
this._bindEvents(sipSession);
|
|
9547
9562
|
} catch (error) {
|
|
9548
9563
|
console.warn(error);
|
|
9549
|
-
logger$
|
|
9564
|
+
logger$4.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
9550
9565
|
return Promise.resolve(null);
|
|
9551
9566
|
}
|
|
9552
9567
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -9574,7 +9589,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9574
9589
|
return;
|
|
9575
9590
|
}
|
|
9576
9591
|
|
|
9577
|
-
logger$
|
|
9592
|
+
logger$4.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
9578
9593
|
|
|
9579
9594
|
this.client.transfer(sipSession, target);
|
|
9580
9595
|
}
|
|
@@ -9583,7 +9598,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9583
9598
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
9584
9599
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
9585
9600
|
|
|
9586
|
-
logger$
|
|
9601
|
+
logger$4.info('WebRTC indirect transfer', {
|
|
9587
9602
|
sipId: sipSession ? sipSession.id : null,
|
|
9588
9603
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
9589
9604
|
});
|
|
@@ -9622,7 +9637,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9622
9637
|
return false;
|
|
9623
9638
|
}
|
|
9624
9639
|
|
|
9625
|
-
logger$
|
|
9640
|
+
logger$4.info('WebRTC hangup', { sipId: sipSession.id });
|
|
9626
9641
|
|
|
9627
9642
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9628
9643
|
|
|
@@ -9668,7 +9683,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9668
9683
|
endCurrentCall(callSession ) {
|
|
9669
9684
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
9670
9685
|
|
|
9671
|
-
logger$
|
|
9686
|
+
logger$4.info('Ending current call', {
|
|
9672
9687
|
id: callSession ? callSession.getId() : null,
|
|
9673
9688
|
isCurrent,
|
|
9674
9689
|
});
|
|
@@ -9692,7 +9707,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9692
9707
|
}
|
|
9693
9708
|
|
|
9694
9709
|
async close() {
|
|
9695
|
-
logger$
|
|
9710
|
+
logger$4.info('WebRTC close');
|
|
9696
9711
|
|
|
9697
9712
|
try {
|
|
9698
9713
|
await Promise.race([
|
|
@@ -9700,7 +9715,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9700
9715
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
9701
9716
|
]);
|
|
9702
9717
|
} catch (e) {
|
|
9703
|
-
logger$
|
|
9718
|
+
logger$4.error('WebRTC close, unregister error', e);
|
|
9704
9719
|
}
|
|
9705
9720
|
|
|
9706
9721
|
this.client.close();
|
|
@@ -9718,12 +9733,12 @@ class WebRTCPhone extends Emitter {
|
|
|
9718
9733
|
}
|
|
9719
9734
|
|
|
9720
9735
|
enableRinging() {
|
|
9721
|
-
logger$
|
|
9736
|
+
logger$4.info('WebRTC enable ringing');
|
|
9722
9737
|
this.ringingEnabled = true;
|
|
9723
9738
|
}
|
|
9724
9739
|
|
|
9725
9740
|
disableRinging() {
|
|
9726
|
-
logger$
|
|
9741
|
+
logger$4.info('WebRTC disable ringing');
|
|
9727
9742
|
this.ringingEnabled = false;
|
|
9728
9743
|
}
|
|
9729
9744
|
|
|
@@ -9763,7 +9778,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9763
9778
|
|
|
9764
9779
|
// Deprecated
|
|
9765
9780
|
getLocalMediaStream(callSession ) {
|
|
9766
|
-
logger$
|
|
9781
|
+
logger$4.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9767
9782
|
return this.getLocalStream(callSession);
|
|
9768
9783
|
}
|
|
9769
9784
|
|
|
@@ -9805,7 +9820,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9805
9820
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
9806
9821
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
9807
9822
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
9808
|
-
logger$
|
|
9823
|
+
logger$4.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
9809
9824
|
|
|
9810
9825
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
9811
9826
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -9828,7 +9843,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9828
9843
|
});
|
|
9829
9844
|
|
|
9830
9845
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
9831
|
-
logger$
|
|
9846
|
+
logger$4.info('WebRTC on reinvite', {
|
|
9832
9847
|
sessionId: args[0].id,
|
|
9833
9848
|
inviteId: args[1].id,
|
|
9834
9849
|
updatedCalleeName: args[2],
|
|
@@ -9848,7 +9863,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9848
9863
|
});
|
|
9849
9864
|
|
|
9850
9865
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
9851
|
-
logger$
|
|
9866
|
+
logger$4.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
9852
9867
|
|
|
9853
9868
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
9854
9869
|
|
|
@@ -9859,22 +9874,22 @@ class WebRTCPhone extends Emitter {
|
|
|
9859
9874
|
this.client.on('ended', () => {});
|
|
9860
9875
|
|
|
9861
9876
|
this.client.on(this.client.ON_ERROR, e => {
|
|
9862
|
-
logger$
|
|
9877
|
+
logger$4.error('WebRTC error', e);
|
|
9863
9878
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
9864
9879
|
});
|
|
9865
9880
|
|
|
9866
9881
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
9867
|
-
logger$
|
|
9882
|
+
logger$4.info('WebRTC unregistered');
|
|
9868
9883
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
9869
9884
|
});
|
|
9870
9885
|
|
|
9871
9886
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
9872
|
-
logger$
|
|
9873
|
-
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
9887
|
+
logger$4.info('WebRTC disconnected');
|
|
9888
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
9874
9889
|
});
|
|
9875
9890
|
|
|
9876
9891
|
this.client.on(this.client.REGISTERED, () => {
|
|
9877
|
-
logger$
|
|
9892
|
+
logger$4.info('WebRTC registered', {
|
|
9878
9893
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
9879
9894
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
9880
9895
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -9887,23 +9902,27 @@ class WebRTCPhone extends Emitter {
|
|
|
9887
9902
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
9888
9903
|
&& this.currentSipSession.state === sessionState.SessionState.Established) {
|
|
9889
9904
|
this.shouldSendReinvite = false;
|
|
9905
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
9906
|
+
const isConference = pc ? pc.sfu : false;
|
|
9907
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
9908
|
+
|
|
9890
9909
|
try {
|
|
9891
9910
|
// Send reinvite with iceRestart
|
|
9892
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
9911
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
9893
9912
|
} catch (e) {
|
|
9894
|
-
logger$
|
|
9913
|
+
logger$4.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
9895
9914
|
}
|
|
9896
9915
|
}
|
|
9897
9916
|
});
|
|
9898
9917
|
|
|
9899
9918
|
this.client.on(this.client.CONNECTED, () => {
|
|
9900
|
-
logger$
|
|
9919
|
+
logger$4.info('WebRTC client connected');
|
|
9901
9920
|
|
|
9902
9921
|
this.stopHeartbeat();
|
|
9903
9922
|
});
|
|
9904
9923
|
|
|
9905
9924
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
9906
|
-
logger$
|
|
9925
|
+
logger$4.info('WebRTC client disconnected');
|
|
9907
9926
|
|
|
9908
9927
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
9909
9928
|
|
|
@@ -9917,7 +9936,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9917
9936
|
});
|
|
9918
9937
|
|
|
9919
9938
|
this.client.on(this.client.ON_TRACK, (session, event) => {
|
|
9920
|
-
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
9939
|
+
this.eventEmitter.emit(ON_TRACK$1, session, event);
|
|
9921
9940
|
});
|
|
9922
9941
|
|
|
9923
9942
|
this.client.on('onVideoInputChange', stream => {
|
|
@@ -9932,7 +9951,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9932
9951
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
9933
9952
|
const callSession = this.getCallSession(this.getSipSessionId(session));
|
|
9934
9953
|
|
|
9935
|
-
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
9954
|
+
this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
|
|
9936
9955
|
});
|
|
9937
9956
|
|
|
9938
9957
|
// Used when upgrading directly in screenshare mode
|
|
@@ -9941,7 +9960,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9941
9960
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
9942
9961
|
const callSession = this.callSessions[sipSessionId];
|
|
9943
9962
|
|
|
9944
|
-
logger$
|
|
9963
|
+
logger$4.info('Updrading directly in screensharing mode', {
|
|
9945
9964
|
sipSessionId,
|
|
9946
9965
|
tracks: localStream ? localStream.getTracks() : null,
|
|
9947
9966
|
});
|
|
@@ -9973,6 +9992,15 @@ class WebRTCPhone extends Emitter {
|
|
|
9973
9992
|
return this.client.getSipSessionId(sipSession);
|
|
9974
9993
|
}
|
|
9975
9994
|
|
|
9995
|
+
_updateCallSession(callSession ) {
|
|
9996
|
+
const sipSession = this.findSipSession(callSession);
|
|
9997
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
9998
|
+
|
|
9999
|
+
if (sipSessionId) {
|
|
10000
|
+
this.callSessions[sipSessionId] = callSession;
|
|
10001
|
+
}
|
|
10002
|
+
}
|
|
10003
|
+
|
|
9976
10004
|
_onMessage(message ) {
|
|
9977
10005
|
if (!message || message.method !== 'MESSAGE') {
|
|
9978
10006
|
return;
|
|
@@ -10110,8 +10138,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10110
10138
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10111
10139
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10112
10140
|
ON_MESSAGE: ON_MESSAGE,
|
|
10113
|
-
ON_REINVITE: ON_REINVITE,
|
|
10114
|
-
ON_TRACK: ON_TRACK,
|
|
10141
|
+
ON_REINVITE: ON_REINVITE$1,
|
|
10142
|
+
ON_TRACK: ON_TRACK$1,
|
|
10115
10143
|
ON_AUDIO_STREAM: ON_AUDIO_STREAM,
|
|
10116
10144
|
ON_VIDEO_STREAM: ON_VIDEO_STREAM,
|
|
10117
10145
|
ON_REMOVE_STREAM: ON_REMOVE_STREAM,
|
|
@@ -10126,19 +10154,19 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10126
10154
|
ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
|
|
10127
10155
|
ON_CALL_ERROR: ON_CALL_ERROR,
|
|
10128
10156
|
ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
|
|
10129
|
-
ON_NETWORK_STATS: ON_NETWORK_STATS,
|
|
10157
|
+
ON_NETWORK_STATS: ON_NETWORK_STATS$1,
|
|
10130
10158
|
ON_CHAT: ON_CHAT,
|
|
10131
10159
|
ON_SIGNAL: ON_SIGNAL,
|
|
10132
|
-
ON_DISCONNECTED: ON_DISCONNECTED,
|
|
10160
|
+
ON_DISCONNECTED: ON_DISCONNECTED$1,
|
|
10133
10161
|
MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
|
|
10134
10162
|
MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
|
|
10135
|
-
events: events,
|
|
10163
|
+
events: events$1,
|
|
10136
10164
|
'default': WebRTCPhone
|
|
10137
10165
|
});
|
|
10138
10166
|
|
|
10139
10167
|
//
|
|
10140
10168
|
|
|
10141
|
-
const logger$
|
|
10169
|
+
const logger$5 = IssueReporter$1.loggerFor('simple-phone');
|
|
10142
10170
|
const sipLogger = IssueReporter$1.loggerFor('sip.js');
|
|
10143
10171
|
const protocolLogger = IssueReporter$1.loggerFor('sip');
|
|
10144
10172
|
|
|
@@ -10245,7 +10273,7 @@ class Phone extends Emitter {
|
|
|
10245
10273
|
async disconnect() {
|
|
10246
10274
|
if (this.phone) {
|
|
10247
10275
|
if (this.phone.hasAnActiveCall()) {
|
|
10248
|
-
logger$
|
|
10276
|
+
logger$5.info('hangup call on disconnect');
|
|
10249
10277
|
// $FlowFixMe
|
|
10250
10278
|
await this.phone.hangup();
|
|
10251
10279
|
}
|
|
@@ -10268,13 +10296,13 @@ class Phone extends Emitter {
|
|
|
10268
10296
|
}
|
|
10269
10297
|
|
|
10270
10298
|
async hangup(callSession ) {
|
|
10271
|
-
logger$
|
|
10299
|
+
logger$5.info('hangup via simple phone', { callId: callSession.getId() });
|
|
10272
10300
|
|
|
10273
10301
|
return this.phone && this.phone.hangup(callSession);
|
|
10274
10302
|
}
|
|
10275
10303
|
|
|
10276
10304
|
async accept(callSession , cameraEnabled ) {
|
|
10277
|
-
logger$
|
|
10305
|
+
logger$5.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
|
|
10278
10306
|
|
|
10279
10307
|
return this.phone && this.phone.accept(callSession, cameraEnabled);
|
|
10280
10308
|
}
|
|
@@ -10313,7 +10341,7 @@ class Phone extends Emitter {
|
|
|
10313
10341
|
muteViaAPI(callSession ) {
|
|
10314
10342
|
if (callSession && callSession.callId) {
|
|
10315
10343
|
Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
|
|
10316
|
-
logger$
|
|
10344
|
+
logger$5.error('Mute via API, error', e);
|
|
10317
10345
|
});
|
|
10318
10346
|
}
|
|
10319
10347
|
}
|
|
@@ -10321,7 +10349,7 @@ class Phone extends Emitter {
|
|
|
10321
10349
|
unmuteViaAPI(callSession ) {
|
|
10322
10350
|
if (callSession && callSession.callId) {
|
|
10323
10351
|
Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
|
|
10324
|
-
logger$
|
|
10352
|
+
logger$5.error('Unmute via API, error', e);
|
|
10325
10353
|
});
|
|
10326
10354
|
}
|
|
10327
10355
|
}
|
|
@@ -10429,7 +10457,7 @@ class Phone extends Emitter {
|
|
|
10429
10457
|
|
|
10430
10458
|
// @Deprecated
|
|
10431
10459
|
getLocalMediaStream(callSession ) {
|
|
10432
|
-
logger$
|
|
10460
|
+
logger$5.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
|
|
10433
10461
|
|
|
10434
10462
|
return this.phone && this.phone.getLocalStream(callSession);
|
|
10435
10463
|
}
|
|
@@ -10452,20 +10480,20 @@ class Phone extends Emitter {
|
|
|
10452
10480
|
|
|
10453
10481
|
// @Deprecated
|
|
10454
10482
|
getRemoteStreamForCall(callSession ) {
|
|
10455
|
-
logger$
|
|
10483
|
+
logger$5.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
|
|
10456
10484
|
return this.getRemoteStream(callSession);
|
|
10457
10485
|
}
|
|
10458
10486
|
|
|
10459
10487
|
// Returns remote streams directly from the peerConnection
|
|
10460
10488
|
// @Deprecated
|
|
10461
10489
|
getRemoteStreamsForCall(callSession ) {
|
|
10462
|
-
logger$
|
|
10490
|
+
logger$5.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
|
|
10463
10491
|
return this.getLocalStream(callSession);
|
|
10464
10492
|
}
|
|
10465
10493
|
|
|
10466
10494
|
// @Deprecated
|
|
10467
10495
|
getRemoteVideoStreamForCall(callSession ) {
|
|
10468
|
-
logger$
|
|
10496
|
+
logger$5.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
|
|
10469
10497
|
|
|
10470
10498
|
return this.getRemoteVideoStream(callSession);
|
|
10471
10499
|
}
|
|
@@ -10526,7 +10554,7 @@ class Phone extends Emitter {
|
|
|
10526
10554
|
|
|
10527
10555
|
_transferEvents() {
|
|
10528
10556
|
this.unbind();
|
|
10529
|
-
[...events
|
|
10557
|
+
[...events, ...transportEvents].forEach(event => {
|
|
10530
10558
|
this.client.on(event, (...args) =>
|
|
10531
10559
|
this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
|
|
10532
10560
|
});
|
|
@@ -10548,7 +10576,7 @@ var Phone$1 = global.wazoTelephonyInstance;
|
|
|
10548
10576
|
|
|
10549
10577
|
//
|
|
10550
10578
|
|
|
10551
|
-
const SOCKET_EVENTS
|
|
10579
|
+
const SOCKET_EVENTS = {
|
|
10552
10580
|
ON_OPEN: 'onopen',
|
|
10553
10581
|
ON_MESSAGE: 'onmessage',
|
|
10554
10582
|
ON_ERROR: 'onerror',
|
|
@@ -10701,16 +10729,16 @@ class WebSocketClient extends Emitter {
|
|
|
10701
10729
|
|
|
10702
10730
|
this.socket.onopen = () => {
|
|
10703
10731
|
logger$6.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
10704
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10732
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
10705
10733
|
};
|
|
10706
10734
|
|
|
10707
10735
|
this.socket.onerror = event => {
|
|
10708
10736
|
logger$6.error('on Wazo WS error', event.target);
|
|
10709
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10737
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
10710
10738
|
};
|
|
10711
10739
|
|
|
10712
10740
|
this.socket.onmessage = (event ) => {
|
|
10713
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10741
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
|
|
10714
10742
|
|
|
10715
10743
|
const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
|
|
10716
10744
|
let { name } = message;
|
|
@@ -10743,11 +10771,11 @@ class WebSocketClient extends Emitter {
|
|
|
10743
10771
|
token: this.token,
|
|
10744
10772
|
});
|
|
10745
10773
|
this.initialized = false;
|
|
10746
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10774
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
|
|
10747
10775
|
|
|
10748
10776
|
switch (event.code) {
|
|
10749
10777
|
case 4002:
|
|
10750
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10778
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
|
|
10751
10779
|
break;
|
|
10752
10780
|
}
|
|
10753
10781
|
};
|
|
@@ -10863,7 +10891,7 @@ class WebSocketClient extends Emitter {
|
|
|
10863
10891
|
break;
|
|
10864
10892
|
case 'start':
|
|
10865
10893
|
this.initialized = true;
|
|
10866
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10894
|
+
this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
|
|
10867
10895
|
break;
|
|
10868
10896
|
default:
|
|
10869
10897
|
this.eventEmitter.emit('message', message);
|
|
@@ -10910,7 +10938,7 @@ class WebSocketClient extends Emitter {
|
|
|
10910
10938
|
logger$6.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
10911
10939
|
|
|
10912
10940
|
this.close();
|
|
10913
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10941
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
10914
10942
|
|
|
10915
10943
|
if (this.onHeartBeatTimeout) {
|
|
10916
10944
|
this.onHeartBeatTimeout();
|
|
@@ -10990,7 +11018,7 @@ WebSocketClient.eventLists = [
|
|
|
10990
11018
|
|
|
10991
11019
|
var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
10992
11020
|
__proto__: null,
|
|
10993
|
-
SOCKET_EVENTS: SOCKET_EVENTS
|
|
11021
|
+
SOCKET_EVENTS: SOCKET_EVENTS,
|
|
10994
11022
|
AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
|
|
10995
11023
|
FAVORITE_ADDED: FAVORITE_ADDED,
|
|
10996
11024
|
FAVORITE_DELETED: FAVORITE_DELETED,
|
|
@@ -11063,10 +11091,10 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
11063
11091
|
|
|
11064
11092
|
//
|
|
11065
11093
|
|
|
11066
|
-
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
11067
|
-
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
11094
|
+
const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
11095
|
+
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
|
|
11068
11096
|
|
|
11069
|
-
const logger$
|
|
11097
|
+
const logger$7 = IssueReporter$1.loggerFor('simple-ws-client');
|
|
11070
11098
|
|
|
11071
11099
|
class Websocket extends Emitter {
|
|
11072
11100
|
|
|
@@ -11080,9 +11108,9 @@ class Websocket extends Emitter {
|
|
|
11080
11108
|
// $FlowFixMe
|
|
11081
11109
|
this[key] = OTHER_EVENTS[key];
|
|
11082
11110
|
});
|
|
11083
|
-
Object.keys(SOCKET_EVENTS).forEach(key => {
|
|
11111
|
+
Object.keys(SOCKET_EVENTS$1).forEach(key => {
|
|
11084
11112
|
// $FlowFixMe
|
|
11085
|
-
this[key] = SOCKET_EVENTS[key];
|
|
11113
|
+
this[key] = SOCKET_EVENTS$1[key];
|
|
11086
11114
|
});
|
|
11087
11115
|
this.eventLists = WebSocketClient.eventLists;
|
|
11088
11116
|
|
|
@@ -11090,7 +11118,7 @@ class Websocket extends Emitter {
|
|
|
11090
11118
|
}
|
|
11091
11119
|
|
|
11092
11120
|
open(host , session ) {
|
|
11093
|
-
logger$
|
|
11121
|
+
logger$7.info('open simple WebSocket', { host, token: session.token });
|
|
11094
11122
|
this.ws = new WebSocketClient(
|
|
11095
11123
|
{
|
|
11096
11124
|
host,
|
|
@@ -11118,7 +11146,7 @@ class Websocket extends Emitter {
|
|
|
11118
11146
|
}
|
|
11119
11147
|
|
|
11120
11148
|
updateToken(token ) {
|
|
11121
|
-
logger$
|
|
11149
|
+
logger$7.info('update token via simple Websocket', { token, ws: !!this.ws });
|
|
11122
11150
|
|
|
11123
11151
|
if (!this.ws) {
|
|
11124
11152
|
return;
|
|
@@ -11146,7 +11174,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
|
|
|
11146
11174
|
|
|
11147
11175
|
//
|
|
11148
11176
|
|
|
11149
|
-
const logger$
|
|
11177
|
+
const logger$8 = IssueReporter$1.loggerFor('room');
|
|
11150
11178
|
|
|
11151
11179
|
class Participant extends Emitter {
|
|
11152
11180
|
|
|
@@ -11268,7 +11296,7 @@ class Participant extends Emitter {
|
|
|
11268
11296
|
}
|
|
11269
11297
|
|
|
11270
11298
|
onTalking(isTalking ) {
|
|
11271
|
-
logger$
|
|
11299
|
+
logger$8.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
|
|
11272
11300
|
this.isTalking = isTalking;
|
|
11273
11301
|
// you may notice we're not broadcasting: since all participants are getting this info
|
|
11274
11302
|
// directly from asterisk, there's no need to do so
|
|
@@ -11371,7 +11399,7 @@ class Participant extends Emitter {
|
|
|
11371
11399
|
}
|
|
11372
11400
|
|
|
11373
11401
|
updateStatus(status , broadcast = true) {
|
|
11374
|
-
logger$
|
|
11402
|
+
logger$8.info('updating participant status', { name: this.name, status });
|
|
11375
11403
|
|
|
11376
11404
|
if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
|
|
11377
11405
|
if (status.audioMuted) {
|
|
@@ -11419,7 +11447,7 @@ class Participant extends Emitter {
|
|
|
11419
11447
|
|
|
11420
11448
|
broadcastStatus(inboundStatus = null) {
|
|
11421
11449
|
const status = inboundStatus || this.getStatus();
|
|
11422
|
-
logger$
|
|
11450
|
+
logger$8.info('broadcasting participant status', { callId: this.callId, status });
|
|
11423
11451
|
|
|
11424
11452
|
this.room.sendSignal({
|
|
11425
11453
|
type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
|
|
@@ -11455,9 +11483,9 @@ class LocalParticipant extends Participant {
|
|
|
11455
11483
|
const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
11456
11484
|
const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
11457
11485
|
|
|
11458
|
-
const logger$
|
|
11486
|
+
const logger$9 = IssueReporter$1.loggerFor('sdk-room');
|
|
11459
11487
|
|
|
11460
|
-
class Room
|
|
11488
|
+
class Room extends Emitter {
|
|
11461
11489
|
|
|
11462
11490
|
|
|
11463
11491
|
|
|
@@ -11515,7 +11543,7 @@ class Room$1 extends Emitter {
|
|
|
11515
11543
|
extra = {},
|
|
11516
11544
|
) {
|
|
11517
11545
|
super();
|
|
11518
|
-
logger$
|
|
11546
|
+
logger$9.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
11519
11547
|
|
|
11520
11548
|
// Represents the room callSession
|
|
11521
11549
|
this.callSession = callSession;
|
|
@@ -11581,7 +11609,7 @@ class Room$1 extends Emitter {
|
|
|
11581
11609
|
* @returns {Promise<Room>}
|
|
11582
11610
|
*/
|
|
11583
11611
|
static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
|
|
11584
|
-
logger$
|
|
11612
|
+
logger$9.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
11585
11613
|
|
|
11586
11614
|
if (!room) {
|
|
11587
11615
|
await Wazo.Phone.connect();
|
|
@@ -11594,7 +11622,7 @@ class Room$1 extends Emitter {
|
|
|
11594
11622
|
|
|
11595
11623
|
// Call_created is triggered before call_accepted, so we have to listen for it here.
|
|
11596
11624
|
Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
|
|
11597
|
-
logger$
|
|
11625
|
+
logger$9.info('room call received via WS', { callId: data.call_id });
|
|
11598
11626
|
if (room) {
|
|
11599
11627
|
room.setCallId(data.call_id);
|
|
11600
11628
|
}
|
|
@@ -11602,7 +11630,7 @@ class Room$1 extends Emitter {
|
|
|
11602
11630
|
|
|
11603
11631
|
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
11604
11632
|
// eslint-disable-next-line no-param-reassign
|
|
11605
|
-
room = new Room
|
|
11633
|
+
room = new Room(callSession, extension, null, null, extra);
|
|
11606
11634
|
|
|
11607
11635
|
// Wait for the call to be accepted
|
|
11608
11636
|
await new Promise((resolve, reject) => {
|
|
@@ -11623,7 +11651,7 @@ class Room$1 extends Emitter {
|
|
|
11623
11651
|
// Retrieve conference
|
|
11624
11652
|
const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
|
|
11625
11653
|
|
|
11626
|
-
logger$
|
|
11654
|
+
logger$9.info('connected to room', {
|
|
11627
11655
|
sourceId: conference ? conference.sourceId : null,
|
|
11628
11656
|
name: conference ? conference.name : null,
|
|
11629
11657
|
});
|
|
@@ -11633,7 +11661,7 @@ class Room$1 extends Emitter {
|
|
|
11633
11661
|
room.setName(conference.name);
|
|
11634
11662
|
}
|
|
11635
11663
|
} else if (meeting) {
|
|
11636
|
-
logger$
|
|
11664
|
+
logger$9.info('Already connected to meeting', {
|
|
11637
11665
|
uuid: meeting.uuid,
|
|
11638
11666
|
name: meeting.name,
|
|
11639
11667
|
});
|
|
@@ -11646,13 +11674,13 @@ class Room$1 extends Emitter {
|
|
|
11646
11674
|
}
|
|
11647
11675
|
|
|
11648
11676
|
static disconnect() {
|
|
11649
|
-
logger$
|
|
11677
|
+
logger$9.info('static disconnection to room');
|
|
11650
11678
|
|
|
11651
11679
|
Wazo.Phone.disconnect();
|
|
11652
11680
|
}
|
|
11653
11681
|
|
|
11654
11682
|
async disconnect() {
|
|
11655
|
-
logger$
|
|
11683
|
+
logger$9.info('disconnection to room called');
|
|
11656
11684
|
|
|
11657
11685
|
await Wazo.Phone.hangup(this.callSession);
|
|
11658
11686
|
this.callSession = null;
|
|
@@ -11672,19 +11700,19 @@ class Room$1 extends Emitter {
|
|
|
11672
11700
|
}
|
|
11673
11701
|
|
|
11674
11702
|
setSourceId(sourceId ) {
|
|
11675
|
-
logger$
|
|
11703
|
+
logger$9.info('set room source id', { sourceId });
|
|
11676
11704
|
|
|
11677
11705
|
this.sourceId = sourceId;
|
|
11678
11706
|
}
|
|
11679
11707
|
|
|
11680
11708
|
setMeetingUuid(meetingUuid ) {
|
|
11681
|
-
logger$
|
|
11709
|
+
logger$9.info('set meeting uuid', { meetingUuid });
|
|
11682
11710
|
|
|
11683
11711
|
this.meetingUuid = meetingUuid;
|
|
11684
11712
|
}
|
|
11685
11713
|
|
|
11686
11714
|
setCallId(callId ) {
|
|
11687
|
-
logger$
|
|
11715
|
+
logger$9.info('set room call id', { callId });
|
|
11688
11716
|
|
|
11689
11717
|
if (callId) {
|
|
11690
11718
|
this.callId = callId;
|
|
@@ -11692,7 +11720,7 @@ class Room$1 extends Emitter {
|
|
|
11692
11720
|
}
|
|
11693
11721
|
|
|
11694
11722
|
setName(name ) {
|
|
11695
|
-
logger$
|
|
11723
|
+
logger$9.info('set room name', { name });
|
|
11696
11724
|
|
|
11697
11725
|
this.name = name;
|
|
11698
11726
|
}
|
|
@@ -11711,7 +11739,7 @@ class Room$1 extends Emitter {
|
|
|
11711
11739
|
}
|
|
11712
11740
|
|
|
11713
11741
|
async startScreenSharing(constraints ) {
|
|
11714
|
-
logger$
|
|
11742
|
+
logger$9.info('start room screen sharing', { constraints });
|
|
11715
11743
|
|
|
11716
11744
|
const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
|
|
11717
11745
|
if (!screensharingStream) {
|
|
@@ -11725,7 +11753,7 @@ class Room$1 extends Emitter {
|
|
|
11725
11753
|
}
|
|
11726
11754
|
|
|
11727
11755
|
async stopScreenSharing(restoreLocalStream = true) {
|
|
11728
|
-
logger$
|
|
11756
|
+
logger$9.info('stop room screen sharing');
|
|
11729
11757
|
|
|
11730
11758
|
await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
11731
11759
|
|
|
@@ -11737,7 +11765,7 @@ class Room$1 extends Emitter {
|
|
|
11737
11765
|
}
|
|
11738
11766
|
|
|
11739
11767
|
turnCameraOff() {
|
|
11740
|
-
logger$
|
|
11768
|
+
logger$9.info('turn room camera off');
|
|
11741
11769
|
|
|
11742
11770
|
Wazo.Phone.turnCameraOff(this.callSession);
|
|
11743
11771
|
|
|
@@ -11747,7 +11775,7 @@ class Room$1 extends Emitter {
|
|
|
11747
11775
|
}
|
|
11748
11776
|
|
|
11749
11777
|
turnCameraOn() {
|
|
11750
|
-
logger$
|
|
11778
|
+
logger$9.info('turn room camera on');
|
|
11751
11779
|
|
|
11752
11780
|
Wazo.Phone.turnCameraOn(this.callSession);
|
|
11753
11781
|
|
|
@@ -11757,7 +11785,7 @@ class Room$1 extends Emitter {
|
|
|
11757
11785
|
}
|
|
11758
11786
|
|
|
11759
11787
|
mute() {
|
|
11760
|
-
logger$
|
|
11788
|
+
logger$9.info('mute room');
|
|
11761
11789
|
|
|
11762
11790
|
Wazo.Phone.mute(this.callSession);
|
|
11763
11791
|
|
|
@@ -11765,7 +11793,7 @@ class Room$1 extends Emitter {
|
|
|
11765
11793
|
}
|
|
11766
11794
|
|
|
11767
11795
|
unmute() {
|
|
11768
|
-
logger$
|
|
11796
|
+
logger$9.info('unmute room');
|
|
11769
11797
|
|
|
11770
11798
|
Wazo.Phone.unmute(this.callSession);
|
|
11771
11799
|
|
|
@@ -11785,7 +11813,7 @@ class Room$1 extends Emitter {
|
|
|
11785
11813
|
}
|
|
11786
11814
|
|
|
11787
11815
|
hold() {
|
|
11788
|
-
logger$
|
|
11816
|
+
logger$9.info('hold room');
|
|
11789
11817
|
|
|
11790
11818
|
Wazo.Phone.hold(this.callSession, true);
|
|
11791
11819
|
|
|
@@ -11795,7 +11823,7 @@ class Room$1 extends Emitter {
|
|
|
11795
11823
|
}
|
|
11796
11824
|
|
|
11797
11825
|
async resume() {
|
|
11798
|
-
logger$
|
|
11826
|
+
logger$9.info('resume room');
|
|
11799
11827
|
|
|
11800
11828
|
const newStream = await Wazo.Phone.resume(this.callSession, true);
|
|
11801
11829
|
|
|
@@ -11823,13 +11851,13 @@ class Room$1 extends Emitter {
|
|
|
11823
11851
|
}
|
|
11824
11852
|
|
|
11825
11853
|
sendDTMF(tone ) {
|
|
11826
|
-
logger$
|
|
11854
|
+
logger$9.info('send room DTMF', { tone });
|
|
11827
11855
|
|
|
11828
11856
|
Wazo.Phone.sendDTMF(tone, this.callSession);
|
|
11829
11857
|
}
|
|
11830
11858
|
|
|
11831
11859
|
async sendReinvite(newConstraints = null) {
|
|
11832
|
-
logger$
|
|
11860
|
+
logger$9.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
11833
11861
|
const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
|
|
11834
11862
|
|
|
11835
11863
|
Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
|
|
@@ -11888,7 +11916,7 @@ class Room$1 extends Emitter {
|
|
|
11888
11916
|
Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
11889
11917
|
|
|
11890
11918
|
this.on(this.ON_AUDIO_STREAM, stream => {
|
|
11891
|
-
logger$
|
|
11919
|
+
logger$9.info('on room audio stream');
|
|
11892
11920
|
|
|
11893
11921
|
this.audioStream = stream;
|
|
11894
11922
|
if (!this.roomAudioElement) {
|
|
@@ -11901,7 +11929,7 @@ class Room$1 extends Emitter {
|
|
|
11901
11929
|
});
|
|
11902
11930
|
|
|
11903
11931
|
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
11904
|
-
logger$
|
|
11932
|
+
logger$9.info('on room video stream', { streamId });
|
|
11905
11933
|
|
|
11906
11934
|
this._mapMsid(sipSession.body.body);
|
|
11907
11935
|
|
|
@@ -11916,7 +11944,7 @@ class Room$1 extends Emitter {
|
|
|
11916
11944
|
});
|
|
11917
11945
|
|
|
11918
11946
|
this.on(this.ON_REMOVE_STREAM, stream => {
|
|
11919
|
-
logger$
|
|
11947
|
+
logger$9.info('on room remove stream');
|
|
11920
11948
|
|
|
11921
11949
|
const participant = this.participants.find(someParticipant =>
|
|
11922
11950
|
someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
|
|
@@ -12048,7 +12076,7 @@ class Room$1 extends Emitter {
|
|
|
12048
12076
|
const requester = this._getParticipantFromCallId(origin.callId);
|
|
12049
12077
|
if (requester) {
|
|
12050
12078
|
// @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
|
|
12051
|
-
logger$
|
|
12079
|
+
logger$9.info('trigger room requester status', { origin });
|
|
12052
12080
|
requester.triggerUpdate('REQUESTER_UPDATE');
|
|
12053
12081
|
}
|
|
12054
12082
|
break;
|
|
@@ -12079,24 +12107,24 @@ class Room$1 extends Emitter {
|
|
|
12079
12107
|
|
|
12080
12108
|
// When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
|
|
12081
12109
|
if (participant.user_uuid === session.uuid) {
|
|
12082
|
-
logger$
|
|
12110
|
+
logger$9.info('room current user joined');
|
|
12083
12111
|
|
|
12084
12112
|
// Retrieve participants via an API calls
|
|
12085
12113
|
const conferenceId = this.sourceId || payload.data.conference_id;
|
|
12086
12114
|
let response;
|
|
12087
12115
|
try {
|
|
12088
12116
|
if (this.meetingUuid) {
|
|
12089
|
-
logger$
|
|
12117
|
+
logger$9.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
12090
12118
|
response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
|
|
12091
12119
|
} else {
|
|
12092
|
-
logger$
|
|
12120
|
+
logger$9.info('fetching conference participants', { conferenceId });
|
|
12093
12121
|
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
12094
12122
|
}
|
|
12095
12123
|
} catch (e) {
|
|
12096
|
-
logger$
|
|
12124
|
+
logger$9.error('room participants fetching, error', e);
|
|
12097
12125
|
}
|
|
12098
12126
|
if (response) {
|
|
12099
|
-
logger$
|
|
12127
|
+
logger$9.info('conference participants fetched', { nb: response.items.length });
|
|
12100
12128
|
participants = response.items.map(item => {
|
|
12101
12129
|
const isMe = item.call_id === this.callId;
|
|
12102
12130
|
|
|
@@ -12123,7 +12151,7 @@ class Room$1 extends Emitter {
|
|
|
12123
12151
|
? new Wazo.RemoteParticipant(this, participant)
|
|
12124
12152
|
: null;
|
|
12125
12153
|
|
|
12126
|
-
logger$
|
|
12154
|
+
logger$9.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
12127
12155
|
|
|
12128
12156
|
if (remoteParticipant) {
|
|
12129
12157
|
this.participants.push(remoteParticipant);
|
|
@@ -12288,12 +12316,12 @@ class Room$1 extends Emitter {
|
|
|
12288
12316
|
|
|
12289
12317
|
//
|
|
12290
12318
|
|
|
12291
|
-
const logger$
|
|
12319
|
+
const logger$a = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
12292
12320
|
|
|
12293
|
-
class SipRoom extends Room
|
|
12321
|
+
class SipRoom extends Room {
|
|
12294
12322
|
|
|
12295
12323
|
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
12296
|
-
logger$
|
|
12324
|
+
logger$a.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
12297
12325
|
|
|
12298
12326
|
if (!room) {
|
|
12299
12327
|
await Wazo.Phone.connect();
|
|
@@ -12309,7 +12337,7 @@ class SipRoom extends Room$1 {
|
|
|
12309
12337
|
room.setCallId(room.callSession.call.id);
|
|
12310
12338
|
}
|
|
12311
12339
|
|
|
12312
|
-
logger$
|
|
12340
|
+
logger$a.info('connected to room', {
|
|
12313
12341
|
extension: room.extension,
|
|
12314
12342
|
});
|
|
12315
12343
|
|
|
@@ -12317,7 +12345,7 @@ class SipRoom extends Room$1 {
|
|
|
12317
12345
|
}
|
|
12318
12346
|
|
|
12319
12347
|
mute() {
|
|
12320
|
-
logger$
|
|
12348
|
+
logger$a.info('mute sip room');
|
|
12321
12349
|
|
|
12322
12350
|
Wazo.Phone.mute(this.callSession, false);
|
|
12323
12351
|
|
|
@@ -12325,7 +12353,7 @@ class SipRoom extends Room$1 {
|
|
|
12325
12353
|
}
|
|
12326
12354
|
|
|
12327
12355
|
unmute() {
|
|
12328
|
-
logger$
|
|
12356
|
+
logger$a.info('unmute sip room');
|
|
12329
12357
|
|
|
12330
12358
|
Wazo.Phone.unmute(this.callSession, false);
|
|
12331
12359
|
|
|
@@ -12592,7 +12620,7 @@ class NotificationOptions {
|
|
|
12592
12620
|
|
|
12593
12621
|
|
|
12594
12622
|
// Represents a conference room, like `9000`.
|
|
12595
|
-
class Room {
|
|
12623
|
+
class Room$1 {
|
|
12596
12624
|
|
|
12597
12625
|
|
|
12598
12626
|
|
|
@@ -12613,7 +12641,7 @@ class Room {
|
|
|
12613
12641
|
}
|
|
12614
12642
|
|
|
12615
12643
|
connect(callSession ) {
|
|
12616
|
-
return new Room({ ...this, connectedCallSession: callSession });
|
|
12644
|
+
return new Room$1({ ...this, connectedCallSession: callSession });
|
|
12617
12645
|
}
|
|
12618
12646
|
|
|
12619
12647
|
has(callSession ) {
|
|
@@ -12622,7 +12650,7 @@ class Room {
|
|
|
12622
12650
|
|
|
12623
12651
|
addParticipant(uuid , extension , talking = null) {
|
|
12624
12652
|
if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
|
|
12625
|
-
return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
12653
|
+
return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
12626
12654
|
}
|
|
12627
12655
|
|
|
12628
12656
|
return this;
|
|
@@ -12641,7 +12669,7 @@ class Room {
|
|
|
12641
12669
|
updatedParticipants.push(participant);
|
|
12642
12670
|
}
|
|
12643
12671
|
|
|
12644
|
-
return new Room({ ...this, participants: updatedParticipants });
|
|
12672
|
+
return new Room$1({ ...this, participants: updatedParticipants });
|
|
12645
12673
|
}
|
|
12646
12674
|
|
|
12647
12675
|
updateParticipantByExtension(extension , participant , shouldAdd = false) {
|
|
@@ -12657,7 +12685,7 @@ class Room {
|
|
|
12657
12685
|
updatedParticipants.push(participant);
|
|
12658
12686
|
}
|
|
12659
12687
|
|
|
12660
|
-
return new Room({ ...this, participants: updatedParticipants });
|
|
12688
|
+
return new Room$1({ ...this, participants: updatedParticipants });
|
|
12661
12689
|
}
|
|
12662
12690
|
|
|
12663
12691
|
hasCallWithId(id ) {
|
|
@@ -12665,18 +12693,18 @@ class Room {
|
|
|
12665
12693
|
}
|
|
12666
12694
|
|
|
12667
12695
|
disconnect() {
|
|
12668
|
-
return new Room({ ...this, connectedCallSession: null });
|
|
12696
|
+
return new Room$1({ ...this, connectedCallSession: null });
|
|
12669
12697
|
}
|
|
12670
12698
|
|
|
12671
12699
|
removeParticipantWithUUID(uuid ) {
|
|
12672
|
-
return new Room({
|
|
12700
|
+
return new Room$1({
|
|
12673
12701
|
...this,
|
|
12674
12702
|
participants: this.participants.filter(participant => participant.uuid !== uuid),
|
|
12675
12703
|
});
|
|
12676
12704
|
}
|
|
12677
12705
|
|
|
12678
12706
|
removeParticipantWithExtension(extension ) {
|
|
12679
|
-
return new Room({
|
|
12707
|
+
return new Room$1({
|
|
12680
12708
|
...this,
|
|
12681
12709
|
participants: this.participants.filter(participant => participant.extension !== extension),
|
|
12682
12710
|
});
|
|
@@ -12687,7 +12715,7 @@ class Room {
|
|
|
12687
12715
|
}
|
|
12688
12716
|
|
|
12689
12717
|
static newFrom(room ) {
|
|
12690
|
-
return newFrom(room, Room);
|
|
12718
|
+
return newFrom(room, Room$1);
|
|
12691
12719
|
}
|
|
12692
12720
|
}
|
|
12693
12721
|
|
|
@@ -12994,11 +13022,11 @@ var wazoWebsocket = {
|
|
|
12994
13022
|
resolve();
|
|
12995
13023
|
};
|
|
12996
13024
|
|
|
12997
|
-
client.on(SOCKET_EVENTS
|
|
13025
|
+
client.on(SOCKET_EVENTS.ON_ERROR, error => {
|
|
12998
13026
|
handleError(`Connection error : ${error}`);
|
|
12999
13027
|
});
|
|
13000
13028
|
|
|
13001
|
-
client.on(SOCKET_EVENTS
|
|
13029
|
+
client.on(SOCKET_EVENTS.ON_OPEN, () => {
|
|
13002
13030
|
if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
|
|
13003
13031
|
client.setOnHeartbeatTimeout(() => {
|
|
13004
13032
|
handleError('No response to heartbeat');
|
|
@@ -13099,7 +13127,7 @@ var webrtc = {
|
|
|
13099
13127
|
}),
|
|
13100
13128
|
};
|
|
13101
13129
|
|
|
13102
|
-
const parseCandidate = line => {
|
|
13130
|
+
const parseCandidate$1 = line => {
|
|
13103
13131
|
let parts;
|
|
13104
13132
|
// Parse both variants.
|
|
13105
13133
|
if (line.indexOf('a=candidate:') === 0) {
|
|
@@ -13190,7 +13218,7 @@ var SymmetricNat = {
|
|
|
13190
13218
|
}
|
|
13191
13219
|
|
|
13192
13220
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
13193
|
-
const cand = parseCandidate(e.candidate.candidate);
|
|
13221
|
+
const cand = parseCandidate$1(e.candidate.candidate);
|
|
13194
13222
|
if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
|
|
13195
13223
|
candidates[cand.relatedPort].push(cand.port);
|
|
13196
13224
|
} else if (!e.candidate) {
|
|
@@ -13258,7 +13286,7 @@ var iceIpv4 = {
|
|
|
13258
13286
|
const rawCandidate = e.candidate.candidate;
|
|
13259
13287
|
if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
|
|
13260
13288
|
hasSrflxOrRelay = true;
|
|
13261
|
-
const candidate = parseCandidate(e.candidate.candidate);
|
|
13289
|
+
const candidate = parseCandidate$1(e.candidate.candidate);
|
|
13262
13290
|
ips.push(candidate.ip);
|
|
13263
13291
|
}
|
|
13264
13292
|
} else if (!e.candidate) {
|
|
@@ -13295,7 +13323,7 @@ var checks = [
|
|
|
13295
13323
|
|
|
13296
13324
|
//
|
|
13297
13325
|
|
|
13298
|
-
const logger$
|
|
13326
|
+
const logger$b = IssueReporter$1.loggerFor('engine-check');
|
|
13299
13327
|
|
|
13300
13328
|
class Checker {
|
|
13301
13329
|
|
|
@@ -13313,28 +13341,28 @@ class Checker {
|
|
|
13313
13341
|
async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
|
|
13314
13342
|
await this._addEngineVersion();
|
|
13315
13343
|
|
|
13316
|
-
logger$
|
|
13344
|
+
logger$b.info('Engine check starting');
|
|
13317
13345
|
|
|
13318
13346
|
for (let i = 0; i < this.checks.length; i++) {
|
|
13319
13347
|
const { name, check } = this.checks[i];
|
|
13320
13348
|
|
|
13321
|
-
logger$
|
|
13349
|
+
logger$b.info(`Checking ${name} ...`);
|
|
13322
13350
|
|
|
13323
13351
|
onCheckBegin(name);
|
|
13324
13352
|
try {
|
|
13325
13353
|
// eslint-disable-next-line no-await-in-loop
|
|
13326
13354
|
const result = await check(this.server, this.session, this.externalAppConfig);
|
|
13327
|
-
logger$
|
|
13355
|
+
logger$b.info(`Checking ${name} success.`, { result });
|
|
13328
13356
|
|
|
13329
13357
|
onCheckResult(name, result);
|
|
13330
13358
|
} catch (e) {
|
|
13331
|
-
logger$
|
|
13359
|
+
logger$b.info(`Checking ${name} failure`, { message: e.message });
|
|
13332
13360
|
|
|
13333
13361
|
onCheckResult(name, e);
|
|
13334
13362
|
}
|
|
13335
13363
|
}
|
|
13336
13364
|
|
|
13337
|
-
logger$
|
|
13365
|
+
logger$b.info('Engine check done.');
|
|
13338
13366
|
}
|
|
13339
13367
|
|
|
13340
13368
|
addCheck(check ) {
|
|
@@ -13358,7 +13386,7 @@ const Wazo = {
|
|
|
13358
13386
|
Auth: Auth$1,
|
|
13359
13387
|
Phone: Phone$1,
|
|
13360
13388
|
Websocket: Websocket$1,
|
|
13361
|
-
Room
|
|
13389
|
+
Room,
|
|
13362
13390
|
SipRoom,
|
|
13363
13391
|
RemoteParticipant,
|
|
13364
13392
|
LocalParticipant,
|
|
@@ -13391,7 +13419,7 @@ const Wazo = {
|
|
|
13391
13419
|
Session,
|
|
13392
13420
|
Voicemail,
|
|
13393
13421
|
Relocation,
|
|
13394
|
-
ConferenceRoom: Room,
|
|
13422
|
+
ConferenceRoom: Room$1,
|
|
13395
13423
|
CallSession,
|
|
13396
13424
|
IndirectTransfer,
|
|
13397
13425
|
SwitchboardCall,
|
|
@@ -13430,7 +13458,7 @@ if (global) {
|
|
|
13430
13458
|
class InvalidSubscription extends Error {}
|
|
13431
13459
|
class InvalidAuthorization extends Error {}
|
|
13432
13460
|
|
|
13433
|
-
const logger = IssueReporter$1.loggerFor('simple-auth');
|
|
13461
|
+
const logger$c = IssueReporter$1.loggerFor('simple-auth');
|
|
13434
13462
|
|
|
13435
13463
|
class Auth {
|
|
13436
13464
|
|
|
@@ -13465,7 +13493,7 @@ class Auth {
|
|
|
13465
13493
|
setApiClientId(this.clientId);
|
|
13466
13494
|
setRefreshExpiration(this.expiration);
|
|
13467
13495
|
setOnRefreshToken((token , session ) => {
|
|
13468
|
-
logger.info('on refresh token done', { token });
|
|
13496
|
+
logger$c.info('on refresh token done', { token });
|
|
13469
13497
|
setApiToken(token);
|
|
13470
13498
|
Wazo.Websocket.updateToken(token);
|
|
13471
13499
|
|
|
@@ -13510,7 +13538,7 @@ class Auth {
|
|
|
13510
13538
|
const rawSession = await getApiClient().auth.authenticate(token);
|
|
13511
13539
|
return this._onAuthenticated(rawSession);
|
|
13512
13540
|
} catch (e) {
|
|
13513
|
-
logger.error('on validate token error', e);
|
|
13541
|
+
logger$c.error('on validate token error', e);
|
|
13514
13542
|
console.warn(e);
|
|
13515
13543
|
return false;
|
|
13516
13544
|
}
|