@webex/plugin-meetings 3.3.1 → 3.4.0

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 (126) hide show
  1. package/dist/breakouts/breakout.js +1 -1
  2. package/dist/breakouts/index.js +7 -2
  3. package/dist/breakouts/index.js.map +1 -1
  4. package/dist/constants.js +11 -4
  5. package/dist/constants.js.map +1 -1
  6. package/dist/interpretation/index.js +1 -1
  7. package/dist/interpretation/siLanguage.js +1 -1
  8. package/dist/locus-info/selfUtils.js +0 -5
  9. package/dist/locus-info/selfUtils.js.map +1 -1
  10. package/dist/media/MediaConnectionAwaiter.js +70 -15
  11. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  12. package/dist/media/index.js +12 -0
  13. package/dist/media/index.js.map +1 -1
  14. package/dist/meeting/connectionStateHandler.js +67 -0
  15. package/dist/meeting/connectionStateHandler.js.map +1 -0
  16. package/dist/meeting/index.js +552 -357
  17. package/dist/meeting/index.js.map +1 -1
  18. package/dist/meeting/locusMediaRequest.js +7 -0
  19. package/dist/meeting/locusMediaRequest.js.map +1 -1
  20. package/dist/meeting/muteState.js +6 -1
  21. package/dist/meeting/muteState.js.map +1 -1
  22. package/dist/meeting/util.js +1 -0
  23. package/dist/meeting/util.js.map +1 -1
  24. package/dist/meeting-info/index.js +4 -4
  25. package/dist/meeting-info/index.js.map +1 -1
  26. package/dist/meeting-info/meeting-info-v2.js +2 -2
  27. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  28. package/dist/meeting-info/util.js +17 -17
  29. package/dist/meeting-info/util.js.map +1 -1
  30. package/dist/meeting-info/utilv2.js +16 -16
  31. package/dist/meeting-info/utilv2.js.map +1 -1
  32. package/dist/meetings/collection.js +1 -1
  33. package/dist/meetings/collection.js.map +1 -1
  34. package/dist/meetings/index.js +37 -33
  35. package/dist/meetings/index.js.map +1 -1
  36. package/dist/meetings/meetings.types.js +8 -0
  37. package/dist/meetings/meetings.types.js.map +1 -1
  38. package/dist/meetings/util.js +3 -2
  39. package/dist/meetings/util.js.map +1 -1
  40. package/dist/metrics/constants.js +2 -1
  41. package/dist/metrics/constants.js.map +1 -1
  42. package/dist/metrics/index.js +57 -0
  43. package/dist/metrics/index.js.map +1 -1
  44. package/dist/personal-meeting-room/index.js +1 -1
  45. package/dist/personal-meeting-room/index.js.map +1 -1
  46. package/dist/reachability/clusterReachability.js +108 -53
  47. package/dist/reachability/clusterReachability.js.map +1 -1
  48. package/dist/reachability/index.js +415 -56
  49. package/dist/reachability/index.js.map +1 -1
  50. package/dist/types/constants.d.ts +11 -3
  51. package/dist/types/media/MediaConnectionAwaiter.d.ts +24 -4
  52. package/dist/types/meeting/connectionStateHandler.d.ts +30 -0
  53. package/dist/types/meeting/index.d.ts +27 -7
  54. package/dist/types/meeting/locusMediaRequest.d.ts +2 -0
  55. package/dist/types/meeting-info/index.d.ts +3 -2
  56. package/dist/types/meeting-info/meeting-info-v2.d.ts +3 -2
  57. package/dist/types/meeting-info/util.d.ts +5 -4
  58. package/dist/types/meeting-info/utilv2.d.ts +3 -2
  59. package/dist/types/meetings/collection.d.ts +3 -2
  60. package/dist/types/meetings/index.d.ts +4 -3
  61. package/dist/types/meetings/meetings.types.d.ts +9 -0
  62. package/dist/types/metrics/constants.d.ts +1 -0
  63. package/dist/types/metrics/index.d.ts +15 -0
  64. package/dist/types/reachability/clusterReachability.d.ts +31 -3
  65. package/dist/types/reachability/index.d.ts +93 -2
  66. package/dist/webinar/index.js +1 -1
  67. package/package.json +23 -23
  68. package/src/breakouts/index.ts +7 -1
  69. package/src/constants.ts +13 -17
  70. package/src/locus-info/selfUtils.ts +0 -5
  71. package/src/media/MediaConnectionAwaiter.ts +89 -14
  72. package/src/media/index.ts +13 -0
  73. package/src/meeting/connectionStateHandler.ts +65 -0
  74. package/src/meeting/index.ts +526 -292
  75. package/src/meeting/locusMediaRequest.ts +5 -0
  76. package/src/meeting/muteState.ts +6 -1
  77. package/src/meeting/util.ts +1 -0
  78. package/src/meeting-info/index.ts +9 -6
  79. package/src/meeting-info/meeting-info-v2.ts +4 -4
  80. package/src/meeting-info/util.ts +23 -28
  81. package/src/meeting-info/utilv2.ts +18 -24
  82. package/src/meetings/collection.ts +3 -3
  83. package/src/meetings/index.ts +39 -40
  84. package/src/meetings/meetings.types.ts +11 -0
  85. package/src/meetings/util.ts +5 -4
  86. package/src/metrics/constants.ts +1 -0
  87. package/src/metrics/index.ts +44 -0
  88. package/src/personal-meeting-room/index.ts +2 -2
  89. package/src/reachability/clusterReachability.ts +86 -25
  90. package/src/reachability/index.ts +316 -27
  91. package/test/unit/spec/breakouts/index.ts +51 -32
  92. package/test/unit/spec/locus-info/selfUtils.js +25 -23
  93. package/test/unit/spec/media/MediaConnectionAwaiter.ts +131 -32
  94. package/test/unit/spec/media/index.ts +42 -27
  95. package/test/unit/spec/meeting/connectionStateHandler.ts +102 -0
  96. package/test/unit/spec/meeting/index.js +758 -179
  97. package/test/unit/spec/meeting/locusMediaRequest.ts +7 -0
  98. package/test/unit/spec/meeting/muteState.js +24 -0
  99. package/test/unit/spec/meeting-info/index.js +4 -4
  100. package/test/unit/spec/meeting-info/meetinginfov2.js +24 -28
  101. package/test/unit/spec/meeting-info/request.js +2 -2
  102. package/test/unit/spec/meeting-info/utilv2.js +41 -49
  103. package/test/unit/spec/meetings/index.js +14 -0
  104. package/test/unit/spec/metrics/index.js +126 -0
  105. package/test/unit/spec/multistream/mediaRequestManager.ts +2 -2
  106. package/test/unit/spec/personal-meeting-room/personal-meeting-room.js +2 -2
  107. package/test/unit/spec/reachability/clusterReachability.ts +116 -22
  108. package/test/unit/spec/reachability/index.ts +1153 -84
  109. package/test/unit/spec/rtcMetrics/index.ts +1 -0
  110. package/dist/mediaQualityMetrics/config.js +0 -321
  111. package/dist/mediaQualityMetrics/config.js.map +0 -1
  112. package/dist/statsAnalyzer/global.js +0 -44
  113. package/dist/statsAnalyzer/global.js.map +0 -1
  114. package/dist/statsAnalyzer/index.js +0 -1072
  115. package/dist/statsAnalyzer/index.js.map +0 -1
  116. package/dist/statsAnalyzer/mqaUtil.js +0 -368
  117. package/dist/statsAnalyzer/mqaUtil.js.map +0 -1
  118. package/dist/types/mediaQualityMetrics/config.d.ts +0 -247
  119. package/dist/types/statsAnalyzer/global.d.ts +0 -36
  120. package/dist/types/statsAnalyzer/index.d.ts +0 -217
  121. package/dist/types/statsAnalyzer/mqaUtil.d.ts +0 -48
  122. package/src/mediaQualityMetrics/config.ts +0 -255
  123. package/src/statsAnalyzer/global.ts +0 -37
  124. package/src/statsAnalyzer/index.ts +0 -1318
  125. package/src/statsAnalyzer/mqaUtil.ts +0 -463
  126. package/test/unit/spec/stats-analyzer/index.js +0 -1819
