@exotel-npm-dev/webrtc-client-sdk 1.0.15 → 1.0.16
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/Changelog +2 -2
- package/dist/exotelsdk.js +51 -14
- package/dist/exotelsdk.js.map +1 -1
- package/package.json +1 -1
- package/src/api/registerAPI/RegisterListener.js +9 -6
- package/src/listeners/ExWebClient.js +40 -6
package/package.json
CHANGED
|
@@ -16,12 +16,15 @@ export function DoRegister(sipAccountInfo, exWebClient) {
|
|
|
16
16
|
* CHANGE IS REQUIRED - in the initialize function provision is to be given to pass Callback functions as arguments
|
|
17
17
|
*/
|
|
18
18
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
setTimeout(function() {
|
|
20
|
+
exWebClient.initialize(userContext,
|
|
21
|
+
sipAccountInfo.domain, //hostname
|
|
22
|
+
sipAccountInfo.userName, //subscriberName
|
|
23
|
+
sipAccountInfo.displayname,//displayName
|
|
24
|
+
sipAccountInfo.accountSid,//accountSid
|
|
25
|
+
'', sipAccountInfo); // subscriberToken
|
|
26
|
+
}, 500);
|
|
27
|
+
|
|
25
28
|
} catch (e) {
|
|
26
29
|
logger.log("Register failed ", e)
|
|
27
30
|
}
|
|
@@ -209,6 +209,10 @@ export class ExotelWebClient {
|
|
|
209
209
|
eventListener = null;
|
|
210
210
|
callListener = null;
|
|
211
211
|
callFromNumber = null;
|
|
212
|
+
shouldAutoRetry = false;
|
|
213
|
+
unregisterInitiated = false;
|
|
214
|
+
registrationInProgress = false;
|
|
215
|
+
isReadyToRegister = true;
|
|
212
216
|
/* OLD-Way to be revisited for multile phone support */
|
|
213
217
|
//this.webRTCPhones = {};
|
|
214
218
|
|
|
@@ -249,10 +253,17 @@ export class ExotelWebClient {
|
|
|
249
253
|
};
|
|
250
254
|
|
|
251
255
|
DoRegister = () => {
|
|
252
|
-
|
|
256
|
+
logger.log("ExWebClient:DoRegister Entry")
|
|
257
|
+
if (!this.isReadyToRegister){
|
|
258
|
+
logger.warn("ExWebClient:DoRegister SDK is not ready to register");
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
DoRegisterRL(this.sipAccountInfo, this);
|
|
262
|
+
return true;
|
|
253
263
|
};
|
|
254
264
|
|
|
255
265
|
UnRegister = () => {
|
|
266
|
+
logger.log("ExWebClient:UnRegister Entry")
|
|
256
267
|
UnRegisterRL(this.sipAccountInfo, this)
|
|
257
268
|
};
|
|
258
269
|
|
|
@@ -331,11 +342,26 @@ export class ExotelWebClient {
|
|
|
331
342
|
* When registration is successful then send the phone number of the same to UI
|
|
332
343
|
*/
|
|
333
344
|
this.eventListener.onInitializationSuccess(phone);
|
|
345
|
+
this.registrationInProgress = false;
|
|
346
|
+
if (this.unregisterInitiated) {
|
|
347
|
+
logger.log("ExWebClient:registerEventCallback unregistering due to unregisterInitiated");
|
|
348
|
+
this.unregisterInitiated = false;
|
|
349
|
+
this.unregister();
|
|
350
|
+
}
|
|
334
351
|
} else if (event === "failed_to_start" || event === "transport_error") {
|
|
335
352
|
/**
|
|
336
353
|
* If registration fails
|
|
337
354
|
*/
|
|
338
355
|
this.eventListener.onInitializationFailure(phone);
|
|
356
|
+
if (this.unregisterInitiated) {
|
|
357
|
+
this.shouldAutoRetry = false;
|
|
358
|
+
this.unregisterInitiated = false;
|
|
359
|
+
this.isReadyToRegister = true;
|
|
360
|
+
}
|
|
361
|
+
if (this.shouldAutoRetry) {
|
|
362
|
+
logger.log("ExWebClient:registerEventCallback Autoretrying");
|
|
363
|
+
DoRegisterRL(this.sipAccountInfo, this);
|
|
364
|
+
}
|
|
339
365
|
} else if (event === "sent_request") {
|
|
340
366
|
/**
|
|
341
367
|
* If registration request waiting...
|
|
@@ -375,8 +401,14 @@ export class ExotelWebClient {
|
|
|
375
401
|
* @param {*} sipAccountInfo
|
|
376
402
|
*/
|
|
377
403
|
unregister = (sipAccountInfo) => {
|
|
378
|
-
|
|
379
|
-
|
|
404
|
+
logger.log("ExWebClient:unregister Entry");
|
|
405
|
+
this.shouldAutoRetry = false;
|
|
406
|
+
this.unregisterInitiated = true;
|
|
407
|
+
if (!this.registrationInProgress) {
|
|
408
|
+
setTimeout(function() {
|
|
409
|
+
webrtcSIPPhone.sipUnRegisterWebRTC();
|
|
410
|
+
}, 500);
|
|
411
|
+
}
|
|
380
412
|
};
|
|
381
413
|
|
|
382
414
|
|
|
@@ -390,9 +422,11 @@ export class ExotelWebClient {
|
|
|
390
422
|
initialize = (uiContext, hostName, subscriberName,
|
|
391
423
|
displayName, accountSid, subscriberToken,
|
|
392
424
|
sipAccountInfo) => {
|
|
393
|
-
|
|
394
425
|
let wssPort = sipAccountInfo.port;
|
|
395
426
|
let wsPort = 4442;
|
|
427
|
+
this.isReadyToRegister = false;
|
|
428
|
+
this.registrationInProgress = true;
|
|
429
|
+
this.shouldAutoRetry = true;
|
|
396
430
|
this.sipAccntInfo = {
|
|
397
431
|
'userName': '',
|
|
398
432
|
'authUser': '',
|
|
@@ -535,8 +569,8 @@ export class ExotelWebClient {
|
|
|
535
569
|
logger.registerLoggerCallback(callback);
|
|
536
570
|
}
|
|
537
571
|
|
|
538
|
-
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback
|
|
539
|
-
webrtcSIPPhone.registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback
|
|
572
|
+
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback) {
|
|
573
|
+
webrtcSIPPhone.registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback);
|
|
540
574
|
}
|
|
541
575
|
}
|
|
542
576
|
|