@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
@@ -5362,7 +5362,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
5362
5362
  const ON_DISCONNECTED = 'onDisconnected';
5363
5363
  class CanceledCallError extends Error {}
5364
5364
 
5365
- const MAX_REGISTER_TRIES = 10;
5365
+ const MAX_REGISTER_TRIES = 5;
5366
5366
 
5367
5367
 
5368
5368
 
@@ -5947,7 +5947,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
5947
5947
  const ON_DISCONNECTED = 'onDisconnected';
5948
5948
  class CanceledCallError extends Error {}
5949
5949
 
5950
- const MAX_REGISTER_TRIES = 10;
5950
+ const MAX_REGISTER_TRIES = 5;
5951
5951
 
5952
5952
 
5953
5953
 
@@ -5947,7 +5947,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
5947
5947
  const ON_DISCONNECTED = 'onDisconnected';
5948
5948
  class CanceledCallError extends Error {}
5949
5949
 
5950
- const MAX_REGISTER_TRIES = 10;
5950
+ const MAX_REGISTER_TRIES = 5;
5951
5951
 
5952
5952
 
5953
5953
 
@@ -5362,7 +5362,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
5362
5362
  const ON_DISCONNECTED = 'onDisconnected';
5363
5363
  class CanceledCallError extends Error {}
5364
5364
 
5365
- const MAX_REGISTER_TRIES = 10;
5365
+ const MAX_REGISTER_TRIES = 5;
5366
5366
 
5367
5367
 
5368
5368
 
@@ -5362,7 +5362,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
5362
5362
  const ON_DISCONNECTED = 'onDisconnected';
5363
5363
  class CanceledCallError extends Error {}
5364
5364
 
5365
- const MAX_REGISTER_TRIES = 10;
5365
+ const MAX_REGISTER_TRIES = 5;
5366
5366
 
5367
5367
 
5368
5368
 
@@ -1722,6 +1722,12 @@ class WebRTCPhone extends Emitter {
1722
1722
  return Promise.resolve(null);
1723
1723
  }
1724
1724
 
1725
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
1726
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
1727
+ logger.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
1728
+ return Promise.resolve(null);
1729
+ }
1730
+
1725
1731
  if (callSession.getId() in this.acceptedSessions) {
1726
1732
  logger.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
1727
1733
  return Promise.resolve(callSession.sipCallId);
@@ -2346,9 +2352,17 @@ class WebRTCPhone extends Emitter {
2346
2352
  });
2347
2353
 
2348
2354
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
2349
- logger.info('WebRTC call accepted', { sipId: sipSession.id });
2355
+ const sessionId = this.getSipSessionId(sipSession);
2356
+ const hasSession = sessionId in this.callSessions;
2357
+
2358
+ logger.info('WebRTC call accepted', { sipId: sessionId, hasSession });
2359
+
2360
+ if (!hasSession) {
2361
+ logger.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
2362
+ return;
2363
+ }
2350
2364
 
2351
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
2365
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
2352
2366
 
