@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),
@@ -6696,7 +6735,9 @@ class WebRTCClient extends Emitter {
6696
6735
  const inviteOptions = {
6697
6736
  requestDelegate: {
6698
6737
  onAccept: (response ) => {
6699
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
6738
+ if (session.sessionDescriptionHandler.peerConnection) {
6739
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
6740
+ }
6700
6741
  this._onAccepted(session, response.session, true);
6701
6742
  },
6702
6743
  onReject: (response ) => {
@@ -7568,6 +7609,16 @@ class WebRTCClient extends Emitter {
7568
7609
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7569
7610
  }
7570
7611
 
7612
+ // Useful in a react-native environment when remoteMediaStream is not updated
7613
+ getRemoteVideoStreamFromPc(sessionId ) {
7614
+ const pc = this.getPeerConnection(sessionId);
7615
+ if (!pc) {
7616
+ return null;
7617
+ }
7618
+
7619
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7620
+ }
7621
+
7571
7622
  hasVideo(sessionId ) {
7572
7623
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7573
7624
  }
@@ -8346,18 +8397,22 @@ class WebRTCClient extends Emitter {
8346
8397
  });
8347
8398
 
8348
8399
  networkStats.packetsLost = packetsLost;
8349
- networkStats.audioBytesSent = audioBytesSent;
8400
+ networkStats.totalAudioBytesSent = audioBytesSent;
8401
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8402
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8350
8403
  networkStats.audioBytesReceived = audioBytesReceived;
8351
- networkStats.videoBytesSent = videoBytesSent;
8352
- networkStats.videoBytesReceived = videoBytesReceived;
8404
+ networkStats.totalVideoBytesSent = videoBytesSent;
8405
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8406
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8407
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8408
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8353
8409
  networkStats.transportSent = transportSent;
8354
- networkStats.transportReceived = transportReceived;
8410
+ networkStats.totalTransportReceived = transportReceived;
8411
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8355
8412
 
8356
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8357
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8358
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8359
-
8360
- networkStats.bandwidth = bandwidth;
8413
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8414
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8415
+ + networkStats.transportSent;
8361
8416
 
8362
8417
  this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8363
8418
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -8768,9 +8823,11 @@ class WebRTCPhone extends Emitter {
8768
8823
  case SessionState.Terminated: {
8769
8824
  logger$8.info('WebRTC phone - call terminated', { sipId: sipSession.id });
8770
8825
 
8826
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
8827
+ const callSession = this._createCallSession(sipSession);
8771
8828
  const wasCurrentSession = this._onCallTerminated(sipSession);
8772
8829
 
8773
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
8830
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
8774
8831
  }
8775
8832
  }
8776
8833
  });
@@ -9718,6 +9775,10 @@ class WebRTCPhone extends Emitter {
9718
9775
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9719
9776
  }
9720
9777
 
9778
+ getRemoteVideoStreamFromPc(callSession ) {
9779
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
9780
+ }
9781
+
9721
9782
  hasRemoteVideo(callSession ) {
9722
9783
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9723
9784
  }
@@ -10401,6 +10462,11 @@ class Phone extends Emitter {
10401
10462
  return this.getRemoteVideoStream(callSession);
10402
10463
  }
10403
10464
 
10465
+ // Useful in a react-native environment when remoteMediaStream is not updated
10466
+ getRemoteVideoStreamFromPc(callSession ) {
10467
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
10468
+ }
10469
+
10404
10470
  hasVideo(callSession ) {
10405
10471
  return this.phone ? this.phone.hasVideo(callSession) : false;
10406
10472
  }
@@ -10560,6 +10626,7 @@ const AGENT_PAUSED = 'agent_paused';
10560
10626
  const AGENT_UNPAUSED = 'agent_unpaused';
10561
10627
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10562
10628
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10629
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10563
10630
 
10564
10631
  const BLACKLIST_EVENTS = [
10565
10632
  CHAT_MESSAGE_SENT,
@@ -10910,6 +10977,7 @@ WebSocketClient.eventLists = [
10910
10977
  AGENT_UNPAUSED,
10911
10978
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
10912
10979
  CONFERENCE_ADHOC_DELETED,
10980
+ MEETING_USER_PROGRESS,
10913
10981
  ];
10914
10982
 
10915
10983
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -10980,6 +11048,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
10980
11048
  AGENT_UNPAUSED: AGENT_UNPAUSED,
10981
11049
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
10982
11050
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11051
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
10983
11052
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
10984
11053
  'default': WebSocketClient
10985
11054
  });
