@exotel-npm-dev/webrtc-client-sdk 1.0.11 → 1.0.13

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.
@@ -1,6 +1,6 @@
1
- import { webrtcLogger } from "../api/omAPI/WebrtcLogger"
1
+ import { webrtcSIPPhone } from "@exotel-npm-dev/webrtc-core-sdk";
2
2
 
3
- var logger = webrtcLogger()
3
+ var logger = webrtcSIPPhone.getLogger();
4
4
 
5
5
  /**
6
6
  * The call backs are called through this function. First initiates the call object and then
@@ -13,15 +13,15 @@ var logger = webrtcLogger()
13
13
  export var callbacks = {
14
14
  callback: null,
15
15
  call: null,
16
- phone:'',
17
- initializeCallback: function(CallListenerCallback){
16
+ phone: '',
17
+ initializeCallback: function (CallListenerCallback) {
18
18
  this.callback = CallListenerCallback;
19
19
  },
20
- initializeCall: function(call, phone){
20
+ initializeCall: function (call, phone) {
21
21
  this.call = call;
22
22
  this.phone = phone;
23
23
  },
24
- triggerCallback: function(eventType){
24
+ triggerCallback: function (eventType) {
25
25
  const callbackFunc = this.callback;
26
26
  const call = this.call;
27
27
  return callbackFunc(call, eventType, this.phone);
@@ -30,147 +30,147 @@ export var callbacks = {
30
30
  /**
31
31
  * Initializes register callback and also sets to which phone registration was renewed
32
32
  */
33
- export var registerCallback = {
34
- registerCallbackHandler :null,
35
- registerState: null,
36
- phone:'',
37
- initializeRegisterCallback: function(RegisterEventCallBack){
38
- registerCallback.registerCallbackHandler = RegisterEventCallBack;
39
- },
40
- initializeRegister: function(state, phone){
41
- registerCallback.registerState = state;
42
- registerCallback.phone = phone;
43
- },
44
- triggerRegisterCallback: function(){
45
- const callbackFunc = registerCallback.registerCallbackHandler;
46
- const state = registerCallback.registerState
47
- return callbackFunc(state, registerCallback.phone);
48
- }
49
- };
33
+ export var registerCallback = {
34
+ registerCallbackHandler: null,
35
+ registerState: null,
36
+ phone: '',
37
+ initializeRegisterCallback: function (RegisterEventCallBack) {
38
+ registerCallback.registerCallbackHandler = RegisterEventCallBack;
39
+ },
40
+ initializeRegister: function (state, phone) {
41
+ registerCallback.registerState = state;
42
+ registerCallback.phone = phone;
43
+ },
44
+ triggerRegisterCallback: function () {
45
+ const callbackFunc = registerCallback.registerCallbackHandler;
46
+ const state = registerCallback.registerState
47
+ return callbackFunc(state, registerCallback.phone);
48
+ }
49
+ };
50
50
  /**
51
51
  * Sets all the phone instances
52
52
  */
