@wazo/sdk 0.37.33 → 0.37.34

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.
Files changed (44) hide show
  1. package/dist/wazo-sdk.js +2 -2
  2. package/esm/__tests__/web-rtc-client.test.js +1 -1
  3. package/esm/checker/Checker.js +1 -1
  4. package/esm/checker/checks/index.js +1 -1
  5. package/esm/checker/checks/webrtc-transport.js +1 -1
  6. package/esm/checker/checks/webrtc.js +1 -1
  7. package/esm/domain/Phone/WebRTCPhone.js +23 -4
  8. package/esm/index.js +24 -5
  9. package/esm/simple/Auth.js +24 -5
  10. package/esm/simple/Configuration.js +24 -5
  11. package/esm/simple/Phone.js +24 -5
  12. package/esm/simple/index.js +24 -5
  13. package/esm/simple/room/LocalParticipant.js +24 -5
  14. package/esm/simple/room/Participant.js +24 -5
  15. package/esm/simple/room/RemoteParticipant.js +24 -5
  16. package/esm/simple/room/Room.js +24 -5
  17. package/esm/simple/room/SipRoom.js +24 -5
  18. package/esm/simple/room/Stream.js +24 -5
  19. package/esm/simple/room/__tests__/RemoteParticipant.test.js +24 -5
  20. package/esm/simple/utils.js +24 -5
  21. package/esm/web-rtc-client.js +1 -1
  22. package/lib/__tests__/web-rtc-client.test.js +1 -1
  23. package/lib/checker/Checker.js +1 -1
  24. package/lib/checker/checks/index.js +1 -1
  25. package/lib/checker/checks/webrtc-transport.js +1 -1
  26. package/lib/checker/checks/webrtc.js +1 -1
  27. package/lib/domain/Phone/WebRTCPhone.js +23 -4
  28. package/lib/index.js +24 -5
  29. package/lib/simple/Auth.js +24 -5
  30. package/lib/simple/Configuration.js +24 -5
  31. package/lib/simple/Phone.js +24 -5
  32. package/lib/simple/index.js +24 -5
  33. package/lib/simple/room/LocalParticipant.js +24 -5
  34. package/lib/simple/room/Participant.js +24 -5
  35. package/lib/simple/room/RemoteParticipant.js +24 -5
  36. package/lib/simple/room/Room.js +24 -5
  37. package/lib/simple/room/SipRoom.js +24 -5
  38. package/lib/simple/room/Stream.js +24 -5
  39. package/lib/simple/room/__tests__/RemoteParticipant.test.js +24 -5
  40. package/lib/simple/utils.js +24 -5
  41. package/lib/web-rtc-client.js +1 -1
  42. package/package.json +1 -1
  43. package/src/domain/Phone/WebRTCPhone.js +23 -4
  44. package/src/web-rtc-client.js +1 -1
@@ -6663,7 +6663,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6663
6663
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6664
6664
  class CanceledCallError extends Error {}
6665
6665
 
6666
- const MAX_REGISTER_TRIES = 10;
6666
+ const MAX_REGISTER_TRIES = 5;
6667
6667
 
6668
6668
 
6669
6669
 
@@ -9626,6 +9626,12 @@ class WebRTCPhone extends Emitter {
9626
9626
  return Promise.resolve(null);
9627
9627
  }
9628
9628
 
9629
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
9630
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
9631
+ logger$7.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
9632
+ return Promise.resolve(null);
9633
+ }
9634
+
9629
9635
  if (callSession.getId() in this.acceptedSessions) {
9630
9636
  logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9631
9637
  return Promise.resolve(callSession.sipCallId);
@@ -10250,9 +10256,17 @@ class WebRTCPhone extends Emitter {
10250
10256
  });
10251
10257
 
10252
10258
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10253
- logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10259
+ const sessionId = this.getSipSessionId(sipSession);
10260
+ const hasSession = sessionId in this.callSessions;
10261
+
10262
+ logger$7.info('WebRTC call accepted', { sipId: sessionId, hasSession });
10263
+
10264
+ if (!hasSession) {
10265
+ logger$7.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
10266
+ return;
10267
+ }
10254
10268
 
10255
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10269
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
10256
10270
 
