@exotel-npm-dev/webrtc-client-sdk 3.0.0 → 3.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exotel-npm-dev/webrtc-client-sdk",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "client sdk for webrtc based on webrtc core sdk",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -29,6 +29,6 @@
29
29
  "webpack-cli": "^4.10.0"
30
30
  },
31
31
  "dependencies": {
32
- "@exotel-npm-dev/webrtc-core-sdk": "^3.0.0"
32
+ "@exotel-npm-dev/webrtc-core-sdk": "^3.0.2"
33
33
  }
34
34
  }
@@ -65,6 +65,7 @@ function fetchPublicIP(sipAccountInfo) {
65
65
  class ExDelegationHandler {
66
66
  constructor(exClient) {
67
67
  this.exClient = exClient;
68
+ this.sessionCallback = exClient.sessionCallback;
68
69
  }
69
70
  setTestingMode(mode) {
70
71
  logger.log("delegationHandler: setTestingMode\n");
@@ -88,6 +89,8 @@ class ExDelegationHandler {
88
89
  }
89
90
  onStatPeerConnectionIceGatheringStateChange(iceGatheringState) {
90
91
  logger.log("delegationHandler: onStatPeerConnectionIceGatheringStateChange\n");
92
+ this.sessionCallback.initializeSession(`ice_gathering_state_${iceGatheringState}`, this.exClient.callFromNumber);
93
+ this.sessionCallback.triggerSessionCallback();
91
94
  }
92
95
  onCallStatIceCandidate(ev, icestate) {
93
96
  logger.log("delegationHandler: onCallStatIceCandidate\n");
@@ -98,8 +101,10 @@ class ExDelegationHandler {
98
101
  onCallStatSignalingStateChange(cstate) {
99
102
  logger.log("delegationHandler: onCallStatSignalingStateChange\n");
100
103
  }
101
- onStatPeerConnectionIceConnectionStateChange() {
104
+ onStatPeerConnectionIceConnectionStateChange(iceConnectionState) {
102
105
  logger.log("delegationHandler: onStatPeerConnectionIceConnectionStateChange\n");
106
+ this.sessionCallback.initializeSession(`ice_connection_state_${iceConnectionState}`, this.exClient.callFromNumber);
107
+ this.sessionCallback.triggerSessionCallback();
103
108
  }
104
109
  onStatPeerConnectionConnectionStateChange() {
105
110
  logger.log("delegationHandler: onStatPeerConnectionConnectionStateChange\n");
@@ -109,6 +114,8 @@ class ExDelegationHandler {
109
114
  }
110
115
  onGetUserMediaErrorCallstatCallback() {
111
116
  logger.log("delegationHandler: onGetUserMediaErrorCallstatCallback\n");
117
+ this.sessionCallback.initializeSession(`media_permission_denied`, this.exClient.callFromNumber);
118
+ this.sessionCallback.triggerSessionCallback();
112
119
  }
113
120
  onCallStatAddStream() {
114
121
  logger.log("delegationHandler: onCallStatAddStream\n");
@@ -231,17 +238,18 @@ export class ExotelWebClient {
231
238
  this.logger = getLogger();
232
239
 
233
240
  // Register logger callback
241
+ let exwebClientOb = this;
234
242
  this.logger.registerLoggerCallback((type, message, args) => {
235
243
  LogManager.onLog(type, message, args);
236
- if (this.clientSDKLoggerCallback) {
237
- this.clientSDKLoggerCallback("log", message, args);
244
+ if (exwebClientOb.clientSDKLoggerCallback) {
245
+ exwebClientOb.clientSDKLoggerCallback("log", message, args);
238
246
  }
239
247
  });
240
248
  }
241
249
 
242
250
 
243
251
  initWebrtc = async (sipAccountInfo_,
244
- RegisterEventCallBack, CallListenerCallback, SessionCallback) => {
252
+ RegisterEventCallBack, CallListenerCallback, SessionCallback, enableAutoAudioDeviceChangeHandling=false) => {
245
253
  const userName = sipAccountInfo_?.userName;
246
254
  if (!userName) return false;
247
255
 
@@ -271,6 +279,7 @@ export class ExotelWebClient {
271
279
  this.ctrlr = new CallController();
272
280
  }
273
281
 
282
+ sipAccountInfo_.enableAutoAudioDeviceChangeHandling = enableAutoAudioDeviceChangeHandling;
274
283
  logger.log("ExWebClient: initWebrtc: Exotel Client Initialised with " + JSON.stringify(sipAccountInfo_))
275
284
  this.sipAccountInfo = sipAccountInfo_;
276
285
  if (!this.sipAccountInfo["userName"] || !this.sipAccountInfo["sipdomain"] || !this.sipAccountInfo["port"]) {
@@ -301,7 +310,7 @@ export class ExotelWebClient {
301
310
  }
302
311
 
303
312
  // Initialize the phone with SIP engine
304
- this.webrtcSIPPhone.registerPhone("sipjs", new ExDelegationHandler(this));
313
+ this.webrtcSIPPhone.registerPhone("sipjs", new ExDelegationHandler(this), this.sipAccountInfo.enableAutoAudioDeviceChangeHandling);
305
314
 
306
315
  // Create call instance after phone is initialized
307
316
  if (!this.call) {
@@ -533,7 +542,7 @@ export class ExotelWebClient {
533
542
  var userName = this.userName;
534
543
 
535
544
 
536
- this.webrtcSIPPhone.registerPhone("sipjs", delegationHandler);
545
+ this.webrtcSIPPhone.registerPhone("sipjs", delegationHandler, this.sipAccountInfo.enableAutoAudioDeviceChangeHandling);
537
546
  this.webrtcSIPPhone.registerWebRTCClient(this.sipAccntInfo, synchronousHandler);
538
547
  phonePool[this.userName] = this.webrtcSIPPhone;
539
548
 
@@ -585,14 +594,14 @@ export class ExotelWebClient {
585
594
  });
586
595
  };
587
596
 
588
- changeAudioInputDevice(deviceId, onSuccess, onError) {
597
+ changeAudioInputDevice(deviceId, onSuccess, onError, forceDeviceChange = false) {
589
598
  logger.log(`ExWebClient: changeAudioInputDevice: Entry`);
590
- this.webrtcSIPPhone.changeAudioInputDevice(deviceId, onSuccess, onError);
599
+ this.webrtcSIPPhone.changeAudioInputDevice(deviceId, onSuccess, onError, forceDeviceChange);
591
600
  }
592
601
 
593
- changeAudioOutputDevice(deviceId, onSuccess, onError) {
602
+ changeAudioOutputDevice(deviceId, onSuccess, onError, forceDeviceChange = false) {
594
603
  logger.log(`ExWebClient: changeAudioOutputDevice: Entry`);
595
- this.webrtcSIPPhone.changeAudioOutputDevice(deviceId, onSuccess, onError);
604
+ this.webrtcSIPPhone.changeAudioOutputDevice(deviceId, onSuccess, onError, forceDeviceChange);
596
605
  }
597
606
 
598
607
  downloadLogs() {
@@ -621,6 +630,15 @@ export class ExotelWebClient {
621
630
  }
622
631
  this.webrtcSIPPhone.registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback);
623
632
  }
633
+
634
+ setEnableConsoleLogging(enable) {
635
+ if (enable) {
636
+ logger.log(`ExWebClient: setEnableConsoleLogging: ${enable}`);
637
+ }
638
+
639
+ logger.setEnableConsoleLogging(enable);
640
+ }
641
+
624
642
  }
625
643
 
626
644
  export default ExotelWebClient;