@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
@@ -47,11 +47,24 @@ class Meeting {
47
47
  });
48
48
  }
49
49
 
50
+ static parseMany(items ) {
51
+ return items.map(plain => Meeting.parse(plain));
52
+ }
53
+
50
54
  static newFrom(meeting ) {
51
55
  return newFrom(meeting, Meeting);
52
56
  }
53
57
 
54
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
58
+ constructor({
59
+ uuid,
60
+ name,
61
+ guestSipAuthorization,
62
+ ownerUuids,
63
+ port,
64
+ uri,
65
+ number,
66
+ persistent,
67
+ } = {}) {
55
68
  this.guestSipAuthorization = guestSipAuthorization;
56
69
  this.uri = uri;
57
70
  this.name = name;
@@ -2510,6 +2510,7 @@ class IssueReporter {
2510
2510
 
2511
2511
 
2512
2512
 
2513
+
2513
2514
 
2514
2515
  constructor() {
2515
2516
  addLevelsTo(this);
@@ -2521,12 +2522,17 @@ class IssueReporter {
2521
2522
  this.bufferTimeout = null;
2522
2523
  this._boundProcessBuffer = this._processBuffer.bind(this);
2523
2524
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
2525
+ this._callback = null;
2524
2526
  }
2525
2527
 
2526
2528
  init() {
2527
2529
  this._catchConsole();
2528
2530
  }
2529
2531
 
2532
+ setCallback(cb ) {
2533
+ this._callback = cb;
2534
+ }
2535
+
2530
2536
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
2531
2537
  this.remoteClientConfiguration = configuration;
2532
2538
  }
@@ -2562,6 +2568,7 @@ class IssueReporter {
2562
2568
 
2563
2569
  // Handle category label
2564
2570
  let category = null;
2571
+ let skipSendToRemote = false;
2565
2572
  let extra = {};
2566
2573
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
2567
2574
  category = args[0].split('=')[1];
@@ -2577,6 +2584,7 @@ class IssueReporter {
2577
2584
  errorMessage: lastArg.message,
2578
2585
  errorStack: lastArg.stack,
2579
2586
  errorType: lastArg.constructor.name,
2587
+ skipSendToRemote: lastArg.skipSendToRemote,
2580
2588
  };
2581
2589
  } else {
2582
2590
  extra = lastArg;
@@ -2585,6 +2593,11 @@ class IssueReporter {
2585
2593
  args.splice(1, 1);
2586
2594
  }
2587
2595
 
2596
+ if (extra.skipSendToRemote) {
2597
+ skipSendToRemote = true;
2598
+ delete extra.skipSendToRemote;
2599
+ }
2600
+
2588
2601
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
2589
2602
  const message = args.join(', ');
2590
2603
  let consoleMessage = message;
@@ -2605,7 +2618,13 @@ class IssueReporter {
2605
2618
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
2606
2619
  oldMethod.apply(oldMethod, [date, consoleMessage]);
2607
2620
 
2608
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
2621
+ if (this._callback) {
2622
+ this._callback(level, consoleMessage);
2623
+ }
2624
+
2625
+ if (!skipSendToRemote) {
2626
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
2627
+ }
2609
2628
  }
2610
2629
 
2611
2630
  logRequest(url , options , response , start ) {
@@ -2750,7 +2769,11 @@ class IssueReporter {
2750
2769
  },
2751
2770
  // $FlowFixMe
2752
2771
  body,
2753
- }).catch(() => {
2772
+ }).catch((e ) => {
2773
+ // $FlowFixMe
2774
+ e.skipSendToRemote = true;
2775
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
2776
+
2754
2777
  setTimeout(() => {
2755
2778
  if (isArray) {
2756
2779
  payload = payload.map(message => {
@@ -3509,11 +3532,24 @@ class Meeting {
3509
3532
  });
3510
3533
  }
3511
3534
 
3535
+ static parseMany(items ) {
3536
+ return items.map(plain => Meeting.parse(plain));
3537
+ }
3538
+
3512
3539
  static newFrom(meeting ) {
3513
3540
  return newFrom(meeting, Meeting);
3514
3541
  }
3515
3542
 
3516
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
3543
+ constructor({
3544
+ uuid,
3545
+ name,
3546
+ guestSipAuthorization,
3547
+ ownerUuids,
3548
+ port,
3549
+ uri,
3550
+ number,
3551
+ persistent,
3552
+ } = {}) {
3517
3553
  this.guestSipAuthorization = guestSipAuthorization;
3518
3554
  this.uri = uri;
3519
3555
  this.name = name;
@@ -3599,8 +3635,11 @@ var confdMethods = (client , baseUrl ) => ({
3599
3635
  }
3600
3636
  },
3601
3637
 
3602
- createMyMeeting: (name ) =>
3603
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
3638
+ getMyMeetings: () =>
3639
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3640
+
3641
+ createMyMeeting: (name , persistent ) =>
3642
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3604
3643
 
3605
3644
  deleteMyMeeting: (meetingUuid ) =>
3606
3645
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -487,6 +487,7 @@ class IssueReporter {
487
487
 
488
488
 
489
489
 
490
+
490
491
 
491
492
  constructor() {
492
493
  addLevelsTo(this);
@@ -498,12 +499,17 @@ class IssueReporter {
498
499
  this.bufferTimeout = null;
499
500
  this._boundProcessBuffer = this._processBuffer.bind(this);
500
501
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
502
+ this._callback = null;
501
503
  }
502
504
 
503
505
  init() {
504
506
  this._catchConsole();
505
507
  }
506
508
 
509
+ setCallback(cb ) {
510
+ this._callback = cb;
511
+ }
512
+
507
513
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
508
514
  this.remoteClientConfiguration = configuration;
509
515
  }
@@ -539,6 +545,7 @@ class IssueReporter {
539
545
 
540
546
  // Handle category label
541
547
  let category = null;
548
+ let skipSendToRemote = false;
542
549
  let extra = {};
543
550
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
544
551
  category = args[0].split('=')[1];
@@ -554,6 +561,7 @@ class IssueReporter {
554
561
  errorMessage: lastArg.message,
555
562
  errorStack: lastArg.stack,
556
563
  errorType: lastArg.constructor.name,
564
+ skipSendToRemote: lastArg.skipSendToRemote,
557
565
  };
558
566
  } else {
559
567
  extra = lastArg;
@@ -562,6 +570,11 @@ class IssueReporter {
562
570
  args.splice(1, 1);
563
571
  }
564
572
 
573
+ if (extra.skipSendToRemote) {
574
+ skipSendToRemote = true;
575
+ delete extra.skipSendToRemote;
576
+ }
577
+
565
578
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
566
579
  const message = args.join(', ');
567
580
  let consoleMessage = message;
@@ -582,7 +595,13 @@ class IssueReporter {
582
595
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
583
596
  oldMethod.apply(oldMethod, [date, consoleMessage]);
584
597
 
585
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
598
+ if (this._callback) {
599
+ this._callback(level, consoleMessage);
600
+ }
601
+
602
+ if (!skipSendToRemote) {
603
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
604
+ }
586
605
  }
587
606
 
588
607
  logRequest(url , options , response , start ) {
@@ -727,7 +746,11 @@ class IssueReporter {
727
746
  },
728
747
  // $FlowFixMe
729
748
  body,
730
- }).catch(() => {
749
+ }).catch((e ) => {
750
+ // $FlowFixMe
751
+ e.skipSendToRemote = true;
752
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
753
+
731
754
  setTimeout(() => {
732
755
  if (isArray) {
733
756
  payload = payload.map(message => {
@@ -1239,9 +1262,11 @@ class WebRTCPhone extends Emitter {
1239
1262
  case SessionState.Terminated: {
1240
1263
  logger.info('WebRTC phone - call terminated', { sipId: sipSession.id });
1241
1264
 
1265
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
1266
+ const callSession = this._createCallSession(sipSession);
1242
1267
  const wasCurrentSession = this._onCallTerminated(sipSession);
1243
1268
 
1244
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
1269
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
1245
1270
  }
1246
1271
  }
1247
1272
  });
@@ -2189,6 +2214,10 @@ class WebRTCPhone extends Emitter {
2189
2214
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
2190
2215
  }
2191
2216
 
2217
+ getRemoteVideoStreamFromPc(callSession ) {
2218
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
2219
+ }
2220
+
2192
2221
  hasRemoteVideo(callSession ) {
2193
2222
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
2194
2223
  }
package/esm/index.js CHANGED
@@ -150,6 +150,7 @@ class IssueReporter {
150
150
 
151
151
 
152
152
 
153
+
153
154
 
154
155
  constructor() {
155
156
  addLevelsTo(this);
@@ -161,12 +162,17 @@ class IssueReporter {
161
162
  this.bufferTimeout = null;
162
163
  this._boundProcessBuffer = this._processBuffer.bind(this);
163
164
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
165
+ this._callback = null;
164
166
  }
165
167
 
166
168
  init() {
167
169
  this._catchConsole();
168
170
  }
169
171
 
172
+ setCallback(cb ) {
173
+ this._callback = cb;
174
+ }
175
+
170
176
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
171
177
  this.remoteClientConfiguration = configuration;
172
178
  }
@@ -202,6 +208,7 @@ class IssueReporter {
202
208
 
203
209
  // Handle category label
204
210
  let category = null;
211
+ let skipSendToRemote = false;
205
212
  let extra = {};
206
213
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
207
214
  category = args[0].split('=')[1];
@@ -217,6 +224,7 @@ class IssueReporter {
217
224
  errorMessage: lastArg.message,
218
225
  errorStack: lastArg.stack,
219
226
  errorType: lastArg.constructor.name,
227
+ skipSendToRemote: lastArg.skipSendToRemote,
220
228
  };
221
229
  } else {
222
230
  extra = lastArg;
@@ -225,6 +233,11 @@ class IssueReporter {
225
233
  args.splice(1, 1);
226
234
  }
227
235
 
236
+ if (extra.skipSendToRemote) {
237
+ skipSendToRemote = true;
238
+ delete extra.skipSendToRemote;
239
+ }
240
+
228
241
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
229
242
  const message = args.join(', ');
230
243
  let consoleMessage = message;
@@ -245,7 +258,13 @@ class IssueReporter {
245
258
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
246
259
  oldMethod.apply(oldMethod, [date, consoleMessage]);
247
260
 
248
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
261
+ if (this._callback) {
262
+ this._callback(level, consoleMessage);
263
+ }
264
+
265
+ if (!skipSendToRemote) {
266
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
267
+ }
249
268
  }
250
269
 
251
270
  logRequest(url , options , response , start ) {
@@ -390,7 +409,11 @@ class IssueReporter {
390
409
  },
391
410
  // $FlowFixMe
392
411
  body,
393
- }).catch(() => {
412
+ }).catch((e ) => {
413
+ // $FlowFixMe
414
+ e.skipSendToRemote = true;
415
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
416
+
394
417
  setTimeout(() => {
395
418
  if (isArray) {
396
419
  payload = payload.map(message => {
@@ -2634,11 +2657,24 @@ class Meeting {
2634
2657
  });
2635
2658
  }
2636
2659
 
2660
+ static parseMany(items ) {
2661
+ return items.map(plain => Meeting.parse(plain));
2662
+ }
2663
+
2637
2664
  static newFrom(meeting ) {
2638
2665
  return newFrom(meeting, Meeting);
2639
2666
  }
2640
2667
 
2641
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2668
+ constructor({
2669
+ uuid,
2670
+ name,
2671
+ guestSipAuthorization,
2672
+ ownerUuids,
2673
+ port,
2674
+ uri,
2675
+ number,
2676
+ persistent,
2677
+ } = {}) {
2642
2678
  this.guestSipAuthorization = guestSipAuthorization;
2643
2679
  this.uri = uri;
2644
2680
  this.name = name;
@@ -2724,8 +2760,11 @@ var confdMethods = (client , baseUrl ) => ({
2724
2760
  }
2725
2761
  },
2726
2762
 
2727
- createMyMeeting: (name ) =>
2728
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2763
+ getMyMeetings: () =>
2764
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2765
+
2766
+ createMyMeeting: (name , persistent ) =>
2767
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2729
2768
 
2730
2769
  deleteMyMeeting: (meetingUuid ) =>
2731
2770
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -6522,7 +6561,9 @@ class WebRTCClient extends Emitter {
6522
6561
  const inviteOptions = {
6523
6562
  requestDelegate: {
6524
6563
  onAccept: (response ) => {
6525
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
6564
+ if (session.sessionDescriptionHandler.peerConnection) {
6565
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
6566
+ }
6526
6567
  this._onAccepted(session, response.session, true);
6527
6568
  },
6528
6569
  onReject: (response ) => {
@@ -7394,6 +7435,16 @@ class WebRTCClient extends Emitter {
7394
7435
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7395
7436
  }
7396
7437
 
7438
+ // Useful in a react-native environment when remoteMediaStream is not updated
7439
+ getRemoteVideoStreamFromPc(sessionId ) {
7440
+ const pc = this.getPeerConnection(sessionId);
7441
+ if (!pc) {
7442
+ return null;
7443
+ }
7444
+
7445
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7446
+ }
7447
+
7397
7448
  hasVideo(sessionId ) {
7398
7449
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7399
7450
  }
@@ -8172,18 +8223,22 @@ class WebRTCClient extends Emitter {
8172
8223
  });
8173
8224
 
8174
8225
  networkStats.packetsLost = packetsLost;
8175
- networkStats.audioBytesSent = audioBytesSent;
8226
+ networkStats.totalAudioBytesSent = audioBytesSent;
8227
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8228
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8176
8229
  networkStats.audioBytesReceived = audioBytesReceived;
8177
- networkStats.videoBytesSent = videoBytesSent;
8178
- networkStats.videoBytesReceived = videoBytesReceived;
8230
+ networkStats.totalVideoBytesSent = videoBytesSent;
8231
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8232
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8233
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8234
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8179
8235
  networkStats.transportSent = transportSent;
8180
- networkStats.transportReceived = transportReceived;
8236
+ networkStats.totalTransportReceived = transportReceived;
8237
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8181
8238
 
8182
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8183
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8184
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8185
-
8186
- networkStats.bandwidth = bandwidth;
8239
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8240
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8241
+ + networkStats.transportSent;
8187
8242
 
8188
8243
  this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8189
8244
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -8279,6 +8334,7 @@ const AGENT_PAUSED = 'agent_paused';
8279
8334
  const AGENT_UNPAUSED = 'agent_unpaused';
8280
8335
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
8281
8336
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
8337
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
8282
8338
 
8283
8339
  const BLACKLIST_EVENTS = [
8284
8340
  CHAT_MESSAGE_SENT,
@@ -8629,6 +8685,7 @@ WebSocketClient.eventLists = [
8629
8685
  AGENT_UNPAUSED,
8630
8686
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
8631
8687
  CONFERENCE_ADHOC_DELETED,
8688
+ MEETING_USER_PROGRESS,
8632
8689
  ];
8633
8690
 
8634
8691
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -8699,6 +8756,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
8699
8756
  AGENT_UNPAUSED: AGENT_UNPAUSED,
8700
8757
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
8701
8758
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
8759
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
8702
8760
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
8703
8761
  'default': WebSocketClient
8704
8762
  });
@@ -9484,9 +9542,11 @@ class WebRTCPhone extends Emitter {
9484
9542
  case SessionState.Terminated: {
9485
9543
  logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9486
9544
 
9545
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
9546
+ const callSession = this._createCallSession(sipSession);
9487
9547
  const wasCurrentSession = this._onCallTerminated(sipSession);
9488
9548
 
9489
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
9549
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
9490
9550
  }
9491
9551
  }
9492
9552
  });
@@ -10434,6 +10494,10 @@ class WebRTCPhone extends Emitter {
10434
10494
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
10435
10495
  }
10436
10496
 
10497
+ getRemoteVideoStreamFromPc(callSession ) {
10498
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
10499
+ }
10500
+
10437
10501
  hasRemoteVideo(callSession ) {
10438
10502
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
10439
10503
  }
@@ -12152,6 +12216,11 @@ class Phone extends Emitter {
12152
12216
  return this.getRemoteVideoStream(callSession);
12153
12217
  }
12154
12218
 
12219
+ // Useful in a react-native environment when remoteMediaStream is not updated
12220
+ getRemoteVideoStreamFromPc(callSession ) {
12221
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
12222
+ }
12223
+
12155
12224
  hasVideo(callSession ) {
12156
12225
  return this.phone ? this.phone.hasVideo(callSession) : false;
12157
12226
  }
@@ -97,6 +97,7 @@ class IssueReporter {
97
97
 
98
98
 
99
99
 
100
+
100
101
 
101
102
  constructor() {
102
103
  addLevelsTo(this);
@@ -108,12 +109,17 @@ class IssueReporter {
108
109
  this.bufferTimeout = null;
109
110
  this._boundProcessBuffer = this._processBuffer.bind(this);
110
111
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
112
+ this._callback = null;
111
113
  }
112
114
 
113
115
  init() {
114
116
  this._catchConsole();
115
117
  }
116
118
 
119
+ setCallback(cb ) {
120
+ this._callback = cb;
121
+ }
122
+
117
123
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
118
124
  this.remoteClientConfiguration = configuration;
119
125
  }
@@ -149,6 +155,7 @@ class IssueReporter {
149
155
 
150
156
  // Handle category label
151
157
  let category = null;
158
+ let skipSendToRemote = false;
152
159
  let extra = {};
153
160
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
154
161
  category = args[0].split('=')[1];
@@ -164,6 +171,7 @@ class IssueReporter {
164
171
  errorMessage: lastArg.message,
165
172
  errorStack: lastArg.stack,
166
173
  errorType: lastArg.constructor.name,
174
+ skipSendToRemote: lastArg.skipSendToRemote,
167
175
  };
168
176
  } else {
169
177
  extra = lastArg;
@@ -172,6 +180,11 @@ class IssueReporter {
172
180
  args.splice(1, 1);
173
181
  }
174
182
 
183
+ if (extra.skipSendToRemote) {
184
+ skipSendToRemote = true;
185
+ delete extra.skipSendToRemote;
186
+ }
187
+
175
188
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
176
189
  const message = args.join(', ');
177
190
  let consoleMessage = message;
@@ -192,7 +205,13 @@ class IssueReporter {
192
205
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
193
206
  oldMethod.apply(oldMethod, [date, consoleMessage]);
194
207
 
195
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
208
+ if (this._callback) {
209
+ this._callback(level, consoleMessage);
210
+ }
211
+
212
+ if (!skipSendToRemote) {
213
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
214
+ }
196
215
  }
197
216
 
198
217
  logRequest(url , options , response , start ) {
@@ -337,7 +356,11 @@ class IssueReporter {
337
356
  },
338
357
  // $FlowFixMe
339
358
  body,
340
- }).catch(() => {
359
+ }).catch((e ) => {
360
+ // $FlowFixMe
361
+ e.skipSendToRemote = true;
362
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
363
+
341
364
  setTimeout(() => {
342
365
  if (isArray) {
343
366
  payload = payload.map(message => {
@@ -2139,6 +2139,7 @@ class IssueReporter {
2139
2139
 
2140
2140
 
2141
2141
 
2142
+
2142
2143
 
2143
2144
  constructor() {
2144
2145
  addLevelsTo(this);
@@ -2150,12 +2151,17 @@ class IssueReporter {
2150
2151
  this.bufferTimeout = null;
2151
2152
  this._boundProcessBuffer = this._processBuffer.bind(this);
2152
2153
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
2154
+ this._callback = null;
2153
2155
  }
2154
2156
 
2155
2157
  init() {
2156
2158
  this._catchConsole();
2157
2159
  }
2158
2160
 
2161
+ setCallback(cb ) {
2162
+ this._callback = cb;
2163
+ }
2164
+
2159
2165
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
2160
2166
  this.remoteClientConfiguration = configuration;
2161
2167
  }
@@ -2191,6 +2197,7 @@ class IssueReporter {
2191
2197
 
2192
2198
  // Handle category label
2193
2199
  let category = null;
2200
+ let skipSendToRemote = false;
2194
2201
  let extra = {};
2195
2202
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
2196
2203
  category = args[0].split('=')[1];
@@ -2206,6 +2213,7 @@ class IssueReporter {
2206
2213
  errorMessage: lastArg.message,
2207
2214
  errorStack: lastArg.stack,
2208
2215
  errorType: lastArg.constructor.name,
2216
+ skipSendToRemote: lastArg.skipSendToRemote,
2209
2217
  };
2210
2218
  } else {
2211
2219
  extra = lastArg;
@@ -2214,6 +2222,11 @@ class IssueReporter {
2214
2222
  args.splice(1, 1);
2215
2223
  }
2216
2224
 
2225
+ if (extra.skipSendToRemote) {
2226
+ skipSendToRemote = true;
2227
+ delete extra.skipSendToRemote;
2228
+ }
2229
+
2217
2230
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
2218
2231
  const message = args.join(', ');
2219
2232
  let consoleMessage = message;
@@ -2234,7 +2247,13 @@ class IssueReporter {
2234
2247
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
2235
2248
  oldMethod.apply(oldMethod, [date, consoleMessage]);
2236
2249
 
2237
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
2250
+ if (this._callback) {
2251
+ this._callback(level, consoleMessage);
2252
+ }
2253
+
2254
+ if (!skipSendToRemote) {
2255
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
2256
+ }
2238
2257
  }
2239
2258
 
2240
2259
  logRequest(url , options , response , start ) {
@@ -2379,7 +2398,11 @@ class IssueReporter {
2379
2398
  },
2380
2399
  // $FlowFixMe
2381
2400
  body,
2382
- }).catch(() => {
2401
+ }).catch((e ) => {
2402
+ // $FlowFixMe
2403
+ e.skipSendToRemote = true;
2404
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
2405
+
2383
2406
  setTimeout(() => {
2384
2407
  if (isArray) {
2385
2408
  payload = payload.map(message => {
@@ -3138,11 +3161,24 @@ class Meeting {
3138
3161
  });
3139
3162
  }
3140
3163
 
3164
+ static parseMany(items ) {
3165
+ return items.map(plain => Meeting.parse(plain));
3166
+ }
3167
+
3141
3168
  static newFrom(meeting ) {
3142
3169
  return newFrom(meeting, Meeting);
3143
3170
  }
3144
3171
 
3145
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
3172
+ constructor({
3173
+ uuid,
3174
+ name,
3175
+ guestSipAuthorization,
3176
+ ownerUuids,
3177
+ port,
3178
+ uri,
3179
+ number,
3180
+ persistent,
3181
+ } = {}) {
3146
3182
  this.guestSipAuthorization = guestSipAuthorization;
3147
3183
  this.uri = uri;
3148
3184
  this.name = name;
@@ -3228,8 +3264,11 @@ var confdMethods = (client , baseUrl ) => ({
3228
3264
  }
3229
3265
  },
3230
3266
 
3231
- createMyMeeting: (name ) =>
3232
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
3267
+ getMyMeetings: () =>
3268
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3269
+
3270
+ createMyMeeting: (name , persistent ) =>
3271
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3233
3272
 
3234
3273
  deleteMyMeeting: (meetingUuid ) =>
3235
3274
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),