53
- export var phoneInstance = {
54
- phones:[],
55
- addPhone: function(webRTCPhone){
56
- const { length } = this.phones;
57
- const id = length + 1;
58
- const found = this.phones.some(el => el.username === webRTCPhone.username);
59
- if (!found) this.phones.push(webRTCPhone);
60
-
61
- },
62
- getPhone: function(phone){
63
- for(var x=0; x<this.phones.length; x++){
64
- if(this.phones[x].username == phone){
65
- logger.log('Username...' + this.phones[x].username);
66
- return this.phones[x];
67
- }
68
- }
69
- },
70
- getPhones: function(){
71
- return this.phones;
72
- },
73
- removePhone: function(phone){
74
- for(var x=0; x<this.phones.length; x++){
75
- if(this.phones[x].username == phone){
76
- this.phones.splice(x, 1);
77
- }
53
+ export var phoneInstance = {
54
+ phones: [],
55
+ addPhone: function (webRTCPhone) {
56
+ const { length } = this.phones;
57
+ const id = length + 1;
58
+ const found = this.phones.some(el => el.username === webRTCPhone.username);
59
+ if (!found) this.phones.push(webRTCPhone);
60
+
61
+ },
62
+ getPhone: function (phone) {
63
+ for (var x = 0; x < this.phones.length; x++) {
64
+ if (this.phones[x].username == phone) {
65
+ logger.log('Username...' + this.phones[x].username);
66
+ return this.phones[x];
78
67
  }
79
68
  }
80
- };
81
-
82
- export var sessionCallback = {
83
- sessioncallback: null,
84
- callState: null,
85
- document: null,
86
- documentCallback: null,
87
- phone:'',
88
- initializeSessionCallback: function(SessionCallback) {
89
- this.sessioncallback = SessionCallback;
90
- },
91
- intializeDocumentCallback: function(DocumentCallback){
92
- this.documentCallback = DocumentCallback;
93
- },
94
- initializeSession: function(state, phone){
95
- this.callState = state;
96
- this.phone = phone;
97
- },
98
- initializeDocument: function(calldocument){
99
- this.document = calldocument;
100
- },
101
- triggerDocumentCallback: function(){
102
- const documentCallbackFunc = this.documentCallback;
103
- return documentCallbackFunc(this.document);
104
- },
105
- triggerSessionCallback: function() {
106
- const sessionCallBackFunc = this.sessioncallback;
107
- if (sessionCallBackFunc) {
108
- return sessionCallBackFunc(this.callState, this.phone);
109
- } else {
110
- logger.log("Session callback is null")
111
- return;
69
+ },
70
+ getPhones: function () {
71
+ return this.phones;
72
+ },
73
+ removePhone: function (phone) {
74
+ for (var x = 0; x < this.phones.length; x++) {
75
+ if (this.phones[x].username == phone) {
76
+ this.phones.splice(x, 1);
112
77
  }
113
78
  }
114
79
  }
80
+ };
115
81
 
116
- export var diagnosticsCallback = {
117
- saveDiagnosticsCallback: null,
118
- keyValueSetCallback: null,
82
+ export var sessionCallback = {
83
+ sessioncallback: null,
84
+ callState: null,
85
+ document: null,
86
+ documentCallback: null,
87
+ phone: '',
88
+ initializeSessionCallback: function (SessionCallback) {
89
+ this.sessioncallback = SessionCallback;
90
+ },
91
+ intializeDocumentCallback: function (DocumentCallback) {
92
+ this.documentCallback = DocumentCallback;
93
+ },
94
+ initializeSession: function (state, phone) {
95
+ this.callState = state;
96
+ this.phone = phone;
97
+ },
98
+ initializeDocument: function (calldocument) {
99
+ this.document = calldocument;
100
+ },
101
+ triggerDocumentCallback: function () {
102
+ const documentCallbackFunc = this.documentCallback;
103
+ return documentCallbackFunc(this.document);
104
+ },
105
+ triggerSessionCallback: function () {
106
+ const sessionCallBackFunc = this.sessioncallback;
107
+ if (sessionCallBackFunc) {
108
+ return sessionCallBackFunc(this.callState, this.phone);
109
+ } else {
110
+ logger.log("Session callback is null")
111
+ return;
112
+ }
113
+ }
114
+ }
119
115
 
120
- setDiagnosticsReportCallback: function(saveDiagnosticsCallback) {
121
- window.localStorage.setItem('troubleShootReport', "")
122
- this.saveDiagnosticsCallback = saveDiagnosticsCallback;
123
- },
124
- setKeyValueCallback: function(keyValueSetCallback) {
125
- this.keyValueSetCallback = keyValueSetCallback;
126
- },
116
+ export var diagnosticsCallback = {
117
+ saveDiagnosticsCallback: null,
118
+ keyValueSetCallback: null,
127
119
 
128
- triggerDiagnosticsSaveCallback: function(saveStatus, saveDescription){
129
- this.saveDiagnosticsCallback(saveStatus, saveDescription);
130
- return true;
131
- },
132
- triggerKeyValueSetCallback: function(key, status, value){
133
- if (this.keyValueSetCallback) {
134
- this.keyValueSetCallback(key, status, value);
135
- }
136
- return true;
137
- },
120
+ setDiagnosticsReportCallback: function (saveDiagnosticsCallback) {
121
+ window.localStorage.setItem('troubleShootReport', "")
122
+ this.saveDiagnosticsCallback = saveDiagnosticsCallback;
123
+ },
124
+ setKeyValueCallback: function (keyValueSetCallback) {
125
+ this.keyValueSetCallback = keyValueSetCallback;
126
+ },
138
127
 
139
- }
128
+ triggerDiagnosticsSaveCallback: function (saveStatus, saveDescription) {
129
+ this.saveDiagnosticsCallback(saveStatus, saveDescription);
130
+ return true;
131
+ },
132
+ triggerKeyValueSetCallback: function (key, status, value) {
133
+ if (this.keyValueSetCallback) {
134
+ this.keyValueSetCallback(key, status, value);
135
+ }
136
+ return true;
137
+ },
140
138
 
141
- export var webrtcTroubleshooterEventBus = {
139
+ }
142
140
 
143
- microphoneTestSuccessEvent: function () {diagnosticsCallback.triggerKeyValueSetCallback("mic", 100, "mic ok");},
144
- microphoneTestFailedEvent: function () {diagnosticsCallback.triggerKeyValueSetCallback("mic", 0, "mic failed");},
145
- microphoneTestDoneEvent: function () {diagnosticsCallback.triggerKeyValueSetCallback("mic", 0, "mic done");},
146
- speakerTestSuccessEvent: function () {diagnosticsCallback.triggerKeyValueSetCallback("speaker", true, "speaker ok");},
147
- speakerTestFailedEvent: function () {diagnosticsCallback.triggerKeyValueSetCallback("speaker", false, "speaker failed");},
148
- speakerTestDoneEvent: function () {diagnosticsCallback.triggerKeyValueSetCallback("speaker", false, "speaker done");},
149
- wsConTestSuccessEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("wss","connected", "ws ok"); },
150
- wsConTestFailedEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("wss","disconnected", "ws failed"); },
151
- wsConTestDoneEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("wss","error", "ws done"); },
152
- userRegTestSuccessEvent: function () {diagnosticsCallback.triggerKeyValueSetCallback("userReg","registered", "registered");},
153
- userRegTestFailedEvent: function () {diagnosticsCallback.triggerKeyValueSetCallback("userReg","unregistered", "unregistered");},
154
- userRegTestDoneEvent: function () {diagnosticsCallback.triggerKeyValueSetCallback("userReg","error", "error done");},
155
- udpTestCompletedEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("udp", true,"udp ok");},
156
- tcpTestCompletedEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("tcp",true, "tcp ok"); },
157
- ipv6TestCompletedEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("ipv6", false, "ipv6 done");},
158
- hostCandidateTestCompletedEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("host",true, "host ok");},
159
- reflexCandidateTestCompletedEvent: function (event, phone, param) {
160
- logger.log("diagnosticEventCallback: Received ---> " + event + 'param sent....' + param + 'for phone....' + phone)
161
- diagnosticsCallback.triggerKeyValueSetCallback("srflx",true, "reflex ok");
162
- }
141
+ export var webrtcTroubleshooterEventBus = {
142
+
143
+ microphoneTestSuccessEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("mic", 100, "mic ok"); },
144
+ microphoneTestFailedEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("mic", 0, "mic failed"); },
145
+ microphoneTestDoneEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("mic", 0, "mic done"); },
146
+ speakerTestSuccessEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("speaker", true, "speaker ok"); },
147
+ speakerTestFailedEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("speaker", false, "speaker failed"); },
148
+ speakerTestDoneEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("speaker", false, "speaker done"); },
149
+ wsConTestSuccessEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("wss", "connected", "ws ok"); },
150
+ wsConTestFailedEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("wss", "disconnected", "ws failed"); },
151
+ wsConTestDoneEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("wss", "error", "ws done"); },
152
+ userRegTestSuccessEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("userReg", "registered", "registered"); },
153
+ userRegTestFailedEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("userReg", "unregistered", "unregistered"); },
154
+ userRegTestDoneEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("userReg", "error", "error done"); },
155
+ udpTestCompletedEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("udp", true, "udp ok"); },
156
+ tcpTestCompletedEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("tcp", true, "tcp ok"); },
157
+ ipv6TestCompletedEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("ipv6", false, "ipv6 done"); },
158
+ hostCandidateTestCompletedEvent: function () { diagnosticsCallback.triggerKeyValueSetCallback("host", true, "host ok"); },
159
+ reflexCandidateTestCompletedEvent: function (event, phone, param) {
160
+ logger.log("diagnosticEventCallback: Received ---> " + event + 'param sent....' + param + 'for phone....' + phone)
161
+ diagnosticsCallback.triggerKeyValueSetCallback("srflx", true, "reflex ok");
163
162
  }
