@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
@@ -49,11 +49,24 @@ class Meeting {
49
49
  });
50
50
  }
51
51
 
52
+ static parseMany(items ) {
53
+ return items.map(plain => Meeting.parse(plain));
54
+ }
55
+
52
56
  static newFrom(meeting ) {
53
57
  return newFrom(meeting, Meeting);
54
58
  }
55
59
 
56
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
60
+ constructor({
61
+ uuid,
62
+ name,
63
+ guestSipAuthorization,
64
+ ownerUuids,
65
+ port,
66
+ uri,
67
+ number,
68
+ persistent,
69
+ } = {}) {
57
70
  this.guestSipAuthorization = guestSipAuthorization;
58
71
  this.uri = uri;
59
72
  this.name = name;
@@ -2519,6 +2519,7 @@ class IssueReporter {
2519
2519
 
2520
2520
 
2521
2521
 
2522
+
2522
2523
 
2523
2524
  constructor() {
2524
2525
  addLevelsTo(this);
@@ -2530,12 +2531,17 @@ class IssueReporter {
2530
2531
  this.bufferTimeout = null;
2531
2532
  this._boundProcessBuffer = this._processBuffer.bind(this);
2532
2533
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
2534
+ this._callback = null;
2533
2535
  }
2534
2536
 
2535
2537
  init() {
2536
2538
  this._catchConsole();
2537
2539
  }
2538
2540
 
2541
+ setCallback(cb ) {
2542
+ this._callback = cb;
2543
+ }
2544
+
2539
2545
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
2540
2546
  this.remoteClientConfiguration = configuration;
2541
2547
  }
@@ -2571,6 +2577,7 @@ class IssueReporter {
2571
2577
 
2572
2578
  // Handle category label
2573
2579
  let category = null;
2580
+ let skipSendToRemote = false;
2574
2581
  let extra = {};
2575
2582
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
2576
2583
  category = args[0].split('=')[1];
@@ -2586,6 +2593,7 @@ class IssueReporter {
2586
2593
  errorMessage: lastArg.message,
2587
2594
  errorStack: lastArg.stack,
2588
2595
  errorType: lastArg.constructor.name,
2596
+ skipSendToRemote: lastArg.skipSendToRemote,
2589
2597
  };
2590
2598
  } else {
2591
2599
  extra = lastArg;
@@ -2594,6 +2602,11 @@ class IssueReporter {
2594
2602
  args.splice(1, 1);
2595
2603
  }
2596
2604
 
2605
+ if (extra.skipSendToRemote) {
2606
+ skipSendToRemote = true;
2607
+ delete extra.skipSendToRemote;
2608
+ }
2609
+
2597
2610
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
2598
2611
  const message = args.join(', ');
2599
2612
  let consoleMessage = message;
@@ -2614,7 +2627,13 @@ class IssueReporter {
2614
2627
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
2615
2628
  oldMethod.apply(oldMethod, [date, consoleMessage]);
2616
2629
 
2617
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
2630
+ if (this._callback) {
2631
+ this._callback(level, consoleMessage);
2632
+ }
2633
+
2634
+ if (!skipSendToRemote) {
2635
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
2636
+ }
2618
2637
  }
2619
2638
 
2620
2639
  logRequest(url , options , response , start ) {
@@ -2759,7 +2778,11 @@ class IssueReporter {
2759
2778
  },
2760
2779
  // $FlowFixMe
2761
2780
  body,
2762
- }).catch(() => {
2781
+ }).catch((e ) => {
2782
+ // $FlowFixMe
2783
+ e.skipSendToRemote = true;
2784
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
2785
+
2763
2786
  setTimeout(() => {
2764
2787
  if (isArray) {
2765
2788
  payload = payload.map(message => {
@@ -3518,11 +3541,24 @@ class Meeting {
3518
3541
  });
3519
3542
  }
3520
3543
 
3544
+ static parseMany(items ) {
3545
+ return items.map(plain => Meeting.parse(plain));
3546
+ }
3547
+
3521
3548
  static newFrom(meeting ) {
3522
3549
  return newFrom(meeting, Meeting);
3523
3550
  }
3524
3551
 
3525
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
3552
+ constructor({
3553
+ uuid,
3554
+ name,
3555
+ guestSipAuthorization,
3556
+ ownerUuids,
3557
+ port,
3558
+ uri,
3559
+ number,
3560
+ persistent,
3561
+ } = {}) {
3526
3562
  this.guestSipAuthorization = guestSipAuthorization;
3527
3563
  this.uri = uri;
3528
3564
  this.name = name;
@@ -3608,8 +3644,11 @@ var confdMethods = (client , baseUrl ) => ({
3608
3644
  }
3609
3645
  },
3610
3646
 
3611
- createMyMeeting: (name ) =>
3612
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
3647
+ getMyMeetings: () =>
3648
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3649
+
3650
+ createMyMeeting: (name , persistent ) =>
3651
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3613
3652
 
3614
3653
  deleteMyMeeting: (meetingUuid ) =>
3615
3654
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -496,6 +496,7 @@ class IssueReporter {
496
496
 
497
497
 
498
498
 
499
+
499
500
 
500
501
  constructor() {
501
502
  addLevelsTo(this);
@@ -507,12 +508,17 @@ class IssueReporter {
507
508
  this.bufferTimeout = null;
508
509
  this._boundProcessBuffer = this._processBuffer.bind(this);
509
510
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
511
+ this._callback = null;
510
512
  }
511
513
 
512
514
  init() {
513
515
  this._catchConsole();
514
516
  }
515
517
 
518
+ setCallback(cb ) {
519
+ this._callback = cb;
520
+ }
521
+
516
522
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
517
523
  this.remoteClientConfiguration = configuration;
518
524
  }
@@ -548,6 +554,7 @@ class IssueReporter {
548
554
 
549
555
  // Handle category label
550
556
  let category = null;
557
+ let skipSendToRemote = false;
551
558
  let extra = {};
552
559
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
553
560
  category = args[0].split('=')[1];
@@ -563,6 +570,7 @@ class IssueReporter {
563
570
  errorMessage: lastArg.message,
564
571
  errorStack: lastArg.stack,
565
572
  errorType: lastArg.constructor.name,
573
+ skipSendToRemote: lastArg.skipSendToRemote,
566
574
  };
567
575
  } else {
568
576
  extra = lastArg;
@@ -571,6 +579,11 @@ class IssueReporter {
571
579
  args.splice(1, 1);
572
580
  }
573
581
 
582
+ if (extra.skipSendToRemote) {
583
+ skipSendToRemote = true;
584
+ delete extra.skipSendToRemote;
585
+ }
586
+
574
587
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
575
588
  const message = args.join(', ');
576
589
  let consoleMessage = message;
@@ -591,7 +604,13 @@ class IssueReporter {
591
604
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
592
605
  oldMethod.apply(oldMethod, [date, consoleMessage]);
593
606
 
594
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
607
+ if (this._callback) {
608
+ this._callback(level, consoleMessage);
609
+ }
610
+
611
+ if (!skipSendToRemote) {
612
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
613
+ }
595
614
  }
596
615
 
597
616
  logRequest(url , options , response , start ) {
@@ -736,7 +755,11 @@ class IssueReporter {
736
755
  },
737
756
  // $FlowFixMe
738
757
  body,
739
- }).catch(() => {
758
+ }).catch((e ) => {
759
+ // $FlowFixMe
760
+ e.skipSendToRemote = true;
761
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
762
+
740
763
  setTimeout(() => {
741
764
  if (isArray) {
742
765
  payload = payload.map(message => {
@@ -1248,9 +1271,11 @@ class WebRTCPhone extends Emitter {
1248
1271
  case sessionState.SessionState.Terminated: {
1249
1272
  logger.info('WebRTC phone - call terminated', { sipId: sipSession.id });
1250
1273
 
1274
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
1275
+ const callSession = this._createCallSession(sipSession);
1251
1276
  const wasCurrentSession = this._onCallTerminated(sipSession);
1252
1277
 
1253
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
1278
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
1254
1279
  }
1255
1280
  }
1256
1281
  });
@@ -2198,6 +2223,10 @@ class WebRTCPhone extends Emitter {
2198
2223
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
2199
2224
  }
2200
2225
 
2226
+ getRemoteVideoStreamFromPc(callSession ) {
2227
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
2228
+ }
2229
+
2201
2230
  hasRemoteVideo(callSession ) {
2202
2231
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
2203
2232
  }
package/lib/index.js CHANGED
@@ -161,6 +161,7 @@ class IssueReporter {
161
161
 
162
162
 
163
163
 
164
+
164
165
 
165
166
  constructor() {
166
167
  addLevelsTo(this);
@@ -172,12 +173,17 @@ class IssueReporter {
172
173
  this.bufferTimeout = null;
173
174
  this._boundProcessBuffer = this._processBuffer.bind(this);
174
175
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
176
+ this._callback = null;
175
177
  }
176
178
 
177
179
  init() {
178
180
  this._catchConsole();
179
181
  }
180
182
 
183
+ setCallback(cb ) {
184
+ this._callback = cb;
185
+ }
186
+
181
187
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
182
188
  this.remoteClientConfiguration = configuration;
183
189
  }
@@ -213,6 +219,7 @@ class IssueReporter {
213
219
 
214
220
  // Handle category label
215
221
  let category = null;
222
+ let skipSendToRemote = false;
216
223
  let extra = {};
217
224
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
218
225
  category = args[0].split('=')[1];
@@ -228,6 +235,7 @@ class IssueReporter {
228
235
  errorMessage: lastArg.message,
229
236
  errorStack: lastArg.stack,
230
237
  errorType: lastArg.constructor.name,
238
+ skipSendToRemote: lastArg.skipSendToRemote,
231
239
  };
232
240
  } else {
233
241
  extra = lastArg;
@@ -236,6 +244,11 @@ class IssueReporter {
236
244
  args.splice(1, 1);
237
245
  }
238
246
 
247
+ if (extra.skipSendToRemote) {
248
+ skipSendToRemote = true;
249
+ delete extra.skipSendToRemote;
250
+ }
251
+
239
252
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
240
253
  const message = args.join(', ');
241
254
  let consoleMessage = message;
@@ -256,7 +269,13 @@ class IssueReporter {
256
269
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
257
270
  oldMethod.apply(oldMethod, [date, consoleMessage]);
258
271
 
259
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
272
+ if (this._callback) {
273
+ this._callback(level, consoleMessage);
274
+ }
275
+
276
+ if (!skipSendToRemote) {
277
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
278
+ }
260
279
  }
261
280
 
262
281
  logRequest(url , options , response , start ) {
@@ -401,7 +420,11 @@ class IssueReporter {
401
420
  },
402
421
  // $FlowFixMe
403
422
  body,
404
- }).catch(() => {
423
+ }).catch((e ) => {
424
+ // $FlowFixMe
425
+ e.skipSendToRemote = true;
426
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
427
+
405
428
  setTimeout(() => {
406
429
  if (isArray) {
407
430
  payload = payload.map(message => {
@@ -2645,11 +2668,24 @@ class Meeting {
2645
2668
  });
2646
2669
  }
2647
2670
 
2671
+ static parseMany(items ) {
2672
+ return items.map(plain => Meeting.parse(plain));
2673
+ }
2674
+
2648
2675
  static newFrom(meeting ) {
2649
2676
  return newFrom(meeting, Meeting);
2650
2677
  }
2651
2678
 
2652
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2679
+ constructor({
2680
+ uuid,
2681
+ name,
2682
+ guestSipAuthorization,
2683
+ ownerUuids,
2684
+ port,
2685
+ uri,
2686
+ number,
2687
+ persistent,
2688
+ } = {}) {
2653
2689
  this.guestSipAuthorization = guestSipAuthorization;
2654
2690
  this.uri = uri;
2655
2691
  this.name = name;
@@ -2735,8 +2771,11 @@ var confdMethods = (client , baseUrl ) => ({
2735
2771
  }
2736
2772
  },
2737
2773
 
2738
- createMyMeeting: (name ) =>
2739
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2774
+ getMyMeetings: () =>
2775
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2776
+
2777
+ createMyMeeting: (name , persistent ) =>
2778
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2740
2779
 
2741
2780
  deleteMyMeeting: (meetingUuid ) =>
2742
2781
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -6533,7 +6572,9 @@ class WebRTCClient extends Emitter {
6533
6572
  const inviteOptions = {
6534
6573
  requestDelegate: {
6535
6574
  onAccept: (response ) => {
6536
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
6575
+ if (session.sessionDescriptionHandler.peerConnection) {
6576
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
6577
+ }
6537
6578
  this._onAccepted(session, response.session, true);
6538
6579
  },
6539
6580
  onReject: (response ) => {
@@ -7405,6 +7446,16 @@ class WebRTCClient extends Emitter {
7405
7446
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7406
7447
  }
7407
7448
 
7449
+ // Useful in a react-native environment when remoteMediaStream is not updated
7450
+ getRemoteVideoStreamFromPc(sessionId ) {
7451
+ const pc = this.getPeerConnection(sessionId);
7452
+ if (!pc) {
7453
+ return null;
7454
+ }
7455
+
7456
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7457
+ }
7458
+
7408
7459
  hasVideo(sessionId ) {
7409
7460
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7410
7461
  }
@@ -8183,18 +8234,22 @@ class WebRTCClient extends Emitter {
8183
8234
  });
8184
8235
 
8185
8236
  networkStats.packetsLost = packetsLost;
8186
- networkStats.audioBytesSent = audioBytesSent;
8237
+ networkStats.totalAudioBytesSent = audioBytesSent;
8238
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8239
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8187
8240
  networkStats.audioBytesReceived = audioBytesReceived;
8188
- networkStats.videoBytesSent = videoBytesSent;
8189
- networkStats.videoBytesReceived = videoBytesReceived;
8241
+ networkStats.totalVideoBytesSent = videoBytesSent;
8242
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8243
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8244
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8245
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8190
8246
  networkStats.transportSent = transportSent;
8191
- networkStats.transportReceived = transportReceived;
8247
+ networkStats.totalTransportReceived = transportReceived;
8248
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8192
8249
 
8193
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8194
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8195
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8196
-
8197
- networkStats.bandwidth = bandwidth;
8250
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8251
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8252
+ + networkStats.transportSent;
8198
8253
 
8199
8254
  this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8200
8255
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -8290,6 +8345,7 @@ const AGENT_PAUSED = 'agent_paused';
8290
8345
  const AGENT_UNPAUSED = 'agent_unpaused';
8291
8346
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
8292
8347
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
8348
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
8293
8349
 
8294
8350
  const BLACKLIST_EVENTS = [
8295
8351
  CHAT_MESSAGE_SENT,
@@ -8640,6 +8696,7 @@ WebSocketClient.eventLists = [
8640
8696
  AGENT_UNPAUSED,
8641
8697
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
8642
8698
  CONFERENCE_ADHOC_DELETED,
8699
+ MEETING_USER_PROGRESS,
8643
8700
  ];
8644
8701
 
8645
8702
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -8710,6 +8767,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
8710
8767
  AGENT_UNPAUSED: AGENT_UNPAUSED,
8711
8768
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
8712
8769
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
8770
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
8713
8771
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
8714
8772
  'default': WebSocketClient
8715
8773
  });
@@ -9495,9 +9553,11 @@ class WebRTCPhone extends Emitter {
9495
9553
  case sessionState.SessionState.Terminated: {
9496
9554
  logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9497
9555
 
9556
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
9557
+ const callSession = this._createCallSession(sipSession);
9498
9558
  const wasCurrentSession = this._onCallTerminated(sipSession);
9499
9559
 
9500
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
9560
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
9501
9561
  }
9502
9562
  }
9503
9563
  });
@@ -10445,6 +10505,10 @@ class WebRTCPhone extends Emitter {
10445
10505
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
10446
10506
  }
10447
10507
 
10508
+ getRemoteVideoStreamFromPc(callSession ) {
10509
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
10510
+ }
10511
+
10448
10512
  hasRemoteVideo(callSession ) {
10449
10513
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
10450
10514
  }
@@ -12163,6 +12227,11 @@ class Phone extends Emitter {
12163
12227
  return this.getRemoteVideoStream(callSession);
12164
12228
  }
12165
12229
 
12230
+ // Useful in a react-native environment when remoteMediaStream is not updated
12231
+ getRemoteVideoStreamFromPc(callSession ) {
12232
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
12233
+ }
12234
+
12166
12235
  hasVideo(callSession ) {
12167
12236
  return this.phone ? this.phone.hasVideo(callSession) : false;
12168
12237
  }
@@ -107,6 +107,7 @@ class IssueReporter {
107
107
 
108
108
 
109
109
 
110
+
110
111
 
111
112
  constructor() {
112
113
  addLevelsTo(this);
@@ -118,12 +119,17 @@ class IssueReporter {
118
119
  this.bufferTimeout = null;
119
120
  this._boundProcessBuffer = this._processBuffer.bind(this);
120
121
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
122
+ this._callback = null;
121
123
  }
122
124
 
123
125
  init() {
124
126
  this._catchConsole();
125
127
  }
126
128
 
129
+ setCallback(cb ) {
130
+ this._callback = cb;
131
+ }
132
+
127
133
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
128
134
  this.remoteClientConfiguration = configuration;
129
135
  }
@@ -159,6 +165,7 @@ class IssueReporter {
159
165
 
160
166
  // Handle category label
161
167
  let category = null;
168
+ let skipSendToRemote = false;
162
169
  let extra = {};
163
170
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
164
171
  category = args[0].split('=')[1];
@@ -174,6 +181,7 @@ class IssueReporter {
174
181
  errorMessage: lastArg.message,
175
182
  errorStack: lastArg.stack,
176
183
  errorType: lastArg.constructor.name,
184
+ skipSendToRemote: lastArg.skipSendToRemote,
177
185
  };
178
186
  } else {
179
187
  extra = lastArg;
@@ -182,6 +190,11 @@ class IssueReporter {
182
190
  args.splice(1, 1);
183
191
  }
184
192
 
193
+ if (extra.skipSendToRemote) {
194
+ skipSendToRemote = true;
195
+ delete extra.skipSendToRemote;
196
+ }
197
+
185
198
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
186
199
  const message = args.join(', ');
187
200
  let consoleMessage = message;
@@ -202,7 +215,13 @@ class IssueReporter {
202
215
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
203
216
  oldMethod.apply(oldMethod, [date, consoleMessage]);
204
217
 
205
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
218
+ if (this._callback) {
219
+ this._callback(level, consoleMessage);
220
+ }
221
+
222
+ if (!skipSendToRemote) {
223
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
224
+ }
206
225
  }
207
226
 
208
227
  logRequest(url , options , response , start ) {
@@ -347,7 +366,11 @@ class IssueReporter {
347
366
  },
348
367
  // $FlowFixMe
349
368
  body,
350
- }).catch(() => {
369
+ }).catch((e ) => {
370
+ // $FlowFixMe
371
+ e.skipSendToRemote = true;
372
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
373
+
351
374
  setTimeout(() => {
352
375
  if (isArray) {
353
376
  payload = payload.map(message => {
@@ -2145,6 +2145,7 @@ class IssueReporter {
2145
2145
 
2146
2146
 
2147
2147
 
2148
+
2148
2149
 
2149
2150
  constructor() {
2150
2151
  addLevelsTo(this);
@@ -2156,12 +2157,17 @@ class IssueReporter {
2156
2157
  this.bufferTimeout = null;
2157
2158
  this._boundProcessBuffer = this._processBuffer.bind(this);
2158
2159
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
2160
+ this._callback = null;
2159
2161
  }
2160
2162
 
2161
2163
  init() {
2162
2164
  this._catchConsole();
2163
2165
  }
2164
2166
 
2167
+ setCallback(cb ) {
2168
+ this._callback = cb;
2169
+ }
2170
+
2165
2171
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
2166
2172
  this.remoteClientConfiguration = configuration;
2167
2173
  }
@@ -2197,6 +2203,7 @@ class IssueReporter {
2197
2203
 
2198
2204
  // Handle category label
2199
2205
  let category = null;
2206
+ let skipSendToRemote = false;
2200
2207
  let extra = {};
2201
2208
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
2202
2209
  category = args[0].split('=')[1];
@@ -2212,6 +2219,7 @@ class IssueReporter {
2212
2219
  errorMessage: lastArg.message,
2213
2220
  errorStack: lastArg.stack,
2214
2221
  errorType: lastArg.constructor.name,
2222
+ skipSendToRemote: lastArg.skipSendToRemote,
2215
2223
  };
2216
2224
  } else {
2217
2225
  extra = lastArg;
@@ -2220,6 +2228,11 @@ class IssueReporter {
2220
2228
  args.splice(1, 1);
2221
2229
  }
2222
2230
 
2231
+ if (extra.skipSendToRemote) {
2232
+ skipSendToRemote = true;
2233
+ delete extra.skipSendToRemote;
2234
+ }
2235
+
2223
2236
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
2224
2237
  const message = args.join(', ');
2225
2238
  let consoleMessage = message;
@@ -2240,7 +2253,13 @@ class IssueReporter {
2240
2253
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
2241
2254
  oldMethod.apply(oldMethod, [date, consoleMessage]);
2242
2255
 
2243
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
2256
+ if (this._callback) {
2257
+ this._callback(level, consoleMessage);
2258
+ }
2259
+
2260
+ if (!skipSendToRemote) {
2261
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
2262
+ }
2244
2263
  }
2245
2264
 
2246
2265
  logRequest(url , options , response , start ) {
@@ -2385,7 +2404,11 @@ class IssueReporter {
2385
2404
  },
2386
2405
  // $FlowFixMe
2387
2406
  body,
2388
- }).catch(() => {
2407
+ }).catch((e ) => {
2408
+ // $FlowFixMe
2409
+ e.skipSendToRemote = true;
2410
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
2411
+
2389
2412
  setTimeout(() => {
2390
2413
  if (isArray) {
2391
2414
  payload = payload.map(message => {
@@ -3144,11 +3167,24 @@ class Meeting {
3144
3167
  });
3145
3168
  }
3146
3169
 
3170
+ static parseMany(items ) {
3171
+ return items.map(plain => Meeting.parse(plain));
3172
+ }
3173
+
3147
3174
  static newFrom(meeting ) {
3148
3175
  return newFrom(meeting, Meeting);
3149
3176
  }
3150
3177
 
3151
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
3178
+ constructor({
3179
+ uuid,
3180
+ name,
3181
+ guestSipAuthorization,
3182
+ ownerUuids,
3183
+ port,
3184
+ uri,
3185
+ number,
3186
+ persistent,
3187
+ } = {}) {
3152
3188
  this.guestSipAuthorization = guestSipAuthorization;
3153
3189
  this.uri = uri;
3154
3190
  this.name = name;
@@ -3234,8 +3270,11 @@ var confdMethods = (client , baseUrl ) => ({
3234
3270
  }
3235
3271
  },
3236
3272
 
3237
- createMyMeeting: (name ) =>
3238
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
3273
+ getMyMeetings: () =>
3274
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3275
+
3276
+ createMyMeeting: (name , persistent ) =>
3277
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3239
3278
 
3240
3279
  deleteMyMeeting: (meetingUuid ) =>
3241
3280
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),