@wazo/sdk 0.37.20 → 0.37.21

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 (110) hide show
  1. package/dist/wazo-sdk.js +5 -5
  2. package/esm/__tests__/api-client.test.js +44 -5
  3. package/esm/__tests__/web-rtc-client.test.js +70 -15
  4. package/esm/api/agentd.js +25 -2
  5. package/esm/api/amid.js +25 -2
  6. package/esm/api/application.js +25 -2
  7. package/esm/api/auth.js +25 -2
  8. package/esm/api/call-logd.js +25 -2
  9. package/esm/api/calld.js +25 -2
  10. package/esm/api/chatd.js +25 -2
  11. package/esm/api/confd.js +44 -5
  12. package/esm/api/ctid-ng.js +25 -2
  13. package/esm/api/dird.js +25 -2
  14. package/esm/api/webhookd.js +25 -2
  15. package/esm/api-client.js +44 -5
  16. package/esm/checker/Checker.js +72 -15
  17. package/esm/checker/checks/aor.js +44 -5
  18. package/esm/checker/checks/api.js +44 -5
  19. package/esm/checker/checks/index.js +72 -15
  20. package/esm/checker/checks/wazo-websocket.js +27 -2
  21. package/esm/checker/checks/webrtc-transport.js +70 -15
  22. package/esm/checker/checks/webrtc.js +70 -15
  23. package/esm/domain/AdHocAPIConference.js +44 -5
  24. package/esm/domain/Features.js +44 -5
  25. package/esm/domain/Meeting.js +14 -1
  26. package/esm/domain/Phone/CTIPhone.js +44 -5
  27. package/esm/domain/Phone/WebRTCPhone.js +32 -3
  28. package/esm/index.js +85 -16
  29. package/esm/lib/WazoSessionDescriptionHandler.js +25 -2
  30. package/esm/service/CallApi.js +44 -5
  31. package/esm/service/IssueReporter.js +25 -2
  32. package/esm/service/__tests__/IssueReporter.test.js +25 -2
  33. package/esm/service/getApiClient.js +44 -5
  34. package/esm/simple/Auth.js +85 -16
  35. package/esm/simple/Configuration.js +85 -16
  36. package/esm/simple/Directory.js +44 -5
  37. package/esm/simple/Phone.js +85 -16
  38. package/esm/simple/Websocket.js +28 -2
  39. package/esm/simple/index.js +85 -16
  40. package/esm/simple/room/LocalParticipant.js +85 -16
  41. package/esm/simple/room/Participant.js +85 -16
  42. package/esm/simple/room/RemoteParticipant.js +85 -16
  43. package/esm/simple/room/Room.js +85 -16
  44. package/esm/simple/room/SipRoom.js +85 -16
  45. package/esm/simple/room/Stream.js +85 -16
  46. package/esm/simple/room/__tests__/RemoteParticipant.test.js +85 -16
  47. package/esm/simple/utils.js +85 -16
  48. package/esm/utils/__tests__/api-requester.test.js +25 -2
  49. package/esm/utils/api-requester.js +25 -2
  50. package/esm/web-rtc-client.js +70 -15
  51. package/esm/websocket-client.js +28 -3
  52. package/lib/__tests__/api-client.test.js +44 -5
  53. package/lib/__tests__/web-rtc-client.test.js +70 -15
  54. package/lib/api/agentd.js +25 -2
  55. package/lib/api/amid.js +25 -2
  56. package/lib/api/application.js +25 -2
  57. package/lib/api/auth.js +25 -2
  58. package/lib/api/call-logd.js +25 -2
  59. package/lib/api/calld.js +25 -2
  60. package/lib/api/chatd.js +25 -2
  61. package/lib/api/confd.js +44 -5
  62. package/lib/api/ctid-ng.js +25 -2
  63. package/lib/api/dird.js +25 -2
  64. package/lib/api/webhookd.js +25 -2
  65. package/lib/api-client.js +44 -5
  66. package/lib/checker/Checker.js +72 -15
  67. package/lib/checker/checks/aor.js +44 -5
  68. package/lib/checker/checks/api.js +44 -5
  69. package/lib/checker/checks/index.js +72 -15
  70. package/lib/checker/checks/wazo-websocket.js +27 -2
  71. package/lib/checker/checks/webrtc-transport.js +70 -15
  72. package/lib/checker/checks/webrtc.js +70 -15
  73. package/lib/domain/AdHocAPIConference.js +44 -5
  74. package/lib/domain/Features.js +44 -5
  75. package/lib/domain/Meeting.js +14 -1
  76. package/lib/domain/Phone/CTIPhone.js +44 -5
  77. package/lib/domain/Phone/WebRTCPhone.js +32 -3
  78. package/lib/index.js +85 -16
  79. package/lib/lib/WazoSessionDescriptionHandler.js +25 -2
  80. package/lib/service/CallApi.js +44 -5
  81. package/lib/service/IssueReporter.js +25 -2
  82. package/lib/service/__tests__/IssueReporter.test.js +25 -2
  83. package/lib/service/getApiClient.js +44 -5
  84. package/lib/simple/Auth.js +85 -16
  85. package/lib/simple/Configuration.js +85 -16
  86. package/lib/simple/Directory.js +44 -5
  87. package/lib/simple/Phone.js +85 -16
  88. package/lib/simple/Websocket.js +28 -2
  89. package/lib/simple/index.js +85 -16
  90. package/lib/simple/room/LocalParticipant.js +85 -16
  91. package/lib/simple/room/Participant.js +85 -16
  92. package/lib/simple/room/RemoteParticipant.js +85 -16
  93. package/lib/simple/room/Room.js +85 -16
  94. package/lib/simple/room/SipRoom.js +85 -16
  95. package/lib/simple/room/Stream.js +85 -16
  96. package/lib/simple/room/__tests__/RemoteParticipant.test.js +85 -16
  97. package/lib/simple/utils.js +85 -16
  98. package/lib/utils/__tests__/api-requester.test.js +25 -2
  99. package/lib/utils/api-requester.js +25 -2
  100. package/lib/web-rtc-client.js +70 -15
  101. package/lib/websocket-client.js +28 -2
  102. package/package.json +1 -1
  103. package/src/api/confd.js +5 -2
  104. package/src/domain/Meeting.js +14 -1
  105. package/src/domain/Phone/WebRTCPhone.js +7 -1
  106. package/src/service/IssueReporter.js +25 -2
  107. package/src/simple/Phone.js +5 -0
  108. package/src/types/WebSocketMessage.js +5 -1
  109. package/src/web-rtc-client.js +26 -10
  110. package/src/websocket-client.js +2 -0