163
+ }
164
164
 
165
165
 
166
- export var timerSession = {
167
-
168
- callTimer: '',
169
- getTimer: function(){
170
- return this.callTimer;
171
- },
172
- setCallTimer: function(callTimer){
173
- this.callTimer = callTimer;
174
- window.localStorage.setItem('callTimer', callTimer)
175
- }
166
+ export var timerSession = {
167
+
168
+ callTimer: '',
169
+ getTimer: function () {
170
+ return this.callTimer;
171
+ },
172
+ setCallTimer: function (callTimer) {
173
+ this.callTimer = callTimer;
174
+ window.localStorage.setItem('callTimer', callTimer)
176
175
  }
176
+ }
@@ -1,32 +1,21 @@
1
1
  import { Call } from "../api/callAPI/Call";
2
- import { CallController } from "./CallCtrlerDummy";
2
+ import { DoRegister as DoRegisterRL, UnRegister as UnRegisterRL } from '../api/registerAPI/RegisterListener';
3
3
  import { CallListener } from '../listeners/CallListener';
4
- import { DoRegister as DoRegisterRL } from '../api/registerAPI/RegisterListener';
5
- import { UnRegister as UnRegisterRL } from '../api/registerAPI/RegisterListener';
6
4
  import { ExotelVoiceClientListener } from '../listeners/ExotelVoiceClientListener';
7
5
  import { SessionListener as SessionListenerSL } from '../listeners/SessionListeners';
6
+ import { CallController } from "./CallCtrlerDummy";
7
+
8
+ import { closeDiagnostics as closeDiagnosticsDL, initDiagnostics as initDiagnosticsDL, startMicDiagnosticsTest as startMicDiagnosticsTestDL, startNetworkDiagnostics as startNetworkDiagnosticsDL, startSpeakerDiagnosticsTest as startSpeakerDiagnosticsTestDL, stopMicDiagnosticsTest as stopMicDiagnosticsTestDL, stopNetworkDiagnostics as stopNetworkDiagnosticsDL, stopSpeakerDiagnosticsTest as stopSpeakerDiagnosticsTestDL } from '../api/omAPI/DiagnosticsListener';
8
9
 
9
- import { initDiagnostics as initDiagnosticsDL } from '../api/omAPI/DiagnosticsListener';
10
- import { startNetworkDiagnostics as startNetworkDiagnosticsDL } from '../api/omAPI/DiagnosticsListener';
11
- import { stopNetworkDiagnostics as stopNetworkDiagnosticsDL } from '../api/omAPI/DiagnosticsListener';
12
- import { startSpeakerDiagnosticsTest as startSpeakerDiagnosticsTestDL } from '../api/omAPI/DiagnosticsListener';
13
- import { stopSpeakerDiagnosticsTest as stopSpeakerDiagnosticsTestDL } from '../api/omAPI/DiagnosticsListener';
14
- import { startMicDiagnosticsTest as startMicDiagnosticsTestDL } from '../api/omAPI/DiagnosticsListener';
15
- import { stopMicDiagnosticsTest as stopMicDiagnosticsTestDL } from '../api/omAPI/DiagnosticsListener';
16
- import { closeDiagnostics as closeDiagnosticsDL } from '../api/omAPI/DiagnosticsListener';
17
-
18
- import { callbacks } from '../listeners/Callback';
19
- import { registerCallback } from '../listeners/Callback';
20
- import { sessionCallback } from '../listeners/Callback';
10
+ import { callbacks, registerCallback, sessionCallback } from '../listeners/Callback';
21
11
  import { webrtcTroubleshooterEventBus } from "./Callback";
22
12
 
23
- import { webrtcLogger } from "../api/omAPI/WebrtcLogger";
24
13
  import { webrtcSIPPhone } from '@exotel-npm-dev/webrtc-core-sdk';
25
14
 
26
15
  var intervalId;
27
16
  var intervalIDMap = new Map();
28
17
 
29
- var logger = webrtcLogger();
18
+ var logger = webrtcSIPPhone.getLogger();
30
19
 
31
20
  function sleep(ms) {
32
21
  return new Promise(resolve => setTimeout(resolve, ms));
@@ -512,10 +501,28 @@ export class ExotelWebClient {
512
501
  }
513
502
  })