@@ -1,5 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
4
+ var _Object$keys2 = require("@babel/runtime-corejs2/core-js/object/keys");
5
+ var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
6
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
7
+ var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
8
+ var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
3
9
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
10
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
5
11
  _Object$defineProperty(exports, "__esModule", {
@@ -11,45 +17,91 @@ var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/
11
17
  var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
12
18
  var _entries = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/entries"));
13
19
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
14
- var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
20
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
15
21
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
16
22
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
17
23
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
18
24
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
25
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/assertThisInitialized"));
26
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
27
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
28
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
19
29
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
20
30
  var _lodash = require("lodash");
31
+ var _common = require("@webex/common");
21
32
  var _loggerProxy = _interopRequireDefault(require("../common/logs/logger-proxy"));
22
33
  var _util = _interopRequireDefault(require("../meeting/util"));
23
34
  var _constants = require("../constants");
24
35
  var _request = _interopRequireDefault(require("./request"));
25
36
  var _clusterReachability = require("./clusterReachability");
26
- /*!
37
+ var _eventsScope = _interopRequireDefault(require("../common/events/events-scope"));
38
+ var _constants2 = _interopRequireDefault(require("../metrics/constants"));
39
+ var _metrics = _interopRequireDefault(require("../metrics"));
40
+ function ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
41
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
42
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
43
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /*!
27
44
  * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
28
- */
29
- /* eslint-disable class-methods-use-this */
45
+ */ /* eslint-disable class-methods-use-this */
30
46
  /**
31
47
  * This is the type that matches what backend expects us to send to them. It is a bit weird, because
32
48
  * it uses strings instead of booleans and numbers, but that's what they require.
33
49
  */
50
+
34
51
  // this is the type that is required by the backend when we send them reachability results
52
+
35
53
  // this is the type used by Reachability class internally and stored in local storage
54
+
55
+ // timeouts in seconds
56
+ var DEFAULT_TIMEOUT = 3;
57
+ var VIDEO_MESH_TIMEOUT = 1;
58
+ var OVERALL_TIMEOUT = 15;
59
+
36
60
  /**
37
61
  * @class Reachability
38
62
  * @export
39
63
  */
40
- var Reachability = exports.default = /*#__PURE__*/function () {
64
+ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
65
+ (0, _inherits2.default)(Reachability, _EventsScope);
66
+ var _super = _createSuper(Reachability);
41
67
  /**
42
68
  * Creates an instance of Reachability.
43
69
  * @param {object} webex
44
70
  * @memberof Reachability
45
71
  */
46
72
  function Reachability(webex) {
73
+ var _this;
47
74
  (0, _classCallCheck2.default)(this, Reachability);
48
- (0, _defineProperty2.default)(this, "namespace", _constants.REACHABILITY.namespace);
49
- (0, _defineProperty2.default)(this, "webex", void 0);
50
- (0, _defineProperty2.default)(this, "reachabilityRequest", void 0);
51
- (0, _defineProperty2.default)(this, "clusterReachability", void 0);
52
- this.webex = webex;
75
+ _this = _super.call(this);
76
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "namespace", _constants.REACHABILITY.namespace);
77
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "webex", void 0);
78
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "reachabilityRequest", void 0);
79
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clusterReachability", void 0);
80
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "reachabilityDefer", void 0);
81
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "vmnTimer", void 0);
82
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "publicCloudTimer", void 0);
83
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "overallTimer", void 0);
84
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "expectedResultsCount", {
85
+ videoMesh: {
86
+ udp: 0
87
+ },
88
+ public: {
89
+ udp: 0,
90
+ tcp: 0,
91
+ xtls: 0
92
+ }
93
+ });
94
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resultsCount", {
95
+ videoMesh: {
96
+ udp: 0
97
+ },
98
+ public: {
99
+ udp: 0,
100
+ tcp: 0,
101
+ xtls: 0
102
+ }
103
+ });
104
+ _this.webex = webex;
53
105
 
