@exotel-npm-dev/webrtc-client-sdk 1.0.2 → 1.0.3
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 +1 -1
- package/src/listeners/ExWebClient.js +111 -111
package/package.json
CHANGED
|
@@ -195,119 +195,119 @@ export function ExSynchronousHandler() {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
export
|
|
198
|
+
export class ExotelWebClient {
|
|
199
199
|
|
|
200
200
|
|
|
201
201
|
|
|
202
|
-
ctrlr
|
|
203
|
-
call
|
|
204
|
-
eventListener
|
|
205
|
-
callListener
|
|
202
|
+
ctrlr = null;
|
|
203
|
+
call = null;
|
|
204
|
+
eventListener = null;
|
|
205
|
+
callListener = null;
|
|
206
206
|
/* OLD-Way to be revisited for multile phone support */
|
|
207
207
|
//this.webRTCPhones = {};
|
|
208
208
|
|
|
209
|
-
sipAccountInfo
|
|
209
|
+
sipAccountInfo = null;
|
|
210
210
|
|
|
211
|
-
initWebrtc
|
|
211
|
+
initWebrtc = (sipAccountInfo_,
|
|
212
212
|
RegisterEventCallBack, CallListenerCallback, SessionCallback) => {
|
|
213
213
|
|
|
214
|
-
if (!
|
|
215
|
-
|
|
214
|
+
if (!this.eventListener) {
|
|
215
|
+
this.eventListener = new ExotelVoiceClientListener();
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
if (!
|
|
219
|
-
|
|
218
|
+
if (!this.callListener) {
|
|
219
|
+
this.callListener = new CallListener();
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
if (!
|
|
223
|
-
|
|
222
|
+
if (!this.ctrlr) {
|
|
223
|
+
this.ctrlr = new CallController();
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
if (!
|
|
227
|
-
|
|
226
|
+
if (!this.call) {
|
|
227
|
+
this.call = new Call();
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
logger.log("Exotel Client Initialised with " + JSON.stringify(sipAccountInfo_))
|
|
231
|
-
|
|
232
|
-
if ( !
|
|
231
|
+
this.sipAccountInfo = sipAccountInfo_;
|
|
232
|
+
if ( !this.sipAccountInfo["userName"] || !this.sipAccountInfo["sipdomain"] || !this.sipAccountInfo["port"]) {
|
|
233
233
|
return false;
|
|
234
234
|
}
|
|
235
|
-
|
|
235
|
+
this.sipAccountInfo["sipUri"] = "wss://" + this.sipAccountInfo["userName"] + "@" + this.sipAccountInfo["sipdomain"] + ":" + this.sipAccountInfo["port"];
|
|
236
236
|
|
|
237
237
|
callbacks.initializeCallback(CallListenerCallback);
|
|
238
238
|
registerCallback.initializeRegisterCallback(RegisterEventCallBack);
|
|
239
239
|
logger.log("Initializing session callback")
|
|
240
240
|
sessionCallback.initializeSessionCallback(SessionCallback);
|
|
241
|
-
|
|
241
|
+
this.setEventListener(this.eventListener);
|
|
242
242
|
return true;
|
|
243
|
-
}
|
|
243
|
+
};
|
|
244
244
|
|
|
245
|
-
DoRegister
|
|
246
|
-
DoRegisterRL(
|
|
247
|
-
}
|
|
245
|
+
DoRegister = () => {
|
|
246
|
+
DoRegisterRL(this.sipAccountInfo, this)
|
|
247
|
+
};
|
|
248
248
|
|
|
249
|
-
UnRegister
|
|
250
|
-
UnRegisterRL(
|
|
251
|
-
}
|
|
249
|
+
UnRegister = () => {
|
|
250
|
+
UnRegisterRL(this.sipAccountInfo, this)
|
|
251
|
+
};
|
|
252
252
|
|
|
253
|
-
initDiagnostics
|
|
253
|
+
initDiagnostics = (saveDiagnosticsCallback, keyValueSetCallback) => {
|
|
254
254
|
initDiagnosticsDL(saveDiagnosticsCallback, keyValueSetCallback)
|
|
255
|
-
}
|
|
255
|
+
};
|
|
256
256
|
|
|
257
|
-
closeDiagnostics
|
|
257
|
+
closeDiagnostics = () => {
|
|
258
258
|
closeDiagnosticsDL()
|
|
259
|
-
}
|
|
259
|
+
};
|
|
260
260
|
|
|
261
|
-
startSpeakerDiagnosticsTest
|
|
261
|
+
startSpeakerDiagnosticsTest = () => {
|
|
262
262
|
startSpeakerDiagnosticsTestDL()
|
|
263
|
-
}
|
|
263
|
+
};
|
|
264
264
|
|
|
265
|
-
stopSpeakerDiagnosticsTest
|
|
265
|
+
stopSpeakerDiagnosticsTest = (speakerTestResponse='none') => {
|
|
266
266
|
stopSpeakerDiagnosticsTestDL(speakerTestResponse)
|
|
267
|
-
}
|
|
267
|
+
};
|
|
268
268
|
|
|
269
|
-
startMicDiagnosticsTest
|
|
269
|
+
startMicDiagnosticsTest = () => {
|
|
270
270
|
startMicDiagnosticsTestDL()
|
|
271
|
-
}
|
|
271
|
+
};
|
|
272
272
|
|
|
273
|
-
stopMicDiagnosticsTest
|
|
273
|
+
stopMicDiagnosticsTest = (micTestResponse='none') => {
|
|
274
274
|
stopMicDiagnosticsTestDL(micTestResponse)
|
|
275
|
-
}
|
|
275
|
+
};
|
|
276
276
|
|
|
277
|
-
startNetworkDiagnostics
|
|
277
|
+
startNetworkDiagnostics = () => {
|
|
278
278
|
startNetworkDiagnosticsDL()
|
|
279
|
-
|
|
280
|
-
}
|
|
279
|
+
this.DoRegister()
|
|
280
|
+
};
|
|
281
281
|
|
|
282
|
-
stopNetworkDiagnostics
|
|
282
|
+
stopNetworkDiagnostics = () => {
|
|
283
283
|
stopNetworkDiagnosticsDL()
|
|
284
|
-
}
|
|
284
|
+
};
|
|
285
285
|
|
|
286
|
-
SessionListener
|
|
286
|
+
SessionListener = () => {
|
|
287
287
|
SessionListenerSL()
|
|
288
|
-
}
|
|
288
|
+
};
|
|
289
289
|
|
|
290
290
|
/**
|
|
291
291
|
* function that returns the instance of the call controller object object
|
|
292
292
|
*/
|
|
293
293
|
|
|
294
|
-
getCallController
|
|
295
|
-
return
|
|
296
|
-
}
|
|
294
|
+
getCallController =() => {
|
|
295
|
+
return this.ctrlr;
|
|
296
|
+
};
|
|
297
297
|
|
|
298
|
-
getCall
|
|
299
|
-
if (!
|
|
300
|
-
|
|
298
|
+
getCall =() => {
|
|
299
|
+
if (!this.call) {
|
|
300
|
+
this.call = call = new Call();
|
|
301
301
|
}
|
|
302
|
-
return
|
|
303
|
-
}
|
|
302
|
+
return this.call;
|
|
303
|
+
};
|
|
304
304
|
|
|
305
305
|
/**
|
|
306
306
|
* Dummy function to set the event listener object
|
|
307
307
|
*/
|
|
308
|
-
setEventListener
|
|
309
|
-
|
|
310
|
-
}
|
|
308
|
+
setEventListener =(eventListener) => {
|
|
309
|
+
this.eventListener = eventListener;
|
|
310
|
+
};
|
|
311
311
|
|
|
312
312
|
|
|
313
313
|
/**
|
|
@@ -317,42 +317,42 @@ export const ExotelWebClient = {
|
|
|
317
317
|
* @param {*} param
|
|
318
318
|
*/
|
|
319
319
|
|
|
320
|
-
registerEventCallback
|
|
320
|
+
registerEventCallback =(event, phone, param) => {
|
|
321
321
|
|
|
322
322
|
logger.log("Dialer: registerEventCallback: Received ---> " + event + 'phone....', phone + 'param....', param)
|
|
323
323
|
if (event === "connected") {
|
|
324
324
|
/**
|
|
325
325
|
* When registration is successful then send the phone number of the same to UI
|
|
326
326
|
*/
|
|
327
|
-
|
|
327
|
+
this.eventListener.onInitializationSuccess(phone);
|
|
328
328
|
} else if( event === "failed_to_start" || event === "transport_error"){
|
|
329
329
|
/**
|
|
330
330
|
* If registration fails
|
|
331
331
|
*/
|
|
332
|
-
|
|
332
|
+
this.eventListener.onInitializationFailure(phone);
|
|
333
333
|
} else if( event === "sent_request"){
|
|
334
334
|
/**
|
|
335
335
|
* If registration request waiting...
|
|
336
336
|
*/
|
|
337
|
-
|
|
337
|
+
this.eventListener.onInitializationWaiting(phone);
|
|
338
338
|
}
|
|
339
|
-
}
|
|
339
|
+
};
|
|
340
340
|
/**
|
|
341
341
|
* Event listener for calls, any change in sipjsphone will trigger the callback here
|
|
342
342
|
* @param {*} event
|
|
343
343
|
* @param {*} phone
|
|
344
344
|
* @param {*} param
|
|
345
345
|
*/
|
|
346
|
-
callEventCallback
|
|
346
|
+
callEventCallback =(event, phone, param) => {
|
|
347
347
|
logger.log("Dialer: callEventCallback: Received ---> " + event + 'param sent....' + param + 'for phone....' + phone)
|
|
348
348
|
if (event === "i_new_call") {
|
|
349
|
-
|
|
349
|
+
this.callListener.onIncomingCall(param,phone)
|
|
350
350
|
} else if (event === "connected") {
|
|
351
|
-
|
|
351
|
+
this.callListener.onCallEstablished(param,phone);
|
|
352
352
|
} else if (event === "terminated") {
|
|
353
|
-
|
|
353
|
+
this.callListener.onCallEnded(param,phone);
|
|
354
354
|
}
|
|
355
|
-
}
|
|
355
|
+
};
|
|
356
356
|
|
|
357
357
|
/**
|
|
358
358
|
* Event listener for diagnostic tests, any change in diagnostic tests will trigger this callback
|
|
@@ -360,34 +360,34 @@ export const ExotelWebClient = {
|
|
|
360
360
|
* @param {*} phone
|
|
361
361
|
* @param {*} param
|
|
362
362
|
*/
|
|
363
|
-
diagnosticEventCallback
|
|
363
|
+
diagnosticEventCallback =(event, phone, param) => {
|
|
364
364
|
webrtcTroubleshooterEventBus.sendDiagnosticEvent(event, phone, param)
|
|
365
|
-
}
|
|
365
|
+
};
|
|
366
366
|
|
|
367
367
|
/**
|
|
368
368
|
* Function to unregister a phone
|
|
369
369
|
* @param {*} sipAccountInfo
|
|
370
370
|
*/
|
|
371
|
-
unregister
|
|
371
|
+
unregister =(sipAccountInfo) => {
|
|
372
372
|
// webrtcSIPPhone.unregister(sipAccountInfo)
|
|
373
373
|
webrtcSIPPhone.sipUnRegisterWebRTC();
|
|
374
|
-
}
|
|
374
|
+
};
|
|
375
375
|
|
|
376
376
|
|
|
377
|
-
webRTCStatusCallbackHandler
|
|
377
|
+
webRTCStatusCallbackHandler =(msg1, arg1) => {
|
|
378
378
|
logger.log("webRTCStatusCallbackHandler: " + msg1 + " " + arg1)
|
|
379
|
-
}
|
|
379
|
+
};
|
|
380
380
|
|
|
381
381
|
/**
|
|
382
382
|
* initialize function called when user wants to register client
|
|
383
383
|
*/
|
|
384
|
-
initialize
|
|
384
|
+
initialize =(uiContext, hostName,subscriberName,
|
|
385
385
|
displayName,accountSid,subscriberToken,
|
|
386
386
|
sipAccountInfo) => {
|
|
387
387
|
|
|
388
388
|
let wssPort = sipAccountInfo.port;
|
|
389
|
-
let wsPort =
|
|
390
|
-
|
|
389
|
+
let wsPort = 4442;
|
|
390
|
+
this.sipAccntInfo = {
|
|
391
391
|
'userName':'',
|
|
392
392
|
'authUser':'',
|
|
393
393
|
'domain':'',
|
|
@@ -407,65 +407,65 @@ export const ExotelWebClient = {
|
|
|
407
407
|
fetchPublicIP(sipAccountInfo);
|
|
408
408
|
|
|
409
409
|
/* Temporary till we figure out the arguments - Start */
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
410
|
+
this.domain = hostName = sipAccountInfo.domain;
|
|
411
|
+
this.sipdomain = sipAccountInfo.sipdomain;
|
|
412
|
+
this.accountName = this.userName = sipAccountInfo.userName;
|
|
413
|
+
this.authUser = subscriberName = sipAccountInfo.authUser;
|
|
414
|
+
this.displayName = sipAccountInfo.displayName;
|
|
415
|
+
this.accountSid = 'exotelt1';
|
|
416
|
+
this.subscriberToken = sipAccountInfo.secret;
|
|
417
|
+
this.secret = this.password = sipAccountInfo.secret;
|
|
418
|
+
this.security = sipAccountInfo.security ? sipAccountInfo.security : "wss";
|
|
419
|
+
this.endpoint = sipAccountInfo.endpoint ? sipAccountInfo.endpoint : "wss";
|
|
420
|
+
this.port = sipAccountInfo.port;
|
|
421
|
+
this.contactHost = sipAccountInfo.contactHost;
|
|
422
|
+
this.sipWsPort = 5061;
|
|
423
|
+
this.sipPort = 5061;
|
|
424
|
+
this.sipSecurePort = 5062;
|
|
424
425
|
/* Temporary till we figure out the arguments - End */
|
|
425
426
|
|
|
426
427
|
/* This is permanent -Start */
|
|
427
|
-
let webrtcPort =
|
|
428
|
+
let webrtcPort = wssPort;
|
|
428
429
|
|
|
429
|
-
if (
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
430
|
+
if (this.security === 'ws') {
|
|
431
|
+
webrtcPort = wsPort;
|
|
432
|
+
}
|
|
433
433
|
|
|
434
434
|
|
|
435
435
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
localStorage.setItem('contactHost',
|
|
436
|
+
this.sipAccntInfo['userName'] = this.userName;
|
|
437
|
+
this.sipAccntInfo['authUser'] = subscriberName;
|
|
438
|
+
this.sipAccntInfo['domain'] = hostName;
|
|
439
|
+
this.sipAccntInfo['sipdomain'] = this.sipdomain;
|
|
440
|
+
this.sipAccntInfo['accountName'] = this.userName;
|
|
441
|
+
this.sipAccntInfo['secret'] = this.password;
|
|
442
|
+
this.sipAccntInfo['sipuri'] = this.sipuri;
|
|
443
|
+
this.sipAccntInfo['security'] = this.security;
|
|
444
|
+
this.sipAccntInfo['endpoint'] = this.endpoint;
|
|
445
|
+
this.sipAccntInfo['port'] = webrtcPort;
|
|
446
|
+
this.sipAccntInfo['contactHost'] = this.contactHost;
|
|
447
|
+
localStorage.setItem('contactHost', this.contactHost);
|
|
448
448
|
/* This is permanent -End */
|
|
449
449
|
|
|
450
450
|
/**
|
|
451
451
|
* Call the webclient function inside this and pass register and call callbacks as arg
|
|
452
452
|
*/
|
|
453
|
-
var synchronousHandler = new ExSynchronousHandler(
|
|
454
|
-
var delegationHandler = new ExDelegationHandler(
|
|
453
|
+
var synchronousHandler = new ExSynchronousHandler(this);
|
|
454
|
+
var delegationHandler = new ExDelegationHandler(this);
|
|
455
455
|
|
|
456
|
-
var userName =
|
|
456
|
+
var userName = this.userName;
|
|
457
457
|
/* OLD-Way to be revisited for multile phone support */
|
|
458
458
|
//webRTCPhones[userName] = webRTC;
|
|
459
459
|
|
|
460
460
|
/* New-Way */
|
|
461
461
|
webrtcSIPPhone.registerPhone("sipjs",delegationHandler);
|
|
462
|
-
webrtcSIPPhone.registerWebRTCClient(
|
|
462
|
+
webrtcSIPPhone.registerWebRTCClient(this.sipAccntInfo, synchronousHandler);
|
|
463
463
|
|
|
464
464
|
/**
|
|
465
465
|
* Store the intervalID against a map
|
|
466
466
|
*/
|
|
467
467
|
intervalIDMap.set(userName, intervalId);
|
|
468
|
-
}
|
|
468
|
+
};
|
|
469
469
|
}
|
|
470
470
|
|
|
471
471
|
export default ExotelWebClient;
|