@vgroup/dialbox 0.0.56 → 0.0.58
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/esm2020/lib/service/twilio.service.mjs +24 -68
- package/fesm2015/vgroup-dialbox.mjs +23 -67
- package/fesm2015/vgroup-dialbox.mjs.map +1 -1
- package/fesm2020/vgroup-dialbox.mjs +23 -67
- package/fesm2020/vgroup-dialbox.mjs.map +1 -1
- package/lib/service/twilio.service.d.ts +0 -3
- package/package.json +1 -1
|
@@ -1315,77 +1315,33 @@ class TwilioService {
|
|
|
1315
1315
|
this.isAvailableNumber = new BehaviorSubject(false);
|
|
1316
1316
|
this.callerIdList = new BehaviorSubject([]);
|
|
1317
1317
|
this.triggerSMSReload = new BehaviorSubject(false);
|
|
1318
|
-
this.
|
|
1319
|
-
this.initializationInProgress = false;
|
|
1320
|
-
// Initialize when token is available
|
|
1321
|
-
if (this.token) {
|
|
1322
|
-
this.initializeTwilioDevice();
|
|
1323
|
-
}
|
|
1324
|
-
else {
|
|
1325
|
-
// If token is not available, try to get it from localStorage
|
|
1326
|
-
const token = localStorage.getItem('ext_token');
|
|
1327
|
-
if (token) {
|
|
1328
|
-
this.token = token;
|
|
1329
|
-
this.initializeTwilioDevice();
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1318
|
+
this.initializeTwilioDevice();
|
|
1332
1319
|
}
|
|
1333
1320
|
initializeTwilioDevice() {
|
|
1334
|
-
if (this.
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
// Clean up existing device if any
|
|
1354
|
-
if (this.device) {
|
|
1355
|
-
this.device.destroy();
|
|
1321
|
+
if (this.token) {
|
|
1322
|
+
this.extensionService.getIncomingCallToken().subscribe((data) => {
|
|
1323
|
+
this.incomingCallToken = data.token;
|
|
1324
|
+
localStorage.setItem('in-token', data.token);
|
|
1325
|
+
this.device = new Device(this.incomingCallToken, {
|
|
1326
|
+
allowIncomingWhileBusy: true,
|
|
1327
|
+
// Add any other necessary options
|
|
1328
|
+
});
|
|
1329
|
+
this.device.register();
|
|
1330
|
+
this.device.on('incoming', (call) => {
|
|
1331
|
+
this.currentCall.next(call);
|
|
1332
|
+
this.callType.next('INCOMING');
|
|
1333
|
+
this.currentCallState.next('incoming');
|
|
1334
|
+
});
|
|
1335
|
+
this.device.on('error', (error) => {
|
|
1336
|
+
console.error('Twilio Device Error:', error);
|
|
1337
|
+
// Add error handling and reconnection logic
|
|
1338
|
+
});
|
|
1339
|
+
});
|
|
1356
1340
|
}
|
|
1357
|
-
this.incomingCallToken = token;
|
|
1358
|
-
localStorage.setItem('in-token', token);
|
|
1359
|
-
this.device = new Device(token, {
|
|
1360
|
-
allowIncomingWhileBusy: true,
|
|
1361
|
-
closeProtection: true
|
|
1362
|
-
});
|
|
1363
|
-
// Set up event listeners
|
|
1364
|
-
this.device.on('registered', () => {
|
|
1365
|
-
console.log('Twilio Device registered successfully');
|
|
1366
|
-
this.initializationInProgress = false;
|
|
1367
|
-
});
|
|
1368
|
-
this.device.on('incoming', (call) => {
|
|
1369
|
-
console.log('Incoming call received');
|
|
1370
|
-
this.currentCall.next(call);
|
|
1371
|
-
this.callType.next('INCOMING');
|
|
1372
|
-
this.currentCallState.next('incoming');
|
|
1373
|
-
});
|
|
1374
|
-
this.device.on('error', (error) => {
|
|
1375
|
-
console.error('Twilio Device Error:', error);
|
|
1376
|
-
this.isInitialized = false;
|
|
1377
|
-
this.initializationInProgress = false;
|
|
1378
|
-
// Attempt to reinitialize after error
|
|
1379
|
-
setTimeout(() => this.initializeTwilioDevice(), 5000);
|
|
1380
|
-
});
|
|
1381
|
-
this.device.on('unregistered', () => {
|
|
1382
|
-
console.log('Twilio Device unregistered');
|
|
1383
|
-
this.isInitialized = false;
|
|
1384
|
-
// Attempt to re-register
|
|
1385
|
-
this.initializeTwilioDevice();
|
|
1386
|
-
});
|
|
1387
|
-
this.device.register();
|
|
1388
1341
|
}
|
|
1342
|
+
// onIncomingCall(){
|
|
1343
|
+
// this.device.on('incoming', (call:any) => {
|
|
1344
|
+
// console.log(call);
|
|
1389
1345
|
// //call.accept();
|
|
1390
1346
|
// });
|
|
1391
1347
|
// }
|