514
503
  .catch(function (error) {
515
- console.log("something went wrong during checkClientStatus ", error);
504
+ logger.log("something went wrong during checkClientStatus ", error);
516
505
  callback("media_permission_denied");
517
506
  });
518
507
  };
508
+
509
+ changeAudioInputDevice(deviceId, onSuccess, onError) {
510
+ logger.log(`in changeAudioInputDevice() of ExWebClient.js`);
511
+ webrtcSIPPhone.changeAudioInputDevice(deviceId, onSuccess, onError);
512
+ }
513
+
514
+ changeAudioOutputDevice(deviceId, onSuccess, onError) {
515
+ logger.log(`in changeAudioOutputDevice() of ExWebClient.js`);
516
+ webrtcSIPPhone.changeAudioOutputDevice(deviceId, onSuccess, onError);
517
+ }
518
+
519
+ registerLoggerCallback(callback) {
520
+ logger.registerLoggerCallback(callback);
521
+ }
522
+
523
+ registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback) {
524
+ webrtcSIPPhone.registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback);
525
+ }
519
526
  }
520
527
 
521
528
  export default ExotelWebClient;
@@ -1,7 +1,7 @@
1
1
  import { registerCallback } from "./Callback";
2
2
  import { diagnosticsCallback } from "./Callback";
