@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
@@ -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;
@@ -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;
@@ -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;
@@ -6675,7 +6675,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6675
6675
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6676
6676
  class CanceledCallError extends Error {}
6677
6677
 
6678
- const MAX_REGISTER_TRIES = 10;
6678
+ const MAX_REGISTER_TRIES = 5;
6679
6679
 
6680
6680
 
6681
6681
 
@@ -9638,6 +9638,12 @@ class WebRTCPhone extends Emitter {
9638
9638
  return Promise.resolve(null);
9639
9639
  }
9640
9640
 
9641
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
9642
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
9643
+ logger$7.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
9644
+ return Promise.resolve(null);
9645
+ }
9646
+
9641
9647
  if (callSession.getId() in this.acceptedSessions) {
9642
9648
  logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9643
9649
  return Promise.resolve(callSession.sipCallId);
@@ -10262,9 +10268,17 @@ class WebRTCPhone extends Emitter {
10262
10268
  });
10263
10269
 
10264
10270
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10265
- logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10271
+ const sessionId = this.getSipSessionId(sipSession);
10272
+ const hasSession = sessionId in this.callSessions;
10273
+
10274
+ logger$7.info('WebRTC call accepted', { sipId: sessionId, hasSession });
10275
+
10276
+ if (!hasSession) {
10277
+ logger$7.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
10278
+ return;
10279
+ }
10266
10280
 
10267
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10281
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
10268
10282
 
10269
10283
  if (this.audioOutputDeviceId) {
10270
10284
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -10400,9 +10414,14 @@ class WebRTCPhone extends Emitter {
10400
10414
  return this.client.getSipSessionId(sipSession);
10401
10415
  }
10402
10416
 
10403
- _updateCallSession(callSession ) {
10417
+ getSipSessionIdFromCallSession(callSession ) {
10404
10418
  const sipSession = this.findSipSession(callSession);
10405
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10419
+
10420
+ return sipSession ? this.getSipSessionId(sipSession) : null;
10421
+ }
10422
+
10423
+ _updateCallSession(callSession ) {
10424
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10406
10425
 
10407
10426
  if (sipSessionId) {
10408
10427
  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;
@@ -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;
@@ -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;
@@ -6675,7 +6675,7 @@ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6675
6675
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6676
6676
  class CanceledCallError extends Error {}
6677
6677
 
6678
- const MAX_REGISTER_TRIES = 10;
6678
+ const MAX_REGISTER_TRIES = 5;
6679
6679
 
6680
6680
 
6681
6681
 
@@ -9638,6 +9638,12 @@ class WebRTCPhone extends Emitter {
9638
9638
  return Promise.resolve(null);
9639
9639
  }
9640
9640
 
9641
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
9642
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
9643
+ logger$7.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
9644
+ return Promise.resolve(null);
9645
+ }
9646
+
9641
9647
  if (callSession.getId() in this.acceptedSessions) {
9642
9648
  logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9643
9649
  return Promise.resolve(callSession.sipCallId);
@@ -10262,9 +10268,17 @@ class WebRTCPhone extends Emitter {
10262
10268
  });
10263
10269
 
10264
10270
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10265
- logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10271
+ const sessionId = this.getSipSessionId(sipSession);
10272
+ const hasSession = sessionId in this.callSessions;
10273
+
10274
+ logger$7.info('WebRTC call accepted', { sipId: sessionId, hasSession });
10275
+
10276
+ if (!hasSession) {
10277
+ logger$7.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
10278
+ return;
10279
+ }
10266
10280
 
10267
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10281
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
10268
10282
 
10269
10283
  if (this.audioOutputDeviceId) {
10270
10284
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -10400,9 +10414,14 @@ class WebRTCPhone extends Emitter {
10400
10414
  return this.client.getSipSessionId(sipSession);
10401
10415
  }
10402
10416
 
10403
- _updateCallSession(callSession ) {
10417
+ getSipSessionIdFromCallSession(callSession ) {
10404
10418
  const sipSession = this.findSipSession(callSession);
10405
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10419
+
10420
+ return sipSession ? this.getSipSessionId(sipSession) : null;
10421
+ }
10422
+
10423
+ _updateCallSession(callSession ) {
10424
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
10406
10425
 
10407
10426
  if (sipSessionId) {
10408
10427
  this.callSessions[sipSessionId] = callSession;
@@ -5376,7 +5376,7 @@ const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
5376
5376
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
5377
5377
  class CanceledCallError extends Error {}
5378
5378
 
5379
- const MAX_REGISTER_TRIES = 10;
5379
+ const MAX_REGISTER_TRIES = 5;
5380
5380
 
5381
5381
 
5382
5382
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wazo/sdk",
3
- "version": "0.37.33",
3
+ "version": "0.37.34",
4
4
  "description": "Wazo's JavaScript Software Development Kit.",
5
5
  "main": "dist/wazo-sdk.js",
6
6
  "author": "Wazo (http://wazo.io)",
@@ -841,6 +841,12 @@ export default class WebRTCPhone extends Emitter implements Phone {
841
841
  return Promise.resolve(null);
842
842
  }
843
843
 
844
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
845
+ if (sipSessionId && !(sipSessionId in this.callSessions)) {
846
+ logger.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
847
+ return Promise.resolve(null);
848
+ }
849
+
844
850
  if (callSession.getId() in this.acceptedSessions) {
845
851
  logger.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
846
852
  return Promise.resolve(callSession.sipCallId);
@@ -1465,9 +1471,17 @@ export default class WebRTCPhone extends Emitter implements Phone {
1465
1471
  });
1466
1472
 
1467
1473
  this.client.on(this.client.ACCEPTED, (sipSession: Session) => {
1468
- logger.info('WebRTC call accepted', { sipId: sipSession.id });
1474
+ const sessionId = this.getSipSessionId(sipSession);
1475
+ const hasSession = sessionId in this.callSessions;
1476
+
1477
+ logger.info('WebRTC call accepted', { sipId: sessionId, hasSession });
1478
+
1479
+ if (!hasSession) {
1480
+ logger.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
1481
+ return;
1482
+ }
1469
1483
 
1470
- this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
1484
+ this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
1471
1485
 
1472
1486
  if (this.audioOutputDeviceId) {
1473
1487
  this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
@@ -1603,9 +1617,14 @@ export default class WebRTCPhone extends Emitter implements Phone {
1603
1617
  return this.client.getSipSessionId(sipSession);
1604
1618
  }
1605
1619
 
1606
- _updateCallSession(callSession: CallSession) {
1620
+ getSipSessionIdFromCallSession(callSession: CallSession) {
1607
1621
  const sipSession = this.findSipSession(callSession);
1608
- const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
1622
+
1623
+ return sipSession ? this.getSipSessionId(sipSession) : null;
1624
+ }
1625
+
1626
+ _updateCallSession(callSession: CallSession) {
1627
+ const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
1609
1628
 
1610
1629
  if (sipSessionId) {
1611
1630
  this.callSessions[sipSessionId] = callSession;
@@ -75,7 +75,7 @@ export const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
75
75
  export const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
76
76
  export class CanceledCallError extends Error {}
77
77
 
78
- const MAX_REGISTER_TRIES = 10;
78
+ const MAX_REGISTER_TRIES = 5;
79
79
 
80
80
  type MediaConfig = {
81
81
  audio: Object & boolean,