@wazo/sdk 0.37.23 → 0.37.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/api-client.test.js +22 -17
- package/esm/__tests__/web-rtc-client.test.js +105 -100
- package/esm/api/amid.js +1 -1
- package/esm/api/call-logd.js +2 -2
- package/esm/api/confd.js +10 -5
- package/esm/api/ctid-ng.js +3 -3
- package/esm/api/dird.js +1 -1
- package/esm/api/webhookd.js +1 -1
- package/esm/api-client.js +22 -17
- package/esm/checker/Checker.js +130 -125
- package/esm/checker/checks/aor.js +22 -17
- package/esm/checker/checks/api.js +22 -17
- package/esm/checker/checks/index.js +120 -115
- package/esm/checker/checks/wazo-websocket.js +15 -15
- package/esm/checker/checks/webrtc-transport.js +105 -100
- package/esm/checker/checks/webrtc.js +105 -100
- package/esm/domain/AdHocAPIConference.js +22 -17
- package/esm/domain/CallLog.js +1 -1
- package/esm/domain/Contact.js +1 -1
- package/esm/domain/Features.js +22 -17
- package/esm/domain/Meeting.js +12 -5
- package/esm/domain/Phone/CTIPhone.js +36 -31
- package/esm/domain/Phone/WebRTCPhone.js +110 -87
- package/esm/domain/__tests__/CallLog.test.js +1 -1
- package/esm/domain/__tests__/Contact.test.js +1 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/index.js +365 -337
- package/esm/lib/WazoSessionDescriptionHandler.js +1 -1
- package/esm/service/CallApi.js +22 -17
- package/esm/service/IssueReporter.js +1 -1
- package/esm/service/__tests__/IssueReporter.test.js +1 -1
- package/esm/service/getApiClient.js +22 -17
- package/esm/simple/Auth.js +355 -327
- package/esm/simple/Configuration.js +355 -327
- package/esm/simple/Directory.js +22 -17
- package/esm/simple/Phone.js +355 -327
- package/esm/simple/Websocket.js +17 -17
- package/esm/simple/index.js +359 -331
- package/esm/simple/room/LocalParticipant.js +359 -331
- package/esm/simple/room/Participant.js +359 -331
- package/esm/simple/room/RemoteParticipant.js +359 -331
- package/esm/simple/room/Room.js +360 -332
- package/esm/simple/room/SipRoom.js +359 -331
- package/esm/simple/room/Stream.js +359 -331
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +359 -331
- package/esm/simple/utils.js +359 -331
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/web-rtc-client.js +105 -100
- package/esm/websocket-client.js +15 -15
- package/lib/__tests__/api-client.test.js +22 -17
- package/lib/__tests__/web-rtc-client.test.js +105 -100
- package/lib/api/amid.js +1 -1
- package/lib/api/call-logd.js +2 -2
- package/lib/api/confd.js +10 -5
- package/lib/api/ctid-ng.js +3 -3
- package/lib/api/dird.js +1 -1
- package/lib/api/webhookd.js +1 -1
- package/lib/api-client.js +22 -17
- package/lib/checker/Checker.js +130 -125
- package/lib/checker/checks/aor.js +22 -17
- package/lib/checker/checks/api.js +22 -17
- package/lib/checker/checks/index.js +120 -115
- package/lib/checker/checks/wazo-websocket.js +15 -15
- package/lib/checker/checks/webrtc-transport.js +105 -100
- package/lib/checker/checks/webrtc.js +105 -100
- package/lib/domain/AdHocAPIConference.js +22 -17
- package/lib/domain/CallLog.js +1 -1
- package/lib/domain/Contact.js +1 -1
- package/lib/domain/Features.js +22 -17
- package/lib/domain/Meeting.js +16 -5
- package/lib/domain/Phone/CTIPhone.js +36 -31
- package/lib/domain/Phone/WebRTCPhone.js +110 -87
- package/lib/domain/__tests__/CallLog.test.js +1 -1
- package/lib/domain/__tests__/Contact.test.js +1 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/index.js +365 -337
- package/lib/lib/WazoSessionDescriptionHandler.js +1 -1
- package/lib/service/CallApi.js +22 -17
- package/lib/service/IssueReporter.js +1 -1
- package/lib/service/__tests__/IssueReporter.test.js +1 -1
- package/lib/service/getApiClient.js +22 -17
- package/lib/simple/Auth.js +355 -327
- package/lib/simple/Configuration.js +355 -327
- package/lib/simple/Directory.js +22 -17
- package/lib/simple/Phone.js +355 -327
- package/lib/simple/Websocket.js +17 -17
- package/lib/simple/index.js +359 -331
- package/lib/simple/room/LocalParticipant.js +359 -331
- package/lib/simple/room/Participant.js +359 -331
- package/lib/simple/room/RemoteParticipant.js +359 -331
- package/lib/simple/room/Room.js +360 -332
- package/lib/simple/room/SipRoom.js +359 -331
- package/lib/simple/room/Stream.js +359 -331
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +359 -331
- package/lib/simple/utils.js +359 -331
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/web-rtc-client.js +105 -100
- package/lib/websocket-client.js +15 -15
- package/package.json +1 -1
- package/src/domain/Meeting.js +12 -5
- package/src/domain/Phone/WebRTCPhone.js +24 -1
- package/src/domain/__tests__/Meeting.test.js +50 -0
package/lib/simple/Auth.js
CHANGED
|
@@ -1959,7 +1959,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
1959
1959
|
|
|
1960
1960
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
1961
1961
|
|
|
1962
|
-
const logger
|
|
1962
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
1963
1963
|
|
|
1964
1964
|
// Use a function here to be able to mock it in tests
|
|
1965
1965
|
const realFetch = () => {
|
|
@@ -2098,7 +2098,7 @@ class ApiRequester {
|
|
|
2098
2098
|
};
|
|
2099
2099
|
|
|
2100
2100
|
if (this.refreshTokenPromise) {
|
|
2101
|
-
logger
|
|
2101
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
2102
2102
|
await this.refreshTokenPromise;
|
|
2103
2103
|
}
|
|
2104
2104
|
|
|
@@ -2118,7 +2118,7 @@ class ApiRequester {
|
|
|
2118
2118
|
return promise.then(async (err ) => {
|
|
2119
2119
|
// Check if the token is still valid
|
|
2120
2120
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
2121
|
-
logger
|
|
2121
|
+
logger.warn('token expired', { error: err.reason });
|
|
2122
2122
|
// Replay the call after refreshing the token
|
|
2123
2123
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
2124
2124
|
}
|
|
@@ -2128,7 +2128,7 @@ class ApiRequester {
|
|
|
2128
2128
|
: exceptionClass.fromResponse(err, response.status);
|
|
2129
2129
|
|
|
2130
2130
|
if (this.shouldLogErrors) {
|
|
2131
|
-
logger
|
|
2131
|
+
logger.error('API error', error);
|
|
2132
2132
|
}
|
|
2133
2133
|
|
|
2134
2134
|
throw error;
|
|
@@ -2138,7 +2138,7 @@ class ApiRequester {
|
|
|
2138
2138
|
return newParse(response, isJson);
|
|
2139
2139
|
}).catch(error => {
|
|
2140
2140
|
if (this.shouldLogErrors) {
|
|
2141
|
-
logger
|
|
2141
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
2142
2142
|
}
|
|
2143
2143
|
|
|
2144
2144
|
throw error;
|
|
@@ -2166,13 +2166,13 @@ class ApiRequester {
|
|
|
2166
2166
|
) {
|
|
2167
2167
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
2168
2168
|
let newPath = path;
|
|
2169
|
-
logger
|
|
2169
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
2170
2170
|
|
|
2171
2171
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
2172
2172
|
|
|
2173
2173
|
return this.refreshTokenPromise.then(() => {
|
|
2174
2174
|
this.refreshTokenPromise = null;
|
|
2175
|
-
logger
|
|
2175
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
2176
2176
|
if (isTokenNotFound) {
|
|
2177
2177
|
const pathParts = path.split('/');
|
|
2178
2178
|
pathParts.pop();
|
|
@@ -2642,8 +2642,9 @@ class ExternalApp {
|
|
|
2642
2642
|
|
|
2643
2643
|
|
|
2644
2644
|
|
|
2645
|
-
|
|
2645
|
+
|
|
2646
2646
|
|
|
2647
|
+
|
|
2647
2648
|
|
|
2648
2649
|
|
|
2649
2650
|
class Meeting {
|
|
@@ -2654,9 +2655,10 @@ class Meeting {
|
|
|
2654
2655
|
|
|
2655
2656
|
|
|
2656
2657
|
|
|
2657
|
-
|
|
2658
|
+
|
|
2658
2659
|
|
|
2659
2660
|
|
|
2661
|
+
|
|
2660
2662
|
|
|
2661
2663
|
static parse(plain ) {
|
|
2662
2664
|
return new Meeting({
|
|
@@ -2666,8 +2668,9 @@ class Meeting {
|
|
|
2666
2668
|
ownerUuids: plain.owner_uuids,
|
|
2667
2669
|
port: plain.port,
|
|
2668
2670
|
uuid: plain.uuid,
|
|
2669
|
-
|
|
2671
|
+
extension: plain.exten,
|
|
2670
2672
|
persistent: plain.persistent,
|
|
2673
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
2671
2674
|
});
|
|
2672
2675
|
}
|
|
2673
2676
|
|
|
@@ -2689,8 +2692,9 @@ class Meeting {
|
|
|
2689
2692
|
ownerUuids,
|
|
2690
2693
|
port,
|
|
2691
2694
|
uri,
|
|
2692
|
-
|
|
2695
|
+
extension,
|
|
2693
2696
|
persistent,
|
|
2697
|
+
creationTime,
|
|
2694
2698
|
} = {}) {
|
|
2695
2699
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2696
2700
|
this.uri = uri;
|
|
@@ -2698,8 +2702,9 @@ class Meeting {
|
|
|
2698
2702
|
this.ownerUuids = ownerUuids;
|
|
2699
2703
|
this.port = port;
|
|
2700
2704
|
this.uuid = uuid;
|
|
2701
|
-
this.
|
|
2705
|
+
this.extension = extension;
|
|
2702
2706
|
this.persistent = persistent;
|
|
2707
|
+
this.creationTime = creationTime;
|
|
2703
2708
|
|
|
2704
2709
|
// Useful to compare instead of instanceof with minified code
|
|
2705
2710
|
this.type = 'Meeting';
|
|
@@ -4060,7 +4065,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
4060
4065
|
|
|
4061
4066
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
4062
4067
|
|
|
4063
|
-
const logger$
|
|
4068
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
4064
4069
|
|
|
4065
4070
|
class CTIPhone extends Emitter {
|
|
4066
4071
|
|
|
@@ -4073,7 +4078,7 @@ class CTIPhone extends Emitter {
|
|
|
4073
4078
|
|
|
4074
4079
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
4075
4080
|
super();
|
|
4076
|
-
logger$
|
|
4081
|
+
logger$1.info('CTI Phone created');
|
|
4077
4082
|
this.session = session;
|
|
4078
4083
|
this.isMobile = isMobile;
|
|
4079
4084
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -4134,7 +4139,7 @@ class CTIPhone extends Emitter {
|
|
|
4134
4139
|
}
|
|
4135
4140
|
|
|
4136
4141
|
async makeCall(number , line ) {
|
|
4137
|
-
logger$
|
|
4142
|
+
logger$1.info('make CTI call', { number });
|
|
4138
4143
|
|
|
4139
4144
|
if (!number) {
|
|
4140
4145
|
return null;
|
|
@@ -4157,7 +4162,7 @@ class CTIPhone extends Emitter {
|
|
|
4157
4162
|
if (!callSession) {
|
|
4158
4163
|
return Promise.resolve(null);
|
|
4159
4164
|
}
|
|
4160
|
-
logger$
|
|
4165
|
+
logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4161
4166
|
|
|
4162
4167
|
if (!this.currentCall) {
|
|
4163
4168
|
this.currentCall = callSession.call;
|
|
@@ -4170,7 +4175,7 @@ class CTIPhone extends Emitter {
|
|
|
4170
4175
|
if (!callSession) {
|
|
4171
4176
|
return;
|
|
4172
4177
|
}
|
|
4173
|
-
logger$
|
|
4178
|
+
logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4174
4179
|
|
|
4175
4180
|
this.currentCall = undefined;
|
|
4176
4181
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4180,7 +4185,7 @@ class CTIPhone extends Emitter {
|
|
|
4180
4185
|
if (!callSession) {
|
|
4181
4186
|
return Promise.resolve(false);
|
|
4182
4187
|
}
|
|
4183
|
-
logger$
|
|
4188
|
+
logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4184
4189
|
|
|
4185
4190
|
try {
|
|
4186
4191
|
await CallApi.cancelCall(callSession);
|
|
@@ -4191,7 +4196,7 @@ class CTIPhone extends Emitter {
|
|
|
4191
4196
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
4192
4197
|
return true;
|
|
4193
4198
|
} catch (e) {
|
|
4194
|
-
logger$
|
|
4199
|
+
logger$1.error('hangup CTI call, error', e);
|
|
4195
4200
|
|
|
4196
4201
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
4197
4202
|
return false;
|
|
@@ -4204,7 +4209,7 @@ class CTIPhone extends Emitter {
|
|
|
4204
4209
|
if (!callSession) {
|
|
4205
4210
|
return;
|
|
4206
4211
|
}
|
|
4207
|
-
logger$
|
|
4212
|
+
logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4208
4213
|
|
|
4209
4214
|
await CallApi.cancelCall(callSession);
|
|
4210
4215
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4214,7 +4219,7 @@ class CTIPhone extends Emitter {
|
|
|
4214
4219
|
if (!callSession) {
|
|
4215
4220
|
return;
|
|
4216
4221
|
}
|
|
4217
|
-
logger$
|
|
4222
|
+
logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4218
4223
|
|
|
4219
4224
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
4220
4225
|
}
|
|
@@ -4227,19 +4232,19 @@ class CTIPhone extends Emitter {
|
|
|
4227
4232
|
if (!callSession) {
|
|
4228
4233
|
return;
|
|
4229
4234
|
}
|
|
4230
|
-
logger$
|
|
4235
|
+
logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4231
4236
|
|
|
4232
4237
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
4233
4238
|
}
|
|
4234
4239
|
|
|
4235
4240
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
4236
|
-
logger$
|
|
4241
|
+
logger$1.info('cancel CTI transfer', { transferId });
|
|
4237
4242
|
|
|
4238
4243
|
return CallApi.cancelCallTransfer(transferId);
|
|
4239
4244
|
}
|
|
4240
4245
|
|
|
4241
4246
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
4242
|
-
logger$
|
|
4247
|
+
logger$1.info('confirm CTI transfer', { transferId });
|
|
4243
4248
|
|
|
4244
4249
|
return CallApi.confirmCallTransfer(transferId);
|
|
4245
4250
|
}
|
|
@@ -4248,19 +4253,19 @@ class CTIPhone extends Emitter {
|
|
|
4248
4253
|
if (!callSession) {
|
|
4249
4254
|
return;
|
|
4250
4255
|
}
|
|
4251
|
-
logger$
|
|
4256
|
+
logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4252
4257
|
|
|
4253
4258
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4254
4259
|
}
|
|
4255
4260
|
|
|
4256
4261
|
onConnectionMade() {
|
|
4257
|
-
logger$
|
|
4262
|
+
logger$1.info('on CTI connection made');
|
|
4258
4263
|
|
|
4259
4264
|
this.eventEmitter.emit('onCallAccepted');
|
|
4260
4265
|
}
|
|
4261
4266
|
|
|
4262
4267
|
async close() {
|
|
4263
|
-
logger$
|
|
4268
|
+
logger$1.info('CTI close');
|
|
4264
4269
|
|
|
4265
4270
|
return Promise.resolve();
|
|
4266
4271
|
}
|
|
@@ -4269,7 +4274,7 @@ class CTIPhone extends Emitter {
|
|
|
4269
4274
|
if (!callSession) {
|
|
4270
4275
|
return;
|
|
4271
4276
|
}
|
|
4272
|
-
logger$
|
|
4277
|
+
logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4273
4278
|
|
|
4274
4279
|
return CallApi.hold(callSession.callId);
|
|
4275
4280
|
}
|
|
@@ -4278,7 +4283,7 @@ class CTIPhone extends Emitter {
|
|
|
4278
4283
|
if (!callSession) {
|
|
4279
4284
|
return;
|
|
4280
4285
|
}
|
|
4281
|
-
logger$
|
|
4286
|
+
logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4282
4287
|
|
|
4283
4288
|
return CallApi.resume(callSession.callId);
|
|
4284
4289
|
}
|
|
@@ -4287,7 +4292,7 @@ class CTIPhone extends Emitter {
|
|
|
4287
4292
|
if (!callSession) {
|
|
4288
4293
|
return;
|
|
4289
4294
|
}
|
|
4290
|
-
logger$
|
|
4295
|
+
logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4291
4296
|
|
|
4292
4297
|
return CallApi.mute(callSession.callId);
|
|
4293
4298
|
}
|
|
@@ -4296,7 +4301,7 @@ class CTIPhone extends Emitter {
|
|
|
4296
4301
|
if (!callSession) {
|
|
4297
4302
|
return;
|
|
4298
4303
|
}
|
|
4299
|
-
logger$
|
|
4304
|
+
logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4300
4305
|
|
|
4301
4306
|
return CallApi.unmute(callSession.callId);
|
|
4302
4307
|
}
|
|
@@ -5305,7 +5310,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5305
5310
|
const WEBHOOKD_VERSION = '1.0';
|
|
5306
5311
|
const AMID_VERSION = '1.0';
|
|
5307
5312
|
|
|
5308
|
-
const logger$
|
|
5313
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5309
5314
|
|
|
5310
5315
|
class ApiClient {
|
|
5311
5316
|
|
|
@@ -5357,12 +5362,12 @@ class ApiClient {
|
|
|
5357
5362
|
}
|
|
5358
5363
|
|
|
5359
5364
|
async forceRefreshToken() {
|
|
5360
|
-
logger$
|
|
5365
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
5361
5366
|
return this.refreshTokenCallback();
|
|
5362
5367
|
}
|
|
5363
5368
|
|
|
5364
5369
|
async refreshTokenCallback() {
|
|
5365
|
-
logger$
|
|
5370
|
+
logger$2.info('refresh token callback called', {
|
|
5366
5371
|
refreshToken: this.refreshToken,
|
|
5367
5372
|
refreshBackend: this.refreshBackend,
|
|
5368
5373
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5380,7 +5385,7 @@ class ApiClient {
|
|
|
5380
5385
|
this.isMobile,
|
|
5381
5386
|
);
|
|
5382
5387
|
|
|
5383
|
-
logger$
|
|
5388
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
5384
5389
|
|
|
5385
5390
|
if (this.onRefreshToken) {
|
|
5386
5391
|
this.onRefreshToken(session.token, session);
|
|
@@ -5693,7 +5698,7 @@ class AdHocAPIConference {
|
|
|
5693
5698
|
|
|
5694
5699
|
/* */
|
|
5695
5700
|
|
|
5696
|
-
const parseCandidate
|
|
5701
|
+
const parseCandidate = (candidate ) => {
|
|
5697
5702
|
if (!candidate) {
|
|
5698
5703
|
return null;
|
|
5699
5704
|
}
|
|
@@ -5847,7 +5852,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5847
5852
|
this.peerConnectionDelegate.onicecandidate = event => {
|
|
5848
5853
|
wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
|
|
5849
5854
|
if (event.candidate) {
|
|
5850
|
-
this.gatheredCandidates.push(parseCandidate
|
|
5855
|
+
this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
|
|
5851
5856
|
}
|
|
5852
5857
|
};
|
|
5853
5858
|
|
|
@@ -6311,7 +6316,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
6311
6316
|
const SEND_STATS_DELAY = 5000;
|
|
6312
6317
|
|
|
6313
6318
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
6314
|
-
const logger$
|
|
6319
|
+
const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
6315
6320
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
6316
6321
|
|
|
6317
6322
|
// events
|
|
@@ -6325,14 +6330,14 @@ const TRANSPORT_ERROR = 'transportError';
|
|
|
6325
6330
|
const MESSAGE = 'message';
|
|
6326
6331
|
const ACCEPTED = 'accepted';
|
|
6327
6332
|
const REJECTED = 'rejected';
|
|
6328
|
-
const ON_TRACK
|
|
6329
|
-
const ON_REINVITE
|
|
6333
|
+
const ON_TRACK = 'onTrack';
|
|
6334
|
+
const ON_REINVITE = 'reinvite';
|
|
6330
6335
|
const ON_ERROR = 'onError';
|
|
6331
6336
|
const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
|
|
6332
|
-
const ON_NETWORK_STATS
|
|
6333
|
-
const ON_DISCONNECTED
|
|
6337
|
+
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
6338
|
+
const ON_DISCONNECTED = 'onDisconnected';
|
|
6334
6339
|
|
|
6335
|
-
const events
|
|
6340
|
+
const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
6336
6341
|
const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
6337
6342
|
class CanceledCallError extends Error {}
|
|
6338
6343
|
|
|
@@ -6468,12 +6473,12 @@ class WebRTCClient extends Emitter {
|
|
|
6468
6473
|
this.MESSAGE = MESSAGE;
|
|
6469
6474
|
this.ACCEPTED = ACCEPTED;
|
|
6470
6475
|
this.REJECTED = REJECTED;
|
|
6471
|
-
this.ON_TRACK = ON_TRACK
|
|
6472
|
-
this.ON_REINVITE = ON_REINVITE
|
|
6476
|
+
this.ON_TRACK = ON_TRACK;
|
|
6477
|
+
this.ON_REINVITE = ON_REINVITE;
|
|
6473
6478
|
this.ON_ERROR = ON_ERROR;
|
|
6474
6479
|
this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
|
|
6475
|
-
this.ON_NETWORK_STATS = ON_NETWORK_STATS
|
|
6476
|
-
this.ON_DISCONNECTED = ON_DISCONNECTED
|
|
6480
|
+
this.ON_NETWORK_STATS = ON_NETWORK_STATS;
|
|
6481
|
+
this.ON_DISCONNECTED = ON_DISCONNECTED;
|
|
6477
6482
|
}
|
|
6478
6483
|
|
|
6479
6484
|
configureMedia(media ) {
|
|
@@ -6490,13 +6495,13 @@ class WebRTCClient extends Emitter {
|
|
|
6490
6495
|
|
|
6491
6496
|
createUserAgent(configOverrides ) {
|
|
6492
6497
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6493
|
-
logger$
|
|
6498
|
+
logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6494
6499
|
|
|
6495
6500
|
webRTCConfiguration.delegate = {
|
|
6496
6501
|
onConnect: this.onConnect.bind(this),
|
|
6497
6502
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6498
6503
|
onInvite: (invitation ) => {
|
|
6499
|
-
logger$
|
|
6504
|
+
logger$3.info('sdk webrtc on invite', {
|
|
6500
6505
|
method: 'delegate.onInvite',
|
|
6501
6506
|
id: invitation.id,
|
|
6502
6507
|
remoteURI: invitation.remoteURI,
|
|
@@ -6539,7 +6544,7 @@ class WebRTCClient extends Emitter {
|
|
|
6539
6544
|
}
|
|
6540
6545
|
|
|
6541
6546
|
onConnect() {
|
|
6542
|
-
logger$
|
|
6547
|
+
logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6543
6548
|
this.eventEmitter.emit(CONNECTED);
|
|
6544
6549
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6545
6550
|
this.registerer.waitingToggle(false);
|
|
@@ -6548,7 +6553,7 @@ class WebRTCClient extends Emitter {
|
|
|
6548
6553
|
}
|
|
6549
6554
|
|
|
6550
6555
|
async onDisconnect(error ) {
|
|
6551
|
-
logger$
|
|
6556
|
+
logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6552
6557
|
this.connectionPromise = null;
|
|
6553
6558
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6554
6559
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6573,37 +6578,37 @@ class WebRTCClient extends Emitter {
|
|
|
6573
6578
|
};
|
|
6574
6579
|
|
|
6575
6580
|
if (this.skipRegister) {
|
|
6576
|
-
logger$
|
|
6581
|
+
logger$3.info('sdk webrtc skip register...', logInfo);
|
|
6577
6582
|
return Promise.resolve();
|
|
6578
6583
|
}
|
|
6579
6584
|
|
|
6580
|
-
logger$
|
|
6585
|
+
logger$3.info('sdk webrtc registering...', logInfo);
|
|
6581
6586
|
|
|
6582
6587
|
if (!this.userAgent) {
|
|
6583
|
-
logger$
|
|
6588
|
+
logger$3.info('sdk webrtc recreating User Agent');
|
|
6584
6589
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6585
6590
|
}
|
|
6586
6591
|
if (!this.userAgent || this.isRegistered()) {
|
|
6587
|
-
logger$
|
|
6592
|
+
logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6588
6593
|
return Promise.resolve();
|
|
6589
6594
|
}
|
|
6590
6595
|
|
|
6591
6596
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6592
|
-
logger$
|
|
6597
|
+
logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6593
6598
|
return Promise.resolve();
|
|
6594
6599
|
}
|
|
6595
6600
|
|
|
6596
6601
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6597
6602
|
|
|
6598
6603
|
const onRegisterFailed = () => {
|
|
6599
|
-
logger$
|
|
6604
|
+
logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6600
6605
|
this.connectionPromise = null;
|
|
6601
6606
|
if (this.registerer && this.registerer.waiting) {
|
|
6602
6607
|
this.registerer.waitingToggle(false);
|
|
6603
6608
|
}
|
|
6604
6609
|
|
|
6605
6610
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6606
|
-
logger$
|
|
6611
|
+
logger$3.info('sdk webrtc registering, retrying...', { tries });
|
|
6607
6612
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6608
6613
|
}
|
|
6609
6614
|
};
|
|
@@ -6612,18 +6617,18 @@ class WebRTCClient extends Emitter {
|
|
|
6612
6617
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6613
6618
|
// during the resolution of the primise.
|
|
6614
6619
|
if (!this.userAgent) {
|
|
6615
|
-
logger$
|
|
6620
|
+
logger$3.info('sdk webrtc recreating User Agent after connection');
|
|
6616
6621
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6617
6622
|
}
|
|
6618
6623
|
|
|
6619
|
-
logger$
|
|
6624
|
+
logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6620
6625
|
this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
|
|
6621
6626
|
this.connectionPromise = null;
|
|
6622
6627
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6623
6628
|
|
|
6624
6629
|
// Bind registerer events
|
|
6625
6630
|
this.registerer.stateChange.addListener(newState => {
|
|
6626
|
-
logger$
|
|
6631
|
+
logger$3.info('sdk webrtc registering, state changed', { newState });
|
|
6627
6632
|
|
|
6628
6633
|
if (newState === registererState.RegistererState.Registered && this.registerer
|
|
6629
6634
|
&& this.registerer.state === registererState.RegistererState.Registered) {
|
|
@@ -6636,7 +6641,7 @@ class WebRTCClient extends Emitter {
|
|
|
6636
6641
|
const options = {
|
|
6637
6642
|
requestDelegate: {
|
|
6638
6643
|
onReject: response => {
|
|
6639
|
-
logger$
|
|
6644
|
+
logger$3.error('sdk webrtc registering, rejected', { response });
|
|
6640
6645
|
|
|
6641
6646
|
onRegisterFailed();
|
|
6642
6647
|
},
|
|
@@ -6644,13 +6649,13 @@ class WebRTCClient extends Emitter {
|
|
|
6644
6649
|
};
|
|
6645
6650
|
|
|
6646
6651
|
return this.registerer.register(options).catch((e) => {
|
|
6647
|
-
logger$
|
|
6652
|
+
logger$3.error('sdk webrtc registering, error', e);
|
|
6648
6653
|
|
|
6649
6654
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6650
6655
|
return e;
|
|
6651
6656
|
});
|
|
6652
6657
|
}).catch(error => {
|
|
6653
|
-
logger$
|
|
6658
|
+
logger$3.error('sdk webrtc registering, transport error', error);
|
|
6654
6659
|
onRegisterFailed();
|
|
6655
6660
|
});
|
|
6656
6661
|
}
|
|
@@ -6679,21 +6684,21 @@ class WebRTCClient extends Emitter {
|
|
|
6679
6684
|
}
|
|
6680
6685
|
|
|
6681
6686
|
unregister() {
|
|
6682
|
-
logger$
|
|
6687
|
+
logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6683
6688
|
if (!this.registerer) {
|
|
6684
6689
|
return Promise.resolve();
|
|
6685
6690
|
}
|
|
6686
6691
|
|
|
6687
6692
|
try {
|
|
6688
6693
|
return this.registerer.unregister().then(() => {
|
|
6689
|
-
logger$
|
|
6694
|
+
logger$3.info('sdk webrtc unregistered');
|
|
6690
6695
|
this._cleanupRegister();
|
|
6691
6696
|
}).catch(e => {
|
|
6692
|
-
logger$
|
|
6697
|
+
logger$3.error('sdk webrtc unregistering, promise error', e);
|
|
6693
6698
|
this._cleanupRegister();
|
|
6694
6699
|
});
|
|
6695
6700
|
} catch (e) {
|
|
6696
|
-
logger$
|
|
6701
|
+
logger$3.error('sdk webrtc unregistering, error', e);
|
|
6697
6702
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6698
6703
|
// error when the registerer is in a bad state
|
|
6699
6704
|
this._cleanupRegister();
|
|
@@ -6701,7 +6706,7 @@ class WebRTCClient extends Emitter {
|
|
|
6701
6706
|
}
|
|
6702
6707
|
|
|
6703
6708
|
stop() {
|
|
6704
|
-
logger$
|
|
6709
|
+
logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6705
6710
|
if (!this.userAgent) {
|
|
6706
6711
|
return Promise.resolve();
|
|
6707
6712
|
}
|
|
@@ -6709,12 +6714,12 @@ class WebRTCClient extends Emitter {
|
|
|
6709
6714
|
return this.userAgent.stop().then(() => {
|
|
6710
6715
|
return this._cleanupRegister();
|
|
6711
6716
|
}).catch(e => {
|
|
6712
|
-
logger$
|
|
6717
|
+
logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6713
6718
|
});
|
|
6714
6719
|
}
|
|
6715
6720
|
|
|
6716
6721
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6717
|
-
logger$
|
|
6722
|
+
logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6718
6723
|
const inviterOptions = {
|
|
6719
6724
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6720
6725
|
conference,
|
|
@@ -6745,7 +6750,7 @@ class WebRTCClient extends Emitter {
|
|
|
6745
6750
|
this._onAccepted(session, response.session, true);
|
|
6746
6751
|
},
|
|
6747
6752
|
onReject: (response ) => {
|
|
6748
|
-
logger$
|
|
6753
|
+
logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6749
6754
|
this._stopSendingStats(session);
|
|
6750
6755
|
this.stopNetworkMonitoring(session);
|
|
6751
6756
|
|
|
@@ -6768,11 +6773,11 @@ class WebRTCClient extends Emitter {
|
|
|
6768
6773
|
}
|
|
6769
6774
|
|
|
6770
6775
|
answer(session , enableVideo ) {
|
|
6771
|
-
logger$
|
|
6776
|
+
logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
6772
6777
|
|
|
6773
6778
|
if (!session || !session.accept) {
|
|
6774
6779
|
const error = 'No session to answer, or not an invitation';
|
|
6775
|
-
logger$
|
|
6780
|
+
logger$3.warn(error);
|
|
6776
6781
|
return Promise.reject(new Error(error));
|
|
6777
6782
|
}
|
|
6778
6783
|
const options = {
|
|
@@ -6782,15 +6787,15 @@ class WebRTCClient extends Emitter {
|
|
|
6782
6787
|
return session.accept(options).then(() => {
|
|
6783
6788
|
if (session.isCanceled) {
|
|
6784
6789
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
6785
|
-
logger$
|
|
6790
|
+
logger$3.error(message, { id: session.id });
|
|
6786
6791
|
this.onCallEnded(session);
|
|
6787
6792
|
|
|
6788
6793
|
throw new CanceledCallError(message);
|
|
6789
6794
|
}
|
|
6790
|
-
logger$
|
|
6795
|
+
logger$3.info('sdk webrtc answer, accepted.');
|
|
6791
6796
|
this._onAccepted(session);
|
|
6792
6797
|
}).catch(e => {
|
|
6793
|
-
logger$
|
|
6798
|
+
logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
6794
6799
|
|
|
6795
6800
|
throw e;
|
|
6796
6801
|
});
|
|
@@ -6798,7 +6803,7 @@ class WebRTCClient extends Emitter {
|
|
|
6798
6803
|
|
|
6799
6804
|
hangup(session ) {
|
|
6800
6805
|
const { state, id } = session;
|
|
6801
|
-
logger$
|
|
6806
|
+
logger$3.info('sdk webrtc hangup call', { id, state });
|
|
6802
6807
|
|
|
6803
6808
|
try {
|
|
6804
6809
|
this._stopSendingStats(session);
|
|
@@ -6827,7 +6832,7 @@ class WebRTCClient extends Emitter {
|
|
|
6827
6832
|
|
|
6828
6833
|
return bye();
|
|
6829
6834
|
} catch (error) {
|
|
6830
|
-
logger$
|
|
6835
|
+
logger$3.warn('sdk webrtc hangup, error', error);
|
|
6831
6836
|
}
|
|
6832
6837
|
|
|
6833
6838
|
return null;
|
|
@@ -6845,7 +6850,7 @@ class WebRTCClient extends Emitter {
|
|
|
6845
6850
|
// Fetch and emit an event at `interval` with session network stats
|
|
6846
6851
|
startNetworkMonitoring(session , interval = 1000) {
|
|
6847
6852
|
const sessionId = this.getSipSessionId(session);
|
|
6848
|
-
logger$
|
|
6853
|
+
logger$3.info('starting network inspection', { id: sessionId });
|
|
6849
6854
|
|
|
6850
6855
|
this.sessionNetworkStats[sessionId] = [];
|
|
6851
6856
|
|
|
@@ -6855,7 +6860,7 @@ class WebRTCClient extends Emitter {
|
|
|
6855
6860
|
stopNetworkMonitoring(session ) {
|
|
6856
6861
|
const sessionId = this.getSipSessionId(session);
|
|
6857
6862
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
6858
|
-
logger$
|
|
6863
|
+
logger$3.info('stopping network inspection', { id: sessionId, exists });
|
|
6859
6864
|
|
|
6860
6865
|
if (exists) {
|
|
6861
6866
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -6865,17 +6870,17 @@ class WebRTCClient extends Emitter {
|
|
|
6865
6870
|
}
|
|
6866
6871
|
|
|
6867
6872
|
reject(session ) {
|
|
6868
|
-
logger$
|
|
6873
|
+
logger$3.info('sdk webrtc reject call', { id: session.id });
|
|
6869
6874
|
|
|
6870
6875
|
try {
|
|
6871
6876
|
return session.reject ? session.reject() : session.cancel();
|
|
6872
6877
|
} catch (e) {
|
|
6873
|
-
logger$
|
|
6878
|
+
logger$3.warn('Error when rejecting call', e.message, e.stack);
|
|
6874
6879
|
}
|
|
6875
6880
|
}
|
|
6876
6881
|
|
|
6877
6882
|
async close() {
|
|
6878
|
-
logger$
|
|
6883
|
+
logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
6879
6884
|
this._cleanupMedia();
|
|
6880
6885
|
this.connectionPromise = null;
|
|
6881
6886
|
|
|
@@ -6906,7 +6911,7 @@ class WebRTCClient extends Emitter {
|
|
|
6906
6911
|
// eg: "INVITE not rejectable in state Completed"
|
|
6907
6912
|
}
|
|
6908
6913
|
this.userAgent = null;
|
|
6909
|
-
logger$
|
|
6914
|
+
logger$3.info('sdk webrtc client closed');
|
|
6910
6915
|
}
|
|
6911
6916
|
|
|
6912
6917
|
getNumber(session ) {
|
|
@@ -6919,13 +6924,13 @@ class WebRTCClient extends Emitter {
|
|
|
6919
6924
|
}
|
|
6920
6925
|
|
|
6921
6926
|
mute(session ) {
|
|
6922
|
-
logger$
|
|
6927
|
+
logger$3.info('sdk webrtc mute', { id: session.id });
|
|
6923
6928
|
|
|
6924
6929
|
this._toggleAudio(session, true);
|
|
6925
6930
|
}
|
|
6926
6931
|
|
|
6927
6932
|
unmute(session ) {
|
|
6928
|
-
logger$
|
|
6933
|
+
logger$3.info('sdk webrtc unmute', { id: session.id });
|
|
6929
6934
|
|
|
6930
6935
|
this._toggleAudio(session, false);
|
|
6931
6936
|
}
|
|
@@ -6965,13 +6970,13 @@ class WebRTCClient extends Emitter {
|
|
|
6965
6970
|
}
|
|
6966
6971
|
|
|
6967
6972
|
toggleCameraOn(session ) {
|
|
6968
|
-
logger$
|
|
6973
|
+
logger$3.info('sdk webrtc toggle camera on', { id: session.id });
|
|
6969
6974
|
|
|
6970
6975
|
this._toggleVideo(session, false);
|
|
6971
6976
|
}
|
|
6972
6977
|
|
|
6973
6978
|
toggleCameraOff(session ) {
|
|
6974
|
-
logger$
|
|
6979
|
+
logger$3.info('sdk webrtc toggle camera off', { id: session.id });
|
|
6975
6980
|
|
|
6976
6981
|
this._toggleVideo(session, true);
|
|
6977
6982
|
}
|
|
@@ -6980,7 +6985,7 @@ class WebRTCClient extends Emitter {
|
|
|
6980
6985
|
const sessionId = this.getSipSessionId(session);
|
|
6981
6986
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
6982
6987
|
|
|
6983
|
-
logger$
|
|
6988
|
+
logger$3.info('sdk webrtc hold', {
|
|
6984
6989
|
sessionId,
|
|
6985
6990
|
keys: Object.keys(this.heldSessions),
|
|
6986
6991
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7029,7 +7034,7 @@ class WebRTCClient extends Emitter {
|
|
|
7029
7034
|
const sessionId = this.getSipSessionId(session);
|
|
7030
7035
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
7031
7036
|
|
|
7032
|
-
logger$
|
|
7037
|
+
logger$3.info('sdk webrtc unhold', {
|
|
7033
7038
|
sessionId,
|
|
7034
7039
|
keys: Object.keys(this.heldSessions),
|
|
7035
7040
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7177,7 +7182,7 @@ class WebRTCClient extends Emitter {
|
|
|
7177
7182
|
if (!session.sessionDescriptionHandler) {
|
|
7178
7183
|
return;
|
|
7179
7184
|
}
|
|
7180
|
-
logger$
|
|
7185
|
+
logger$3.info('Sending DTMF', {
|
|
7181
7186
|
id: this.getSipSessionId(session),
|
|
7182
7187
|
tone,
|
|
7183
7188
|
});
|
|
@@ -7193,7 +7198,7 @@ class WebRTCClient extends Emitter {
|
|
|
7193
7198
|
transfer(session , target ) {
|
|
7194
7199
|
this.hold(session);
|
|
7195
7200
|
|
|
7196
|
-
logger$
|
|
7201
|
+
logger$3.info('Transfering a session', {
|
|
7197
7202
|
id: this.getSipSessionId(session),
|
|
7198
7203
|
target,
|
|
7199
7204
|
});
|
|
@@ -7215,17 +7220,17 @@ class WebRTCClient extends Emitter {
|
|
|
7215
7220
|
atxfer(session ) {
|
|
7216
7221
|
this.hold(session);
|
|
7217
7222
|
|
|
7218
|
-
logger$
|
|
7223
|
+
logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
7219
7224
|
|
|
7220
7225
|
const result = {
|
|
7221
7226
|
newSession: null,
|
|
7222
7227
|
init: async (target ) => {
|
|
7223
|
-
logger$
|
|
7228
|
+
logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
7224
7229
|
|
|
7225
7230
|
result.newSession = await this.call(target);
|
|
7226
7231
|
},
|
|
7227
7232
|
complete: () => {
|
|
7228
|
-
logger$
|
|
7233
|
+
logger$3.info('webrtc transfer completed', {
|
|
7229
7234
|
id: this.getSipSessionId(session),
|
|
7230
7235
|
referId: this.getSipSessionId(result.newSession),
|
|
7231
7236
|
});
|
|
@@ -7246,7 +7251,7 @@ class WebRTCClient extends Emitter {
|
|
|
7246
7251
|
return;
|
|
7247
7252
|
}
|
|
7248
7253
|
|
|
7249
|
-
logger$
|
|
7254
|
+
logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
7250
7255
|
|
|
7251
7256
|
try {
|
|
7252
7257
|
sipSession.message({
|
|
@@ -7288,7 +7293,7 @@ class WebRTCClient extends Emitter {
|
|
|
7288
7293
|
}
|
|
7289
7294
|
|
|
7290
7295
|
changeAudioOutputVolume(volume ) {
|
|
7291
|
-
logger$
|
|
7296
|
+
logger$3.info('Changing audio output volume', { volume });
|
|
7292
7297
|
|
|
7293
7298
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7294
7299
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -7300,7 +7305,7 @@ class WebRTCClient extends Emitter {
|
|
|
7300
7305
|
}
|
|
7301
7306
|
|
|
7302
7307
|
changeAudioOutputDevice(id ) {
|
|
7303
|
-
logger$
|
|
7308
|
+
logger$3.info('Changing audio output device', { id });
|
|
7304
7309
|
|
|
7305
7310
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7306
7311
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -7317,7 +7322,7 @@ class WebRTCClient extends Emitter {
|
|
|
7317
7322
|
|
|
7318
7323
|
changeAudioInputDevice(id , session ) {
|
|
7319
7324
|
const currentId = this.getAudioDeviceId();
|
|
7320
|
-
logger$
|
|
7325
|
+
logger$3.info('setting audio input device', { id, currentId, session: !!session });
|
|
7321
7326
|
|
|
7322
7327
|
if (id === currentId) {
|
|
7323
7328
|
return null;
|
|
@@ -7363,7 +7368,7 @@ class WebRTCClient extends Emitter {
|
|
|
7363
7368
|
|
|
7364
7369
|
setVideoInputDevice(id ) {
|
|
7365
7370
|
const currentId = this.getVideoDeviceId();
|
|
7366
|
-
logger$
|
|
7371
|
+
logger$3.info('setting video input device', { id, currentId });
|
|
7367
7372
|
|
|
7368
7373
|
if (id === currentId) {
|
|
7369
7374
|
return null;
|
|
@@ -7388,7 +7393,7 @@ class WebRTCClient extends Emitter {
|
|
|
7388
7393
|
const sessionId = this.getSipSessionId(session);
|
|
7389
7394
|
const localStream = this.getLocalStream(sessionId);
|
|
7390
7395
|
|
|
7391
|
-
logger$
|
|
7396
|
+
logger$3.info('changing video input device', { id, sessionId });
|
|
7392
7397
|
|
|
7393
7398
|
// Release old video stream
|
|
7394
7399
|
if (localStream) {
|
|
@@ -7456,7 +7461,7 @@ class WebRTCClient extends Emitter {
|
|
|
7456
7461
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
7457
7462
|
const desktop = newConstraints && newConstraints.desktop;
|
|
7458
7463
|
|
|
7459
|
-
logger$
|
|
7464
|
+
logger$3.info('Sending reinvite', {
|
|
7460
7465
|
id: this.getSipSessionId(sipSession),
|
|
7461
7466
|
newConstraints,
|
|
7462
7467
|
conference,
|
|
@@ -7494,7 +7499,7 @@ class WebRTCClient extends Emitter {
|
|
|
7494
7499
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
7495
7500
|
}
|
|
7496
7501
|
|
|
7497
|
-
logger$
|
|
7502
|
+
logger$3.info('on re-INVITE accepted', {
|
|
7498
7503
|
id: this.getSipSessionId(sipSession),
|
|
7499
7504
|
wasMuted,
|
|
7500
7505
|
shouldDoScreenSharing,
|
|
@@ -7512,7 +7517,7 @@ class WebRTCClient extends Emitter {
|
|
|
7512
7517
|
this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
|
|
7513
7518
|
}
|
|
7514
7519
|
|
|
7515
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
7520
|
+
return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
|
|
7516
7521
|
},
|
|
7517
7522
|
},
|
|
7518
7523
|
sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
|
|
@@ -7669,7 +7674,7 @@ class WebRTCClient extends Emitter {
|
|
|
7669
7674
|
}
|
|
7670
7675
|
|
|
7671
7676
|
startHeartbeat() {
|
|
7672
|
-
logger$
|
|
7677
|
+
logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7673
7678
|
if (!this.userAgent) {
|
|
7674
7679
|
this.heartbeat.stop();
|
|
7675
7680
|
return;
|
|
@@ -7682,7 +7687,7 @@ class WebRTCClient extends Emitter {
|
|
|
7682
7687
|
}
|
|
7683
7688
|
|
|
7684
7689
|
stopHeartbeat() {
|
|
7685
|
-
logger$
|
|
7690
|
+
logger$3.info('sdk webrtc stop heartbeat');
|
|
7686
7691
|
this.heartbeat.stop();
|
|
7687
7692
|
}
|
|
7688
7693
|
|
|
@@ -7703,7 +7708,7 @@ class WebRTCClient extends Emitter {
|
|
|
7703
7708
|
}
|
|
7704
7709
|
|
|
7705
7710
|
attemptReconnection() {
|
|
7706
|
-
logger$
|
|
7711
|
+
logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7707
7712
|
if (!this.userAgent) {
|
|
7708
7713
|
return;
|
|
7709
7714
|
}
|
|
@@ -7728,7 +7733,7 @@ class WebRTCClient extends Emitter {
|
|
|
7728
7733
|
return;
|
|
7729
7734
|
}
|
|
7730
7735
|
|
|
7731
|
-
logger$
|
|
7736
|
+
logger$3.info('setting local media stream', {
|
|
7732
7737
|
sipSessionId,
|
|
7733
7738
|
tracks: newStream ? newStream.getTracks() : null,
|
|
7734
7739
|
});
|
|
@@ -7745,7 +7750,7 @@ class WebRTCClient extends Emitter {
|
|
|
7745
7750
|
|
|
7746
7751
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
7747
7752
|
|
|
7748
|
-
logger$
|
|
7753
|
+
logger$3.info('updating local stream', {
|
|
7749
7754
|
sipSessionId,
|
|
7750
7755
|
oldStream: !!oldStream,
|
|
7751
7756
|
tracks: newStream.getTracks(),
|
|
@@ -7765,7 +7770,7 @@ class WebRTCClient extends Emitter {
|
|
|
7765
7770
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
7766
7771
|
const pc = this.getPeerConnection(sessionId);
|
|
7767
7772
|
|
|
7768
|
-
logger$
|
|
7773
|
+
logger$3.info('Updating remote stream', {
|
|
7769
7774
|
sessionId,
|
|
7770
7775
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
7771
7776
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -7791,7 +7796,7 @@ class WebRTCClient extends Emitter {
|
|
|
7791
7796
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
7792
7797
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
7793
7798
|
|
|
7794
|
-
logger$
|
|
7799
|
+
logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
7795
7800
|
|
|
7796
7801
|
return {
|
|
7797
7802
|
constraints: {
|
|
@@ -7840,7 +7845,7 @@ class WebRTCClient extends Emitter {
|
|
|
7840
7845
|
}
|
|
7841
7846
|
|
|
7842
7847
|
_onTransportError() {
|
|
7843
|
-
logger$
|
|
7848
|
+
logger$3.error('on transport error');
|
|
7844
7849
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
7845
7850
|
this.attemptReconnection();
|
|
7846
7851
|
}
|
|
@@ -7849,7 +7854,7 @@ class WebRTCClient extends Emitter {
|
|
|
7849
7854
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
7850
7855
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
7851
7856
|
if (this.hasHeartbeat()) {
|
|
7852
|
-
logger$
|
|
7857
|
+
logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
7853
7858
|
|
|
7854
7859
|
this.heartbeat.onHeartbeat();
|
|
7855
7860
|
if (this.heartbeatCb) {
|
|
@@ -7860,7 +7865,7 @@ class WebRTCClient extends Emitter {
|
|
|
7860
7865
|
}
|
|
7861
7866
|
|
|
7862
7867
|
async _onHeartbeatTimeout() {
|
|
7863
|
-
logger$
|
|
7868
|
+
logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
7864
7869
|
|
|
7865
7870
|
if (this.heartbeatTimeoutCb) {
|
|
7866
7871
|
this.heartbeatTimeoutCb();
|
|
@@ -7872,7 +7877,7 @@ class WebRTCClient extends Emitter {
|
|
|
7872
7877
|
try {
|
|
7873
7878
|
await this.userAgent.transport.disconnect();
|
|
7874
7879
|
} catch (e) {
|
|
7875
|
-
logger$
|
|
7880
|
+
logger$3.error('Transport disconnection after heartbeat timeout, error', e);
|
|
7876
7881
|
}
|
|
7877
7882
|
}
|
|
7878
7883
|
|
|
@@ -7905,31 +7910,31 @@ class WebRTCClient extends Emitter {
|
|
|
7905
7910
|
}
|
|
7906
7911
|
|
|
7907
7912
|
_connectIfNeeded() {
|
|
7908
|
-
logger$
|
|
7913
|
+
logger$3.info('connect if needed, checking', { connected: this.isConnected() });
|
|
7909
7914
|
if (!this.userAgent) {
|
|
7910
|
-
logger$
|
|
7915
|
+
logger$3.info('need to recreate User Agent');
|
|
7911
7916
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
7912
7917
|
}
|
|
7913
7918
|
|
|
7914
7919
|
if (this.isConnected()) {
|
|
7915
|
-
logger$
|
|
7920
|
+
logger$3.info('webrtc sdk, already connected');
|
|
7916
7921
|
return Promise.resolve();
|
|
7917
7922
|
}
|
|
7918
7923
|
|
|
7919
7924
|
if (this.isConnecting()) {
|
|
7920
|
-
logger$
|
|
7925
|
+
logger$3.info('webrtc sdk, already connecting...');
|
|
7921
7926
|
|
|
7922
7927
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
7923
7928
|
return this.connectionPromise;
|
|
7924
7929
|
}
|
|
7925
7930
|
|
|
7926
7931
|
if (this.connectionPromise) {
|
|
7927
|
-
logger$
|
|
7932
|
+
logger$3.info('webrtc sdk, connection promise connecting...');
|
|
7928
7933
|
// $FlowFixMe
|
|
7929
7934
|
return this.connectionPromise;
|
|
7930
7935
|
}
|
|
7931
7936
|
|
|
7932
|
-
logger$
|
|
7937
|
+
logger$3.info('WebRTC UA needs to connect');
|
|
7933
7938
|
|
|
7934
7939
|
// Force UA to reconnect
|
|
7935
7940
|
if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
|
|
@@ -8054,7 +8059,7 @@ class WebRTCClient extends Emitter {
|
|
|
8054
8059
|
|
|
8055
8060
|
sdh.peerConnectionDelegate = {
|
|
8056
8061
|
onicecandidateerror: (error ) => {
|
|
8057
|
-
logger$
|
|
8062
|
+
logger$3.error('on icecandidate error', {
|
|
8058
8063
|
address: error.address,
|
|
8059
8064
|
port: error.port,
|
|
8060
8065
|
errorCode: error.errorCode,
|
|
@@ -8083,7 +8088,7 @@ class WebRTCClient extends Emitter {
|
|
|
8083
8088
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
8084
8089
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
8085
8090
|
}
|
|
8086
|
-
logger$
|
|
8091
|
+
logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
8087
8092
|
|
|
8088
8093
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
8089
8094
|
|
|
@@ -8099,12 +8104,12 @@ class WebRTCClient extends Emitter {
|
|
|
8099
8104
|
|
|
8100
8105
|
this._setupMedias(session);
|
|
8101
8106
|
|
|
8102
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
8107
|
+
return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
|
|
8103
8108
|
};
|
|
8104
8109
|
}
|
|
8105
8110
|
|
|
8106
8111
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
8107
|
-
logger$
|
|
8112
|
+
logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
8108
8113
|
|
|
8109
8114
|
this.storeSipSession(session);
|
|
8110
8115
|
|
|
@@ -8116,14 +8121,14 @@ class WebRTCClient extends Emitter {
|
|
|
8116
8121
|
const onTrack = (event ) => {
|
|
8117
8122
|
const isAudioOnly = this._isAudioOnly(session);
|
|
8118
8123
|
const { kind, label, readyState, id, muted } = event.track;
|
|
8119
|
-
logger$
|
|
8124
|
+
logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
8120
8125
|
|
|
8121
8126
|
// Stop video track in audio only mode
|
|
8122
8127
|
if (isAudioOnly && kind === 'video') {
|
|
8123
8128
|
event.track.stop();
|
|
8124
8129
|
}
|
|
8125
8130
|
|
|
8126
|
-
this.eventEmitter.emit(ON_TRACK
|
|
8131
|
+
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
8127
8132
|
};
|
|
8128
8133
|
|
|
8129
8134
|
if (session.sessionDescriptionHandler.peerConnection) {
|
|
@@ -8133,9 +8138,9 @@ class WebRTCClient extends Emitter {
|
|
|
8133
8138
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
8134
8139
|
|
|
8135
8140
|
pc.oniceconnectionstatechange = () => {
|
|
8136
|
-
logger$
|
|
8141
|
+
logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
8137
8142
|
if (pc.iceConnectionState === 'disconnected') {
|
|
8138
|
-
this.eventEmitter.emit(ON_DISCONNECTED
|
|
8143
|
+
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
8139
8144
|
}
|
|
8140
8145
|
};
|
|
8141
8146
|
|
|
@@ -8306,10 +8311,10 @@ class WebRTCClient extends Emitter {
|
|
|
8306
8311
|
|
|
8307
8312
|
_stopSendingStats(session ) {
|
|
8308
8313
|
const sessionId = this.getSipSessionId(session);
|
|
8309
|
-
logger$
|
|
8314
|
+
logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
8310
8315
|
|
|
8311
8316
|
if (sessionId in this.statsIntervals) {
|
|
8312
|
-
logger$
|
|
8317
|
+
logger$3.trace('Stop sending stats for call', { sessionId });
|
|
8313
8318
|
this.statsIntervals[sessionId]();
|
|
8314
8319
|
delete this.statsIntervals[sessionId];
|
|
8315
8320
|
}
|
|
@@ -8325,7 +8330,7 @@ class WebRTCClient extends Emitter {
|
|
|
8325
8330
|
try {
|
|
8326
8331
|
await this.userAgent.transport.disconnect();
|
|
8327
8332
|
} catch (e) {
|
|
8328
|
-
logger$
|
|
8333
|
+
logger$3.error('WebRTC transport disconnect, error', e);
|
|
8329
8334
|
}
|
|
8330
8335
|
}
|
|
8331
8336
|
}
|
|
@@ -8419,7 +8424,7 @@ class WebRTCClient extends Emitter {
|
|
|
8419
8424
|
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
8420
8425
|
+ networkStats.transportSent;
|
|
8421
8426
|
|
|
8422
|
-
this.eventEmitter.emit(ON_NETWORK_STATS
|
|
8427
|
+
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
8423
8428
|
this.sessionNetworkStats[sessionId].push(networkStats);
|
|
8424
8429
|
}
|
|
8425
8430
|
|
|
@@ -8447,8 +8452,8 @@ const ON_CALL_FAILED = 'onCallFailed';
|
|
|
8447
8452
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
8448
8453
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
8449
8454
|
const ON_MESSAGE = 'onMessage';
|
|
8450
|
-
const ON_REINVITE = 'reinvite';
|
|
8451
|
-
const ON_TRACK = 'onTrack';
|
|
8455
|
+
const ON_REINVITE$1 = 'reinvite';
|
|
8456
|
+
const ON_TRACK$1 = 'onTrack';
|
|
8452
8457
|
const ON_AUDIO_STREAM = 'onAudioStream';
|
|
8453
8458
|
const ON_VIDEO_STREAM = 'onVideoStream';
|
|
8454
8459
|
const ON_REMOVE_STREAM = 'onRemoveStream';
|
|
@@ -8463,15 +8468,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
|
|
|
8463
8468
|
const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
|
|
8464
8469
|
const ON_CALL_ERROR = 'onCallError';
|
|
8465
8470
|
const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
|
|
8466
|
-
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
8471
|
+
const ON_NETWORK_STATS$1 = 'onNetworkStats';
|
|
8467
8472
|
const ON_CHAT = 'phone/ON_CHAT';
|
|
8468
8473
|
const ON_SIGNAL = 'phone/ON_SIGNAL';
|
|
8469
|
-
const ON_DISCONNECTED = 'onDisconnected';
|
|
8474
|
+
const ON_DISCONNECTED$1 = 'onDisconnected';
|
|
8470
8475
|
|
|
8471
8476
|
const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
8472
8477
|
const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
8473
8478
|
|
|
8474
|
-
const events = [
|
|
8479
|
+
const events$1 = [
|
|
8475
8480
|
ON_USER_AGENT,
|
|
8476
8481
|
ON_REGISTERED,
|
|
8477
8482
|
ON_UNREGISTERED,
|
|
@@ -8489,8 +8494,8 @@ const events = [
|
|
|
8489
8494
|
ON_CALL_FAILED,
|
|
8490
8495
|
ON_CALL_ENDED,
|
|
8491
8496
|
ON_MESSAGE,
|
|
8492
|
-
ON_REINVITE,
|
|
8493
|
-
ON_TRACK,
|
|
8497
|
+
ON_REINVITE$1,
|
|
8498
|
+
ON_TRACK$1,
|
|
8494
8499
|
ON_AUDIO_STREAM,
|
|
8495
8500
|
ON_VIDEO_STREAM,
|
|
8496
8501
|
ON_REMOVE_STREAM,
|
|
@@ -8505,11 +8510,11 @@ const events = [
|
|
|
8505
8510
|
ON_CALL_ERROR,
|
|
8506
8511
|
ON_CHAT,
|
|
8507
8512
|
ON_SIGNAL,
|
|
8508
|
-
ON_NETWORK_STATS,
|
|
8509
|
-
ON_DISCONNECTED,
|
|
8513
|
+
ON_NETWORK_STATS$1,
|
|
8514
|
+
ON_DISCONNECTED$1,
|
|
8510
8515
|
];
|
|
8511
8516
|
|
|
8512
|
-
const logger$
|
|
8517
|
+
const logger$4 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
8513
8518
|
|
|
8514
8519
|
class WebRTCPhone extends Emitter {
|
|
8515
8520
|
|
|
@@ -8582,7 +8587,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8582
8587
|
}).catch(error => {
|
|
8583
8588
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
8584
8589
|
console.error('register error', error, error.message, error.stack);
|
|
8585
|
-
logger$
|
|
8590
|
+
logger$4.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
8586
8591
|
});
|
|
8587
8592
|
}
|
|
8588
8593
|
|
|
@@ -8597,7 +8602,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8597
8602
|
if (!this.client) {
|
|
8598
8603
|
return;
|
|
8599
8604
|
}
|
|
8600
|
-
logger$
|
|
8605
|
+
logger$4.info('WebRTC phone stop');
|
|
8601
8606
|
this.client.stop();
|
|
8602
8607
|
}
|
|
8603
8608
|
|
|
@@ -8612,7 +8617,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8612
8617
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
8613
8618
|
audioOnly = false, iceRestart = false) {
|
|
8614
8619
|
const sipSession = this.findSipSession(callSession);
|
|
8615
|
-
logger$
|
|
8620
|
+
logger$4.info('WebRTC phone - send reinvite', {
|
|
8616
8621
|
sessionId: sipSession ? sipSession.id : null,
|
|
8617
8622
|
constraints,
|
|
8618
8623
|
audioOnly,
|
|
@@ -8649,7 +8654,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8649
8654
|
}
|
|
8650
8655
|
|
|
8651
8656
|
startHeartbeat() {
|
|
8652
|
-
logger$
|
|
8657
|
+
logger$4.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
8653
8658
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
8654
8659
|
return;
|
|
8655
8660
|
}
|
|
@@ -8658,7 +8663,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8658
8663
|
}
|
|
8659
8664
|
|
|
8660
8665
|
stopHeartbeat() {
|
|
8661
|
-
logger$
|
|
8666
|
+
logger$4.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
8662
8667
|
if (!this.client) {
|
|
8663
8668
|
return;
|
|
8664
8669
|
}
|
|
@@ -8675,7 +8680,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8675
8680
|
}
|
|
8676
8681
|
|
|
8677
8682
|
reconnect() {
|
|
8678
|
-
logger$
|
|
8683
|
+
logger$4.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
8679
8684
|
if (!this.client) {
|
|
8680
8685
|
return;
|
|
8681
8686
|
}
|
|
@@ -8716,10 +8721,15 @@ class WebRTCPhone extends Emitter {
|
|
|
8716
8721
|
return false;
|
|
8717
8722
|
}
|
|
8718
8723
|
|
|
8719
|
-
logger$
|
|
8724
|
+
logger$4.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
8720
8725
|
|
|
8721
8726
|
this.client.downgradeToAudio(sipSession);
|
|
8722
8727
|
|
|
8728
|
+
if (callSession) {
|
|
8729
|
+
callSession.cameraEnabled = false;
|
|
8730
|
+
this._updateCallSession(callSession);
|
|
8731
|
+
}
|
|
8732
|
+
|
|
8723
8733
|
if (withMessage) {
|
|
8724
8734
|
this._sendReinviteMessage(callSession, false);
|
|
8725
8735
|
}
|
|
@@ -8734,7 +8744,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8734
8744
|
return Promise.resolve(false);
|
|
8735
8745
|
}
|
|
8736
8746
|
|
|
8737
|
-
logger$
|
|
8747
|
+
logger$4.info('Upgrade to video', {
|
|
8738
8748
|
id: callSession ? callSession.getId() : null,
|
|
8739
8749
|
constraints,
|
|
8740
8750
|
isConference,
|
|
@@ -8747,6 +8757,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8747
8757
|
|
|
8748
8758
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
8749
8759
|
|
|
8760
|
+
if (callSession) {
|
|
8761
|
+
callSession.cameraEnabled = true;
|
|
8762
|
+
this._updateCallSession(callSession);
|
|
8763
|
+
}
|
|
8764
|
+
|
|
8750
8765
|
// If no stream is returned, it means we have to reinvite
|
|
8751
8766
|
if (!newStream) {
|
|
8752
8767
|
return true;
|
|
@@ -8769,7 +8784,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8769
8784
|
|
|
8770
8785
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
8771
8786
|
const sipSession = this.findSipSession(callSession);
|
|
8772
|
-
logger$
|
|
8787
|
+
logger$4.info('Sending reinvite message', {
|
|
8773
8788
|
id: callSession ? callSession.getId() : null,
|
|
8774
8789
|
isUpgrade,
|
|
8775
8790
|
});
|
|
@@ -8795,7 +8810,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8795
8810
|
// Monkey patch to know when canceled with the CANCEL message
|
|
8796
8811
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
8797
8812
|
sipSession._onCancel = (message ) => {
|
|
8798
|
-
logger$
|
|
8813
|
+
logger$4.trace('on sip session canceled', { callId: message.callId });
|
|
8799
8814
|
|
|
8800
8815
|
onCancel(message);
|
|
8801
8816
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
@@ -8823,13 +8838,13 @@ class WebRTCPhone extends Emitter {
|
|
|
8823
8838
|
this.audioOutputVolume,
|
|
8824
8839
|
);
|
|
8825
8840
|
case sessionState.SessionState.Terminating:
|
|
8826
|
-
logger$
|
|
8841
|
+
logger$4.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
8827
8842
|
|
|
8828
8843
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
8829
8844
|
|
|
8830
8845
|
break;
|
|
8831
8846
|
case sessionState.SessionState.Terminated: {
|
|
8832
|
-
logger$
|
|
8847
|
+
logger$4.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
8833
8848
|
|
|
8834
8849
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
8835
8850
|
const callSession = this._createCallSession(sipSession);
|
|
@@ -8851,7 +8866,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8851
8866
|
const [stream] = event.streams;
|
|
8852
8867
|
const kind = event && event.track && event.track.kind;
|
|
8853
8868
|
|
|
8854
|
-
logger$
|
|
8869
|
+
logger$4.info('on track stream called on the peer connection', {
|
|
8855
8870
|
callId: this.getSipSessionId(sipSession),
|
|
8856
8871
|
streamId: stream ? stream.id : null,
|
|
8857
8872
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -8871,7 +8886,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8871
8886
|
};
|
|
8872
8887
|
|
|
8873
8888
|
peerConnection.onremovestream = event => {
|
|
8874
|
-
logger$
|
|
8889
|
+
logger$4.info('on remove stream called on the peer connection', {
|
|
8875
8890
|
id: event.stream.id,
|
|
8876
8891
|
tracks: event.stream.getTracks(),
|
|
8877
8892
|
});
|
|
@@ -8881,7 +8896,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8881
8896
|
}
|
|
8882
8897
|
|
|
8883
8898
|
async startScreenSharing(constraints , callSession ) {
|
|
8884
|
-
logger$
|
|
8899
|
+
logger$4.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
8885
8900
|
|
|
8886
8901
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
8887
8902
|
if (!screenShareStream) {
|
|
@@ -8921,7 +8936,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8921
8936
|
return;
|
|
8922
8937
|
}
|
|
8923
8938
|
|
|
8924
|
-
logger$
|
|
8939
|
+
logger$4.info('WebRTC phone - stop screen sharing', {
|
|
8925
8940
|
restoreLocalStream,
|
|
8926
8941
|
});
|
|
8927
8942
|
|
|
@@ -8977,7 +8992,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8977
8992
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
8978
8993
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
8979
8994
|
|
|
8980
|
-
logger$
|
|
8995
|
+
logger$4.info('WebRTC phone - on screensharing', {
|
|
8981
8996
|
hadVideo,
|
|
8982
8997
|
id: this.getSipSessionId(sipSession),
|
|
8983
8998
|
screenTrack,
|
|
@@ -8985,7 +9000,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8985
9000
|
|
|
8986
9001
|
if (screenTrack) {
|
|
8987
9002
|
screenTrack.onended = () => {
|
|
8988
|
-
logger$
|
|
9003
|
+
logger$4.info('WebRTC phone - on screenshare ended', {
|
|
8989
9004
|
hadVideo,
|
|
8990
9005
|
id: this.getSipSessionId(sipSession),
|
|
8991
9006
|
screenTrack,
|
|
@@ -9016,7 +9031,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9016
9031
|
}
|
|
9017
9032
|
|
|
9018
9033
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
9019
|
-
logger$
|
|
9034
|
+
logger$4.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
9020
9035
|
|
|
9021
9036
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
9022
9037
|
this.currentSipSession = sipSession;
|
|
@@ -9034,7 +9049,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9034
9049
|
}
|
|
9035
9050
|
|
|
9036
9051
|
changeAudioDevice(id ) {
|
|
9037
|
-
logger$
|
|
9052
|
+
logger$4.info('WebRTC phone - change audio device', { deviceId: id });
|
|
9038
9053
|
this.audioOutputDeviceId = id;
|
|
9039
9054
|
this.client.changeAudioOutputDevice(id);
|
|
9040
9055
|
}
|
|
@@ -9044,14 +9059,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9044
9059
|
}
|
|
9045
9060
|
|
|
9046
9061
|
changeRingDevice(id ) {
|
|
9047
|
-
logger$
|
|
9062
|
+
logger$4.info('WebRTC phone - changing ring device', { id });
|
|
9048
9063
|
|
|
9049
9064
|
this.audioRingDeviceId = id;
|
|
9050
9065
|
}
|
|
9051
9066
|
|
|
9052
9067
|
// volume is a value between 0 and 1
|
|
9053
9068
|
changeAudioVolume(volume ) {
|
|
9054
|
-
logger$
|
|
9069
|
+
logger$4.info('WebRTC phone - changing audio volume', { volume });
|
|
9055
9070
|
|
|
9056
9071
|
this.audioOutputVolume = volume;
|
|
9057
9072
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -9059,31 +9074,31 @@ class WebRTCPhone extends Emitter {
|
|
|
9059
9074
|
|
|
9060
9075
|
// volume is a value between 0 and 1
|
|
9061
9076
|
changeRingVolume(volume ) {
|
|
9062
|
-
logger$
|
|
9077
|
+
logger$4.info('WebRTC phone - changing ring volume', { volume });
|
|
9063
9078
|
|
|
9064
9079
|
this.audioRingVolume = volume;
|
|
9065
9080
|
}
|
|
9066
9081
|
|
|
9067
9082
|
changeAudioInputDevice(id ) {
|
|
9068
|
-
logger$
|
|
9083
|
+
logger$4.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
9069
9084
|
|
|
9070
9085
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
9071
9086
|
}
|
|
9072
9087
|
|
|
9073
9088
|
changeVideoInputDevice(id ) {
|
|
9074
|
-
logger$
|
|
9089
|
+
logger$4.info('WebRTC phone - change video input device', { deviceId: id });
|
|
9075
9090
|
|
|
9076
9091
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
9077
9092
|
}
|
|
9078
9093
|
|
|
9079
9094
|
changeSessionVideoInputDevice(id ) {
|
|
9080
|
-
logger$
|
|
9095
|
+
logger$4.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
9081
9096
|
|
|
9082
9097
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
9083
9098
|
}
|
|
9084
9099
|
|
|
9085
9100
|
_onCallTerminated(sipSession ) {
|
|
9086
|
-
logger$
|
|
9101
|
+
logger$4.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9087
9102
|
|
|
9088
9103
|
const callSession = this._createCallSession(sipSession);
|
|
9089
9104
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -9117,7 +9132,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9117
9132
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
9118
9133
|
|
|
9119
9134
|
// Re-trigger incoming call event for remaining incoming calls
|
|
9120
|
-
logger$
|
|
9135
|
+
logger$4.info('WebRTC phone - check to re-trigger incoming call', {
|
|
9121
9136
|
sipId: sipSession.id,
|
|
9122
9137
|
shouldRetrigger,
|
|
9123
9138
|
hasIncomingCallSession,
|
|
@@ -9208,37 +9223,37 @@ class WebRTCPhone extends Emitter {
|
|
|
9208
9223
|
|
|
9209
9224
|
// Deprecated
|
|
9210
9225
|
getLocalStreamForCall(callSession ) {
|
|
9211
|
-
logger$
|
|
9226
|
+
logger$4.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9212
9227
|
|
|
9213
9228
|
return this.getLocalStream(callSession);
|
|
9214
9229
|
}
|
|
9215
9230
|
|
|
9216
9231
|
// Deprecated
|
|
9217
9232
|
getRemoteStreamForCall(callSession ) {
|
|
9218
|
-
logger$
|
|
9233
|
+
logger$4.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
9219
9234
|
|
|
9220
9235
|
return this.getRemoteVideoStream(callSession);
|
|
9221
9236
|
}
|
|
9222
9237
|
|
|
9223
9238
|
getRemoteStreamsForCall(callSession ) {
|
|
9224
|
-
logger$
|
|
9239
|
+
logger$4.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
9225
9240
|
|
|
9226
9241
|
return this.getRemoteStream(callSession);
|
|
9227
9242
|
}
|
|
9228
9243
|
|
|
9229
9244
|
accept(callSession , cameraEnabled ) {
|
|
9230
|
-
logger$
|
|
9245
|
+
logger$4.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
9231
9246
|
if (this.currentSipSession) {
|
|
9232
9247
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
9233
9248
|
}
|
|
9234
9249
|
|
|
9235
9250
|
if (!callSession) {
|
|
9236
|
-
logger$
|
|
9251
|
+
logger$4.warn('no CallSession to accept.');
|
|
9237
9252
|
return Promise.resolve(null);
|
|
9238
9253
|
}
|
|
9239
9254
|
|
|
9240
9255
|
if (callSession.getId() in this.acceptedSessions) {
|
|
9241
|
-
logger$
|
|
9256
|
+
logger$4.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9242
9257
|
return Promise.resolve(callSession.sipCallId);
|
|
9243
9258
|
}
|
|
9244
9259
|
|
|
@@ -9250,24 +9265,24 @@ class WebRTCPhone extends Emitter {
|
|
|
9250
9265
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
9251
9266
|
if (sipSession) {
|
|
9252
9267
|
if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
|
|
9253
|
-
logger$
|
|
9268
|
+
logger$4.warn('Trying to answer a terminated sipSession.');
|
|
9254
9269
|
|
|
9255
9270
|
return Promise.resolve(null);
|
|
9256
9271
|
}
|
|
9257
9272
|
|
|
9258
|
-
logger$
|
|
9273
|
+
logger$4.info('accept call, session found', { sipId: sipSession.id });
|
|
9259
9274
|
|
|
9260
9275
|
// $FlowFixMe
|
|
9261
9276
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
9262
9277
|
return callSession.sipCallId;
|
|
9263
9278
|
}).catch(e => {
|
|
9264
|
-
logger$
|
|
9279
|
+
logger$4.error(e);
|
|
9265
9280
|
this.endCurrentCall(callSession);
|
|
9266
9281
|
throw e;
|
|
9267
9282
|
});
|
|
9268
9283
|
}
|
|
9269
9284
|
|
|
9270
|
-
logger$
|
|
9285
|
+
logger$4.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9271
9286
|
|
|
9272
9287
|
return Promise.resolve(null);
|
|
9273
9288
|
}
|
|
@@ -9277,7 +9292,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9277
9292
|
}
|
|
9278
9293
|
|
|
9279
9294
|
async reject(callSession ) {
|
|
9280
|
-
logger$
|
|
9295
|
+
logger$4.info('reject WebRTC called', { id: callSession.getId() });
|
|
9281
9296
|
|
|
9282
9297
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
9283
9298
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -9289,14 +9304,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9289
9304
|
|
|
9290
9305
|
const sipSession = this.findSipSession(callSession);
|
|
9291
9306
|
if (sipSession) {
|
|
9292
|
-
logger$
|
|
9307
|
+
logger$4.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
9293
9308
|
|
|
9294
9309
|
this.client.hangup(sipSession);
|
|
9295
9310
|
}
|
|
9296
9311
|
}
|
|
9297
9312
|
|
|
9298
9313
|
async ignore(callSession ) {
|
|
9299
|
-
logger$
|
|
9314
|
+
logger$4.info('WebRTC ignore', { id: callSession.getId() });
|
|
9300
9315
|
|
|
9301
9316
|
// kill the ring
|
|
9302
9317
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -9308,14 +9323,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9308
9323
|
const sipSession = this.findSipSession(callSession);
|
|
9309
9324
|
|
|
9310
9325
|
if (sipSession) {
|
|
9311
|
-
logger$
|
|
9326
|
+
logger$4.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
9312
9327
|
|
|
9313
9328
|
return this.client.atxfer(sipSession);
|
|
9314
9329
|
}
|
|
9315
9330
|
}
|
|
9316
9331
|
|
|
9317
9332
|
hold(callSession , withEvent = true, isConference = false) {
|
|
9318
|
-
logger$
|
|
9333
|
+
logger$4.info('WebRTC hold', { id: callSession.getId() });
|
|
9319
9334
|
|
|
9320
9335
|
const sipSession = this.findSipSession(callSession);
|
|
9321
9336
|
|
|
@@ -9330,18 +9345,18 @@ class WebRTCPhone extends Emitter {
|
|
|
9330
9345
|
}
|
|
9331
9346
|
|
|
9332
9347
|
resume(callSession , isConference = false, withEvent = true) {
|
|
9333
|
-
logger$
|
|
9348
|
+
logger$4.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
9334
9349
|
|
|
9335
9350
|
const sipSession = this.findSipSession(callSession);
|
|
9336
9351
|
if (!sipSession) {
|
|
9337
9352
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
9338
9353
|
}
|
|
9339
9354
|
|
|
9340
|
-
logger$
|
|
9355
|
+
logger$4.info('WebRTC resuming', { sipId: sipSession.id });
|
|
9341
9356
|
|
|
9342
9357
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
9343
9358
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
9344
|
-
logger$
|
|
9359
|
+
logger$4.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
9345
9360
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
9346
9361
|
}
|
|
9347
9362
|
|
|
@@ -9366,7 +9381,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9366
9381
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9367
9382
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
9368
9383
|
|
|
9369
|
-
logger$
|
|
9384
|
+
logger$4.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9370
9385
|
|
|
9371
9386
|
// Stop screenshre if needed
|
|
9372
9387
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -9397,7 +9412,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9397
9412
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
9398
9413
|
}
|
|
9399
9414
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9400
|
-
logger$
|
|
9415
|
+
logger$4.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
9401
9416
|
|
|
9402
9417
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
9403
9418
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -9441,14 +9456,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9441
9456
|
}
|
|
9442
9457
|
|
|
9443
9458
|
mute(callSession , withEvent = true) {
|
|
9444
|
-
logger$
|
|
9459
|
+
logger$4.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
9445
9460
|
|
|
9446
9461
|
const sipSession = this.findSipSession(callSession);
|
|
9447
9462
|
if (!sipSession) {
|
|
9448
9463
|
return;
|
|
9449
9464
|
}
|
|
9450
9465
|
|
|
9451
|
-
logger$
|
|
9466
|
+
logger$4.info('WebRTC muting', { sipId: sipSession.id });
|
|
9452
9467
|
this.client.mute(sipSession);
|
|
9453
9468
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
9454
9469
|
|
|
@@ -9462,14 +9477,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9462
9477
|
}
|
|
9463
9478
|
|
|
9464
9479
|
unmute(callSession , withEvent = true) {
|
|
9465
|
-
logger$
|
|
9480
|
+
logger$4.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
9466
9481
|
|
|
9467
9482
|
const sipSession = this.findSipSession(callSession);
|
|
9468
9483
|
if (!sipSession) {
|
|
9469
9484
|
return;
|
|
9470
9485
|
}
|
|
9471
9486
|
|
|
9472
|
-
logger$
|
|
9487
|
+
logger$4.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
9473
9488
|
this.client.unmute(sipSession);
|
|
9474
9489
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
9475
9490
|
|
|
@@ -9496,7 +9511,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9496
9511
|
if (!sipSession) {
|
|
9497
9512
|
return;
|
|
9498
9513
|
}
|
|
9499
|
-
logger$
|
|
9514
|
+
logger$4.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
9500
9515
|
|
|
9501
9516
|
this.client.toggleCameraOn(sipSession);
|
|
9502
9517
|
|
|
@@ -9508,7 +9523,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9508
9523
|
if (!sipSession) {
|
|
9509
9524
|
return;
|
|
9510
9525
|
}
|
|
9511
|
-
logger$
|
|
9526
|
+
logger$4.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
9512
9527
|
|
|
9513
9528
|
this.client.toggleCameraOff(sipSession);
|
|
9514
9529
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -9520,7 +9535,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9520
9535
|
return;
|
|
9521
9536
|
}
|
|
9522
9537
|
|
|
9523
|
-
logger$
|
|
9538
|
+
logger$4.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
9524
9539
|
this.client.sendDTMF(sipSession, tone);
|
|
9525
9540
|
}
|
|
9526
9541
|
|
|
@@ -9528,7 +9543,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9528
9543
|
// @TODO: line is not used here
|
|
9529
9544
|
async makeCall(number , line , cameraEnabled ,
|
|
9530
9545
|
audioOnly = false, conference = false) {
|
|
9531
|
-
logger$
|
|
9546
|
+
logger$4.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
9532
9547
|
if (!number) {
|
|
9533
9548
|
return Promise.resolve(null);
|
|
9534
9549
|
}
|
|
@@ -9538,7 +9553,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9538
9553
|
}
|
|
9539
9554
|
if (this.currentSipSession) {
|
|
9540
9555
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
9541
|
-
logger$
|
|
9556
|
+
logger$4.warn('Unable to hold current session when making another call', e);
|
|
9542
9557
|
});
|
|
9543
9558
|
}
|
|
9544
9559
|
|
|
@@ -9548,7 +9563,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9548
9563
|
this._bindEvents(sipSession);
|
|
9549
9564
|
} catch (error) {
|
|
9550
9565
|
console.warn(error);
|
|
9551
|
-
logger$
|
|
9566
|
+
logger$4.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
9552
9567
|
return Promise.resolve(null);
|
|
9553
9568
|
}
|
|
9554
9569
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -9576,7 +9591,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9576
9591
|
return;
|
|
9577
9592
|
}
|
|
9578
9593
|
|
|
9579
|
-
logger$
|
|
9594
|
+
logger$4.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
9580
9595
|
|
|
9581
9596
|
this.client.transfer(sipSession, target);
|
|
9582
9597
|
}
|
|
@@ -9585,7 +9600,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9585
9600
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
9586
9601
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
9587
9602
|
|
|
9588
|
-
logger$
|
|
9603
|
+
logger$4.info('WebRTC indirect transfer', {
|
|
9589
9604
|
sipId: sipSession ? sipSession.id : null,
|
|
9590
9605
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
9591
9606
|
});
|
|
@@ -9624,7 +9639,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9624
9639
|
return false;
|
|
9625
9640
|
}
|
|
9626
9641
|
|
|
9627
|
-
logger$
|
|
9642
|
+
logger$4.info('WebRTC hangup', { sipId: sipSession.id });
|
|
9628
9643
|
|
|
9629
9644
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9630
9645
|
|
|
@@ -9670,7 +9685,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9670
9685
|
endCurrentCall(callSession ) {
|
|
9671
9686
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
9672
9687
|
|
|
9673
|
-
logger$
|
|
9688
|
+
logger$4.info('Ending current call', {
|
|
9674
9689
|
id: callSession ? callSession.getId() : null,
|
|
9675
9690
|
isCurrent,
|
|
9676
9691
|
});
|
|
@@ -9694,7 +9709,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9694
9709
|
}
|
|
9695
9710
|
|
|
9696
9711
|
async close() {
|
|
9697
|
-
logger$
|
|
9712
|
+
logger$4.info('WebRTC close');
|
|
9698
9713
|
|
|
9699
9714
|
try {
|
|
9700
9715
|
await Promise.race([
|
|
@@ -9702,7 +9717,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9702
9717
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
9703
9718
|
]);
|
|
9704
9719
|
} catch (e) {
|
|
9705
|
-
logger$
|
|
9720
|
+
logger$4.error('WebRTC close, unregister error', e);
|
|
9706
9721
|
}
|
|
9707
9722
|
|
|
9708
9723
|
this.client.close();
|
|
@@ -9720,12 +9735,12 @@ class WebRTCPhone extends Emitter {
|
|
|
9720
9735
|
}
|
|
9721
9736
|
|
|
9722
9737
|
enableRinging() {
|
|
9723
|
-
logger$
|
|
9738
|
+
logger$4.info('WebRTC enable ringing');
|
|
9724
9739
|
this.ringingEnabled = true;
|
|
9725
9740
|
}
|
|
9726
9741
|
|
|
9727
9742
|
disableRinging() {
|
|
9728
|
-
logger$
|
|
9743
|
+
logger$4.info('WebRTC disable ringing');
|
|
9729
9744
|
this.ringingEnabled = false;
|
|
9730
9745
|
}
|
|
9731
9746
|
|
|
@@ -9765,7 +9780,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9765
9780
|
|
|
9766
9781
|
// Deprecated
|
|
9767
9782
|
getLocalMediaStream(callSession ) {
|
|
9768
|
-
logger$
|
|
9783
|
+
logger$4.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9769
9784
|
return this.getLocalStream(callSession);
|
|
9770
9785
|
}
|
|
9771
9786
|
|
|
@@ -9807,7 +9822,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9807
9822
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
9808
9823
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
9809
9824
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
9810
|
-
logger$
|
|
9825
|
+
logger$4.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
9811
9826
|
|
|
9812
9827
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
9813
9828
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -9830,7 +9845,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9830
9845
|
});
|
|
9831
9846
|
|
|
9832
9847
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
9833
|
-
logger$
|
|
9848
|
+
logger$4.info('WebRTC on reinvite', {
|
|
9834
9849
|
sessionId: args[0].id,
|
|
9835
9850
|
inviteId: args[1].id,
|
|
9836
9851
|
updatedCalleeName: args[2],
|
|
@@ -9850,7 +9865,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9850
9865
|
});
|
|
9851
9866
|
|
|
9852
9867
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
9853
|
-
logger$
|
|
9868
|
+
logger$4.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
9854
9869
|
|
|
9855
9870
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
9856
9871
|
|
|
@@ -9861,22 +9876,22 @@ class WebRTCPhone extends Emitter {
|
|
|
9861
9876
|
this.client.on('ended', () => {});
|
|
9862
9877
|
|
|
9863
9878
|
this.client.on(this.client.ON_ERROR, e => {
|
|
9864
|
-
logger$
|
|
9879
|
+
logger$4.error('WebRTC error', e);
|
|
9865
9880
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
9866
9881
|
});
|
|
9867
9882
|
|
|
9868
9883
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
9869
|
-
logger$
|
|
9884
|
+
logger$4.info('WebRTC unregistered');
|
|
9870
9885
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
9871
9886
|
});
|
|
9872
9887
|
|
|
9873
9888
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
9874
|
-
logger$
|
|
9875
|
-
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
9889
|
+
logger$4.info('WebRTC disconnected');
|
|
9890
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
9876
9891
|
});
|
|
9877
9892
|
|
|
9878
9893
|
this.client.on(this.client.REGISTERED, () => {
|
|
9879
|
-
logger$
|
|
9894
|
+
logger$4.info('WebRTC registered', {
|
|
9880
9895
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
9881
9896
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
9882
9897
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -9889,23 +9904,27 @@ class WebRTCPhone extends Emitter {
|
|
|
9889
9904
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
9890
9905
|
&& this.currentSipSession.state === sessionState.SessionState.Established) {
|
|
9891
9906
|
this.shouldSendReinvite = false;
|
|
9907
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
9908
|
+
const isConference = pc ? pc.sfu : false;
|
|
9909
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
9910
|
+
|
|
9892
9911
|
try {
|
|
9893
9912
|
// Send reinvite with iceRestart
|
|
9894
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
9913
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
9895
9914
|
} catch (e) {
|
|
9896
|
-
logger$
|
|
9915
|
+
logger$4.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
9897
9916
|
}
|
|
9898
9917
|
}
|
|
9899
9918
|
});
|
|
9900
9919
|
|
|
9901
9920
|
this.client.on(this.client.CONNECTED, () => {
|
|
9902
|
-
logger$
|
|
9921
|
+
logger$4.info('WebRTC client connected');
|
|
9903
9922
|
|
|
9904
9923
|
this.stopHeartbeat();
|
|
9905
9924
|
});
|
|
9906
9925
|
|
|
9907
9926
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
9908
|
-
logger$
|
|
9927
|
+
logger$4.info('WebRTC client disconnected');
|
|
9909
9928
|
|
|
9910
9929
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
9911
9930
|
|
|
@@ -9919,7 +9938,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9919
9938
|
});
|
|
9920
9939
|
|
|
9921
9940
|
this.client.on(this.client.ON_TRACK, (session, event) => {
|
|
9922
|
-
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
9941
|
+
this.eventEmitter.emit(ON_TRACK$1, session, event);
|
|
9923
9942
|
});
|
|
9924
9943
|
|
|
9925
9944
|
this.client.on('onVideoInputChange', stream => {
|
|
@@ -9934,7 +9953,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9934
9953
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
9935
9954
|
const callSession = this.getCallSession(this.getSipSessionId(session));
|
|
9936
9955
|
|
|
9937
|
-
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
9956
|
+
this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
|
|
9938
9957
|
});
|
|
9939
9958
|
|
|
9940
9959
|
// Used when upgrading directly in screenshare mode
|
|
@@ -9943,7 +9962,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9943
9962
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
9944
9963
|
const callSession = this.callSessions[sipSessionId];
|
|
9945
9964
|
|
|
9946
|
-
logger$
|
|
9965
|
+
logger$4.info('Updrading directly in screensharing mode', {
|
|
9947
9966
|
sipSessionId,
|
|
9948
9967
|
tracks: localStream ? localStream.getTracks() : null,
|
|
9949
9968
|
});
|
|
@@ -9975,6 +9994,15 @@ class WebRTCPhone extends Emitter {
|
|
|
9975
9994
|
return this.client.getSipSessionId(sipSession);
|
|
9976
9995
|
}
|
|
9977
9996
|
|
|
9997
|
+
_updateCallSession(callSession ) {
|
|
9998
|
+
const sipSession = this.findSipSession(callSession);
|
|
9999
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
10000
|
+
|
|
10001
|
+
if (sipSessionId) {
|
|
10002
|
+
this.callSessions[sipSessionId] = callSession;
|
|
10003
|
+
}
|
|
10004
|
+
}
|
|
10005
|
+
|
|
9978
10006
|
_onMessage(message ) {
|
|
9979
10007
|
if (!message || message.method !== 'MESSAGE') {
|
|
9980
10008
|
return;
|
|
@@ -10112,8 +10140,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10112
10140
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10113
10141
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10114
10142
|
ON_MESSAGE: ON_MESSAGE,
|
|
10115
|
-
ON_REINVITE: ON_REINVITE,
|
|
10116
|
-
ON_TRACK: ON_TRACK,
|
|
10143
|
+
ON_REINVITE: ON_REINVITE$1,
|
|
10144
|
+
ON_TRACK: ON_TRACK$1,
|
|
10117
10145
|
ON_AUDIO_STREAM: ON_AUDIO_STREAM,
|
|
10118
10146
|
ON_VIDEO_STREAM: ON_VIDEO_STREAM,
|
|
10119
10147
|
ON_REMOVE_STREAM: ON_REMOVE_STREAM,
|
|
@@ -10128,19 +10156,19 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10128
10156
|
ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
|
|
10129
10157
|
ON_CALL_ERROR: ON_CALL_ERROR,
|
|
10130
10158
|
ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
|
|
10131
|
-
ON_NETWORK_STATS: ON_NETWORK_STATS,
|
|
10159
|
+
ON_NETWORK_STATS: ON_NETWORK_STATS$1,
|
|
10132
10160
|
ON_CHAT: ON_CHAT,
|
|
10133
10161
|
ON_SIGNAL: ON_SIGNAL,
|
|
10134
|
-
ON_DISCONNECTED: ON_DISCONNECTED,
|
|
10162
|
+
ON_DISCONNECTED: ON_DISCONNECTED$1,
|
|
10135
10163
|
MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
|
|
10136
10164
|
MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
|
|
10137
|
-
events: events,
|
|
10165
|
+
events: events$1,
|
|
10138
10166
|
'default': WebRTCPhone
|
|
10139
10167
|
});
|
|
10140
10168
|
|
|
10141
10169
|
//
|
|
10142
10170
|
|
|
10143
|
-
const logger$
|
|
10171
|
+
const logger$5 = IssueReporter$1.loggerFor('simple-phone');
|
|
10144
10172
|
const sipLogger = IssueReporter$1.loggerFor('sip.js');
|
|
10145
10173
|
const protocolLogger = IssueReporter$1.loggerFor('sip');
|
|
10146
10174
|
|
|
@@ -10247,7 +10275,7 @@ class Phone extends Emitter {
|
|
|
10247
10275
|
async disconnect() {
|
|
10248
10276
|
if (this.phone) {
|
|
10249
10277
|
if (this.phone.hasAnActiveCall()) {
|
|
10250
|
-
logger$
|
|
10278
|
+
logger$5.info('hangup call on disconnect');
|
|
10251
10279
|
// $FlowFixMe
|
|
10252
10280
|
await this.phone.hangup();
|
|
10253
10281
|
}
|
|
@@ -10270,13 +10298,13 @@ class Phone extends Emitter {
|
|
|
10270
10298
|
}
|
|
10271
10299
|
|
|
10272
10300
|
async hangup(callSession ) {
|
|
10273
|
-
logger$
|
|
10301
|
+
logger$5.info('hangup via simple phone', { callId: callSession.getId() });
|
|
10274
10302
|
|
|
10275
10303
|
return this.phone && this.phone.hangup(callSession);
|
|
10276
10304
|
}
|
|
10277
10305
|
|
|
10278
10306
|
async accept(callSession , cameraEnabled ) {
|
|
10279
|
-
logger$
|
|
10307
|
+
logger$5.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
|
|
10280
10308
|
|
|
10281
10309
|
return this.phone && this.phone.accept(callSession, cameraEnabled);
|
|
10282
10310
|
}
|
|
@@ -10315,7 +10343,7 @@ class Phone extends Emitter {
|
|
|
10315
10343
|
muteViaAPI(callSession ) {
|
|
10316
10344
|
if (callSession && callSession.callId) {
|
|
10317
10345
|
Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
|
|
10318
|
-
logger$
|
|
10346
|
+
logger$5.error('Mute via API, error', e);
|
|
10319
10347
|
});
|
|
10320
10348
|
}
|
|
10321
10349
|
}
|
|
@@ -10323,7 +10351,7 @@ class Phone extends Emitter {
|
|
|
10323
10351
|
unmuteViaAPI(callSession ) {
|
|
10324
10352
|
if (callSession && callSession.callId) {
|
|
10325
10353
|
Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
|
|
10326
|
-
logger$
|
|
10354
|
+
logger$5.error('Unmute via API, error', e);
|
|
10327
10355
|
});
|
|
10328
10356
|
}
|
|
10329
10357
|
}
|
|
@@ -10431,7 +10459,7 @@ class Phone extends Emitter {
|
|
|
10431
10459
|
|
|
10432
10460
|
// @Deprecated
|
|
10433
10461
|
getLocalMediaStream(callSession ) {
|
|
10434
|
-
logger$
|
|
10462
|
+
logger$5.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
|
|
10435
10463
|
|
|
10436
10464
|
return this.phone && this.phone.getLocalStream(callSession);
|
|
10437
10465
|
}
|
|
@@ -10454,20 +10482,20 @@ class Phone extends Emitter {
|
|
|
10454
10482
|
|
|
10455
10483
|
// @Deprecated
|
|
10456
10484
|
getRemoteStreamForCall(callSession ) {
|
|
10457
|
-
logger$
|
|
10485
|
+
logger$5.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
|
|
10458
10486
|
return this.getRemoteStream(callSession);
|
|
10459
10487
|
}
|
|
10460
10488
|
|
|
10461
10489
|
// Returns remote streams directly from the peerConnection
|
|
10462
10490
|
// @Deprecated
|
|
10463
10491
|
getRemoteStreamsForCall(callSession ) {
|
|
10464
|
-
logger$
|
|
10492
|
+
logger$5.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
|
|
10465
10493
|
return this.getLocalStream(callSession);
|
|
10466
10494
|
}
|
|
10467
10495
|
|
|
10468
10496
|
// @Deprecated
|
|
10469
10497
|
getRemoteVideoStreamForCall(callSession ) {
|
|
10470
|
-
logger$
|
|
10498
|
+
logger$5.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
|
|
10471
10499
|
|
|
10472
10500
|
return this.getRemoteVideoStream(callSession);
|
|
10473
10501
|
}
|
|
@@ -10528,7 +10556,7 @@ class Phone extends Emitter {
|
|
|
10528
10556
|
|
|
10529
10557
|
_transferEvents() {
|
|
10530
10558
|
this.unbind();
|
|
10531
|
-
[...events
|
|
10559
|
+
[...events, ...transportEvents].forEach(event => {
|
|
10532
10560
|
this.client.on(event, (...args) =>
|
|
10533
10561
|
this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
|
|
10534
10562
|
});
|
|
@@ -10550,7 +10578,7 @@ var Phone$1 = global.wazoTelephonyInstance;
|
|
|
10550
10578
|
|
|
10551
10579
|
//
|
|
10552
10580
|
|
|
10553
|
-
const SOCKET_EVENTS
|
|
10581
|
+
const SOCKET_EVENTS = {
|
|
10554
10582
|
ON_OPEN: 'onopen',
|
|
10555
10583
|
ON_MESSAGE: 'onmessage',
|
|
10556
10584
|
ON_ERROR: 'onerror',
|
|
@@ -10703,16 +10731,16 @@ class WebSocketClient extends Emitter {
|
|
|
10703
10731
|
|
|
10704
10732
|
this.socket.onopen = () => {
|
|
10705
10733
|
logger$6.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
10706
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10734
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
10707
10735
|
};
|
|
10708
10736
|
|
|
10709
10737
|
this.socket.onerror = event => {
|
|
10710
10738
|
logger$6.error('on Wazo WS error', event.target);
|
|
10711
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10739
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
10712
10740
|
};
|
|
10713
10741
|
|
|
10714
10742
|
this.socket.onmessage = (event ) => {
|
|
10715
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10743
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
|
|
10716
10744
|
|
|
10717
10745
|
const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
|
|
10718
10746
|
let { name } = message;
|
|
@@ -10745,11 +10773,11 @@ class WebSocketClient extends Emitter {
|
|
|
10745
10773
|
token: this.token,
|
|
10746
10774
|
});
|
|
10747
10775
|
this.initialized = false;
|
|
10748
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10776
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
|
|
10749
10777
|
|
|
10750
10778
|
switch (event.code) {
|
|
10751
10779
|
case 4002:
|
|
10752
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10780
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
|
|
10753
10781
|
break;
|
|
10754
10782
|
}
|
|
10755
10783
|
};
|
|
@@ -10865,7 +10893,7 @@ class WebSocketClient extends Emitter {
|
|
|
10865
10893
|
break;
|
|
10866
10894
|
case 'start':
|
|
10867
10895
|
this.initialized = true;
|
|
10868
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10896
|
+
this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
|
|
10869
10897
|
break;
|
|
10870
10898
|
default:
|
|
10871
10899
|
this.eventEmitter.emit('message', message);
|
|
@@ -10912,7 +10940,7 @@ class WebSocketClient extends Emitter {
|
|
|
10912
10940
|
logger$6.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
10913
10941
|
|
|
10914
10942
|
this.close();
|
|
10915
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10943
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
10916
10944
|
|
|
10917
10945
|
if (this.onHeartBeatTimeout) {
|
|
10918
10946
|
this.onHeartBeatTimeout();
|
|
@@ -10992,7 +11020,7 @@ WebSocketClient.eventLists = [
|
|
|
10992
11020
|
|
|
10993
11021
|
var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
10994
11022
|
__proto__: null,
|
|
10995
|
-
SOCKET_EVENTS: SOCKET_EVENTS
|
|
11023
|
+
SOCKET_EVENTS: SOCKET_EVENTS,
|
|
10996
11024
|
AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
|
|
10997
11025
|
FAVORITE_ADDED: FAVORITE_ADDED,
|
|
10998
11026
|
FAVORITE_DELETED: FAVORITE_DELETED,
|
|
@@ -11065,10 +11093,10 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
11065
11093
|
|
|
11066
11094
|
//
|
|
11067
11095
|
|
|
11068
|
-
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
11069
|
-
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
11096
|
+
const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
11097
|
+
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
|
|
11070
11098
|
|
|
11071
|
-
const logger$
|
|
11099
|
+
const logger$7 = IssueReporter$1.loggerFor('simple-ws-client');
|
|
11072
11100
|
|
|
11073
11101
|
class Websocket extends Emitter {
|
|
11074
11102
|
|
|
@@ -11082,9 +11110,9 @@ class Websocket extends Emitter {
|
|
|
11082
11110
|
// $FlowFixMe
|
|
11083
11111
|
this[key] = OTHER_EVENTS[key];
|
|
11084
11112
|
});
|
|
11085
|
-
Object.keys(SOCKET_EVENTS).forEach(key => {
|
|
11113
|
+
Object.keys(SOCKET_EVENTS$1).forEach(key => {
|
|
11086
11114
|
// $FlowFixMe
|
|
11087
|
-
this[key] = SOCKET_EVENTS[key];
|
|
11115
|
+
this[key] = SOCKET_EVENTS$1[key];
|
|
11088
11116
|
});
|
|
11089
11117
|
this.eventLists = WebSocketClient.eventLists;
|
|
11090
11118
|
|
|
@@ -11092,7 +11120,7 @@ class Websocket extends Emitter {
|
|
|
11092
11120
|
}
|
|
11093
11121
|
|
|
11094
11122
|
open(host , session ) {
|
|
11095
|
-
logger$
|
|
11123
|
+
logger$7.info('open simple WebSocket', { host, token: session.token });
|
|
11096
11124
|
this.ws = new WebSocketClient(
|
|
11097
11125
|
{
|
|
11098
11126
|
host,
|
|
@@ -11120,7 +11148,7 @@ class Websocket extends Emitter {
|
|
|
11120
11148
|
}
|
|
11121
11149
|
|
|
11122
11150
|
updateToken(token ) {
|
|
11123
|
-
logger$
|
|
11151
|
+
logger$7.info('update token via simple Websocket', { token, ws: !!this.ws });
|
|
11124
11152
|
|
|
11125
11153
|
if (!this.ws) {
|
|
11126
11154
|
return;
|
|
@@ -11148,7 +11176,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
|
|
|
11148
11176
|
|
|
11149
11177
|
//
|
|
11150
11178
|
|
|
11151
|
-
const logger$
|
|
11179
|
+
const logger$8 = IssueReporter$1.loggerFor('room');
|
|
11152
11180
|
|
|
11153
11181
|
class Participant extends Emitter {
|
|
11154
11182
|
|
|
@@ -11270,7 +11298,7 @@ class Participant extends Emitter {
|
|
|
11270
11298
|
}
|
|
11271
11299
|
|
|
11272
11300
|
onTalking(isTalking ) {
|
|
11273
|
-
logger$
|
|
11301
|
+
logger$8.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
|
|
11274
11302
|
this.isTalking = isTalking;
|
|
11275
11303
|
// you may notice we're not broadcasting: since all participants are getting this info
|
|
11276
11304
|
// directly from asterisk, there's no need to do so
|
|
@@ -11373,7 +11401,7 @@ class Participant extends Emitter {
|
|
|
11373
11401
|
}
|
|
11374
11402
|
|
|
11375
11403
|
updateStatus(status , broadcast = true) {
|
|
11376
|
-
logger$
|
|
11404
|
+
logger$8.info('updating participant status', { name: this.name, status });
|
|
11377
11405
|
|
|
11378
11406
|
if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
|
|
11379
11407
|
if (status.audioMuted) {
|
|
@@ -11421,7 +11449,7 @@ class Participant extends Emitter {
|
|
|
11421
11449
|
|
|
11422
11450
|
broadcastStatus(inboundStatus = null) {
|
|
11423
11451
|
const status = inboundStatus || this.getStatus();
|
|
11424
|
-
logger$
|
|
11452
|
+
logger$8.info('broadcasting participant status', { callId: this.callId, status });
|
|
11425
11453
|
|
|
11426
11454
|
this.room.sendSignal({
|
|
11427
11455
|
type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
|
|
@@ -11457,9 +11485,9 @@ class LocalParticipant extends Participant {
|
|
|
11457
11485
|
const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
11458
11486
|
const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
11459
11487
|
|
|
11460
|
-
const logger$
|
|
11488
|
+
const logger$9 = IssueReporter$1.loggerFor('sdk-room');
|
|
11461
11489
|
|
|
11462
|
-
class Room
|
|
11490
|
+
class Room extends Emitter {
|
|
11463
11491
|
|
|
11464
11492
|
|
|
11465
11493
|
|
|
@@ -11517,7 +11545,7 @@ class Room$1 extends Emitter {
|
|
|
11517
11545
|
extra = {},
|
|
11518
11546
|
) {
|
|
11519
11547
|
super();
|
|
11520
|
-
logger$
|
|
11548
|
+
logger$9.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
11521
11549
|
|
|
11522
11550
|
// Represents the room callSession
|
|
11523
11551
|
this.callSession = callSession;
|
|
@@ -11583,7 +11611,7 @@ class Room$1 extends Emitter {
|
|
|
11583
11611
|
* @returns {Promise<Room>}
|
|
11584
11612
|
*/
|
|
11585
11613
|
static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
|
|
11586
|
-
logger$
|
|
11614
|
+
logger$9.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
11587
11615
|
|
|
11588
11616
|
if (!room) {
|
|
11589
11617
|
await Wazo.Phone.connect();
|
|
@@ -11596,7 +11624,7 @@ class Room$1 extends Emitter {
|
|
|
11596
11624
|
|
|
11597
11625
|
// Call_created is triggered before call_accepted, so we have to listen for it here.
|
|
11598
11626
|
Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
|
|
11599
|
-
logger$
|
|
11627
|
+
logger$9.info('room call received via WS', { callId: data.call_id });
|
|
11600
11628
|
if (room) {
|
|
11601
11629
|
room.setCallId(data.call_id);
|
|
11602
11630
|
}
|
|
@@ -11604,7 +11632,7 @@ class Room$1 extends Emitter {
|
|
|
11604
11632
|
|
|
11605
11633
|
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
11606
11634
|
// eslint-disable-next-line no-param-reassign
|
|
11607
|
-
room = new Room
|
|
11635
|
+
room = new Room(callSession, extension, null, null, extra);
|
|
11608
11636
|
|
|
11609
11637
|
// Wait for the call to be accepted
|
|
11610
11638
|
await new Promise((resolve, reject) => {
|
|
@@ -11625,7 +11653,7 @@ class Room$1 extends Emitter {
|
|
|
11625
11653
|
// Retrieve conference
|
|
11626
11654
|
const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
|
|
11627
11655
|
|
|
11628
|
-
logger$
|
|
11656
|
+
logger$9.info('connected to room', {
|
|
11629
11657
|
sourceId: conference ? conference.sourceId : null,
|
|
11630
11658
|
name: conference ? conference.name : null,
|
|
11631
11659
|
});
|
|
@@ -11635,7 +11663,7 @@ class Room$1 extends Emitter {
|
|
|
11635
11663
|
room.setName(conference.name);
|
|
11636
11664
|
}
|
|
11637
11665
|
} else if (meeting) {
|
|
11638
|
-
logger$
|
|
11666
|
+
logger$9.info('Already connected to meeting', {
|
|
11639
11667
|
uuid: meeting.uuid,
|
|
11640
11668
|
name: meeting.name,
|
|
11641
11669
|
});
|
|
@@ -11648,13 +11676,13 @@ class Room$1 extends Emitter {
|
|
|
11648
11676
|
}
|
|
11649
11677
|
|
|
11650
11678
|
static disconnect() {
|
|
11651
|
-
logger$
|
|
11679
|
+
logger$9.info('static disconnection to room');
|
|
11652
11680
|
|
|
11653
11681
|
Wazo.Phone.disconnect();
|
|
11654
11682
|
}
|
|
11655
11683
|
|
|
11656
11684
|
async disconnect() {
|
|
11657
|
-
logger$
|
|
11685
|
+
logger$9.info('disconnection to room called');
|
|
11658
11686
|
|
|
11659
11687
|
await Wazo.Phone.hangup(this.callSession);
|
|
11660
11688
|
this.callSession = null;
|
|
@@ -11674,19 +11702,19 @@ class Room$1 extends Emitter {
|
|
|
11674
11702
|
}
|
|
11675
11703
|
|
|
11676
11704
|
setSourceId(sourceId ) {
|
|
11677
|
-
logger$
|
|
11705
|
+
logger$9.info('set room source id', { sourceId });
|
|
11678
11706
|
|
|
11679
11707
|
this.sourceId = sourceId;
|
|
11680
11708
|
}
|
|
11681
11709
|
|
|
11682
11710
|
setMeetingUuid(meetingUuid ) {
|
|
11683
|
-
logger$
|
|
11711
|
+
logger$9.info('set meeting uuid', { meetingUuid });
|
|
11684
11712
|
|
|
11685
11713
|
this.meetingUuid = meetingUuid;
|
|
11686
11714
|
}
|
|
11687
11715
|
|
|
11688
11716
|
setCallId(callId ) {
|
|
11689
|
-
logger$
|
|
11717
|
+
logger$9.info('set room call id', { callId });
|
|
11690
11718
|
|
|
11691
11719
|
if (callId) {
|
|
11692
11720
|
this.callId = callId;
|
|
@@ -11694,7 +11722,7 @@ class Room$1 extends Emitter {
|
|
|
11694
11722
|
}
|
|
11695
11723
|
|
|
11696
11724
|
setName(name ) {
|
|
11697
|
-
logger$
|
|
11725
|
+
logger$9.info('set room name', { name });
|
|
11698
11726
|
|
|
11699
11727
|
this.name = name;
|
|
11700
11728
|
}
|
|
@@ -11713,7 +11741,7 @@ class Room$1 extends Emitter {
|
|
|
11713
11741
|
}
|
|
11714
11742
|
|
|
11715
11743
|
async startScreenSharing(constraints ) {
|
|
11716
|
-
logger$
|
|
11744
|
+
logger$9.info('start room screen sharing', { constraints });
|
|
11717
11745
|
|
|
11718
11746
|
const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
|
|
11719
11747
|
if (!screensharingStream) {
|
|
@@ -11727,7 +11755,7 @@ class Room$1 extends Emitter {
|
|
|
11727
11755
|
}
|
|
11728
11756
|
|
|
11729
11757
|
async stopScreenSharing(restoreLocalStream = true) {
|
|
11730
|
-
logger$
|
|
11758
|
+
logger$9.info('stop room screen sharing');
|
|
11731
11759
|
|
|
11732
11760
|
await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
11733
11761
|
|
|
@@ -11739,7 +11767,7 @@ class Room$1 extends Emitter {
|
|
|
11739
11767
|
}
|
|
11740
11768
|
|
|
11741
11769
|
turnCameraOff() {
|
|
11742
|
-
logger$
|
|
11770
|
+
logger$9.info('turn room camera off');
|
|
11743
11771
|
|
|
11744
11772
|
Wazo.Phone.turnCameraOff(this.callSession);
|
|
11745
11773
|
|
|
@@ -11749,7 +11777,7 @@ class Room$1 extends Emitter {
|
|
|
11749
11777
|
}
|
|
11750
11778
|
|
|
11751
11779
|
turnCameraOn() {
|
|
11752
|
-
logger$
|
|
11780
|
+
logger$9.info('turn room camera on');
|
|
11753
11781
|
|
|
11754
11782
|
Wazo.Phone.turnCameraOn(this.callSession);
|
|
11755
11783
|
|
|
@@ -11759,7 +11787,7 @@ class Room$1 extends Emitter {
|
|
|
11759
11787
|
}
|
|
11760
11788
|
|
|
11761
11789
|
mute() {
|
|
11762
|
-
logger$
|
|
11790
|
+
logger$9.info('mute room');
|
|
11763
11791
|
|
|
11764
11792
|
Wazo.Phone.mute(this.callSession);
|
|
11765
11793
|
|
|
@@ -11767,7 +11795,7 @@ class Room$1 extends Emitter {
|
|
|
11767
11795
|
}
|
|
11768
11796
|
|
|
11769
11797
|
unmute() {
|
|
11770
|
-
logger$
|
|
11798
|
+
logger$9.info('unmute room');
|
|
11771
11799
|
|
|
11772
11800
|
Wazo.Phone.unmute(this.callSession);
|
|
11773
11801
|
|
|
@@ -11787,7 +11815,7 @@ class Room$1 extends Emitter {
|
|
|
11787
11815
|
}
|
|
11788
11816
|
|
|
11789
11817
|
hold() {
|
|
11790
|
-
logger$
|
|
11818
|
+
logger$9.info('hold room');
|
|
11791
11819
|
|
|
11792
11820
|
Wazo.Phone.hold(this.callSession, true);
|
|
11793
11821
|
|
|
@@ -11797,7 +11825,7 @@ class Room$1 extends Emitter {
|
|
|
11797
11825
|
}
|
|
11798
11826
|
|
|
11799
11827
|
async resume() {
|
|
11800
|
-
logger$
|
|
11828
|
+
logger$9.info('resume room');
|
|
11801
11829
|
|
|
11802
11830
|
const newStream = await Wazo.Phone.resume(this.callSession, true);
|
|
11803
11831
|
|
|
@@ -11825,13 +11853,13 @@ class Room$1 extends Emitter {
|
|
|
11825
11853
|
}
|
|
11826
11854
|
|
|
11827
11855
|
sendDTMF(tone ) {
|
|
11828
|
-
logger$
|
|
11856
|
+
logger$9.info('send room DTMF', { tone });
|
|
11829
11857
|
|
|
11830
11858
|
Wazo.Phone.sendDTMF(tone, this.callSession);
|
|
11831
11859
|
}
|
|
11832
11860
|
|
|
11833
11861
|
async sendReinvite(newConstraints = null) {
|
|
11834
|
-
logger$
|
|
11862
|
+
logger$9.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
11835
11863
|
const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
|
|
11836
11864
|
|
|
11837
11865
|
Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
|
|
@@ -11890,7 +11918,7 @@ class Room$1 extends Emitter {
|
|
|
11890
11918
|
Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
11891
11919
|
|
|
11892
11920
|
this.on(this.ON_AUDIO_STREAM, stream => {
|
|
11893
|
-
logger$
|
|
11921
|
+
logger$9.info('on room audio stream');
|
|
11894
11922
|
|
|
11895
11923
|
this.audioStream = stream;
|
|
11896
11924
|
if (!this.roomAudioElement) {
|
|
@@ -11903,7 +11931,7 @@ class Room$1 extends Emitter {
|
|
|
11903
11931
|
});
|
|
11904
11932
|
|
|
11905
11933
|
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
11906
|
-
logger$
|
|
11934
|
+
logger$9.info('on room video stream', { streamId });
|
|
11907
11935
|
|
|
11908
11936
|
this._mapMsid(sipSession.body.body);
|
|
11909
11937
|
|
|
@@ -11918,7 +11946,7 @@ class Room$1 extends Emitter {
|
|
|
11918
11946
|
});
|
|
11919
11947
|
|
|
11920
11948
|
this.on(this.ON_REMOVE_STREAM, stream => {
|
|
11921
|
-
logger$
|
|
11949
|
+
logger$9.info('on room remove stream');
|
|
11922
11950
|
|
|
11923
11951
|
const participant = this.participants.find(someParticipant =>
|
|
11924
11952
|
someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
|
|
@@ -12050,7 +12078,7 @@ class Room$1 extends Emitter {
|
|
|
12050
12078
|
const requester = this._getParticipantFromCallId(origin.callId);
|
|
12051
12079
|
if (requester) {
|
|
12052
12080
|
// @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
|
|
12053
|
-
logger$
|
|
12081
|
+
logger$9.info('trigger room requester status', { origin });
|
|
12054
12082
|
requester.triggerUpdate('REQUESTER_UPDATE');
|
|
12055
12083
|
}
|
|
12056
12084
|
break;
|
|
@@ -12081,24 +12109,24 @@ class Room$1 extends Emitter {
|
|
|
12081
12109
|
|
|
12082
12110
|
// When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
|
|
12083
12111
|
if (participant.user_uuid === session.uuid) {
|
|
12084
|
-
logger$
|
|
12112
|
+
logger$9.info('room current user joined');
|
|
12085
12113
|
|
|
12086
12114
|
// Retrieve participants via an API calls
|
|
12087
12115
|
const conferenceId = this.sourceId || payload.data.conference_id;
|
|
12088
12116
|
let response;
|
|
12089
12117
|
try {
|
|
12090
12118
|
if (this.meetingUuid) {
|
|
12091
|
-
logger$
|
|
12119
|
+
logger$9.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
12092
12120
|
response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
|
|
12093
12121
|
} else {
|
|
12094
|
-
logger$
|
|
12122
|
+
logger$9.info('fetching conference participants', { conferenceId });
|
|
12095
12123
|
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
12096
12124
|
}
|
|
12097
12125
|
} catch (e) {
|
|
12098
|
-
logger$
|
|
12126
|
+
logger$9.error('room participants fetching, error', e);
|
|
12099
12127
|
}
|
|
12100
12128
|
if (response) {
|
|
12101
|
-
logger$
|
|
12129
|
+
logger$9.info('conference participants fetched', { nb: response.items.length });
|
|
12102
12130
|
participants = response.items.map(item => {
|
|
12103
12131
|
const isMe = item.call_id === this.callId;
|
|
12104
12132
|
|
|
@@ -12125,7 +12153,7 @@ class Room$1 extends Emitter {
|
|
|
12125
12153
|
? new Wazo.RemoteParticipant(this, participant)
|
|
12126
12154
|
: null;
|
|
12127
12155
|
|
|
12128
|
-
logger$
|
|
12156
|
+
logger$9.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
12129
12157
|
|
|
12130
12158
|
if (remoteParticipant) {
|
|
12131
12159
|
this.participants.push(remoteParticipant);
|
|
@@ -12290,12 +12318,12 @@ class Room$1 extends Emitter {
|
|
|
12290
12318
|
|
|
12291
12319
|
//
|
|
12292
12320
|
|
|
12293
|
-
const logger$
|
|
12321
|
+
const logger$a = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
12294
12322
|
|
|
12295
|
-
class SipRoom extends Room
|
|
12323
|
+
class SipRoom extends Room {
|
|
12296
12324
|
|
|
12297
12325
|
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
12298
|
-
logger$
|
|
12326
|
+
logger$a.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
12299
12327
|
|
|
12300
12328
|
if (!room) {
|
|
12301
12329
|
await Wazo.Phone.connect();
|
|
@@ -12311,7 +12339,7 @@ class SipRoom extends Room$1 {
|
|
|
12311
12339
|
room.setCallId(room.callSession.call.id);
|
|
12312
12340
|
}
|
|
12313
12341
|
|
|
12314
|
-
logger$
|
|
12342
|
+
logger$a.info('connected to room', {
|
|
12315
12343
|
extension: room.extension,
|
|
12316
12344
|
});
|
|
12317
12345
|
|
|
@@ -12319,7 +12347,7 @@ class SipRoom extends Room$1 {
|
|
|
12319
12347
|
}
|
|
12320
12348
|
|
|
12321
12349
|
mute() {
|
|
12322
|
-
logger$
|
|
12350
|
+
logger$a.info('mute sip room');
|
|
12323
12351
|
|
|
12324
12352
|
Wazo.Phone.mute(this.callSession, false);
|
|
12325
12353
|
|
|
@@ -12327,7 +12355,7 @@ class SipRoom extends Room$1 {
|
|
|
12327
12355
|
}
|
|
12328
12356
|
|
|
12329
12357
|
unmute() {
|
|
12330
|
-
logger$
|
|
12358
|
+
logger$a.info('unmute sip room');
|
|
12331
12359
|
|
|
12332
12360
|
Wazo.Phone.unmute(this.callSession, false);
|
|
12333
12361
|
|
|
@@ -12611,7 +12639,7 @@ class NotificationOptions {
|
|
|
12611
12639
|
|
|
12612
12640
|
|
|
12613
12641
|
// Represents a conference room, like `9000`.
|
|
12614
|
-
class Room {
|
|
12642
|
+
class Room$1 {
|
|
12615
12643
|
|
|
12616
12644
|
|
|
12617
12645
|
|
|
@@ -12632,7 +12660,7 @@ class Room {
|
|
|
12632
12660
|
}
|
|
12633
12661
|
|
|
12634
12662
|
connect(callSession ) {
|
|
12635
|
-
return new Room({ ...this, connectedCallSession: callSession });
|
|
12663
|
+
return new Room$1({ ...this, connectedCallSession: callSession });
|
|
12636
12664
|
}
|
|
12637
12665
|
|
|
12638
12666
|
has(callSession ) {
|
|
@@ -12641,7 +12669,7 @@ class Room {
|
|
|
12641
12669
|
|
|
12642
12670
|
addParticipant(uuid , extension , talking = null) {
|
|
12643
12671
|
if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
|
|
12644
|
-
return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
12672
|
+
return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
12645
12673
|
}
|
|
12646
12674
|
|
|
12647
12675
|
return this;
|
|
@@ -12660,7 +12688,7 @@ class Room {
|
|
|
12660
12688
|
updatedParticipants.push(participant);
|
|
12661
12689
|
}
|
|
12662
12690
|
|
|
12663
|
-
return new Room({ ...this, participants: updatedParticipants });
|
|
12691
|
+
return new Room$1({ ...this, participants: updatedParticipants });
|
|
12664
12692
|
}
|
|
12665
12693
|
|
|
12666
12694
|
updateParticipantByExtension(extension , participant , shouldAdd = false) {
|
|
@@ -12676,7 +12704,7 @@ class Room {
|
|
|
12676
12704
|
updatedParticipants.push(participant);
|
|
12677
12705
|
}
|
|
12678
12706
|
|
|
12679
|
-
return new Room({ ...this, participants: updatedParticipants });
|
|
12707
|
+
return new Room$1({ ...this, participants: updatedParticipants });
|
|
12680
12708
|
}
|
|
12681
12709
|
|
|
12682
12710
|
hasCallWithId(id ) {
|
|
@@ -12684,18 +12712,18 @@ class Room {
|
|
|
12684
12712
|
}
|
|
12685
12713
|
|
|
12686
12714
|
disconnect() {
|
|
12687
|
-
return new Room({ ...this, connectedCallSession: null });
|
|
12715
|
+
return new Room$1({ ...this, connectedCallSession: null });
|
|
12688
12716
|
}
|
|
12689
12717
|
|
|
12690
12718
|
removeParticipantWithUUID(uuid ) {
|
|
12691
|
-
return new Room({
|
|
12719
|
+
return new Room$1({
|
|
12692
12720
|
...this,
|
|
12693
12721
|
participants: this.participants.filter(participant => participant.uuid !== uuid),
|
|
12694
12722
|
});
|
|
12695
12723
|
}
|
|
12696
12724
|
|
|
12697
12725
|
removeParticipantWithExtension(extension ) {
|
|
12698
|
-
return new Room({
|
|
12726
|
+
return new Room$1({
|
|
12699
12727
|
...this,
|
|
12700
12728
|
participants: this.participants.filter(participant => participant.extension !== extension),
|
|
12701
12729
|
});
|
|
@@ -12706,7 +12734,7 @@ class Room {
|
|
|
12706
12734
|
}
|
|
12707
12735
|
|
|
12708
12736
|
static newFrom(room ) {
|
|
12709
|
-
return newFrom(room, Room);
|
|
12737
|
+
return newFrom(room, Room$1);
|
|
12710
12738
|
}
|
|
12711
12739
|
}
|
|
12712
12740
|
|
|
@@ -13013,11 +13041,11 @@ var wazoWebsocket = {
|
|
|
13013
13041
|
resolve();
|
|
13014
13042
|
};
|
|
13015
13043
|
|
|
13016
|
-
client.on(SOCKET_EVENTS
|
|
13044
|
+
client.on(SOCKET_EVENTS.ON_ERROR, error => {
|
|
13017
13045
|
handleError(`Connection error : ${error}`);
|
|
13018
13046
|
});
|
|
13019
13047
|
|
|
13020
|
-
client.on(SOCKET_EVENTS
|
|
13048
|
+
client.on(SOCKET_EVENTS.ON_OPEN, () => {
|
|
13021
13049
|
if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
|
|
13022
13050
|
client.setOnHeartbeatTimeout(() => {
|
|
13023
13051
|
handleError('No response to heartbeat');
|
|
@@ -13118,7 +13146,7 @@ var webrtc = {
|
|
|
13118
13146
|
}),
|
|
13119
13147
|
};
|
|
13120
13148
|
|
|
13121
|
-
const parseCandidate = line => {
|
|
13149
|
+
const parseCandidate$1 = line => {
|
|
13122
13150
|
let parts;
|
|
13123
13151
|
// Parse both variants.
|
|
13124
13152
|
if (line.indexOf('a=candidate:') === 0) {
|
|
@@ -13209,7 +13237,7 @@ var SymmetricNat = {
|
|
|
13209
13237
|
}
|
|
13210
13238
|
|
|
13211
13239
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
13212
|
-
const cand = parseCandidate(e.candidate.candidate);
|
|
13240
|
+
const cand = parseCandidate$1(e.candidate.candidate);
|
|
13213
13241
|
if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
|
|
13214
13242
|
candidates[cand.relatedPort].push(cand.port);
|
|
13215
13243
|
} else if (!e.candidate) {
|
|
@@ -13277,7 +13305,7 @@ var iceIpv4 = {
|
|
|
13277
13305
|
const rawCandidate = e.candidate.candidate;
|
|
13278
13306
|
if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
|
|
13279
13307
|
hasSrflxOrRelay = true;
|
|
13280
|
-
const candidate = parseCandidate(e.candidate.candidate);
|
|
13308
|
+
const candidate = parseCandidate$1(e.candidate.candidate);
|
|
13281
13309
|
ips.push(candidate.ip);
|
|
13282
13310
|
}
|
|
13283
13311
|
} else if (!e.candidate) {
|
|
@@ -13314,7 +13342,7 @@ var checks = [
|
|
|
13314
13342
|
|
|
13315
13343
|
//
|
|
13316
13344
|
|
|
13317
|
-
const logger$
|
|
13345
|
+
const logger$b = IssueReporter$1.loggerFor('engine-check');
|
|
13318
13346
|
|
|
13319
13347
|
class Checker {
|
|
13320
13348
|
|
|
@@ -13332,28 +13360,28 @@ class Checker {
|
|
|
13332
13360
|
async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
|
|
13333
13361
|
await this._addEngineVersion();
|
|
13334
13362
|
|
|
13335
|
-
logger$
|
|
13363
|
+
logger$b.info('Engine check starting');
|
|
13336
13364
|
|
|
13337
13365
|
for (let i = 0; i < this.checks.length; i++) {
|
|
13338
13366
|
const { name, check } = this.checks[i];
|
|
13339
13367
|
|
|
13340
|
-
logger$
|
|
13368
|
+
logger$b.info(`Checking ${name} ...`);
|
|
13341
13369
|
|
|
13342
13370
|
onCheckBegin(name);
|
|
13343
13371
|
try {
|
|
13344
13372
|
// eslint-disable-next-line no-await-in-loop
|
|
13345
13373
|
const result = await check(this.server, this.session, this.externalAppConfig);
|
|
13346
|
-
logger$
|
|
13374
|
+
logger$b.info(`Checking ${name} success.`, { result });
|
|
13347
13375
|
|
|
13348
13376
|
onCheckResult(name, result);
|
|
13349
13377
|
} catch (e) {
|
|
13350
|
-
logger$
|
|
13378
|
+
logger$b.info(`Checking ${name} failure`, { message: e.message });
|
|
13351
13379
|
|
|
13352
13380
|
onCheckResult(name, e);
|
|
13353
13381
|
}
|
|
13354
13382
|
}
|
|
13355
13383
|
|
|
13356
|
-
logger$
|
|
13384
|
+
logger$b.info('Engine check done.');
|
|
13357
13385
|
}
|
|
13358
13386
|
|
|
13359
13387
|
addCheck(check ) {
|
|
@@ -13377,7 +13405,7 @@ const Wazo = {
|
|
|
13377
13405
|
Auth: Auth$1,
|
|
13378
13406
|
Phone: Phone$1,
|
|
13379
13407
|
Websocket: Websocket$1,
|
|
13380
|
-
Room
|
|
13408
|
+
Room,
|
|
13381
13409
|
SipRoom,
|
|
13382
13410
|
RemoteParticipant,
|
|
13383
13411
|
LocalParticipant,
|
|
@@ -13410,7 +13438,7 @@ const Wazo = {
|
|
|
13410
13438
|
Session,
|
|
13411
13439
|
Voicemail,
|
|
13412
13440
|
Relocation,
|
|
13413
|
-
ConferenceRoom: Room,
|
|
13441
|
+
ConferenceRoom: Room$1,
|
|
13414
13442
|
CallSession,
|
|
13415
13443
|
IndirectTransfer,
|
|
13416
13444
|
SwitchboardCall,
|
|
@@ -13449,7 +13477,7 @@ if (global) {
|
|
|
13449
13477
|
class InvalidSubscription extends Error {}
|
|
13450
13478
|
class InvalidAuthorization extends Error {}
|
|
13451
13479
|
|
|
13452
|
-
const logger = IssueReporter$1.loggerFor('simple-auth');
|
|
13480
|
+
const logger$c = IssueReporter$1.loggerFor('simple-auth');
|
|
13453
13481
|
|
|
13454
13482
|
class Auth {
|
|
13455
13483
|
|
|
@@ -13484,7 +13512,7 @@ class Auth {
|
|
|
13484
13512
|
setApiClientId(this.clientId);
|
|
13485
13513
|
setRefreshExpiration(this.expiration);
|
|
13486
13514
|
setOnRefreshToken((token , session ) => {
|
|
13487
|
-
logger.info('on refresh token done', { token });
|
|
13515
|
+
logger$c.info('on refresh token done', { token });
|
|
13488
13516
|
setApiToken(token);
|
|
13489
13517
|
Wazo.Websocket.updateToken(token);
|
|
13490
13518
|
|
|
@@ -13529,7 +13557,7 @@ class Auth {
|
|
|
13529
13557
|
const rawSession = await getApiClient().auth.authenticate(token);
|
|
13530
13558
|
return this._onAuthenticated(rawSession);
|
|
13531
13559
|
} catch (e) {
|
|
13532
|
-
logger.error('on validate token error', e);
|
|
13560
|
+
logger$c.error('on validate token error', e);
|
|
13533
13561
|
console.warn(e);
|
|
13534
13562
|
return false;
|
|
13535
13563
|
}
|