@flashphoner/websdk 2.0.263 → 2.0.264

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flashphoner/websdk",
3
- "version": "2.0.263",
3
+ "version": "2.0.264",
4
4
  "description": "Official Flashphoner WebCallServer WebSDK package",
5
5
  "main": "./src/flashphoner-core.js",
6
6
  "types": "./src/flashphoner-core.d.ts",
@@ -20,7 +20,6 @@
20
20
  "chai": "^3.5.0",
21
21
  "grunt": "^1.0.1",
22
22
  "grunt-browserify": "^5.0.0",
23
- "grunt-contrib": "^0.11.0",
24
23
  "grunt-contrib-clean": "^1.0.0",
25
24
  "grunt-contrib-concat": "^1.0.1",
26
25
  "grunt-contrib-copy": "^1.0.0",
@@ -225,9 +225,7 @@ const StreamStatsCollector = function(description, id, mediaConnection, wsConnec
225
225
  statCollector.timerBusy = true;
226
226
  let stats = await statCollector.mediaConnection.getWebRTCStats();
227
227
 
228
- if (!statCollector.metricsBatch) {
229
- statCollector.metricsBatch = [];
230
- }
228
+ statCollector.startNewBatch();
231
229
 
232
230
  let metrics = [];
233
231
  let lostMetrics = [];
@@ -238,7 +236,7 @@ const StreamStatsCollector = function(description, id, mediaConnection, wsConnec
238
236
  id: components[1],
239
237
  name: components[2]
240
238
  }
241
- let value = "NO";
239
+ let value = null;
242
240
 
243
241
  if (stats[descriptor.type]) {
244
242
  for (const report of stats[descriptor.type]) {
@@ -248,23 +246,29 @@ const StreamStatsCollector = function(description, id, mediaConnection, wsConnec
248
246
  }
249
247
  }
250
248
  }
251
- metrics.push(value);
252
- if (value == "NO") {
249
+ if (value === null) {
253
250
  lostMetrics.push(descriptor);
251
+ } else {
252
+ metrics.push(value);
254
253
  }
255
254
  });
255
+ // Metrics list may change if some metrics are added or some metrics are lost #WCS-4627
256
+ let headersUpdated = await statCollector.updateHeaders(stats);
256
257
  if (lostMetrics.length) {
257
258
  statCollector.logger.info(LOG_PREFIX + "-" + statCollector.id, "Missing metrics: " + JSON.stringify(lostMetrics));
258
- }
259
- statCollector.metricsBatch.push(metrics);
260
- statCollector.batchCount--;
261
- if (statCollector.batchCount === 0) {
259
+ // Send metrics already collected and start a new batch with current metrics array to send them later #WCS-4627
262
260
  await statCollector.sendMetrics();
261
+ statCollector.startNewBatch(metrics);
262
+ } else {
263
+ statCollector.metricsBatch.push(metrics);
264
+ statCollector.batchCount--;
265
+ if (statCollector.batchCount === 0 || headersUpdated) {
266
+ await statCollector.sendMetrics();
267
+ }
263
268
  }
264
269
  // Check if metrics list changed and send a new headers if needed #WCS-4619
265
- if (await statCollector.updateHeaders(stats)) {
270
+ if (headersUpdated) {
266
271
  statCollector.logger.info(LOG_PREFIX + "-" + statCollector.id, "RTC metrics list has changed, sending a new metrics description");
267
- await statCollector.sendMetrics();
268
272
  statCollector.sendHeaders();
269
273
  }
270
274
  statCollector.timerBusy = false;
@@ -275,7 +279,7 @@ const StreamStatsCollector = function(description, id, mediaConnection, wsConnec
275
279
  let metricsToSend = [];
276
280
  let metricsData;
277
281
 
278
- for (let i = 0; i < statCollector.metricsBatch.length; i++) {
282
+ for (let i = 0; statCollector.metricsBatch && i < statCollector.metricsBatch.length; i++) {
279
283
  let metricsString = "";
280
284
  for (let j = 0; j < statCollector.metricsBatch[i].length; j++) {
281
285
  let valueString = valueToString(statCollector.metricsBatch[i][j]);
@@ -312,8 +316,21 @@ const StreamStatsCollector = function(description, id, mediaConnection, wsConnec
312
316
  };
313
317
  statCollector.send("webRTCMetricsBatch", data);
314
318
  }
315
- statCollector.metricsBatch = null;
316
- statCollector.batchCount = statCollector.description.batchSize;
319
+ statCollector.cleanBatch();
320
+ },
321
+ startNewBatch: function(metrics) {
322
+ if (!statCollector.metricsBatch) {
323
+ statCollector.metricsBatch = [];
324
+ if (metrics) {
325
+ statCollector.metricsBatch.push(metrics);
326
+ }
327
+ }
328
+ },
329
+ cleanBatch: function() {
330
+ if (statCollector.metricsBatch) {
331
+ statCollector.metricsBatch = null;
332
+ statCollector.batchCount = statCollector.description.batchSize;
333
+ }
317
334
  }
318
335
  }
319
336
  return statCollector;