@@ -1634,6 +1634,7 @@ class IssueReporter {
1634
1634
 
1635
1635
 
1636
1636
 
1637
+
1637
1638
 
1638
1639
  constructor() {
1639
1640
  addLevelsTo(this);
@@ -1645,12 +1646,17 @@ class IssueReporter {
1645
1646
  this.bufferTimeout = null;
1646
1647
  this._boundProcessBuffer = this._processBuffer.bind(this);
1647
1648
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
1649
+ this._callback = null;
1648
1650
  }
1649
1651
 
1650
1652
  init() {
1651
1653
  this._catchConsole();
1652
1654
  }
1653
1655
 
1656
+ setCallback(cb ) {
1657
+ this._callback = cb;
1658
+ }
1659
+
1654
1660
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
1655
1661
  this.remoteClientConfiguration = configuration;
1656
1662
  }
@@ -1686,6 +1692,7 @@ class IssueReporter {
1686
1692
 
1687
1693
  // Handle category label
1688
1694
  let category = null;
1695
+ let skipSendToRemote = false;
1689
1696
  let extra = {};
1690
1697
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
1691
1698
  category = args[0].split('=')[1];
@@ -1701,6 +1708,7 @@ class IssueReporter {
1701
1708
  errorMessage: lastArg.message,
1702
1709
  errorStack: lastArg.stack,
1703
1710
  errorType: lastArg.constructor.name,
1711
+ skipSendToRemote: lastArg.skipSendToRemote,
1704
1712
  };
1705
1713
  } else {
1706
1714
  extra = lastArg;
@@ -1709,6 +1717,11 @@ class IssueReporter {
1709
1717
  args.splice(1, 1);
1710
1718
  }
1711
1719
 
1720
+ if (extra.skipSendToRemote) {
1721
+ skipSendToRemote = true;
1722
+ delete extra.skipSendToRemote;
1723
+ }
1724
+
1712
1725
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
1713
1726
  const message = args.join(', ');
1714
1727
  let consoleMessage = message;
@@ -1729,7 +1742,13 @@ class IssueReporter {
1729
1742
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
1730
1743
  oldMethod.apply(oldMethod, [date, consoleMessage]);
1731
1744
 
1732
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
1745
+ if (this._callback) {
1746
+ this._callback(level, consoleMessage);
1747
+ }
1748
+
1749
+ if (!skipSendToRemote) {
1750
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
1751
+ }
1733
1752
  }
1734
1753
 
1735
1754
  logRequest(url , options , response , start ) {
@@ -1874,7 +1893,11 @@ class IssueReporter {
1874
1893
  },
1875
1894
  // $FlowFixMe
1876
1895
  body,
1877
- }).catch(() => {
1896
+ }).catch((e ) => {
1897
+ // $FlowFixMe
1898
+ e.skipSendToRemote = true;
1899
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
1900
+
1878
1901
  setTimeout(() => {
1879
1902
  if (isArray) {
1880
1903
  payload = payload.map(message => {
@@ -2633,11 +2656,24 @@ class Meeting {
2633
2656
  });
2634
2657
  }
2635
2658
 
2659
+ static parseMany(items ) {
2660
+ return items.map(plain => Meeting.parse(plain));
2661
+ }
2662
+
2636
2663
  static newFrom(meeting ) {
2637
2664
  return newFrom(meeting, Meeting);
2638
2665
  }
2639
2666
 
2640
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2667
+ constructor({
2668
+ uuid,
2669
+ name,
2670
+ guestSipAuthorization,
2671
+ ownerUuids,
2672
+ port,
2673
+ uri,
2674
+ number,
2675
+ persistent,
2676
+ } = {}) {
2641
2677
  this.guestSipAuthorization = guestSipAuthorization;
2642
2678
  this.uri = uri;
2643
2679
  this.name = name;
@@ -2723,8 +2759,11 @@ var confdMethods = (client , baseUrl ) => ({
2723
2759
  }
2724
2760
  },
2725
2761
 
2726
- createMyMeeting: (name ) =>
2727
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2762
+ getMyMeetings: () =>
2763
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2764
+
2765
+ createMyMeeting: (name , persistent ) =>
2766
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2728
2767
 
2729
2768
  deleteMyMeeting: (meetingUuid ) =>
2730
2769
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -6960,7 +6999,9 @@ class WebRTCClient extends Emitter {
6960
6999
  const inviteOptions = {
6961
7000
  requestDelegate: {
6962
7001
  onAccept: (response ) => {
6963
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
7002
+ if (session.sessionDescriptionHandler.peerConnection) {
7003
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
7004
+ }
6964
7005
  this._onAccepted(session, response.session, true);
6965
7006
  },
6966
7007
  onReject: (response ) => {
@@ -7832,6 +7873,16 @@ class WebRTCClient extends Emitter {
7832
7873
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7833
7874
  }
7834
7875
 
7876
+ // Useful in a react-native environment when remoteMediaStream is not updated
7877
+ getRemoteVideoStreamFromPc(sessionId ) {
7878
+ const pc = this.getPeerConnection(sessionId);
7879
+ if (!pc) {
7880
+ return null;
7881
+ }
7882
+
7883
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7884
+ }
7885
+
7835
7886
  hasVideo(sessionId ) {
7836
7887
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7837
7888
  }
@@ -8610,18 +8661,22 @@ class WebRTCClient extends Emitter {
8610
8661
  });
8611
8662
 
8612
8663
  networkStats.packetsLost = packetsLost;
8613
- networkStats.audioBytesSent = audioBytesSent;
8664
+ networkStats.totalAudioBytesSent = audioBytesSent;
8665
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8666
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8614
8667
  networkStats.audioBytesReceived = audioBytesReceived;
8615
- networkStats.videoBytesSent = videoBytesSent;
8616
- networkStats.videoBytesReceived = videoBytesReceived;
8668
+ networkStats.totalVideoBytesSent = videoBytesSent;
8669
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8670
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8671
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8672
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8617
8673
  networkStats.transportSent = transportSent;
8618
- networkStats.transportReceived = transportReceived;
8674
+ networkStats.totalTransportReceived = transportReceived;
8675
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8619
8676
 
8620
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8621
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8622
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8623
-
8624
- networkStats.bandwidth = bandwidth;
8677
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8678
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8679
+ + networkStats.transportSent;
8625
8680
 
8626
8681
  this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8627
8682
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -9032,9 +9087,11 @@ class WebRTCPhone extends Emitter {
9032
9087
  case SessionState.Terminated: {
9033
9088
  logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9034
9089
 
9090
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
9091
+ const callSession = this._createCallSession(sipSession);
9035
9092
  const wasCurrentSession = this._onCallTerminated(sipSession);
9036
9093
 
9037
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
9094
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
9038
9095
  }
9039
9096
  }
9040
9097
  });
@@ -9982,6 +10039,10 @@ class WebRTCPhone extends Emitter {
9982
10039
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9983
10040
  }
9984
10041
 
10042
+ getRemoteVideoStreamFromPc(callSession ) {
10043
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
10044
+ }
10045
+
9985
10046
  hasRemoteVideo(callSession ) {
9986
10047
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9987
10048
  }
@@ -10665,6 +10726,11 @@ class Phone extends Emitter {
10665
10726
  return this.getRemoteVideoStream(callSession);
10666
10727
  }
10667
10728
 
10729
+ // Useful in a react-native environment when remoteMediaStream is not updated
10730
+ getRemoteVideoStreamFromPc(callSession ) {
10731
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
10732
+ }
10733
+
10668
10734
  hasVideo(callSession ) {
10669
10735
  return this.phone ? this.phone.hasVideo(callSession) : false;
10670
10736
  }
@@ -10824,6 +10890,7 @@ const AGENT_PAUSED = 'agent_paused';
10824
10890
  const AGENT_UNPAUSED = 'agent_unpaused';
10825
10891
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10826
10892
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10893
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10827
10894
 
10828
10895
  const BLACKLIST_EVENTS = [
10829
10896
  CHAT_MESSAGE_SENT,
@@ -11174,6 +11241,7 @@ WebSocketClient.eventLists = [
11174
11241
  AGENT_UNPAUSED,
11175
11242
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11176
11243
  CONFERENCE_ADHOC_DELETED,
11244
+ MEETING_USER_PROGRESS,
11177
11245
  ];
11178
11246
 
11179
11247
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11244,6 +11312,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11244
11312
  AGENT_UNPAUSED: AGENT_UNPAUSED,
11245
11313
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11246
11314
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11315
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11247
11316
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11248
11317
  'default': WebSocketClient
11249
11318
  });
@@ -1634,6 +1634,7 @@ class IssueReporter {
1634
1634
 
1635
1635
 
1636
1636
 
1637
+
1637
1638
 
1638
1639
  constructor() {
1639
1640
  addLevelsTo(this);
@@ -1645,12 +1646,17 @@ class IssueReporter {
1645
1646
  this.bufferTimeout = null;
1646
1647
  this._boundProcessBuffer = this._processBuffer.bind(this);
1647
1648
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
1649
+ this._callback = null;
1648
1650
  }
1649
1651
 
1650
1652
  init() {
1651
1653
  this._catchConsole();
1652
1654
  }
1653
1655
 
1656
+ setCallback(cb ) {
1657
+ this._callback = cb;
1658
+ }
1659
+
1654
1660
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
1655
1661
  this.remoteClientConfiguration = configuration;
1656
1662
  }
@@ -1686,6 +1692,7 @@ class IssueReporter {
1686
1692
 
1687
1693
  // Handle category label
1688
1694
  let category = null;
1695
+ let skipSendToRemote = false;
1689
1696
  let extra = {};
1690
1697
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
1691
1698
  category = args[0].split('=')[1];
@@ -1701,6 +1708,7 @@ class IssueReporter {
1701
1708
  errorMessage: lastArg.message,
1702
1709
  errorStack: lastArg.stack,
1703
1710
  errorType: lastArg.constructor.name,
1711
+ skipSendToRemote: lastArg.skipSendToRemote,
1704
1712
  };
1705
1713
  } else {
1706
1714
  extra = lastArg;
@@ -1709,6 +1717,11 @@ class IssueReporter {
1709
1717
  args.splice(1, 1);
1710
1718
  }
1711
1719
 
1720
+ if (extra.skipSendToRemote) {
1721
+ skipSendToRemote = true;
1722
+ delete extra.skipSendToRemote;
1723
+ }
1724
+
1712
1725
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
1713
1726
  const message = args.join(', ');
1714
1727
  let consoleMessage = message;
@@ -1729,7 +1742,13 @@ class IssueReporter {
1729
1742
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
1730
1743
  oldMethod.apply(oldMethod, [date, consoleMessage]);
1731
1744
 
1732
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
1745
+ if (this._callback) {
1746
+ this._callback(level, consoleMessage);
1747
+ }
1748
+
1749
+ if (!skipSendToRemote) {
1750
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
1751
+ }
1733
1752
  }
1734
1753
 
1735
1754
  logRequest(url , options , response , start ) {
@@ -1874,7 +1893,11 @@ class IssueReporter {
1874
1893
  },
1875
1894
  // $FlowFixMe
1876
1895
  body,
1877
- }).catch(() => {
1896
+ }).catch((e ) => {
1897
+ // $FlowFixMe
1898
+ e.skipSendToRemote = true;
1899
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
1900
+
1878
1901
  setTimeout(() => {
1879
1902
  if (isArray) {
1880
1903
  payload = payload.map(message => {
@@ -2633,11 +2656,24 @@ class Meeting {
2633
2656
  });
2634
2657
  }
2635
2658
 
2659
+ static parseMany(items ) {
2660
+ return items.map(plain => Meeting.parse(plain));
2661
+ }
2662
+
2636
2663
  static newFrom(meeting ) {
2637
2664
  return newFrom(meeting, Meeting);
2638
2665
  }
2639
2666
 
2640
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2667
+ constructor({
2668
+ uuid,
2669
+ name,
2670
+ guestSipAuthorization,
2671
+ ownerUuids,
2672
+ port,
2673
+ uri,
2674
+ number,
2675
+ persistent,
2676
+ } = {}) {
2641
2677
  this.guestSipAuthorization = guestSipAuthorization;
2642
2678
  this.uri = uri;
2643
2679
  this.name = name;
@@ -2723,8 +2759,11 @@ var confdMethods = (client , baseUrl ) => ({
2723
2759
  }
2724
2760
  },
2725
2761
 
2726
- createMyMeeting: (name ) =>
2727
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2762
+ getMyMeetings: () =>
2763
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2764
+
2765
+ createMyMeeting: (name , persistent ) =>
2766
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2728
2767
 
2729
2768
  deleteMyMeeting: (meetingUuid ) =>
2730
2769
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -6960,7 +6999,9 @@ class WebRTCClient extends Emitter {
6960
6999
  const inviteOptions = {
6961
7000
  requestDelegate: {
6962
7001
  onAccept: (response ) => {
6963
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
7002
+ if (session.sessionDescriptionHandler.peerConnection) {
7003
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
7004
+ }
6964
7005
  this._onAccepted(session, response.session, true);
6965
7006
  },
6966
7007
  onReject: (response ) => {
@@ -7832,6 +7873,16 @@ class WebRTCClient extends Emitter {
7832
7873
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7833
7874
  }
7834
7875
 
7876
+ // Useful in a react-native environment when remoteMediaStream is not updated
7877
+ getRemoteVideoStreamFromPc(sessionId ) {
7878
+ const pc = this.getPeerConnection(sessionId);
7879
+ if (!pc) {
7880
+ return null;
7881
+ }
7882
+
7883
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7884
+ }
7885
+
7835
7886
  hasVideo(sessionId ) {
7836
7887
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7837
7888
  }
@@ -8610,18 +8661,22 @@ class WebRTCClient extends Emitter {
8610
8661
  });
8611
8662
 
8612
8663
  networkStats.packetsLost = packetsLost;
8613
- networkStats.audioBytesSent = audioBytesSent;
8664
+ networkStats.totalAudioBytesSent = audioBytesSent;
8665
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8666
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8614
8667
  networkStats.audioBytesReceived = audioBytesReceived;
8615
- networkStats.videoBytesSent = videoBytesSent;
8616
- networkStats.videoBytesReceived = videoBytesReceived;
8668
+ networkStats.totalVideoBytesSent = videoBytesSent;
8669
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8670
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8671
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8672
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8617
8673
  networkStats.transportSent = transportSent;
8618
- networkStats.transportReceived = transportReceived;
8674
+ networkStats.totalTransportReceived = transportReceived;
8675
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8619
8676
 
8620
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8621
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8622
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8623
-
8624
- networkStats.bandwidth = bandwidth;
8677
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8678
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8679
+ + networkStats.transportSent;
8625
8680
 
8626
8681
  this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8627
8682
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -9032,9 +9087,11 @@ class WebRTCPhone extends Emitter {
9032
9087
  case SessionState.Terminated: {
9033
9088
  logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9034
9089
 
9090
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
9091
+ const callSession = this._createCallSession(sipSession);
9035
9092
  const wasCurrentSession = this._onCallTerminated(sipSession);
9036
9093
 
9037
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
9094
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
9038
9095
  }
9039
9096
  }
9040
9097
  });
@@ -9982,6 +10039,10 @@ class WebRTCPhone extends Emitter {
9982
10039
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9983
10040
  }
9984
10041
 
10042
+ getRemoteVideoStreamFromPc(callSession ) {
10043
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
10044
+ }
10045
+
9985
10046
  hasRemoteVideo(callSession ) {
9986
10047
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9987
10048
  }
@@ -10665,6 +10726,11 @@ class Phone extends Emitter {
10665
10726
  return this.getRemoteVideoStream(callSession);
10666
10727
  }
10667
10728
 
10729
+ // Useful in a react-native environment when remoteMediaStream is not updated
10730
+ getRemoteVideoStreamFromPc(callSession ) {
10731
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
10732
+ }
10733
+
10668
10734
  hasVideo(callSession ) {
10669
10735
  return this.phone ? this.phone.hasVideo(callSession) : false;
10670
10736
  }
@@ -10824,6 +10890,7 @@ const AGENT_PAUSED = 'agent_paused';
10824
10890
  const AGENT_UNPAUSED = 'agent_unpaused';
10825
10891
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10826
10892
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10893
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10827
10894
 
10828
10895
  const BLACKLIST_EVENTS = [
10829
10896
  CHAT_MESSAGE_SENT,
@@ -11174,6 +11241,7 @@ WebSocketClient.eventLists = [
11174
11241
  AGENT_UNPAUSED,
11175
11242
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11176
11243
  CONFERENCE_ADHOC_DELETED,
11244
+ MEETING_USER_PROGRESS,
11177
11245
  ];
11178
11246
 
11179
11247
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11244,6 +11312,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11244
11312
  AGENT_UNPAUSED: AGENT_UNPAUSED,
11245
11313
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11246
11314
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11315
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11247
11316
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11248
11317
  'default': WebSocketClient
11249
11318
  });