3
3
 
4
- export class ExotelVoiceClientListener{
4
+ export class ExotelVoiceClientListener {
5
5
  onInitializationSuccess(phone) {
6
6
  /**
7
7
  * Abstract class for Initialization Success
@@ -11,33 +11,33 @@ export class ExotelVoiceClientListener{
11
11
  * Triggers UI callback to indicate the status of the registered phone
12
12
  */
13
13
  registerCallback.triggerRegisterCallback();
14
- diagnosticsCallback.triggerKeyValueSetCallback("userReg", "registered", phone);
14
+ diagnosticsCallback.triggerKeyValueSetCallback("userReg", "registered", phone);
15
15
  }
16
-
17
- onInitializationFailure(phone){
16
+
17
+ onInitializationFailure(phone) {
18
18
  /**
19
19
  * If register fails send error message to Callback function
20
20
  */
21
21
  registerCallback.initializeRegister("unregistered", phone);
22
22
  registerCallback.triggerRegisterCallback();
23
- diagnosticsCallback.triggerKeyValueSetCallback("userReg", "unregistered", phone);
23
+ diagnosticsCallback.triggerKeyValueSetCallback("userReg", "unregistered", phone);
24
24
  }
25
25
 
26
- onInitializationWaiting(phone){
26
+ onInitializationWaiting(phone) {
27
27
  /**
28
28
  * If register fails send error message to Callback function
29
29
  */
30
30
  registerCallback.initializeRegister("sent_request", phone);
31
31
  registerCallback.triggerRegisterCallback();
32
- diagnosticsCallback.triggerKeyValueSetCallback("userReg", "sent_request", phone);
32
+ diagnosticsCallback.triggerKeyValueSetCallback("userReg", "sent_request", phone);
33
33
  }
34
34
 
35
- onLog(LogLevel, tag, message){
35
+ onLog(LogLevel, tag, message) {
36
36
  /**
37
37
  * To get SDK logs
38
38
  */
39
39
  }
40
- onAuthenticationFailure(){
40
+ onAuthenticationFailure() {
41
41
  /**
42
42
  * In case if there is any authentication error in registration, handle here
43
43
  */