@exotel-npm-dev/webrtc-client-sdk 1.0.6 → 1.0.7
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 +3 -0
- package/demo-non-npm/cert.pem +21 -0
- package/demo-non-npm/demo.js +35 -33
- package/demo-non-npm/dist/beep.wav +0 -0
- package/demo-non-npm/dist/dtmf.wav +0 -0
- package/demo-non-npm/dist/exotelsdk.js +73 -7
- package/demo-non-npm/dist/exotelsdk.js.map +1 -1
- package/demo-non-npm/dist/ringbacktone.wav +0 -0
- package/demo-non-npm/dist/ringtone.wav +0 -0
- package/demo-non-npm/index.html +11 -7
- package/demo-non-npm/key.pem +28 -0
- package/demo-non-npm/phone.js +3 -3
- package/dist/exotelsdk.js +73 -5
- package/dist/exotelsdk.js.map +1 -1
- package/package.json +3 -3
- package/src/listeners/ExWebClient.js +159 -112
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exotel-npm-dev/webrtc-client-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "client sdk for webrtc based on webrtc core sdk",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"homepage": "https://bitbucket.org/Exotel/webrtc#readme",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@exotel-npm-dev/webrtc-core-sdk": "^1.0.
|
|
24
|
+
"@exotel-npm-dev/webrtc-core-sdk": "^1.0.7"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"babel-loader": "^8.2.5",
|
|
@@ -31,4 +31,4 @@
|
|
|
31
31
|
"webpack": "^5.74.0",
|
|
32
32
|
"webpack-cli": "^4.10.0"
|
|
33
33
|
}
|
|
34
|
-
}
|
|
34
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Call }
|
|
1
|
+
import { Call } from "../api/callAPI/Call";
|
|
2
2
|
import { CallController } from "./CallCtrlerDummy";
|
|
3
3
|
import { CallListener } from '../listeners/CallListener';
|
|
4
4
|
import { DoRegister as DoRegisterRL } from '../api/registerAPI/RegisterListener';
|
|
@@ -6,14 +6,14 @@ import { UnRegister as UnRegisterRL } from '../api/registerAPI/RegisterListener'
|
|
|
6
6
|
import { ExotelVoiceClientListener } from '../listeners/ExotelVoiceClientListener';
|
|
7
7
|
import { SessionListener as SessionListenerSL } from '../listeners/SessionListeners';
|
|
8
8
|
|
|
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';
|
|
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
15
|
import { stopMicDiagnosticsTest as stopMicDiagnosticsTestDL } from '../api/omAPI/DiagnosticsListener';
|
|
16
|
-
import { closeDiagnostics as closeDiagnosticsDL} from '../api/omAPI/DiagnosticsListener';
|
|
16
|
+
import { closeDiagnostics as closeDiagnosticsDL } from '../api/omAPI/DiagnosticsListener';
|
|
17
17
|
|
|
18
18
|
import { callbacks } from '../listeners/Callback';
|
|
19
19
|
import { registerCallback } from '../listeners/Callback';
|
|
@@ -37,26 +37,26 @@ function sleep(ms) {
|
|
|
37
37
|
*/
|
|
38
38
|
function fetchPublicIP(sipAccountInfo) {
|
|
39
39
|
var publicIp = "";
|
|
40
|
-
const pc = new RTCPeerConnection({ iceServers: [
|
|
40
|
+
const pc = new RTCPeerConnection({ iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] });
|
|
41
41
|
pc.createDataChannel('');
|
|
42
42
|
pc.createOffer().then(offer => pc.setLocalDescription(offer))
|
|
43
43
|
pc.onicecandidate = (ice) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
44
|
+
if (!ice || !ice.candidate || !ice.candidate.candidate) {
|
|
45
|
+
logger.log("all done.");
|
|
46
|
+
pc.close();
|
|
47
|
+
return "";
|
|
48
|
+
}
|
|
49
|
+
logger.log("iceCandidate =" + ice.candidate.candidate);
|
|
50
|
+
let split = ice.candidate.candidate.split(" ");
|
|
51
|
+
if (split[7] === "host") {
|
|
52
|
+
logger.log(`fetchPublicIP:Local IP : ${split[4]}`);
|
|
53
|
+
} else {
|
|
54
|
+
logger.log(`fetchPublicIP:External IP : ${split[4]}`);
|
|
55
|
+
publicIp = `${split[4]}`
|
|
56
|
+
logger.log("fetchPublicIP:Public IP :" + publicIp);
|
|
57
|
+
localStorage.setItem("contactHost", publicIp);
|
|
58
|
+
pc.close();
|
|
59
|
+
}
|
|
60
60
|
};
|
|
61
61
|
sleep(500).then(function () {
|
|
62
62
|
logger.log("fetchPublicIP: public ip = ", publicIp)
|
|
@@ -66,137 +66,137 @@ function fetchPublicIP(sipAccountInfo) {
|
|
|
66
66
|
sipAccountInfo.contactHost = publicIp;
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
|
-
return;
|
|
69
|
+
return;
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
export function ExDelegationHandler(exClient_) {
|
|
74
74
|
var exClient = exClient_;
|
|
75
|
-
this.setTestingMode = function(mode) {
|
|
75
|
+
this.setTestingMode = function (mode) {
|
|
76
76
|
logger.log("delegationHandler: setTestingMode\n");
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
this.onCallStatSipJsSessionEvent = function(ev) {
|
|
79
|
+
this.onCallStatSipJsSessionEvent = function (ev) {
|
|
80
80
|
logger.log("delegationHandler: onCallStatSipJsSessionEvent\n");
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
this.sendWebRTCEventsToFSM = function(eventType, sipMethod) {
|
|
83
|
+
this.sendWebRTCEventsToFSM = function (eventType, sipMethod) {
|
|
84
84
|
logger.log("delegationHandler: sendWebRTCEventsToFSM\n");
|
|
85
85
|
logger.log("delegationHandler: eventType\n", eventType);
|
|
86
86
|
logger.log("delegationHandler: sipMethod\n", sipMethod);
|
|
87
87
|
if (sipMethod == "CONNECTION") {
|
|
88
88
|
exClient.registerEventCallback(eventType, exClient.userName)
|
|
89
89
|
} else if (sipMethod == "CALL") {
|
|
90
|
-
exClient.callEventCallback(eventType, exClient.callFromNumber,exClient.call)
|
|
90
|
+
exClient.callEventCallback(eventType, exClient.callFromNumber, exClient.call)
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
this.playBeepTone = function() {
|
|
94
|
+
this.playBeepTone = function () {
|
|
95
95
|
logger.log("delegationHandler: playBeepTone\n");
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
this.onStatPeerConnectionIceGatheringStateChange = function(iceGatheringState) {
|
|
98
|
+
this.onStatPeerConnectionIceGatheringStateChange = function (iceGatheringState) {
|
|
99
99
|
logger.log("delegationHandler: onStatPeerConnectionIceGatheringStateChange\n");
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
this.onCallStatIceCandidate = function(ev,icestate) {
|
|
102
|
+
this.onCallStatIceCandidate = function (ev, icestate) {
|
|
103
103
|
logger.log("delegationHandler: onCallStatIceCandidate\n");
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
this.onCallStatNegoNeeded = function(icestate) {
|
|
106
|
+
this.onCallStatNegoNeeded = function (icestate) {
|
|
107
107
|
logger.log("delegationHandler: onCallStatNegoNeeded\n");
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
this.onCallStatSignalingStateChange = function(cstate) {
|
|
110
|
+
this.onCallStatSignalingStateChange = function (cstate) {
|
|
111
111
|
logger.log("delegationHandler: onCallStatSignalingStateChange\n");
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
this.onStatPeerConnectionIceConnectionStateChange = function() {
|
|
114
|
+
this.onStatPeerConnectionIceConnectionStateChange = function () {
|
|
115
115
|
logger.log("delegationHandler: onStatPeerConnectionIceConnectionStateChange\n");
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
this.onStatPeerConnectionConnectionStateChange = function() {
|
|
118
|
+
this.onStatPeerConnectionConnectionStateChange = function () {
|
|
119
119
|
logger.log("delegationHandler: onStatPeerConnectionConnectionStateChange\n");
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
this.onGetUserMediaSuccessCallstatCallback = function() {
|
|
122
|
+
this.onGetUserMediaSuccessCallstatCallback = function () {
|
|
123
123
|
logger.log("delegationHandler: onGetUserMediaSuccessCallstatCallback\n");
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
this.onGetUserMediaErrorCallstatCallback = function() {
|
|
126
|
+
this.onGetUserMediaErrorCallstatCallback = function () {
|
|
127
127
|
logger.log("delegationHandler: onGetUserMediaErrorCallstatCallback\n");
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
this.onCallStatAddStream = function() {
|
|
130
|
+
this.onCallStatAddStream = function () {
|
|
131
131
|
logger.log("delegationHandler: onCallStatAddStream\n");
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
this.onCallStatRemoveStream = function() {
|
|
134
|
+
this.onCallStatRemoveStream = function () {
|
|
135
135
|
logger.log("delegationHandler: onCallStatRemoveStream\n");
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
this.setWebRTCFSMMapper = function(stack) {
|
|
138
|
+
this.setWebRTCFSMMapper = function (stack) {
|
|
139
139
|
logger.log("delegationHandler: setWebRTCFSMMapper : Initialisation complete \n");
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
this.onCallStatSipJsTransportEvent = function() {
|
|
142
|
+
this.onCallStatSipJsTransportEvent = function () {
|
|
143
143
|
logger.log("delegationHandler: onCallStatSipJsTransportEvent\n");
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
this.onCallStatSipSendCallback = function() {
|
|
146
|
+
this.onCallStatSipSendCallback = function () {
|
|
147
147
|
logger.log("delegationHandler: onCallStatSipSendCallback\n");
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
this.onCallStatSipRecvCallback = function() {
|
|
150
|
+
this.onCallStatSipRecvCallback = function () {
|
|
151
151
|
logger.log("delegationHandler: onCallStatSipRecvCallback\n");
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
this.stopCallStat = function() {
|
|
154
|
+
this.stopCallStat = function () {
|
|
155
155
|
logger.log("delegationHandler: stopCallStat\n");
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
this.onRecieveInvite = function(incomingSession) {
|
|
158
|
+
this.onRecieveInvite = function (incomingSession) {
|
|
159
159
|
logger.log("delegationHandler: onRecieveInvite\n");
|
|
160
160
|
exClient.callFromNumber = incomingSession.incomingInviteRequest.message.from.displayName;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
this.onPickCall = function() {
|
|
163
|
+
this.onPickCall = function () {
|
|
164
164
|
logger.log("delegationHandler: onPickCall\n");
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
this.onRejectCall = function() {
|
|
167
|
+
this.onRejectCall = function () {
|
|
168
168
|
logger.log("delegationHandler: onRejectCall\n");
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
this.onCreaterAnswer = function() {
|
|
171
|
+
this.onCreaterAnswer = function () {
|
|
172
172
|
logger.log("delegationHandler: onCreaterAnswer\n");
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
this.onSettingLocalDesc = function() {
|
|
175
|
+
this.onSettingLocalDesc = function () {
|
|
176
176
|
logger.log("delegationHandler: onSettingLocalDesc\n");
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
this.initGetStats = function(pc, callid, username) {
|
|
179
|
+
this.initGetStats = function (pc, callid, username) {
|
|
180
180
|
logger.log("delegationHandler: initGetStats\n");
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
this.onRegisterWebRTCSIPEngine = function(engine) {
|
|
183
|
+
this.onRegisterWebRTCSIPEngine = function (engine) {
|
|
184
184
|
logger.log("delegationHandler: onRegisterWebRTCSIPEngine, engine=\n", engine);
|
|
185
|
-
}
|
|
185
|
+
}
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
export function ExSynchronousHandler() {
|
|
189
189
|
|
|
190
|
-
this.onFailure = function() {
|
|
190
|
+
this.onFailure = function () {
|
|
191
191
|
logger.log("synchronousHandler: onFailure, phone is offline.\n");
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
this.onResponse = function() {
|
|
194
|
+
this.onResponse = function () {
|
|
195
195
|
logger.log("synchronousHandler: onResponse, phone is connected.\n");
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
export class ExotelWebClient
|
|
199
|
+
export class ExotelWebClient {
|
|
200
200
|
|
|
201
201
|
|
|
202
202
|
|
|
@@ -210,7 +210,7 @@ export class ExotelWebClient {
|
|
|
210
210
|
|
|
211
211
|
sipAccountInfo = null;
|
|
212
212
|
|
|
213
|
-
initWebrtc = (sipAccountInfo_,
|
|
213
|
+
initWebrtc = (sipAccountInfo_,
|
|
214
214
|
RegisterEventCallBack, CallListenerCallback, SessionCallback) => {
|
|
215
215
|
|
|
216
216
|
if (!this.eventListener) {
|
|
@@ -231,8 +231,8 @@ export class ExotelWebClient {
|
|
|
231
231
|
|
|
232
232
|
logger.log("Exotel Client Initialised with " + JSON.stringify(sipAccountInfo_))
|
|
233
233
|
this.sipAccountInfo = sipAccountInfo_;
|
|
234
|
-
if (
|
|
235
|
-
return false;
|
|
234
|
+
if (!this.sipAccountInfo["userName"] || !this.sipAccountInfo["sipdomain"] || !this.sipAccountInfo["port"]) {
|
|
235
|
+
return false;
|
|
236
236
|
}
|
|
237
237
|
this.sipAccountInfo["sipUri"] = "wss://" + this.sipAccountInfo["userName"] + "@" + this.sipAccountInfo["sipdomain"] + ":" + this.sipAccountInfo["port"];
|
|
238
238
|
|
|
@@ -241,7 +241,7 @@ export class ExotelWebClient {
|
|
|
241
241
|
logger.log("Initializing session callback")
|
|
242
242
|
sessionCallback.initializeSessionCallback(SessionCallback);
|
|
243
243
|
this.setEventListener(this.eventListener);
|
|
244
|
-
return true;
|
|
244
|
+
return true;
|
|
245
245
|
};
|
|
246
246
|
|
|
247
247
|
DoRegister = () => {
|
|
@@ -255,7 +255,7 @@ export class ExotelWebClient {
|
|
|
255
255
|
initDiagnostics = (saveDiagnosticsCallback, keyValueSetCallback) => {
|
|
256
256
|
initDiagnosticsDL(saveDiagnosticsCallback, keyValueSetCallback)
|
|
257
257
|
};
|
|
258
|
-
|
|
258
|
+
|
|
259
259
|
closeDiagnostics = () => {
|
|
260
260
|
closeDiagnosticsDL()
|
|
261
261
|
};
|
|
@@ -264,7 +264,7 @@ export class ExotelWebClient {
|
|
|
264
264
|
startSpeakerDiagnosticsTestDL()
|
|
265
265
|
};
|
|
266
266
|
|
|
267
|
-
stopSpeakerDiagnosticsTest = (speakerTestResponse='none') => {
|
|
267
|
+
stopSpeakerDiagnosticsTest = (speakerTestResponse = 'none') => {
|
|
268
268
|
stopSpeakerDiagnosticsTestDL(speakerTestResponse)
|
|
269
269
|
};
|
|
270
270
|
|
|
@@ -272,7 +272,7 @@ export class ExotelWebClient {
|
|
|
272
272
|
startMicDiagnosticsTestDL()
|
|
273
273
|
};
|
|
274
274
|
|
|
275
|
-
stopMicDiagnosticsTest = (micTestResponse='none') => {
|
|
275
|
+
stopMicDiagnosticsTest = (micTestResponse = 'none') => {
|
|
276
276
|
stopMicDiagnosticsTestDL(micTestResponse)
|
|
277
277
|
};
|
|
278
278
|
|
|
@@ -293,21 +293,21 @@ export class ExotelWebClient {
|
|
|
293
293
|
* function that returns the instance of the call controller object object
|
|
294
294
|
*/
|
|
295
295
|
|
|
296
|
-
getCallController =() => {
|
|
296
|
+
getCallController = () => {
|
|
297
297
|
return this.ctrlr;
|
|
298
298
|
};
|
|
299
299
|
|
|
300
|
-
getCall =() => {
|
|
300
|
+
getCall = () => {
|
|
301
301
|
if (!this.call) {
|
|
302
302
|
this.call = call = new Call();
|
|
303
|
-
}
|
|
303
|
+
}
|
|
304
304
|
return this.call;
|
|
305
305
|
};
|
|
306
306
|
|
|
307
307
|
/**
|
|
308
308
|
* Dummy function to set the event listener object
|
|
309
309
|
*/
|
|
310
|
-
setEventListener =(eventListener) => {
|
|
310
|
+
setEventListener = (eventListener) => {
|
|
311
311
|
this.eventListener = eventListener;
|
|
312
312
|
};
|
|
313
313
|
|
|
@@ -319,25 +319,25 @@ export class ExotelWebClient {
|
|
|
319
319
|
* @param {*} param
|
|
320
320
|
*/
|
|
321
321
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
322
|
+
registerEventCallback = (event, phone, param) => {
|
|
323
|
+
|
|
324
|
+
logger.log("Dialer: registerEventCallback: Received ---> " + event + 'phone....', phone + 'param....', param)
|
|
325
325
|
if (event === "connected") {
|
|
326
326
|
/**
|
|
327
327
|
* When registration is successful then send the phone number of the same to UI
|
|
328
328
|
*/
|
|
329
|
-
|
|
330
|
-
} else if(
|
|
329
|
+
this.eventListener.onInitializationSuccess(phone);
|
|
330
|
+
} else if (event === "failed_to_start" || event === "transport_error") {
|
|
331
331
|
/**
|
|
332
332
|
* If registration fails
|
|
333
333
|
*/
|
|
334
|
-
|
|
335
|
-
} else if(
|
|
334
|
+
this.eventListener.onInitializationFailure(phone);
|
|
335
|
+
} else if (event === "sent_request") {
|
|
336
336
|
/**
|
|
337
337
|
* If registration request waiting...
|
|
338
338
|
*/
|
|
339
|
-
|
|
340
|
-
}
|
|
339
|
+
this.eventListener.onInitializationWaiting(phone);
|
|
340
|
+
}
|
|
341
341
|
};
|
|
342
342
|
/**
|
|
343
343
|
* Event listener for calls, any change in sipjsphone will trigger the callback here
|
|
@@ -345,65 +345,65 @@ export class ExotelWebClient {
|
|
|
345
345
|
* @param {*} phone
|
|
346
346
|
* @param {*} param
|
|
347
347
|
*/
|
|
348
|
-
callEventCallback =(event, phone, param) => {
|
|
349
|
-
|
|
348
|
+
callEventCallback = (event, phone, param) => {
|
|
349
|
+
logger.log("Dialer: callEventCallback: Received ---> " + event + 'param sent....' + param + 'for phone....' + phone)
|
|
350
350
|
if (event === "i_new_call") {
|
|
351
|
-
this.callListener.onIncomingCall(param,phone)
|
|
351
|
+
this.callListener.onIncomingCall(param, phone)
|
|
352
352
|
} else if (event === "connected") {
|
|
353
|
-
this.callListener.onCallEstablished(param,phone);
|
|
353
|
+
this.callListener.onCallEstablished(param, phone);
|
|
354
354
|
} else if (event === "terminated") {
|
|
355
|
-
this.callListener.onCallEnded(param,phone);
|
|
355
|
+
this.callListener.onCallEnded(param, phone);
|
|
356
356
|
}
|
|
357
357
|
};
|
|
358
|
-
|
|
358
|
+
|
|
359
359
|
/**
|
|
360
360
|
* Event listener for diagnostic tests, any change in diagnostic tests will trigger this callback
|
|
361
361
|
* @param {*} event
|
|
362
362
|
* @param {*} phone
|
|
363
363
|
* @param {*} param
|
|
364
364
|
*/
|
|
365
|
-
|
|
365
|
+
diagnosticEventCallback = (event, phone, param) => {
|
|
366
366
|
webrtcTroubleshooterEventBus.sendDiagnosticEvent(event, phone, param)
|
|
367
367
|
};
|
|
368
|
-
|
|
368
|
+
|
|
369
369
|
/**
|
|
370
370
|
* Function to unregister a phone
|
|
371
371
|
* @param {*} sipAccountInfo
|
|
372
372
|
*/
|
|
373
|
-
unregister =(sipAccountInfo) => {
|
|
373
|
+
unregister = (sipAccountInfo) => {
|
|
374
374
|
// webrtcSIPPhone.unregister(sipAccountInfo)
|
|
375
375
|
webrtcSIPPhone.sipUnRegisterWebRTC();
|
|
376
376
|
};
|
|
377
377
|
|
|
378
378
|
|
|
379
|
-
webRTCStatusCallbackHandler =(msg1, arg1) => {
|
|
379
|
+
webRTCStatusCallbackHandler = (msg1, arg1) => {
|
|
380
380
|
logger.log("webRTCStatusCallbackHandler: " + msg1 + " " + arg1)
|
|
381
381
|
};
|
|
382
382
|
|
|
383
383
|
/**
|
|
384
384
|
* initialize function called when user wants to register client
|
|
385
385
|
*/
|
|
386
|
-
initialize =(uiContext, hostName,subscriberName,
|
|
387
|
-
|
|
388
|
-
|
|
386
|
+
initialize = (uiContext, hostName, subscriberName,
|
|
387
|
+
displayName, accountSid, subscriberToken,
|
|
388
|
+
sipAccountInfo) => {
|
|
389
389
|
|
|
390
390
|
let wssPort = sipAccountInfo.port;
|
|
391
391
|
let wsPort = 4442;
|
|
392
392
|
this.sipAccntInfo = {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
393
|
+
'userName': '',
|
|
394
|
+
'authUser': '',
|
|
395
|
+
'domain': '',
|
|
396
|
+
'sipdomain': '',
|
|
397
|
+
'displayname': '',
|
|
398
|
+
'accountSid': '',
|
|
399
|
+
'secret': '',
|
|
400
|
+
'sipUri': '',
|
|
401
|
+
'security': '',
|
|
402
|
+
'endpoint': '',
|
|
403
|
+
'port': '',
|
|
404
|
+
'contactHost': ''
|
|
405
405
|
}
|
|
406
|
-
|
|
406
|
+
|
|
407
407
|
logger.log('Sending register for the number..', subscriberName);
|
|
408
408
|
|
|
409
409
|
fetchPublicIP(sipAccountInfo);
|
|
@@ -431,8 +431,8 @@ export class ExotelWebClient {
|
|
|
431
431
|
|
|
432
432
|
if (this.security === 'ws') {
|
|
433
433
|
webrtcPort = wsPort;
|
|
434
|
-
}
|
|
435
|
-
|
|
434
|
+
}
|
|
435
|
+
|
|
436
436
|
|
|
437
437
|
|
|
438
438
|
this.sipAccntInfo['userName'] = this.userName;
|
|
@@ -448,7 +448,7 @@ export class ExotelWebClient {
|
|
|
448
448
|
this.sipAccntInfo['contactHost'] = this.contactHost;
|
|
449
449
|
localStorage.setItem('contactHost', this.contactHost);
|
|
450
450
|
/* This is permanent -End */
|
|
451
|
-
|
|
451
|
+
|
|
452
452
|
/**
|
|
453
453
|
* Call the webclient function inside this and pass register and call callbacks as arg
|
|
454
454
|
*/
|
|
@@ -460,13 +460,60 @@ export class ExotelWebClient {
|
|
|
460
460
|
//webRTCPhones[userName] = webRTC;
|
|
461
461
|
|
|
462
462
|
/* New-Way */
|
|
463
|
-
webrtcSIPPhone.registerPhone("sipjs",delegationHandler);
|
|
463
|
+
webrtcSIPPhone.registerPhone("sipjs", delegationHandler);
|
|
464
464
|
webrtcSIPPhone.registerWebRTCClient(this.sipAccntInfo, synchronousHandler);
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Store the intervalID against a map
|
|
468
|
+
*/
|
|
469
|
+
intervalIDMap.set(userName, intervalId);
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
checkClientStatus = (callback) => {
|
|
473
|
+
// using this function , first it will check mic permission is given or not
|
|
474
|
+
// then it will check if transport is intialize or not
|
|
475
|
+
// then it will check if user is registered or not
|
|
476
|
+
// based on this we can evaludate SDK is ready for call
|
|
477
|
+
var constraints = { audio: true, video: false };
|
|
478
|
+
navigator.mediaDevices
|
|
479
|
+
.getUserMedia(constraints)
|
|
480
|
+
.then(function (mediaStream) {
|
|
481
|
+
var transportState = webrtcSIPPhone.getTransportState();
|
|
482
|
+
|
|
483
|
+
switch (transportState) {
|
|
484
|
+
case "":
|
|
485
|
+
callback("not_intialized");
|
|
486
|
+
break;
|
|
487
|
+
case "unknown":
|
|
488
|
+
case "Connecting":
|
|
489
|
+
callback(transportState);
|
|
490
|
+
break;
|
|
491
|
+
|
|
492
|
+
default:
|
|
493
|
+
var registerationState = webrtcSIPPhone.getRegistrationState();
|
|
494
|
+
switch (registerationState) {
|
|
495
|
+
case "":
|
|
496
|
+
callback("websocket_connection_failed");
|
|
497
|
+
break;
|
|
498
|
+
case "Registered":
|
|
499
|
+
if (transportState != "Connected") {
|
|
500
|
+
callback("Disconnected");
|
|
501
|
+
} else {
|
|
502
|
+
callback(registerationState);
|
|
503
|
+
}
|
|
504
|
+
break;
|
|
505
|
+
default:
|
|
506
|
+
callback(registerationState);
|
|
507
|
+
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
}
|
|
512
|
+
})
|
|
513
|
+
.catch(function (error) {
|
|
514
|
+
console.log("something went wrong during checkClientStatus ", error);
|
|
515
|
+
callback("media_permission_denied");
|
|
516
|
+
});
|
|
470
517
|
};
|
|
471
518
|
}
|
|
472
519
|
|