10257
10271
  if (this.audioOutputDeviceId) {
10258
10272
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -10388,9 +10402,14 @@ class WebRTCPhone extends Emitter {
10388
10402
  return this.client.getSipSessionId(sipSession);
10389
10403
  }
10390
10404
 
10391
- _updateCallSession(callSession ) {
10405
+ getSipSessionIdFromCallSession(callSession ) {
10392
10406
  const sipSession = this.findSipSession(callSession);
10393
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10407
+
10408
+ return sipSession ? this.getSipSessionId(sipSession) : null;
10409
+ }
10410
+
10411
+ _updateCallSession(callSession ) {
10412
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10394
10413
 
10395
10414
  if (sipSessionId) {
10396
10415
  this.callSessions[sipSessionId] = callSession;
@@ -6663,7 +6663,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6663
6663
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6664
6664
  class CanceledCallError extends Error {}
6665
6665
 
6666
- const MAX_REGISTER_TRIES = 10;
6666
+ const MAX_REGISTER_TRIES = 5;
6667
6667
 
6668
6668
 
6669
6669
 
@@ -9626,6 +9626,12 @@ class WebRTCPhone extends Emitter {
9626
9626
  return Promise.resolve(null);
9627
9627
  }
9628
9628
 
9629
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
9630
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
9631
+ logger$7.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
9632
+ return Promise.resolve(null);
9633
+ }
9634
+
9629
9635
  if (callSession.getId() in this.acceptedSessions) {
9630
9636
  logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9631
9637
  return Promise.resolve(callSession.sipCallId);
@@ -10250,9 +10256,17 @@ class WebRTCPhone extends Emitter {
10250
10256
  });
10251
10257
 
10252
10258
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10253
- logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10259
+ const sessionId = this.getSipSessionId(sipSession);
10260
+ const hasSession = sessionId in this.callSessions;
10261
+
10262
+ logger$7.info('WebRTC call accepted', { sipId: sessionId, hasSession });
10263
+
10264
+ if (!hasSession) {
10265
+ logger$7.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
10266
+ return;
10267
+ }
10254
10268
 
10255
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10269
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
10256
10270
 
10257
10271
  if (this.audioOutputDeviceId) {
10258
10272
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -10388,9 +10402,14 @@ class WebRTCPhone extends Emitter {
10388
10402
  return this.client.getSipSessionId(sipSession);
10389
10403
  }
10390
10404
 
10391
- _updateCallSession(callSession ) {
10405
+ getSipSessionIdFromCallSession(callSession ) {
10392
10406
  const sipSession = this.findSipSession(callSession);
10393
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10407
+
10408
+ return sipSession ? this.getSipSessionId(sipSession) : null;
10409
+ }
10410
+
10411
+ _updateCallSession(callSession ) {
10412
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10394
10413
 
10395
10414
  if (sipSessionId) {
10396
10415
  this.callSessions[sipSessionId] = callSession;
@@ -6663,7 +6663,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6663
6663
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6664
6664
  class CanceledCallError extends Error {}
6665
6665
 
6666
- const MAX_REGISTER_TRIES = 10;
6666
+ const MAX_REGISTER_TRIES = 5;
6667
6667
 
6668
6668
 
6669
6669
 
@@ -9626,6 +9626,12 @@ class WebRTCPhone extends Emitter {
9626
9626
  return Promise.resolve(null);
9627
9627
  }
9628
9628
 
9629
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
9630
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
9631
+ logger$7.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
9632
+ return Promise.resolve(null);
9633
+ }
9634
+
9629
9635
  if (callSession.getId() in this.acceptedSessions) {
9630
9636
  logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9631
9637
  return Promise.resolve(callSession.sipCallId);
@@ -10250,9 +10256,17 @@ class WebRTCPhone extends Emitter {
10250
10256
  });
10251
10257
 
10252
10258
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10253
- logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10259
+ const sessionId = this.getSipSessionId(sipSession);
10260
+ const hasSession = sessionId in this.callSessions;
10261
+
10262
+ logger$7.info('WebRTC call accepted', { sipId: sessionId, hasSession });
10263
+
10264
+ if (!hasSession) {
10265
+ logger$7.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
10266
+ return;
10267
+ }
10254
10268
 
10255
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10269
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
10256
10270
 
10257
10271
  if (this.audioOutputDeviceId) {
10258
10272
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -10388,9 +10402,14 @@ class WebRTCPhone extends Emitter {
10388
10402
  return this.client.getSipSessionId(sipSession);
10389
10403
  }
10390
10404
 
10391
- _updateCallSession(callSession ) {
10405
+ getSipSessionIdFromCallSession(callSession ) {
10392
10406
  const sipSession = this.findSipSession(callSession);
10393
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10407
+
10408
+ return sipSession ? this.getSipSessionId(sipSession) : null;
10409
+ }
10410
+
10411
+ _updateCallSession(callSession ) {
10412
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10394
10413
 
10395
10414
  if (sipSessionId) {
10396
10415
  this.callSessions[sipSessionId] = callSession;
@@ -6663,7 +6663,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6663
6663
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6664
6664
  class CanceledCallError extends Error {}
6665
6665
 
6666
- const MAX_REGISTER_TRIES = 10;
6666
+ const MAX_REGISTER_TRIES = 5;
6667
6667
 
6668
6668
 
6669
6669
 
@@ -9626,6 +9626,12 @@ class WebRTCPhone extends Emitter {
9626
9626
  return Promise.resolve(null);
9627
9627
  }
9628
9628
 
9629
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
9630
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
9631
+ logger$7.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
9632
+ return Promise.resolve(null);
9633
+ }
9634
+
9629
9635
  if (callSession.getId() in this.acceptedSessions) {
9630
9636
  logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9631
9637
  return Promise.resolve(callSession.sipCallId);
@@ -10250,9 +10256,17 @@ class WebRTCPhone extends Emitter {
10250
10256
  });
10251
10257
 
10252
10258
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10253
- logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10259
+ const sessionId = this.getSipSessionId(sipSession);
10260
+ const hasSession = sessionId in this.callSessions;
10261
+
10262
+ logger$7.info('WebRTC call accepted', { sipId: sessionId, hasSession });
10263
+
10264
+ if (!hasSession) {
10265
+ logger$7.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
10266
+ return;
10267
+ }
10254
10268
 
10255
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10269
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
10256
10270
 
10257
10271
  if (this.audioOutputDeviceId) {
10258
10272
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -10388,9 +10402,14 @@ class WebRTCPhone extends Emitter {
10388
10402
  return this.client.getSipSessionId(sipSession);
10389
10403
  }
10390
10404
 
10391
- _updateCallSession(callSession ) {
10405
+ getSipSessionIdFromCallSession(callSession ) {
10392
10406
  const sipSession = this.findSipSession(callSession);
10393
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10407
+
10408
+ return sipSession ? this.getSipSessionId(sipSession) : null;
10409
+ }
10410
+
10411
+ _updateCallSession(callSession ) {
10412
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10394
10413
 
10395
10414
  if (sipSessionId) {
10396
10415
  this.callSessions[sipSessionId] = callSession;
@@ -5365,7 +5365,7 @@ const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
5365
5365
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
5366
5366
  class CanceledCallError extends Error {}
5367
5367
 
5368
- const MAX_REGISTER_TRIES = 10;
5368
+ const MAX_REGISTER_TRIES = 5;
5369
5369
 
5370
5370
 
5371
5371
 
@@ -5371,7 +5371,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
5371
5371
  const ON_DISCONNECTED = 'onDisconnected';
5372
5372
  class CanceledCallError extends Error {}
5373
5373
 
5374
- const MAX_REGISTER_TRIES = 10;
5374
+ const MAX_REGISTER_TRIES = 5;
5375
5375
 
5376
5376
 
5377
5377
 
@@ -5957,7 +5957,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
5957
5957
  const ON_DISCONNECTED = 'onDisconnected';
5958
5958
  class CanceledCallError extends Error {}
5959
5959
 
5960
- const MAX_REGISTER_TRIES = 10;
5960
+ const MAX_REGISTER_TRIES = 5;
5961
5961
 
5962
5962
 
5963
5963
 
@@ -5957,7 +5957,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
5957
5957
  const ON_DISCONNECTED = 'onDisconnected';
5958
5958
  class CanceledCallError extends Error {}
5959
5959
 
5960
- const MAX_REGISTER_TRIES = 10;
5960
+ const MAX_REGISTER_TRIES = 5;
5961
5961
 
5962
5962
 
5963
5963
 
@@ -5371,7 +5371,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
5371
5371
  const ON_DISCONNECTED = 'onDisconnected';
5372
5372
  class CanceledCallError extends Error {}
5373
5373
 
5374
- const MAX_REGISTER_TRIES = 10;
5374
+ const MAX_REGISTER_TRIES = 5;
5375
5375
 
5376
5376
 
5377
5377
 
@@ -5371,7 +5371,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
5371
5371
  const ON_DISCONNECTED = 'onDisconnected';
5372
5372
  class CanceledCallError extends Error {}
5373
5373
 
5374
- const MAX_REGISTER_TRIES = 10;
5374
+ const MAX_REGISTER_TRIES = 5;
5375
5375
 
5376
5376
 
5377
5377
 
@@ -1731,6 +1731,12 @@ class WebRTCPhone extends Emitter {
1731
1731
  return Promise.resolve(null);
1732
1732
  }
1733
1733
 
1734
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
1735
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
1736
+ logger.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
1737
+ return Promise.resolve(null);
1738
+ }
1739
+
1734
1740
  if (callSession.getId() in this.acceptedSessions) {
1735
1741
  logger.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
1736
1742
  return Promise.resolve(callSession.sipCallId);
@@ -2355,9 +2361,17 @@ class WebRTCPhone extends Emitter {
2355
2361
  });
2356
2362
 
2357
2363
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
2358
- logger.info('WebRTC call accepted', { sipId: sipSession.id });
2364
+ const sessionId = this.getSipSessionId(sipSession);
2365
+ const hasSession = sessionId in this.callSessions;
2366
+
2367
+ logger.info('WebRTC call accepted', { sipId: sessionId, hasSession });
2368
+
2369
+ if (!hasSession) {
2370
+ logger.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
2371
+ return;
2372
+ }
2359
2373
 
2360
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
2374
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
2361
2375
 
2362
2376
  if (this.audioOutputDeviceId) {
2363
2377
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -2493,9 +2507,14 @@ class WebRTCPhone extends Emitter {
2493
2507
  return this.client.getSipSessionId(sipSession);
2494
2508
  }
2495
2509
 
2496
- _updateCallSession(callSession ) {
2510
+ getSipSessionIdFromCallSession(callSession ) {
2497
2511
  const sipSession = this.findSipSession(callSession);
2498
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
2512
+
2513
+ return sipSession ? this.getSipSessionId(sipSession) : null;
2514
+ }
2515
+
2516
+ _updateCallSession(callSession ) {
2517
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
2499
2518
 
2500
2519
  if (sipSessionId) {
2501
2520
  this.callSessions[sipSessionId] = callSession;
package/lib/index.js CHANGED
@@ -6236,7 +6236,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6236
6236
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6237
6237
  class CanceledCallError extends Error {}
6238
6238
 
6239
- const MAX_REGISTER_TRIES = 10;
6239
+ const MAX_REGISTER_TRIES = 5;
6240
6240
 
6241
6241
 
6242
6242
 
@@ -10100,6 +10100,12 @@ class WebRTCPhone extends Emitter {
10100
10100
  return Promise.resolve(null);
10101
10101
  }
10102
10102
 
10103
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10104
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
10105
+ logger$7.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
10106
+ return Promise.resolve(null);
10107
+ }
10108
+
10103
10109
  if (callSession.getId() in this.acceptedSessions) {
10104
10110
  logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
10105
10111
  return Promise.resolve(callSession.sipCallId);
@@ -10724,9 +10730,17 @@ class WebRTCPhone extends Emitter {
10724
10730
  });
10725
10731
 
10726
10732
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10727
- logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10733
+ const sessionId = this.getSipSessionId(sipSession);
10734
+ const hasSession = sessionId in this.callSessions;
10735
+
10736
+ logger$7.info('WebRTC call accepted', { sipId: sessionId, hasSession });
10737
+
10738
+ if (!hasSession) {
10739
+ logger$7.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
10740
+ return;
10741
+ }
10728
10742
 
10729
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10743
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
10730
10744
 
10731
10745
  if (this.audioOutputDeviceId) {
10732
10746
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -10862,9 +10876,14 @@ class WebRTCPhone extends Emitter {
10862
10876
  return this.client.getSipSessionId(sipSession);
10863
10877
  }
10864
10878
 
10865
- _updateCallSession(callSession ) {
10879
+ getSipSessionIdFromCallSession(callSession ) {
10866
10880
  const sipSession = this.findSipSession(callSession);
10867
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10881
+
10882
+ return sipSession ? this.getSipSessionId(sipSession) : null;
10883
+ }
10884
+
10885
+ _updateCallSession(callSession ) {
10886
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10868
10887
 
10869
10888
  if (sipSessionId) {
10870
10889
  this.callSessions[sipSessionId] = callSession;
@@ -6411,7 +6411,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6411
6411
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6412
6412
  class CanceledCallError extends Error {}
6413
6413
 
6414
- const MAX_REGISTER_TRIES = 10;
6414
+ const MAX_REGISTER_TRIES = 5;
6415
6415
 
6416
6416
 
6417
6417
 
@@ -9374,6 +9374,12 @@ class WebRTCPhone extends Emitter {
9374
9374
  return Promise.resolve(null);
9375
9375
  }
9376
9376
 
9377
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
9378
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
9379
+ logger$8.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
9380
+ return Promise.resolve(null);
9381
+ }
9382
+
9377
9383
  if (callSession.getId() in this.acceptedSessions) {
9378
9384
  logger$8.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9379
9385
  return Promise.resolve(callSession.sipCallId);
@@ -9998,9 +10004,17 @@ class WebRTCPhone extends Emitter {
9998
10004
  });
9999
10005
 
10000
10006
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10001
- logger$8.info('WebRTC call accepted', { sipId: sipSession.id });
10007
+ const sessionId = this.getSipSessionId(sipSession);
10008
+ const hasSession = sessionId in this.callSessions;
10009
+
10010
+ logger$8.info('WebRTC call accepted', { sipId: sessionId, hasSession });
10011
+
10012
+ if (!hasSession) {
10013
+ logger$8.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
10014
+ return;
10015
+ }
10002
10016
 
10003
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10017
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
10004
10018
 
10005
10019
  if (this.audioOutputDeviceId) {
10006
10020
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -10136,9 +10150,14 @@ class WebRTCPhone extends Emitter {
10136
10150
  return this.client.getSipSessionId(sipSession);
10137
10151
  }
10138
10152
 
10139
- _updateCallSession(callSession ) {
10153
+ getSipSessionIdFromCallSession(callSession ) {
10140
10154
  const sipSession = this.findSipSession(callSession);
10141
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10155
+
10156
+ return sipSession ? this.getSipSessionId(sipSession) : null;
10157
+ }
10158
+
10159
+ _updateCallSession(callSession ) {
10160
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10142
10161
 
10143
10162
  if (sipSessionId) {
10144
10163
  this.callSessions[sipSessionId] = callSession;
@@ -6409,7 +6409,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6409
6409
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6410
6410
  class CanceledCallError extends Error {}
6411
6411
 
6412
- const MAX_REGISTER_TRIES = 10;
6412
+ const MAX_REGISTER_TRIES = 5;
6413
6413
 
6414
6414
 
6415
6415
 
@@ -9372,6 +9372,12 @@ class WebRTCPhone extends Emitter {
9372
9372
  return Promise.resolve(null);
9373
9373
  }
9374
9374
 
9375
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
9376
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
9377
+ logger$8.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
9378
+ return Promise.resolve(null);
9379
+ }
9380
+
9375
9381
  if (callSession.getId() in this.acceptedSessions) {
9376
9382
  logger$8.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9377
9383
  return Promise.resolve(callSession.sipCallId);
@@ -9996,9 +10002,17 @@ class WebRTCPhone extends Emitter {
9996
10002
  });
9997
10003
 
9998
10004
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
9999
- logger$8.info('WebRTC call accepted', { sipId: sipSession.id });
10005
+ const sessionId = this.getSipSessionId(sipSession);
10006
+ const hasSession = sessionId in this.callSessions;
10007
+
10008
+ logger$8.info('WebRTC call accepted', { sipId: sessionId, hasSession });
10009
+
10010
+ if (!hasSession) {
10011
+ logger$8.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
10012
+ return;
10013
+ }
10000
10014
 
10001
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10015
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
10002
10016
 
10003
10017
  if (this.audioOutputDeviceId) {
10004
10018
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -10134,9 +10148,14 @@ class WebRTCPhone extends Emitter {
10134
10148
  return this.client.getSipSessionId(sipSession);
10135
10149
  }
10136
10150
 
10137
- _updateCallSession(callSession ) {
10151
+ getSipSessionIdFromCallSession(callSession ) {
10138
10152
  const sipSession = this.findSipSession(callSession);
10139
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10153
+
10154
+ return sipSession ? this.getSipSessionId(sipSession) : null;
10155
+ }
10156
+
10157
+ _updateCallSession(callSession ) {
10158
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10140
10159
 
10141
10160
  if (sipSessionId) {
10142
10161
  this.callSessions[sipSessionId] = callSession;
@@ -6409,7 +6409,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6409
6409
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6410
6410
  class CanceledCallError extends Error {}
6411
6411
 
6412
- const MAX_REGISTER_TRIES = 10;
6412
+ const MAX_REGISTER_TRIES = 5;
6413
6413
 
6414
6414
 
6415
6415
 
@@ -9372,6 +9372,12 @@ class WebRTCPhone extends Emitter {
9372
9372
  return Promise.resolve(null);
9373
9373
  }
9374
9374
 
9375
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
9376
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
9377
+ logger$8.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
9378
+ return Promise.resolve(null);
9379
+ }
9380
+
9375
9381
  if (callSession.getId() in this.acceptedSessions) {
9376
9382
  logger$8.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9377
9383
  return Promise.resolve(callSession.sipCallId);
@@ -9996,9 +10002,17 @@ class WebRTCPhone extends Emitter {
9996
10002
  });
9997
10003
 
9998
10004
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
9999
- logger$8.info('WebRTC call accepted', { sipId: sipSession.id });
10005
+ const sessionId = this.getSipSessionId(sipSession);
10006
+ const hasSession = sessionId in this.callSessions;
10007
+
10008
+ logger$8.info('WebRTC call accepted', { sipId: sessionId, hasSession });
10009
+
10010
+ if (!hasSession) {
10011
+ logger$8.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
10012
+ return;
10013
+ }
10000
10014
 
10001
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10015
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
10002
10016
 
10003
10017
  if (this.audioOutputDeviceId) {
10004
10018
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -10134,9 +10148,14 @@ class WebRTCPhone extends Emitter {
10134
10148
  return this.client.getSipSessionId(sipSession);
10135
10149
  }
10136
10150
 
10137
- _updateCallSession(callSession ) {
10151
+ getSipSessionIdFromCallSession(callSession ) {
10138
10152
  const sipSession = this.findSipSession(callSession);
10139
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10153
+
10154
+ return sipSession ? this.getSipSessionId(sipSession) : null;
10155
+ }
10156
+
10157
+ _updateCallSession(callSession ) {
10158
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10140
10159
 
10141
10160
  if (sipSessionId) {
10142
10161
  this.callSessions[sipSessionId] = callSession;
@@ -6673,7 +6673,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6673
6673
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6674
6674
  class CanceledCallError extends Error {}
6675
6675
 
6676
- const MAX_REGISTER_TRIES = 10;
6676
+ const MAX_REGISTER_TRIES = 5;
6677
6677
 
6678
6678
 
6679
6679
 
@@ -9636,6 +9636,12 @@ class WebRTCPhone extends Emitter {
9636
9636
  return Promise.resolve(null);
9637
9637
  }
9638
9638
 
9639
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
9640
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
9641
+ logger$7.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
9642
+ return Promise.resolve(null);
9643
+ }
9644
+
9639
9645
  if (callSession.getId() in this.acceptedSessions) {
9640
9646
  logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9641
9647
  return Promise.resolve(callSession.sipCallId);
@@ -10260,9 +10266,17 @@ class WebRTCPhone extends Emitter {
10260
10266
  });
10261
10267
 
10262
10268
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10263
- logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10269
+ const sessionId = this.getSipSessionId(sipSession);
10270
+ const hasSession = sessionId in this.callSessions;
10271
+
10272
+ logger$7.info('WebRTC call accepted', { sipId: sessionId, hasSession });
10273
+
10274
+ if (!hasSession) {
10275
+ logger$7.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
10276
+ return;
10277
+ }
10264
10278
 
10265
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10279
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
10266
10280
 
10267
10281
  if (this.audioOutputDeviceId) {
10268
10282
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -10398,9 +10412,14 @@ class WebRTCPhone extends Emitter {
10398
10412
  return this.client.getSipSessionId(sipSession);
10399
10413
  }
10400
10414
 
10401
- _updateCallSession(callSession ) {
10415
+ getSipSessionIdFromCallSession(callSession ) {
10402
10416
  const sipSession = this.findSipSession(callSession);
10403
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10417
+
10418
+ return sipSession ? this.getSipSessionId(sipSession) : null;
10419
+ }
10420
+
10421
+ _updateCallSession(callSession ) {
10422
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10404
10423
 
10405
10424
  if (sipSessionId) {
10406
10425
  this.callSessions[sipSessionId] = callSession;