54
106
  /**
55
107
  * internal request object for the server
@@ -58,8 +110,9 @@ var Reachability = exports.default = /*#__PURE__*/function () {
58
110
  * @private
59
111
  * @memberof Reachability
60
112
  */
61
- this.reachabilityRequest = new _request.default(this.webex);
62
- this.clusterReachability = {};
113
+ _this.reachabilityRequest = new _request.default(_this.webex);
114
+ _this.clusterReachability = {};
115
+ return _this;
63
116
  }
64
117
 
65
118
  /**
@@ -72,7 +125,7 @@ var Reachability = exports.default = /*#__PURE__*/function () {
72
125
  key: "gatherReachability",
73
126
  value: (function () {
74
127
  var _gatherReachability = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
75
- var _yield$this$reachabil, clusters, joinCookie, results;
128
+ var _yield$this$reachabil, clusters, joinCookie;
76
129
  return _regenerator.default.wrap(function _callee$(_context) {
77
130
  while (1) switch (_context.prev = _context.next) {
78
131
  case 0:
@@ -84,27 +137,25 @@ var Reachability = exports.default = /*#__PURE__*/function () {
84
137
  clusters = _yield$this$reachabil.clusters;
85
138
  joinCookie = _yield$this$reachabil.joinCookie;
86
139
  _context.next = 8;
87
- return this.performReachabilityChecks(clusters);
140
+ return this.webex.boundedStorage.put(this.namespace, _constants.REACHABILITY.localStorageJoinCookie, (0, _stringify.default)(joinCookie));
88
141
  case 8:
89
- results = _context.sent;
142
+ this.reachabilityDefer = new _common.Defer();
143
+
144
+ // Perform Reachability Check
90
145
  _context.next = 11;
91
- return this.webex.boundedStorage.put(this.namespace, _constants.REACHABILITY.localStorageResult, (0, _stringify.default)(results));
146
+ return this.performReachabilityChecks(clusters);
92
147
  case 11:
93
- _context.next = 13;
94
- return this.webex.boundedStorage.put(this.namespace, _constants.REACHABILITY.localStorageJoinCookie, (0, _stringify.default)(joinCookie));
95
- case 13:
96
- _loggerProxy.default.logger.log('Reachability:index#gatherReachability --> Reachability checks completed');
97
- return _context.abrupt("return", results);
98
- case 17:
99
- _context.prev = 17;
148
+ return _context.abrupt("return", this.reachabilityDefer.promise);
149
+ case 14:
150
+ _context.prev = 14;
100
151
  _context.t0 = _context["catch"](0);
101
152
  _loggerProxy.default.logger.error("Reachability:index#gatherReachability --> Error:", _context.t0);
102
153
  return _context.abrupt("return", {});
103
- case 21:
154
+ case 18:
104
155
  case "end":
105
156
  return _context.stop();
106
157
  }
107
- }, _callee, this, [[0, 17]]);
158
+ }, _callee, this, [[0, 14]]);
108
159
  }));