@@ -130,6 +130,7 @@ class IssueReporter {
130
130
 
131
131
 
132
132
 
133
+
133
134
 
134
135
  constructor() {
135
136
  addLevelsTo(this);
@@ -141,12 +142,17 @@ class IssueReporter {
141
142
  this.bufferTimeout = null;
142
143
  this._boundProcessBuffer = this._processBuffer.bind(this);
143
144
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
145
+ this._callback = null;
144
146
  }
145
147
 
146
148
  init() {
147
149
  this._catchConsole();
148
150
  }
149
151
 
152
+ setCallback(cb ) {
153
+ this._callback = cb;
154
+ }
155
+
150
156
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
151
157
  this.remoteClientConfiguration = configuration;
152
158
  }
@@ -182,6 +188,7 @@ class IssueReporter {
182
188
 
183
189
  // Handle category label
184
190
  let category = null;
191
+ let skipSendToRemote = false;
185
192
  let extra = {};
186
193
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
187
194
  category = args[0].split('=')[1];
@@ -197,6 +204,7 @@ class IssueReporter {
197
204
  errorMessage: lastArg.message,
198
205
  errorStack: lastArg.stack,
199
206
  errorType: lastArg.constructor.name,
207
+ skipSendToRemote: lastArg.skipSendToRemote,
200
208
  };
201
209
  } else {
202
210
  extra = lastArg;
@@ -205,6 +213,11 @@ class IssueReporter {
205
213
  args.splice(1, 1);
206
214
  }
207
215
 
216
+ if (extra.skipSendToRemote) {
217
+ skipSendToRemote = true;
218
+ delete extra.skipSendToRemote;
219
+ }
220
+
208
221
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
209
222
  const message = args.join(', ');
210
223
  let consoleMessage = message;
@@ -225,7 +238,13 @@ class IssueReporter {
225
238
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
226
239
  oldMethod.apply(oldMethod, [date, consoleMessage]);
227
240
 
228
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
241
+ if (this._callback) {
242
+ this._callback(level, consoleMessage);
243
+ }
244
+
245
+ if (!skipSendToRemote) {
246
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
247
+ }
229
248
  }
230
249
 
231
250
  logRequest(url , options , response , start ) {
@@ -370,7 +389,11 @@ class IssueReporter {
370
389
  },
371
390
  // $FlowFixMe
372
391
  body,
373
- }).catch(() => {
392
+ }).catch((e ) => {
393
+ // $FlowFixMe
394
+ e.skipSendToRemote = true;
395
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
396
+
374
397
  setTimeout(() => {
375
398
  if (isArray) {
376
399
  payload = payload.map(message => {
@@ -2614,11 +2637,24 @@ class Meeting {
2614
2637
  });
2615
2638
  }
2616
2639
 
2640
+ static parseMany(items ) {
2641
+ return items.map(plain => Meeting.parse(plain));
2642
+ }
2643
+
2617
2644
  static newFrom(meeting ) {
2618
2645
  return newFrom(meeting, Meeting);
2619
2646
  }
2620
2647
 
2621
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2648
+ constructor({
2649
+ uuid,
2650
+ name,
2651
+ guestSipAuthorization,
2652
+ ownerUuids,
2653
+ port,
2654
+ uri,
2655
+ number,
2656
+ persistent,
2657
+ } = {}) {
2622
2658
  this.guestSipAuthorization = guestSipAuthorization;
2623
2659
  this.uri = uri;
2624
2660
  this.name = name;
@@ -2704,8 +2740,11 @@ var confdMethods = (client , baseUrl ) => ({
2704
2740
  }
2705
2741
  },
2706
2742
 
2707
- createMyMeeting: (name ) =>
2708
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2743
+ getMyMeetings: () =>
2744
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2745
+
2746
+ createMyMeeting: (name , persistent ) =>
2747
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2709
2748
 
2710
2749
  deleteMyMeeting: (meetingUuid ) =>
2711
2750
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -711,6 +711,7 @@ class IssueReporter {
711
711
 
712
712
 
713
713
 
714
+
714
715
 
715
716
  constructor() {
716
717
  addLevelsTo(this);
@@ -722,12 +723,17 @@ class IssueReporter {
722
723
  this.bufferTimeout = null;
723
724
  this._boundProcessBuffer = this._processBuffer.bind(this);
724
725
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
726
+ this._callback = null;
725
727
  }
726
728
 
727
729
  init() {
728
730
  this._catchConsole();
729
731
  }
730
732
 
733
+ setCallback(cb ) {
734
+ this._callback = cb;
735
+ }
736
+
731
737
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
732
738
  this.remoteClientConfiguration = configuration;
733
739
  }
@@ -763,6 +769,7 @@ class IssueReporter {
763
769
 
764
770
  // Handle category label
765
771
  let category = null;
772
+ let skipSendToRemote = false;
766
773
  let extra = {};
767
774
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
768
775
  category = args[0].split('=')[1];
@@ -778,6 +785,7 @@ class IssueReporter {
778
785
  errorMessage: lastArg.message,
779
786
  errorStack: lastArg.stack,
780
787
  errorType: lastArg.constructor.name,
788
+ skipSendToRemote: lastArg.skipSendToRemote,
781
789
  };
782
790
  } else {
783
791
  extra = lastArg;
@@ -786,6 +794,11 @@ class IssueReporter {
786
794
  args.splice(1, 1);
787
795
  }
788
796
 
797
+ if (extra.skipSendToRemote) {
798
+ skipSendToRemote = true;
799
+ delete extra.skipSendToRemote;
800
+ }
801
+
789
802
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
790
803
  const message = args.join(', ');
791
804
  let consoleMessage = message;
@@ -806,7 +819,13 @@ class IssueReporter {
806
819
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
807
820
  oldMethod.apply(oldMethod, [date, consoleMessage]);
808
821
 
809
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
822
+ if (this._callback) {
823
+ this._callback(level, consoleMessage);
824
+ }
825
+
826
+ if (!skipSendToRemote) {
827
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
828
+ }
810
829
  }
811
830
 
812
831
  logRequest(url , options , response , start ) {
@@ -951,7 +970,11 @@ class IssueReporter {
951
970
  },
952
971
  // $FlowFixMe
953
972
  body,
954
- }).catch(() => {
973
+ }).catch((e ) => {
974
+ // $FlowFixMe
975
+ e.skipSendToRemote = true;
976
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
977
+
955
978
  setTimeout(() => {
956
979
  if (isArray) {
957
980
  payload = payload.map(message => {
@@ -3184,11 +3207,24 @@ class Meeting {
3184
3207
  });
3185
3208
  }
3186
3209
 
3210
+ static parseMany(items ) {
3211
+ return items.map(plain => Meeting.parse(plain));
3212
+ }
3213
+
3187
3214
  static newFrom(meeting ) {
3188
3215
  return newFrom(meeting, Meeting);
3189
3216
  }
3190
3217
 
3191
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
3218
+ constructor({
3219
+ uuid,
3220
+ name,
3221
+ guestSipAuthorization,
3222
+ ownerUuids,
3223
+ port,
3224
+ uri,
3225
+ number,
3226
+ persistent,
3227
+ } = {}) {
3192
3228
  this.guestSipAuthorization = guestSipAuthorization;
3193
3229
  this.uri = uri;
3194
3230
  this.name = name;
@@ -3274,8 +3310,11 @@ var confdMethods = (client , baseUrl ) => ({
3274
3310
  }
3275
3311
  },
3276
3312
 
3277
- createMyMeeting: (name ) =>
3278
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
3313
+ getMyMeetings: () =>
3314
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3315
+
3316
+ createMyMeeting: (name , persistent ) =>
3317
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3279
3318
 
3280
3319
  deleteMyMeeting: (meetingUuid ) =>
3281
3320
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -6696,7 +6735,9 @@ class WebRTCClient extends Emitter {
6696
6735
  const inviteOptions = {
6697
6736
  requestDelegate: {
6698
6737
  onAccept: (response ) => {
6699
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
6738
+ if (session.sessionDescriptionHandler.peerConnection) {
6739
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
6740
+ }
6700
6741
  this._onAccepted(session, response.session, true);
6701
6742
  },
6702
6743
  onReject: (response ) => {
@@ -7568,6 +7609,16 @@ class WebRTCClient extends Emitter {
7568
7609
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7569
7610
  }
7570
7611
 
7612
+ // Useful in a react-native environment when remoteMediaStream is not updated
7613
+ getRemoteVideoStreamFromPc(sessionId ) {
7614
+ const pc = this.getPeerConnection(sessionId);
7615
+ if (!pc) {
7616
+ return null;
7617
+ }
7618
+
7619
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7620
+ }
7621
+
7571
7622
  hasVideo(sessionId ) {
7572
7623
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7573
7624
  }
@@ -8346,18 +8397,22 @@ class WebRTCClient extends Emitter {
8346
8397
  });
8347
8398
 
8348
8399
  networkStats.packetsLost = packetsLost;
8349
- networkStats.audioBytesSent = audioBytesSent;
8400
+ networkStats.totalAudioBytesSent = audioBytesSent;
8401
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8402
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8350
8403
  networkStats.audioBytesReceived = audioBytesReceived;
8351
- networkStats.videoBytesSent = videoBytesSent;
8352
- networkStats.videoBytesReceived = videoBytesReceived;
8404
+ networkStats.totalVideoBytesSent = videoBytesSent;
8405
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8406
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8407
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8408
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8353
8409
  networkStats.transportSent = transportSent;
8354
- networkStats.transportReceived = transportReceived;
8410
+ networkStats.totalTransportReceived = transportReceived;
8411
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8355
8412
 
8356
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8357
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8358
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8359
-
8360
- networkStats.bandwidth = bandwidth;
8413
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8414
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8415
+ + networkStats.transportSent;
8361
8416
 
8362
8417
  this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8363
8418
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -8768,9 +8823,11 @@ class WebRTCPhone extends Emitter {
8768
8823
  case SessionState.Terminated: {
8769
8824
  logger$8.info('WebRTC phone - call terminated', { sipId: sipSession.id });
8770
8825
 
8826
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
8827
+ const callSession = this._createCallSession(sipSession);
8771
8828
  const wasCurrentSession = this._onCallTerminated(sipSession);
8772
8829
 
8773
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
8830
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
8774
8831
  }
8775
8832
  }
8776
8833
  });
@@ -9718,6 +9775,10 @@ class WebRTCPhone extends Emitter {
9718
9775
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9719
9776
  }
9720
9777
 
9778
+ getRemoteVideoStreamFromPc(callSession ) {
9779
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
9780
+ }
9781
+
9721
9782
  hasRemoteVideo(callSession ) {
9722
9783
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9723
9784
  }
@@ -10419,6 +10480,7 @@ const AGENT_PAUSED = 'agent_paused';
10419
10480
  const AGENT_UNPAUSED = 'agent_unpaused';
10420
10481
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10421
10482
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10483
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10422
10484
 
10423
10485
  const BLACKLIST_EVENTS = [
10424
10486
  CHAT_MESSAGE_SENT,
@@ -10769,6 +10831,7 @@ WebSocketClient.eventLists = [
10769
10831
  AGENT_UNPAUSED,
10770
10832
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
10771
10833
  CONFERENCE_ADHOC_DELETED,
10834
+ MEETING_USER_PROGRESS,
10772
10835
  ];
10773
10836
 
10774
10837
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -10839,6 +10902,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
10839
10902
  AGENT_UNPAUSED: AGENT_UNPAUSED,
10840
10903
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
10841
10904
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
10905
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
10842
10906
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
10843
10907
  'default': WebSocketClient
10844
10908
  });
@@ -13558,6 +13622,11 @@ class Phone extends Emitter {
13558
13622
  return this.getRemoteVideoStream(callSession);
13559
13623
  }
13560
13624
 
13625
+ // Useful in a react-native environment when remoteMediaStream is not updated
13626
+ getRemoteVideoStreamFromPc(callSession ) {
13627
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
13628
+ }
13629
+
13561
13630
  hasVideo(callSession ) {
13562
13631
  return this.phone ? this.phone.hasVideo(callSession) : false;
13563
13632
  }
@@ -121,6 +121,7 @@ class IssueReporter {
121
121
 
122
122
 
123
123
 
124
+
124
125
 
125
126
  constructor() {
126
127
  addLevelsTo(this);
@@ -132,12 +133,17 @@ class IssueReporter {
132
133
  this.bufferTimeout = null;
133
134
  this._boundProcessBuffer = this._processBuffer.bind(this);
134
135
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
136
+ this._callback = null;
135
137
  }
136
138
 
137
139
  init() {
138
140
  this._catchConsole();
139
141
  }
140
142
 
143
+ setCallback(cb ) {
144
+ this._callback = cb;
145
+ }
146
+
141
147
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
142
148
  this.remoteClientConfiguration = configuration;
143
149
  }
@@ -173,6 +179,7 @@ class IssueReporter {
173
179
 
174
180
  // Handle category label
175
181
  let category = null;
182
+ let skipSendToRemote = false;
176
183
  let extra = {};
177
184
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
178
185
  category = args[0].split('=')[1];
@@ -188,6 +195,7 @@ class IssueReporter {
188
195
  errorMessage: lastArg.message,
189
196
  errorStack: lastArg.stack,
190
197
  errorType: lastArg.constructor.name,
198
+ skipSendToRemote: lastArg.skipSendToRemote,
191
199
  };
192
200
  } else {
193
201
  extra = lastArg;
@@ -196,6 +204,11 @@ class IssueReporter {
196
204
  args.splice(1, 1);
197
205
  }
198
206
 
207
+ if (extra.skipSendToRemote) {
208
+ skipSendToRemote = true;
209
+ delete extra.skipSendToRemote;
210
+ }
211
+
199
212
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
200
213
  const message = args.join(', ');
201
214
  let consoleMessage = message;
@@ -216,7 +229,13 @@ class IssueReporter {
216
229
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
217
230
  oldMethod.apply(oldMethod, [date, consoleMessage]);
218
231
 
219
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
232
+ if (this._callback) {
233
+ this._callback(level, consoleMessage);
234
+ }
235
+
236
+ if (!skipSendToRemote) {
237
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
238
+ }
220
239
  }
221
240
 
222
241
  logRequest(url , options , response , start ) {
@@ -361,7 +380,11 @@ class IssueReporter {
361
380
  },
362
381
  // $FlowFixMe
363
382
  body,
364
- }).catch(() => {
383
+ }).catch((e ) => {
384
+ // $FlowFixMe
385
+ e.skipSendToRemote = true;
386
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
387
+
365
388
  setTimeout(() => {
366
389
  if (isArray) {
367
390
  payload = payload.map(message => {
@@ -578,6 +601,7 @@ const AGENT_PAUSED = 'agent_paused';
578
601
  const AGENT_UNPAUSED = 'agent_unpaused';
579
602
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
580
603
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
604
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
581
605
 
582
606
  const BLACKLIST_EVENTS = [
583
607
  CHAT_MESSAGE_SENT,
@@ -928,6 +952,7 @@ WebSocketClient.eventLists = [
928
952
  AGENT_UNPAUSED,
929
953
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
930
954
  CONFERENCE_ADHOC_DELETED,
955
+ MEETING_USER_PROGRESS,
931
956
  ];
932
957
 
933
958
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -998,6 +1023,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
998
1023
  AGENT_UNPAUSED: AGENT_UNPAUSED,
999
1024
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
1000
1025
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
1026
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
1001
1027
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
1002
1028
  'default': WebSocketClient
1003
1029
  });