2353
2367
  if (this.audioOutputDeviceId) {
2354
2368
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -2484,9 +2498,14 @@ class WebRTCPhone extends Emitter {
2484
2498
  return this.client.getSipSessionId(sipSession);
2485
2499
  }
2486
2500
 
2487
- _updateCallSession(callSession ) {
2501
+ getSipSessionIdFromCallSession(callSession ) {
2488
2502
  const sipSession = this.findSipSession(callSession);
2489
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
2503
+
2504
+ return sipSession ? this.getSipSessionId(sipSession) : null;
2505
+ }
2506
+
2507
+ _updateCallSession(callSession ) {
2508
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
2490
2509
 
2491
2510
  if (sipSessionId) {
2492
2511
  this.callSessions[sipSessionId] = callSession;
package/esm/index.js CHANGED
@@ -6225,7 +6225,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6225
6225
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6226
6226
  class CanceledCallError extends Error {}
6227
6227
 
6228
- const MAX_REGISTER_TRIES = 10;
6228
+ const MAX_REGISTER_TRIES = 5;
6229
6229
 
6230
6230
 
6231
6231
 
@@ -10089,6 +10089,12 @@ class WebRTCPhone extends Emitter {
10089
10089
  return Promise.resolve(null);
10090
10090
  }
10091
10091
 
10092
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10093
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
10094
+ logger$7.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
10095
+ return Promise.resolve(null);
10096
+ }
10097
+
10092
10098
  if (callSession.getId() in this.acceptedSessions) {
10093
10099
  logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
10094
10100
  return Promise.resolve(callSession.sipCallId);
@@ -10713,9 +10719,17 @@ class WebRTCPhone extends Emitter {
10713
10719
  });
10714
10720
 
10715
10721
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10716
- logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10722
+ const sessionId = this.getSipSessionId(sipSession);
10723
+ const hasSession = sessionId in this.callSessions;
10724
+
10725
+ logger$7.info('WebRTC call accepted', { sipId: sessionId, hasSession });
10726
+
10727
+ if (!hasSession) {
10728
+ logger$7.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
10729
+ return;
10730
+ }
10717
10731
 
10718
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10732
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
10719
10733
 
10720
10734
  if (this.audioOutputDeviceId) {
10721
10735
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -10851,9 +10865,14 @@ class WebRTCPhone extends Emitter {
10851
10865
  return this.client.getSipSessionId(sipSession);
10852
10866
  }
10853
10867
 
10854
- _updateCallSession(callSession ) {
10868
+ getSipSessionIdFromCallSession(callSession ) {
10855
10869
  const sipSession = this.findSipSession(callSession);
10856
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10870
+
10871
+ return sipSession ? this.getSipSessionId(sipSession) : null;
10872
+ }
10873
+
10874
+ _updateCallSession(callSession ) {
10875
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10857
10876
 
10858
10877
  if (sipSessionId) {
10859
10878
  this.callSessions[sipSessionId] = callSession;
@@ -6399,7 +6399,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6399
6399
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6400
6400
  class CanceledCallError extends Error {}
6401
6401
 
6402
- const MAX_REGISTER_TRIES = 10;
6402
+ const MAX_REGISTER_TRIES = 5;
6403
6403
 
6404
6404
 
6405
6405
 
@@ -9362,6 +9362,12 @@ class WebRTCPhone extends Emitter {
9362
9362
  return Promise.resolve(null);
9363
9363
  }
9364
9364
 
9365
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
9366
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
9367
+ logger$8.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
9368
+ return Promise.resolve(null);
9369
+ }
9370
+
9365
9371
  if (callSession.getId() in this.acceptedSessions) {
9366
9372
  logger$8.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9367
9373
  return Promise.resolve(callSession.sipCallId);
@@ -9986,9 +9992,17 @@ class WebRTCPhone extends Emitter {
9986
9992
  });
9987
9993
 
9988
9994
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
9989
- logger$8.info('WebRTC call accepted', { sipId: sipSession.id });
9995
+ const sessionId = this.getSipSessionId(sipSession);
9996
+ const hasSession = sessionId in this.callSessions;
9997
+
9998
+ logger$8.info('WebRTC call accepted', { sipId: sessionId, hasSession });
9999
+
10000
+ if (!hasSession) {
10001
+ logger$8.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
10002
+ return;
10003
+ }
9990
10004
 
9991
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10005
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
9992
10006
 
9993
10007
  if (this.audioOutputDeviceId) {
9994
10008
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -10124,9 +10138,14 @@ class WebRTCPhone extends Emitter {
10124
10138
  return this.client.getSipSessionId(sipSession);
10125
10139
  }
10126
10140
 
10127
- _updateCallSession(callSession ) {
10141
+ getSipSessionIdFromCallSession(callSession ) {
10128
10142
  const sipSession = this.findSipSession(callSession);
10129
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10143
+
10144
+ return sipSession ? this.getSipSessionId(sipSession) : null;
10145
+ }
10146
+
10147
+ _updateCallSession(callSession ) {
10148
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10130
10149
 
10131
10150
  if (sipSessionId) {
10132
10151
  this.callSessions[sipSessionId] = callSession;
@@ -6399,7 +6399,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6399
6399
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6400
6400
  class CanceledCallError extends Error {}
6401
6401
 
6402
- const MAX_REGISTER_TRIES = 10;
6402
+ const MAX_REGISTER_TRIES = 5;
6403
6403
 
6404
6404
 
6405
6405
 
@@ -9362,6 +9362,12 @@ class WebRTCPhone extends Emitter {
9362
9362
  return Promise.resolve(null);
9363
9363
  }
9364
9364
 
9365
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
9366
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
9367
+ logger$8.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
9368
+ return Promise.resolve(null);
9369
+ }
9370
+
9365
9371
  if (callSession.getId() in this.acceptedSessions) {
9366
9372
  logger$8.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9367
9373
  return Promise.resolve(callSession.sipCallId);
@@ -9986,9 +9992,17 @@ class WebRTCPhone extends Emitter {
9986
9992
  });
9987
9993
 
9988
9994
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
9989
- logger$8.info('WebRTC call accepted', { sipId: sipSession.id });
9995
+ const sessionId = this.getSipSessionId(sipSession);
9996
+ const hasSession = sessionId in this.callSessions;
9997
+
9998
+ logger$8.info('WebRTC call accepted', { sipId: sessionId, hasSession });
9999
+
10000
+ if (!hasSession) {
10001
+ logger$8.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
10002
+ return;
10003
+ }
9990
10004
 
9991
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10005
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
9992
10006
 
9993
10007
  if (this.audioOutputDeviceId) {
9994
10008
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -10124,9 +10138,14 @@ class WebRTCPhone extends Emitter {
10124
10138
  return this.client.getSipSessionId(sipSession);
10125
10139
  }
10126
10140
 
10127
- _updateCallSession(callSession ) {
10141
+ getSipSessionIdFromCallSession(callSession ) {
10128
10142
  const sipSession = this.findSipSession(callSession);
10129
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10143
+
10144
+ return sipSession ? this.getSipSessionId(sipSession) : null;
10145
+ }
10146
+
10147
+ _updateCallSession(callSession ) {
10148
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10130
10149
 
10131
10150
  if (sipSessionId) {
10132
10151
  this.callSessions[sipSessionId] = callSession;
@@ -6399,7 +6399,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6399
6399
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6400
6400
  class CanceledCallError extends Error {}
6401
6401
 
6402
- const MAX_REGISTER_TRIES = 10;
6402
+ const MAX_REGISTER_TRIES = 5;
6403
6403
 
6404
6404
 
6405
6405
 
@@ -9362,6 +9362,12 @@ class WebRTCPhone extends Emitter {
9362
9362
  return Promise.resolve(null);
9363
9363
  }
9364
9364
 
9365
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
9366
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
9367
+ logger$8.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
9368
+ return Promise.resolve(null);
9369
+ }
9370
+
9365
9371
  if (callSession.getId() in this.acceptedSessions) {
9366
9372
  logger$8.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9367
9373
  return Promise.resolve(callSession.sipCallId);
@@ -9986,9 +9992,17 @@ class WebRTCPhone extends Emitter {
9986
9992
  });
9987
9993
 
9988
9994
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
9989
- logger$8.info('WebRTC call accepted', { sipId: sipSession.id });
9995
+ const sessionId = this.getSipSessionId(sipSession);
9996
+ const hasSession = sessionId in this.callSessions;
9997
+
9998
+ logger$8.info('WebRTC call accepted', { sipId: sessionId, hasSession });
9999
+
10000
+ if (!hasSession) {
10001
+ logger$8.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
10002
+ return;
10003
+ }
9990
10004
 
9991
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10005
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
9992
10006
 
9993
10007
  if (this.audioOutputDeviceId) {
9994
10008
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -10124,9 +10138,14 @@ class WebRTCPhone extends Emitter {
10124
10138
  return this.client.getSipSessionId(sipSession);
10125
10139
  }
10126
10140
 
10127
- _updateCallSession(callSession ) {
10141
+ getSipSessionIdFromCallSession(callSession ) {
10128
10142
  const sipSession = this.findSipSession(callSession);
10129
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10143
+
10144
+ return sipSession ? this.getSipSessionId(sipSession) : null;
10145
+ }
10146
+
10147
+ _updateCallSession(callSession ) {
10148
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10130
10149
 
10131
10150
  if (sipSessionId) {
10132
10151
  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;
@@ -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;