109
160
  function gatherReachability() {
110
161
  return _gatherReachability.apply(this, arguments);
@@ -230,7 +281,7 @@ var Reachability = exports.default = /*#__PURE__*/function () {
230
281
  key: "getReachabilityResults",
231
282
  value: (function () {
232
283
  var _getReachabilityResults = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
233
- var _this = this;
284
+ var _this2 = this;
234
285
  var results, resultsJson, allClusterResults;
235
286
  return _regenerator.default.wrap(function _callee3$(_context3) {
236
287
  while (1) switch (_context3.prev = _context3.next) {
@@ -243,13 +294,13 @@ var Reachability = exports.default = /*#__PURE__*/function () {
243
294
  allClusterResults = JSON.parse(resultsJson);
244
295
  results = (0, _lodash.mapValues)(allClusterResults, function (clusterResult) {
245
296
  return {
246
- udp: _this.mapTransportResultToBackendDataFormat(clusterResult.udp || {
297
+ udp: _this2.mapTransportResultToBackendDataFormat(clusterResult.udp || {
247
298
  result: 'untested'
248
299
  }),
249
- tcp: _this.mapTransportResultToBackendDataFormat(clusterResult.tcp || {
300
+ tcp: _this2.mapTransportResultToBackendDataFormat(clusterResult.tcp || {
250
301
  result: 'untested'
251
302
  }),
252
- xtls: _this.mapTransportResultToBackendDataFormat(clusterResult.xtls || {
303
+ xtls: _this2.mapTransportResultToBackendDataFormat(clusterResult.xtls || {
253
304
  result: 'untested'
254
305
  })
255
306
  };
@@ -445,71 +496,379 @@ var Reachability = exports.default = /*#__PURE__*/function () {
445
496
  });
446
497
  }
447
498
 
499
+ /**
500
+ * Returns true if we've obtained all the reachability results for all the public clusters
501
+ * In other words, it means that all public clusters are reachable over each protocol,
502
+ * because we only get a "result" if we managed to reach a cluster
503
+ *
504
+ * @returns {boolean}
505
+ */
506
+ }, {
507
+ key: "areAllPublicClusterResultsReady",
508
+ value: function areAllPublicClusterResultsReady() {
509
+ return (0, _lodash.isEqual)(this.expectedResultsCount.public, this.resultsCount.public);
510
+ }
511
+
512
+ /**
513
+ * Returns true if we've obtained all the reachability results for all the clusters
514
+ *
515
+ * @returns {boolean}
516
+ */
517
+ }, {
518
+ key: "areAllResultsReady",
519
+ value: function areAllResultsReady() {
520
+ return (0, _lodash.isEqual)(this.expectedResultsCount, this.resultsCount);
521
+ }
522
+
523
+ /**
524
+ * Resolves the promise returned by gatherReachability() method
525
+ * @returns {void}
526
+ */
527
+ }, {
528
+ key: "resolveReachabilityPromise",
529
+ value: function resolveReachabilityPromise() {
530
+ var _this$reachabilityDef;
531
+ if (this.vmnTimer) {
532
+ clearTimeout(this.vmnTimer);
533
+ }
534
+ if (this.publicCloudTimer) {
535
+ clearTimeout(this.publicCloudTimer);
536
+ }
537
+ this.logUnreachableClusters();
538
+ (_this$reachabilityDef = this.reachabilityDefer) === null || _this$reachabilityDef === void 0 ? void 0 : _this$reachabilityDef.resolve();
539
+ }
540
+
541
+ /**
542
+ * Aborts all cluster reachability checks that are in progress
543
+ *
544
+ * @returns {void}
545
+ */
546
+ }, {
547
+ key: "abortClusterReachability",
548
+ value: function abortClusterReachability() {
549
+ (0, _values.default)(this.clusterReachability).forEach(function (clusterReachability) {
550
+ clusterReachability.abort();
551
+ });
552
+ }
553
+
554
+ /**
555
+ * Helper function for calculating min/max/average values of latency
556
+ *
557
+ * @param {Array<any>} results
558
+ * @param {string} protocol
559
+ * @param {boolean} isVideoMesh
560
+ * @returns {{min:number, max: number, average: number}}
561
+ */
562
+ }, {
563
+ key: "getStatistics",
564
+ value: function getStatistics(results, protocol, isVideoMesh) {
565
+ var values = results.filter(function (result) {
566
+ return result.isVideoMesh === isVideoMesh;
567
+ }).filter(function (result) {
568
+ return result[protocol].result === 'reachable';
569
+ }).map(function (result) {
570
+ return result[protocol].latencyInMilliseconds;
571
+ });
572
+ if (values.length === 0) {
573
+ return {
574
+ min: -1,
575
+ max: -1,
576
+ average: -1
577
+ };
578
+ }
579
+ return {
580
+ min: Math.min.apply(Math, (0, _toConsumableArray2.default)(values)),
581
+ max: Math.max.apply(Math, (0, _toConsumableArray2.default)(values)),
582
+ average: (0, _lodash.mean)(values)
583
+ };
584
+ }
585
+
586
+ /**
587
+ * Sends a metric with all the statistics about how long reachability took
588
+ *
589
+ * @returns {void}
590
+ */
591
+ }, {
592
+ key: "sendMetric",
593
+ value: (function () {
594
+ var _sendMetric = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
595
+ var results, stats;
596
+ return _regenerator.default.wrap(function _callee6$(_context6) {
597
+ while (1) switch (_context6.prev = _context6.next) {
598
+ case 0:
599
+ results = [];
600
+ (0, _values.default)(this.clusterReachability).forEach(function (clusterReachability) {
601
+ results.push(_objectSpread(_objectSpread({}, clusterReachability.getResult()), {}, {
602
+ isVideoMesh: clusterReachability.isVideoMesh
603
+ }));
604
+ });
605
+ stats = {
606
+ vmn: {
607
+ udp: this.getStatistics(results, 'udp', true)
608
+ },
609
+ public: {
610
+ udp: this.getStatistics(results, 'udp', false),
611
+ tcp: this.getStatistics(results, 'tcp', false),
612
+ xtls: this.getStatistics(results, 'xtls', false)
613
+ }
614
+ };
615
+ _metrics.default.sendBehavioralMetric(_constants2.default.REACHABILITY_COMPLETED, _metrics.default.prepareMetricFields(stats));
616
+ case 4:
617
+ case "end":
618
+ return _context6.stop();
619
+ }
620
+ }, _callee6, this);
621
+ }));
622
+ function sendMetric() {
623
+ return _sendMetric.apply(this, arguments);
624
+ }
625
+ return sendMetric;
626
+ }()
627
+ /**
628
+ * Starts all the timers used for various timeouts
629
+ *
630
+ * @returns {void}
631
+ */
632
+ )
633
+ }, {
634
+ key: "startTimers",
635
+ value: function startTimers() {
636
+ var _this3 = this;
637
+ this.vmnTimer = setTimeout(function () {
638
+ _this3.vmnTimer = undefined;
639
+ // if we are only missing VMN results, then we don't want to wait for them any longer
640
+ // as they are likely to fail if users are not on corporate network
641
+ if (_this3.areAllPublicClusterResultsReady()) {
642
+ _loggerProxy.default.logger.log('Reachability:index#startTimers --> Reachability checks timed out (VMN timeout)');
643
+ _this3.resolveReachabilityPromise();
644
+ }
645
+ }, VIDEO_MESH_TIMEOUT * 1000);
646
+ this.publicCloudTimer = setTimeout(function () {
647
+ _this3.publicCloudTimer = undefined;
648
+ _loggerProxy.default.logger.log("Reachability:index#startTimers --> Reachability checks timed out (".concat(DEFAULT_TIMEOUT, "s)"));
649
+
650
+ // resolve the promise, so that the client won't be blocked waiting on meetings.register() for too long
651
+ _this3.resolveReachabilityPromise();
652
+ }, DEFAULT_TIMEOUT * 1000);
653
+ this.overallTimer = setTimeout(function () {
654
+ _this3.overallTimer = undefined;
655
+ _this3.abortClusterReachability();
656
+ _this3.emit({
657
+ file: 'reachability',
658
+ function: 'overallTimer timeout'
659
+ }, 'reachability:done', {});
660
+ _this3.sendMetric();
661
+ _loggerProxy.default.logger.log("Reachability:index#startTimers --> Reachability checks fully timed out (".concat(OVERALL_TIMEOUT, "s)"));
662
+ }, OVERALL_TIMEOUT * 1000);
663
+ }
664
+
665
+ /**
666
+ * Stores given reachability results in local storage
667
+ *
668
+ * @param {ReachabilityResults} results
669
+ * @returns {Promise<void>}
670
+ */
671
+ }, {
672
+ key: "storeResults",
673
+ value: (function () {
674
+ var _storeResults = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(results) {
675
+ return _regenerator.default.wrap(function _callee7$(_context7) {
676
+ while (1) switch (_context7.prev = _context7.next) {
677
+ case 0:
678
+ _context7.next = 2;
679
+ return this.webex.boundedStorage.put(this.namespace, _constants.REACHABILITY.localStorageResult, (0, _stringify.default)(results));
680
+ case 2:
681
+ case "end":
682
+ return _context7.stop();
683
+ }
684
+ }, _callee7, this);
685
+ }));
686
+ function storeResults(_x) {
687
+ return _storeResults.apply(this, arguments);
688
+ }
689
+ return storeResults;
690
+ }()
691
+ /**
692
+ * Resets all the internal counters that keep track of the results
693
+ *
694
+ * @returns {void}
695
+ */
696
+ )
697
+ }, {
698
+ key: "resetResultCounters",
699
+ value: function resetResultCounters() {
700
+ this.expectedResultsCount.videoMesh.udp = 0;
701
+ this.expectedResultsCount.public.udp = 0;
702
+ this.expectedResultsCount.public.tcp = 0;
703
+ this.expectedResultsCount.public.xtls = 0;
704
+ this.resultsCount.videoMesh.udp = 0;
705
+ this.resultsCount.public.udp = 0;
706
+ this.resultsCount.public.tcp = 0;
707
+ this.resultsCount.public.xtls = 0;
708
+ }
709
+
448
710
  /**
449
711
  * Performs reachability checks for all clusters
450
712
  * @param {ClusterList} clusterList
451
- * @returns {Promise<ReachabilityResults>} reachability check results
713
+ * @returns {Promise<void>} promise that's resolved as soon as the checks are started
452
714
  */
453
715
  }, {
454
716
  key: "performReachabilityChecks",
455
717
  value: (function () {
456
- var _performReachabilityChecks = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(clusterList) {
457
- var _this2 = this;
458
- var results, clusterReachabilityChecks;
459
- return _regenerator.default.wrap(function _callee6$(_context6) {
460
- while (1) switch (_context6.prev = _context6.next) {
718
+ var _performReachabilityChecks = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(clusterList) {
719
+ var _this4 = this;
720
+ var results, isFirstResult;
721
+ return _regenerator.default.wrap(function _callee10$(_context10) {
722
+ while (1) switch (_context10.prev = _context10.next) {
461
723
  case 0:
462
724
  results = {};
725
+ this.clusterReachability = {};
463
726
  if (!(!clusterList || !(0, _keys.default)(clusterList).length)) {
464
- _context6.next = 3;
727
+ _context10.next = 4;
465
728
  break;
466
729
  }
467
- return _context6.abrupt("return", _promise.default.resolve(results));
468
- case 3:
730
+ return _context10.abrupt("return");
731
+ case 4:
469
732
  _loggerProxy.default.logger.log("Reachability:index#performReachabilityChecks --> doing UDP".concat(
470
733
  // @ts-ignore
471
734
  this.webex.config.meetings.experimental.enableTcpReachability ? ',TCP' : '').concat(
472
735
  // @ts-ignore
473
736
  this.webex.config.meetings.experimental.enableTlsReachability ? ',TLS' : '', " reachability checks"));
474
- clusterReachabilityChecks = (0, _keys.default)(clusterList).map(function (key) {
737
+ this.resetResultCounters();
738
+ this.startTimers();
739
+
740
+ // sanitize the urls in the clusterList
741
+ (0, _keys.default)(clusterList).forEach(function (key) {
475
742
  var cluster = clusterList[key];
476
743
 
477
744
  // Linus doesn't support TCP reachability checks on video mesh nodes
478
745
  var includeTcpReachability =
479
746
  // @ts-ignore
480
- _this2.webex.config.meetings.experimental.enableTcpReachability && !cluster.isVideoMesh;
747
+ _this4.webex.config.meetings.experimental.enableTcpReachability && !cluster.isVideoMesh;
481
748
  if (!includeTcpReachability) {
482
749
  cluster.tcp = [];
483
750
  }
751
+
752
+ // Linus doesn't support xTLS reachability checks on video mesh nodes
484
753
  var includeTlsReachability =
485
754
  // @ts-ignore
486
- _this2.webex.config.meetings.experimental.enableTlsReachability && !cluster.isVideoMesh;
755
+ _this4.webex.config.meetings.experimental.enableTlsReachability && !cluster.isVideoMesh;
487
756
  if (!includeTlsReachability) {
488
757
  cluster.xtls = [];
489
758
  }
490
- _this2.clusterReachability[key] = new _clusterReachability.ClusterReachability(key, cluster);
491
- return _this2.clusterReachability[key].start().then(function (result) {
492
- results[key] = result;
493
- results[key].isVideoMesh = cluster.isVideoMesh;
494
- });
759
+
760
+ // initialize the result for this cluster
761
+ results[key] = {
762
+ udp: {
763
+ result: cluster.udp.length > 0 ? 'unreachable' : 'untested'
764
+ },
765
+ tcp: {
766
+ result: cluster.tcp.length > 0 ? 'unreachable' : 'untested'
767
+ },
768
+ xtls: {
769
+ result: cluster.xtls.length > 0 ? 'unreachable' : 'untested'
770
+ },
771
+ isVideoMesh: cluster.isVideoMesh
772
+ };
773
+
774
+ // update expected results counters to include this cluster
775
+ _this4.expectedResultsCount[cluster.isVideoMesh ? 'videoMesh' : 'public'].udp += cluster.udp.length;
776
+ if (!cluster.isVideoMesh) {
777
+ _this4.expectedResultsCount.public.tcp += cluster.tcp.length;
778
+ _this4.expectedResultsCount.public.xtls += cluster.xtls.length;
779
+ }
495
780
  });
496
- _context6.next = 7;
497
- return _promise.default.all(clusterReachabilityChecks);
498
- case 7:
499
- this.logUnreachableClusters();
500
- return _context6.abrupt("return", results);
501
- case 9:
781
+ isFirstResult = {
782
+ udp: true,
783
+ tcp: true,
784
+ xtls: true
785
+ }; // save the initialized results (in case we don't get any "resultReady" events at all)
786
+ _context10.next = 11;
787
+ return this.storeResults(results);
788
+ case 11:
789
+ // now start the reachability on all the clusters
790
+ (0, _keys.default)(clusterList).forEach(function (key) {
791
+ var cluster = clusterList[key];
792
+ _this4.clusterReachability[key] = new _clusterReachability.ClusterReachability(key, cluster);
793
+ _this4.clusterReachability[key].on(_clusterReachability.Events.resultReady, /*#__PURE__*/function () {
794
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(data) {
795
+ var protocol, result, clientMediaIPs, latencyInMilliseconds, areAllResultsReady;
796
+ return _regenerator.default.wrap(function _callee8$(_context8) {
797
+ while (1) switch (_context8.prev = _context8.next) {
798
+ case 0:
799
+ protocol = data.protocol, result = data.result, clientMediaIPs = data.clientMediaIPs, latencyInMilliseconds = data.latencyInMilliseconds;
800
+ if (isFirstResult[protocol]) {
801
+ _this4.emit({
802
+ file: 'reachability',
803
+ function: 'resultReady event handler'
804
+ }, 'reachability:firstResultAvailable', {
805
+ protocol: protocol
806
+ });
807
+ isFirstResult[protocol] = false;
808
+ }
809
+ _this4.resultsCount[cluster.isVideoMesh ? 'videoMesh' : 'public'][protocol] += 1;
810
+ areAllResultsReady = _this4.areAllResultsReady();
811
+ results[key][protocol].result = result;
812
+ results[key][protocol].clientMediaIPs = clientMediaIPs;
813
+ results[key][protocol].latencyInMilliseconds = latencyInMilliseconds;
814
+ _context8.next = 9;
815
+ return _this4.storeResults(results);
816
+ case 9:
817
+ if (areAllResultsReady) {
818
+ clearTimeout(_this4.overallTimer);
819
+ _this4.overallTimer = undefined;
820
+ _this4.emit({
821
+ file: 'reachability',
822
+ function: 'performReachabilityChecks'
823
+ }, 'reachability:done', {});
824
+ _this4.sendMetric();
825
+ _loggerProxy.default.logger.log("Reachability:index#gatherReachability --> Reachability checks fully completed");
826
+ _this4.resolveReachabilityPromise();
827
+ }
828
+ case 10:
829
+ case "end":
830
+ return _context8.stop();
831
+ }
832
+ }, _callee8);
833
+ }));
834
+ return function (_x3) {
835
+ return _ref4.apply(this, arguments);
836
+ };
837
+ }());
838
+
839
+ // clientMediaIps can be updated independently from the results, so we need to listen for them too
840
+ _this4.clusterReachability[key].on(_clusterReachability.Events.clientMediaIpsUpdated, /*#__PURE__*/function () {
841
+ var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(data) {
842
+ return _regenerator.default.wrap(function _callee9$(_context9) {
843
+ while (1) switch (_context9.prev = _context9.next) {
844
+ case 0:
845
+ results[key][data.protocol].clientMediaIPs = data.clientMediaIPs;
846
+ _context9.next = 3;
847
+ return _this4.storeResults(results);
848
+ case 3:
849
+ case "end":
850
+ return _context9.stop();
851
+ }
852
+ }, _callee9);
853
+ }));
854
+ return function (_x4) {
855
+ return _ref5.apply(this, arguments);
856
+ };
857
+ }());
858
+ _this4.clusterReachability[key].start(); // not awaiting on purpose
859
+ });
860
+ case 12:
502
861
  case "end":
503
- return _context6.stop();
862
+ return _context10.stop();
504
863
  }
505
- }, _callee6, this);
864
+ }, _callee10, this);
506
865
  }));
507
- function performReachabilityChecks(_x) {
866
+ function performReachabilityChecks(_x2) {
508
867
  return _performReachabilityChecks.apply(this, arguments);
509
868
  }
510
869
  return performReachabilityChecks;
511
870
  }())
512
871
  }]);
513
872
  return Reachability;
514
- }();
873
+ }(_eventsScope.default);
515
874
  //# sourceMappingURL=index.js.map