@webex/plugin-meetings 3.7.0 → 3.8.0-next.10

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 (206) hide show
  1. package/dist/annotation/index.js +17 -0
  2. package/dist/annotation/index.js.map +1 -1
  3. package/dist/breakouts/breakout.js +1 -1
  4. package/dist/breakouts/index.js +1 -1
  5. package/dist/common/errors/join-forbidden-error.js +52 -0
  6. package/dist/common/errors/join-forbidden-error.js.map +1 -0
  7. package/dist/common/errors/{webinar-registration-error.js → join-webinar-error.js} +12 -12
  8. package/dist/common/errors/join-webinar-error.js.map +1 -0
  9. package/dist/common/errors/multistream-not-supported-error.js +53 -0
  10. package/dist/common/errors/multistream-not-supported-error.js.map +1 -0
  11. package/dist/config.js +3 -1
  12. package/dist/config.js.map +1 -1
  13. package/dist/constants.js +69 -6
  14. package/dist/constants.js.map +1 -1
  15. package/dist/index.js +16 -11
  16. package/dist/index.js.map +1 -1
  17. package/dist/interpretation/index.js +4 -4
  18. package/dist/interpretation/index.js.map +1 -1
  19. package/dist/interpretation/siLanguage.js +1 -1
  20. package/dist/locus-info/index.js +14 -3
  21. package/dist/locus-info/index.js.map +1 -1
  22. package/dist/locus-info/selfUtils.js +35 -17
  23. package/dist/locus-info/selfUtils.js.map +1 -1
  24. package/dist/media/MediaConnectionAwaiter.js +1 -0
  25. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  26. package/dist/media/properties.js +30 -16
  27. package/dist/media/properties.js.map +1 -1
  28. package/dist/meeting/brbState.js +167 -0
  29. package/dist/meeting/brbState.js.map +1 -0
  30. package/dist/meeting/in-meeting-actions.js +13 -1
  31. package/dist/meeting/in-meeting-actions.js.map +1 -1
  32. package/dist/meeting/index.js +1373 -1052
  33. package/dist/meeting/index.js.map +1 -1
  34. package/dist/meeting/locusMediaRequest.js +32 -11
  35. package/dist/meeting/locusMediaRequest.js.map +1 -1
  36. package/dist/meeting/muteState.js +1 -6
  37. package/dist/meeting/muteState.js.map +1 -1
  38. package/dist/meeting/request.js +51 -29
  39. package/dist/meeting/request.js.map +1 -1
  40. package/dist/meeting/request.type.js.map +1 -1
  41. package/dist/meeting/util.js +103 -67
  42. package/dist/meeting/util.js.map +1 -1
  43. package/dist/meeting-info/meeting-info-v2.js +115 -45
  44. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  45. package/dist/meeting-info/utilv2.js +6 -2
  46. package/dist/meeting-info/utilv2.js.map +1 -1
  47. package/dist/meetings/index.js +107 -55
  48. package/dist/meetings/index.js.map +1 -1
  49. package/dist/meetings/meetings.types.js +2 -0
  50. package/dist/meetings/meetings.types.js.map +1 -1
  51. package/dist/meetings/util.js +1 -1
  52. package/dist/meetings/util.js.map +1 -1
  53. package/dist/member/index.js +9 -0
  54. package/dist/member/index.js.map +1 -1
  55. package/dist/member/types.js.map +1 -1
  56. package/dist/member/util.js +39 -28
  57. package/dist/member/util.js.map +1 -1
  58. package/dist/members/util.js +4 -2
  59. package/dist/members/util.js.map +1 -1
  60. package/dist/metrics/constants.js +6 -1
  61. package/dist/metrics/constants.js.map +1 -1
  62. package/dist/multistream/remoteMedia.js +30 -15
  63. package/dist/multistream/remoteMedia.js.map +1 -1
  64. package/dist/multistream/remoteMediaManager.js +40 -8
  65. package/dist/multistream/remoteMediaManager.js.map +1 -1
  66. package/dist/multistream/sendSlotManager.js +24 -0
  67. package/dist/multistream/sendSlotManager.js.map +1 -1
  68. package/dist/reachability/clusterReachability.js +12 -15
  69. package/dist/reachability/clusterReachability.js.map +1 -1
  70. package/dist/reachability/index.js +471 -140
  71. package/dist/reachability/index.js.map +1 -1
  72. package/dist/{rtcMetrics/constants.js → reachability/reachability.types.js} +1 -5
  73. package/dist/reachability/reachability.types.js.map +1 -0
  74. package/dist/reachability/request.js +21 -8
  75. package/dist/reachability/request.js.map +1 -1
  76. package/dist/recording-controller/enums.js +8 -4
  77. package/dist/recording-controller/enums.js.map +1 -1
  78. package/dist/recording-controller/index.js +18 -9
  79. package/dist/recording-controller/index.js.map +1 -1
  80. package/dist/recording-controller/util.js +13 -9
  81. package/dist/recording-controller/util.js.map +1 -1
  82. package/dist/roap/index.js +15 -15
  83. package/dist/roap/index.js.map +1 -1
  84. package/dist/roap/request.js +45 -79
  85. package/dist/roap/request.js.map +1 -1
  86. package/dist/roap/turnDiscovery.js +3 -6
  87. package/dist/roap/turnDiscovery.js.map +1 -1
  88. package/dist/types/annotation/index.d.ts +5 -0
  89. package/dist/types/common/errors/join-forbidden-error.d.ts +15 -0
  90. package/dist/types/common/errors/{webinar-registration-error.d.ts → join-webinar-error.d.ts} +2 -2
  91. package/dist/types/common/errors/multistream-not-supported-error.d.ts +17 -0
  92. package/dist/types/config.d.ts +2 -0
  93. package/dist/types/constants.d.ts +54 -1
  94. package/dist/types/index.d.ts +3 -3
  95. package/dist/types/locus-info/index.d.ts +2 -1
  96. package/dist/types/meeting/brbState.d.ts +54 -0
  97. package/dist/types/meeting/in-meeting-actions.d.ts +12 -0
  98. package/dist/types/meeting/index.d.ts +86 -14
  99. package/dist/types/meeting/locusMediaRequest.d.ts +6 -3
  100. package/dist/types/meeting/request.d.ts +14 -3
  101. package/dist/types/meeting/request.type.d.ts +6 -0
  102. package/dist/types/meeting/util.d.ts +3 -3
  103. package/dist/types/meeting-info/meeting-info-v2.d.ts +30 -5
  104. package/dist/types/meetings/index.d.ts +20 -2
  105. package/dist/types/meetings/meetings.types.d.ts +8 -0
  106. package/dist/types/member/index.d.ts +1 -0
  107. package/dist/types/member/types.d.ts +7 -0
  108. package/dist/types/members/util.d.ts +2 -0
  109. package/dist/types/metrics/constants.d.ts +6 -1
  110. package/dist/types/multistream/remoteMediaManager.d.ts +10 -1
  111. package/dist/types/multistream/sendSlotManager.d.ts +8 -1
  112. package/dist/types/reachability/clusterReachability.d.ts +1 -10
  113. package/dist/types/reachability/index.d.ts +83 -36
  114. package/dist/types/reachability/reachability.types.d.ts +64 -0
  115. package/dist/types/reachability/request.d.ts +5 -1
  116. package/dist/types/recording-controller/enums.d.ts +5 -2
  117. package/dist/types/recording-controller/index.d.ts +1 -0
  118. package/dist/types/recording-controller/util.d.ts +2 -1
  119. package/dist/types/roap/request.d.ts +1 -13
  120. package/dist/webinar/index.js +390 -7
  121. package/dist/webinar/index.js.map +1 -1
  122. package/package.json +23 -22
  123. package/src/annotation/index.ts +16 -0
  124. package/src/common/errors/join-forbidden-error.ts +26 -0
  125. package/src/common/errors/join-webinar-error.ts +24 -0
  126. package/src/common/errors/multistream-not-supported-error.ts +30 -0
  127. package/src/config.ts +2 -0
  128. package/src/constants.ts +62 -3
  129. package/src/index.ts +5 -3
  130. package/src/interpretation/index.ts +3 -3
  131. package/src/locus-info/index.ts +20 -3
  132. package/src/locus-info/selfUtils.ts +24 -6
  133. package/src/media/MediaConnectionAwaiter.ts +2 -0
  134. package/src/media/properties.ts +34 -13
  135. package/src/meeting/brbState.ts +169 -0
  136. package/src/meeting/in-meeting-actions.ts +25 -0
  137. package/src/meeting/index.ts +485 -88
  138. package/src/meeting/locusMediaRequest.ts +38 -12
  139. package/src/meeting/muteState.ts +1 -6
  140. package/src/meeting/request.ts +30 -12
  141. package/src/meeting/request.type.ts +7 -0
  142. package/src/meeting/util.ts +32 -13
  143. package/src/meeting-info/meeting-info-v2.ts +83 -12
  144. package/src/meeting-info/utilv2.ts +17 -3
  145. package/src/meetings/index.ts +79 -20
  146. package/src/meetings/meetings.types.ts +10 -0
  147. package/src/meetings/util.ts +2 -1
  148. package/src/member/index.ts +9 -0
  149. package/src/member/types.ts +8 -0
  150. package/src/member/util.ts +34 -24
  151. package/src/members/util.ts +1 -0
  152. package/src/metrics/constants.ts +6 -1
  153. package/src/multistream/remoteMedia.ts +28 -15
  154. package/src/multistream/remoteMediaManager.ts +32 -10
  155. package/src/multistream/sendSlotManager.ts +31 -0
  156. package/src/reachability/clusterReachability.ts +5 -15
  157. package/src/reachability/index.ts +315 -75
  158. package/src/reachability/reachability.types.ts +85 -0
  159. package/src/reachability/request.ts +55 -31
  160. package/src/recording-controller/enums.ts +5 -2
  161. package/src/recording-controller/index.ts +17 -4
  162. package/src/recording-controller/util.ts +28 -9
  163. package/src/roap/index.ts +14 -13
  164. package/src/roap/request.ts +30 -44
  165. package/src/roap/turnDiscovery.ts +2 -4
  166. package/src/webinar/index.ts +235 -9
  167. package/test/unit/spec/annotation/index.ts +46 -1
  168. package/test/unit/spec/interpretation/index.ts +39 -1
  169. package/test/unit/spec/locus-info/index.js +292 -60
  170. package/test/unit/spec/locus-info/selfConstant.js +7 -0
  171. package/test/unit/spec/locus-info/selfUtils.js +101 -1
  172. package/test/unit/spec/media/properties.ts +15 -0
  173. package/test/unit/spec/meeting/brbState.ts +114 -0
  174. package/test/unit/spec/meeting/in-meeting-actions.ts +15 -1
  175. package/test/unit/spec/meeting/index.js +908 -124
  176. package/test/unit/spec/meeting/locusMediaRequest.ts +111 -66
  177. package/test/unit/spec/meeting/muteState.js +0 -24
  178. package/test/unit/spec/meeting/request.js +3 -26
  179. package/test/unit/spec/meeting/utils.js +73 -28
  180. package/test/unit/spec/meeting-info/meetinginfov2.js +46 -4
  181. package/test/unit/spec/meeting-info/utilv2.js +26 -0
  182. package/test/unit/spec/meetings/index.js +172 -18
  183. package/test/unit/spec/meetings/utils.js +10 -0
  184. package/test/unit/spec/member/util.js +52 -11
  185. package/test/unit/spec/members/utils.js +95 -0
  186. package/test/unit/spec/multistream/remoteMedia.ts +11 -7
  187. package/test/unit/spec/multistream/remoteMediaManager.ts +397 -118
  188. package/test/unit/spec/reachability/clusterReachability.ts +7 -0
  189. package/test/unit/spec/reachability/index.ts +391 -9
  190. package/test/unit/spec/reachability/request.js +48 -12
  191. package/test/unit/spec/recording-controller/index.js +61 -5
  192. package/test/unit/spec/recording-controller/util.js +39 -3
  193. package/test/unit/spec/roap/index.ts +48 -1
  194. package/test/unit/spec/roap/request.ts +51 -109
  195. package/test/unit/spec/roap/turnDiscovery.ts +202 -147
  196. package/test/unit/spec/webinar/index.ts +509 -0
  197. package/dist/common/errors/webinar-registration-error.js.map +0 -1
  198. package/dist/networkQualityMonitor/index.js +0 -227
  199. package/dist/networkQualityMonitor/index.js.map +0 -1
  200. package/dist/rtcMetrics/constants.js.map +0 -1
  201. package/dist/rtcMetrics/index.js +0 -197
  202. package/dist/rtcMetrics/index.js.map +0 -1
  203. package/dist/types/networkQualityMonitor/index.d.ts +0 -70
  204. package/dist/types/rtcMetrics/constants.d.ts +0 -4
  205. package/dist/types/rtcMetrics/index.d.ts +0 -71
  206. package/src/common/errors/webinar-registration-error.ts +0 -27
@@ -12,11 +12,11 @@ _Object$defineProperty(exports, "__esModule", {
12
12
  value: true
13
13
  });
14
14
  exports.default = void 0;
15
+ var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
15
16
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
16
17
  var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
17
18
  var _entries = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/entries"));
18
19
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
19
- var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
20
20
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
21
21
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
22
22
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
@@ -43,15 +43,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
43
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; } } /*!
44
44
  * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
45
45
  */ /* eslint-disable class-methods-use-this */
46
- /**
47
- * This is the type that matches what backend expects us to send to them. It is a bit weird, because
48
- * it uses strings instead of booleans and numbers, but that's what they require.
49
- */
50
-
51
- // this is the type that is required by the backend when we send them reachability results
52
-
53
- // this is the type used by Reachability class internally and stored in local storage
54
-
55
46
  // timeouts in seconds
56
47
  var DEFAULT_TIMEOUT = 3;
57
48
  var VIDEO_MESH_TIMEOUT = 1;
@@ -77,6 +68,8 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
77
68
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "webex", void 0);
78
69
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "reachabilityRequest", void 0);
79
70
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clusterReachability", void 0);
71
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "minRequiredClusters", void 0);
72
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "orpheusApiVersion", void 0);
80
73
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "reachabilityDefer", void 0);
81
74
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "vmnTimer", void 0);
82
75
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "publicCloudTimer", void 0);
@@ -101,6 +94,8 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
101
94
  xtls: 0
102
95
  }
103
96
  });
97
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "startTime", undefined);
98
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "totalDuration", undefined);
104
99
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "lastTrigger", void 0);
105
100
  _this.webex = webex;
106
101
 
@@ -118,6 +113,8 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
118
113
 
119
114
  /**
120
115
  * Fetches the list of media clusters from the backend
116
+ * @param {string} trigger - explains the reason for starting reachability, used by Orpheus
117
+ * @param {Object} previousReport - last reachability report
121
118
  * @param {boolean} isRetry
122
119
  * @private
123
120
  * @returns {Promise<{clusters: ClusterList, joinCookie: any}>}
@@ -125,45 +122,54 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
125
122
  (0, _createClass2.default)(Reachability, [{
126
123
  key: "getClusters",
127
124
  value: (function () {
128
- var _getClusters = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
125
+ var _getClusters = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(trigger, previousReport) {
129
126
  var isRetry,
130
127
  _yield$this$reachabil,
131
128
  clusters,
132
129
  joinCookie,
130
+ discoveryOptions,
133
131
  _args = arguments;
134
132
  return _regenerator.default.wrap(function _callee$(_context) {
135
133
  while (1) switch (_context.prev = _context.next) {
136
134
  case 0:
137
- isRetry = _args.length > 0 && _args[0] !== undefined ? _args[0] : false;
135
+ isRetry = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
138
136
  _context.prev = 1;
139
137
  _context.next = 4;
140
- return this.reachabilityRequest.getClusters(_util.default.getIpVersion(this.webex));
138
+ return this.reachabilityRequest.getClusters(trigger, _util.default.getIpVersion(this.webex), previousReport);
141
139
  case 4:
142
140
  _yield$this$reachabil = _context.sent;
143
141
  clusters = _yield$this$reachabil.clusters;
144
142
  joinCookie = _yield$this$reachabil.joinCookie;
143
+ discoveryOptions = _yield$this$reachabil.discoveryOptions;
144
+ this.minRequiredClusters = discoveryOptions === null || discoveryOptions === void 0 ? void 0 : discoveryOptions['early-call-min-clusters'];
145
+ this.orpheusApiVersion = discoveryOptions === null || discoveryOptions === void 0 ? void 0 : discoveryOptions['report-version'];
146
+
147
+ // @ts-ignore
148
+ _context.next = 12;
149
+ return this.webex.boundedStorage.put(this.namespace, _constants.REACHABILITY.localStorageJoinCookie, (0, _stringify.default)(joinCookie));
150
+ case 12:
145
151
  return _context.abrupt("return", {
146
152
  clusters: clusters,
147
153
  joinCookie: joinCookie
148
154
  });
149
- case 10:
150
- _context.prev = 10;
155
+ case 15:
156
+ _context.prev = 15;
151
157
  _context.t0 = _context["catch"](1);
152
158
  if (!isRetry) {
153
- _context.next = 14;
159
+ _context.next = 19;
154
160
  break;
155
161
  }
156
162
  throw _context.t0;
157
- case 14:
163
+ case 19:
158
164
  _loggerProxy.default.logger.error("Reachability:index#getClusters --> Failed with error: ".concat(_context.t0, ", retrying..."));
159
- return _context.abrupt("return", this.getClusters(true));
160
- case 16:
165
+ return _context.abrupt("return", this.getClusters(trigger, previousReport, true));
166
+ case 21:
161
167
  case "end":
162
168
  return _context.stop();
163
169
  }
164
- }, _callee, this, [[1, 10]]);
170
+ }, _callee, this, [[1, 15]]);
165
171
  }));
166
- function getClusters() {
172
+ function getClusters(_x, _x2) {
167
173
  return _getClusters.apply(this, arguments);
168
174
  }
169
175
  return getClusters;
@@ -180,63 +186,231 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
180
186
  key: "gatherReachability",
181
187
  value: (function () {
182
188
  var _gatherReachability = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(trigger) {
183
- var _yield$this$getCluste, clusters, joinCookie;
189
+ var _yield$this$getCluste, clusters;
184
190
  return _regenerator.default.wrap(function _callee2$(_context2) {
185
191
  while (1) switch (_context2.prev = _context2.next) {
186
192
  case 0:
187
- _context2.prev = 0;
193
+ if (this.webex.config.meetings.enableReachabilityChecks) {
194
+ _context2.next = 2;
195
+ break;
196
+ }
197
+ throw new Error('enableReachabilityChecks is disabled in config');
198
+ case 2:
199
+ _context2.prev = 2;
188
200
  this.lastTrigger = trigger;
189
201
 
190
202
  // kick off ip version detection. We don't await it, as we don't want to waste time
191
203
  // and if it fails, that's ok we can still carry on
192
204
  // @ts-ignore
193
205
  this.webex.internal.device.ipNetworkDetector.detect(true);
194
- _context2.next = 5;
195
- return this.getClusters();
196
- case 5:
206
+ _context2.next = 7;
207
+ return this.getClusters('startup');
208
+ case 7:
197
209
  _yield$this$getCluste = _context2.sent;
198
210
  clusters = _yield$this$getCluste.clusters;
199
- joinCookie = _yield$this$getCluste.joinCookie;
200
- _context2.next = 10;
201
- return this.webex.boundedStorage.put(this.namespace, _constants.REACHABILITY.localStorageJoinCookie, (0, _stringify.default)(joinCookie));
202
- case 10:
203
211
  this.reachabilityDefer = new _common.Defer();
204
212
 
205
213
  // Perform Reachability Check
206
- _context2.next = 13;
214
+ _context2.next = 12;
207
215
  return this.performReachabilityChecks(clusters);
208
- case 13:
216
+ case 12:
209
217
  return _context2.abrupt("return", this.reachabilityDefer.promise);
210
- case 16:
211
- _context2.prev = 16;
212
- _context2.t0 = _context2["catch"](0);
218
+ case 15:
219
+ _context2.prev = 15;
220
+ _context2.t0 = _context2["catch"](2);
213
221
  _loggerProxy.default.logger.error("Reachability:index#gatherReachability --> Error:", _context2.t0);
214
222
  return _context2.abrupt("return", {});
215
- case 20:
223
+ case 19:
216
224
  case "end":
217
225
  return _context2.stop();
218
226
  }
219
- }, _callee2, this, [[0, 16]]);
227
+ }, _callee2, this, [[2, 15]]);
220
228
  }));
221
- function gatherReachability(_x) {
229
+ function gatherReachability(_x3) {
222
230
  return _gatherReachability.apply(this, arguments);
223
231
  }
224
232
  return gatherReachability;
225
233
  }()
234
+ /**
235
+ * Gets the last join cookie we got from Orpheus
236
+ *
237
+ * @returns {Promise<Object>} join cookie
238
+ */
239
+ )
240
+ }, {
241
+ key: "getJoinCookie",
242
+ value: (function () {
243
+ var _getJoinCookie = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
244
+ var joinCookieRaw, joinCookie;
245
+ return _regenerator.default.wrap(function _callee3$(_context3) {
246
+ while (1) switch (_context3.prev = _context3.next) {
247
+ case 0:
248
+ _context3.next = 2;
249
+ return this.webex.boundedStorage.get(_constants.REACHABILITY.namespace, _constants.REACHABILITY.localStorageJoinCookie).catch(function () {});
250
+ case 2:
251
+ joinCookieRaw = _context3.sent;
252
+ if (joinCookieRaw) {
253
+ try {
254
+ joinCookie = JSON.parse(joinCookieRaw);
255
+ } catch (e) {
256
+ _loggerProxy.default.logger.error("MeetingRequest#constructor --> Error in parsing join cookie data: ".concat(e));
257
+ }
258
+ }
259
+ return _context3.abrupt("return", joinCookie);
260
+ case 5:
261
+ case "end":
262
+ return _context3.stop();
263
+ }
264
+ }, _callee3, this);
265
+ }));
266
+ function getJoinCookie() {
267
+ return _getJoinCookie.apply(this, arguments);
268
+ }
269
+ return getJoinCookie;
270
+ }()
271
+ /**
272
+ * Returns the reachability report that needs to be attached to the ROAP messages
273
+ * that we send to the backend.
274
+ *
275
+ * @returns {Promise<Object>}
276
+ */
277
+ )
278
+ }, {
279
+ key: "getReachabilityReport",
280
+ value: (function () {
281
+ var _getReachabilityReport = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
282
+ var reachabilityResult, joinCookie;
283
+ return _regenerator.default.wrap(function _callee4$(_context4) {
284
+ while (1) switch (_context4.prev = _context4.next) {
285
+ case 0:
286
+ _context4.next = 2;
287
+ return this.getReachabilityResults();
288
+ case 2:
289
+ reachabilityResult = _context4.sent;
290
+ _context4.next = 5;
291
+ return this.getJoinCookie();
292
+ case 5:
293
+ joinCookie = _context4.sent;
294
+ if (this.orpheusApiVersion) {
295
+ _context4.next = 8;
296
+ break;
297
+ }
298
+ return _context4.abrupt("return", {
299
+ reachability: reachabilityResult
300
+ });
301
+ case 8:
302
+ return _context4.abrupt("return", {
303
+ reachability: {
304
+ version: 1,
305
+ result: {
306
+ usedDiscoveryOptions: {
307
+ 'early-call-min-clusters': this.minRequiredClusters
308
+ },
309
+ metrics: {
310
+ 'total-duration-ms': this.totalDuration
311
+ },
312
+ tests: reachabilityResult
313
+ }
314
+ },
315
+ joinCookie: joinCookie
316
+ });
317
+ case 9:
318
+ case "end":
319
+ return _context4.stop();
320
+ }
321
+ }, _callee4, this);
322
+ }));
323
+ function getReachabilityReport() {
324
+ return _getReachabilityReport.apply(this, arguments);
325
+ }
326
+ return getReachabilityReport;
327
+ }()
328
+ /**
329
+ * This method is called when we don't succeed in reaching the minimum number of clusters
330
+ * required by Orpheus. It sends the results to Orpheus and gets a new list that it tries to reach again.
331
+ * @returns {Promise<ReachabilityResults>} reachability results
332
+ * @public
333
+ * @memberof Reachability
334
+ */
335
+ )
336
+ }, {
337
+ key: "gatherReachabilityFallback",
338
+ value: (function () {
339
+ var _gatherReachabilityFallback = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
340
+ var reachabilityReport, _yield$this$getCluste2, clusters;
341
+ return _regenerator.default.wrap(function _callee5$(_context5) {
342
+ while (1) switch (_context5.prev = _context5.next) {
343
+ case 0:
344
+ _context5.prev = 0;
345
+ _context5.next = 3;
346
+ return this.getReachabilityReport();
347
+ case 3:
348
+ reachabilityReport = _context5.sent;
349
+ _context5.next = 6;
350
+ return this.getClusters('early-call/no-min-reached', reachabilityReport);
351
+ case 6:
352
+ _yield$this$getCluste2 = _context5.sent;
353
+ clusters = _yield$this$getCluste2.clusters;
354
+ // stop all previous reachability checks that might still be going on in the background
355
+ this.abortCurrentChecks();
356
+
357
+ // Perform Reachability Check
358
+ _context5.next = 11;
359
+ return this.performReachabilityChecks(clusters);
360
+ case 11:
361
+ _context5.next = 16;
362
+ break;
363
+ case 13:
364
+ _context5.prev = 13;
365
+ _context5.t0 = _context5["catch"](0);
366
+ _loggerProxy.default.logger.error("Reachability:index#gatherReachabilityFallback --> Error:", _context5.t0);
367
+ case 16:
368
+ case "end":
369
+ return _context5.stop();
370
+ }
371
+ }, _callee5, this, [[0, 13]]);
372
+ }));
373
+ function gatherReachabilityFallback() {
374
+ return _gatherReachabilityFallback.apply(this, arguments);
375
+ }
376
+ return gatherReachabilityFallback;
377
+ }()
378
+ /**
379
+ * Stops all reachability checks that are in progress
380
+ * @public
381
+ * @memberof Reachability
382
+ * @returns {void}
383
+ */
384
+ )
385
+ }, {
386
+ key: "stopReachability",
387
+ value: function stopReachability() {
388
+ // overallTimer is always there only if there is reachability in progress
389
+ if (this.overallTimer) {
390
+ _loggerProxy.default.logger.log('Reachability:index#stopReachability --> stopping reachability checks');
391
+ this.abortCurrentChecks();
392
+ this.emit({
393
+ file: 'reachability',
394
+ function: 'stopReachability'
395
+ }, 'reachability:stopped', {});
396
+ this.sendMetric(true);
397
+ this.resolveReachabilityPromise();
398
+ }
399
+ }
400
+
226
401
  /**
227
402
  * Returns statistics about last reachability results. The returned value is an object
228
403
  * with a flat list of properties so that it can be easily sent with metrics
229
404
  *
230
405
  * @returns {Promise} Promise with metrics values, it never rejects/throws.
231
406
  */
232
- )
233
407
  }, {
234
408
  key: "getReachabilityMetrics",
235
409
  value: (function () {
236
- var _getReachabilityMetrics = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
410
+ var _getReachabilityMetrics = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
237
411
  var stats, updateStats, resultsJson, results;
238
- return _regenerator.default.wrap(function _callee3$(_context3) {
239
- while (1) switch (_context3.prev = _context3.next) {
412
+ return _regenerator.default.wrap(function _callee6$(_context6) {
413
+ while (1) switch (_context6.prev = _context6.next) {
240
414
  case 0:
241
415
  stats = {
242
416
  reachability_public_udp_success: 0,
@@ -266,29 +440,29 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
266
440
  stats["reachability_".concat(clusterType, "_xtls_").concat(_outcome2)] += 1;
267
441
  }
268
442
  };
269
- _context3.prev = 2;
270
- _context3.next = 5;
443
+ _context6.prev = 2;
444
+ _context6.next = 5;
271
445
  return this.webex.boundedStorage.get(_constants.REACHABILITY.namespace, _constants.REACHABILITY.localStorageResult);
272
446
  case 5:
273
- resultsJson = _context3.sent;
447
+ resultsJson = _context6.sent;
274
448
  results = JSON.parse(resultsJson);
275
449
  (0, _values.default)(results).forEach(function (result) {
276
450
  updateStats(result.isVideoMesh ? 'vmn' : 'public', result);
277
451
  });
278
- _context3.next = 13;
452
+ _context6.next = 13;
279
453
  break;
280
454
  case 10:
281
- _context3.prev = 10;
282
- _context3.t0 = _context3["catch"](2);
455
+ _context6.prev = 10;
456
+ _context6.t0 = _context6["catch"](2);
283
457
  // empty storage, that's ok
284
- _loggerProxy.default.logger.warn('Roap:request#getReachabilityMetrics --> Error parsing reachability data: ', _context3.t0);
458
+ _loggerProxy.default.logger.warn('Roap:request#getReachabilityMetrics --> Error parsing reachability data: ', _context6.t0);
285
459
  case 13:
286
- return _context3.abrupt("return", stats);
460
+ return _context6.abrupt("return", stats);
287
461
  case 14:
288
462
  case "end":
289
- return _context3.stop();
463
+ return _context6.stop();
290
464
  }
291
- }, _callee3, this, [[2, 10]]);
465
+ }, _callee6, this, [[2, 10]]);
292
466
  }));
293
467
  function getReachabilityMetrics() {
294
468
  return _getReachabilityMetrics.apply(this, arguments);
@@ -341,17 +515,17 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
341
515
  }, {
342
516
  key: "getReachabilityResults",
343
517
  value: (function () {
344
- var _getReachabilityResults = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
518
+ var _getReachabilityResults = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
345
519
  var _this2 = this;
346
520
  var results, resultsJson, allClusterResults;
347
- return _regenerator.default.wrap(function _callee4$(_context4) {
348
- while (1) switch (_context4.prev = _context4.next) {
521
+ return _regenerator.default.wrap(function _callee7$(_context7) {
522
+ while (1) switch (_context7.prev = _context7.next) {
349
523
  case 0:
350
- _context4.prev = 0;
351
- _context4.next = 3;
524
+ _context7.prev = 0;
525
+ _context7.next = 3;
352
526
  return this.webex.boundedStorage.get(_constants.REACHABILITY.namespace, _constants.REACHABILITY.localStorageResult);
353
527
  case 3:
354
- resultsJson = _context4.sent;
528
+ resultsJson = _context7.sent;
355
529
  allClusterResults = JSON.parse(resultsJson);
356
530
  results = (0, _lodash.mapValues)(allClusterResults, function (clusterResult) {
357
531
  return {
@@ -366,20 +540,20 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
366
540
  })
367
541
  };
368
542
  });
369
- _context4.next = 11;
543
+ _context7.next = 11;
370
544
  break;
371
545
  case 8:
372
- _context4.prev = 8;
373
- _context4.t0 = _context4["catch"](0);
546
+ _context7.prev = 8;
547
+ _context7.t0 = _context7["catch"](0);
374
548
  // empty storage, that's ok
375
- _loggerProxy.default.logger.warn('Roap:request#attachReachabilityData --> Error parsing reachability data: ', _context4.t0);
549
+ _loggerProxy.default.logger.warn('Reachability:index#getReachabilityResults --> Error parsing reachability data: ', _context7.t0);
376
550
  case 11:
377
- return _context4.abrupt("return", results);
551
+ return _context7.abrupt("return", results);
378
552
  case 12:
379
553
  case "end":
380
- return _context4.stop();
554
+ return _context7.stop();
381
555
  }
382
- }, _callee4, this, [[0, 8]]);
556
+ }, _callee7, this, [[0, 8]]);
383
557
  }));
384
558
  function getReachabilityResults() {
385
559
  return _getReachabilityResults.apply(this, arguments);
@@ -396,16 +570,16 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
396
570
  }, {
397
571
  key: "isAnyPublicClusterReachable",
398
572
  value: (function () {
399
- var _isAnyPublicClusterReachable = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
573
+ var _isAnyPublicClusterReachable = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
400
574
  var reachable, reachabilityData, reachabilityResults;
401
- return _regenerator.default.wrap(function _callee5$(_context5) {
402
- while (1) switch (_context5.prev = _context5.next) {
575
+ return _regenerator.default.wrap(function _callee8$(_context8) {
576
+ while (1) switch (_context8.prev = _context8.next) {
403
577
  case 0:
404
578
  reachable = false; // @ts-ignore
405
- _context5.next = 3;
579
+ _context8.next = 3;
406
580
  return this.webex.boundedStorage.get(this.namespace, _constants.REACHABILITY.localStorageResult).catch(function () {});
407
581
  case 3:
408
- reachabilityData = _context5.sent;
582
+ reachabilityData = _context8.sent;
409
583
  if (reachabilityData) {
410
584
  try {
411
585
  reachabilityResults = JSON.parse(reachabilityData);
@@ -414,15 +588,15 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
414
588
  return !result.isVideoMesh && (((_result$udp = result.udp) === null || _result$udp === void 0 ? void 0 : _result$udp.result) === 'reachable' || ((_result$tcp = result.tcp) === null || _result$tcp === void 0 ? void 0 : _result$tcp.result) === 'reachable');
415
589
  });
416
590
  } catch (e) {
417
- _loggerProxy.default.logger.error("Roap:request#attachReachabilityData --> Error in parsing reachability data: ".concat(e));
591
+ _loggerProxy.default.logger.error("Reachability:index#isAnyPublicClusterReachable --> Error in parsing reachability data: ".concat(e));
418
592
  }
419
593
  }
420
- return _context5.abrupt("return", reachable);
594
+ return _context8.abrupt("return", reachable);
421
595
  case 6:
422
596
  case "end":
423
- return _context5.stop();
597
+ return _context8.stop();
424
598
  }
425
- }, _callee5, this);
599
+ }, _callee8, this);
426
600
  }));
427
601
  function isAnyPublicClusterReachable() {
428
602
  return _isAnyPublicClusterReachable.apply(this, arguments);
@@ -443,16 +617,16 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
443
617
  }, {
444
618
  key: "isWebexMediaBackendUnreachable",
445
619
  value: (function () {
446
- var _isWebexMediaBackendUnreachable = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
620
+ var _isWebexMediaBackendUnreachable = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
447
621
  var unreachable, reachabilityData, reachabilityResults, protocols;
448
- return _regenerator.default.wrap(function _callee6$(_context6) {
449
- while (1) switch (_context6.prev = _context6.next) {
622
+ return _regenerator.default.wrap(function _callee9$(_context9) {
623
+ while (1) switch (_context9.prev = _context9.next) {
450
624
  case 0:
451
625
  unreachable = false; // @ts-ignore
452
- _context6.next = 3;
626
+ _context9.next = 3;
453
627
  return this.webex.boundedStorage.get(this.namespace, _constants.REACHABILITY.localStorageResult).catch(function () {});
454
628
  case 3:
455
- reachabilityData = _context6.sent;
629
+ reachabilityData = _context9.sent;
456
630
  if (reachabilityData) {
457
631
  try {
458
632
  reachabilityResults = JSON.parse(reachabilityData);
@@ -487,15 +661,15 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
487
661
  return protocol.tested && !protocol.reachable;
488
662
  });
489
663
  } catch (e) {
490
- _loggerProxy.default.logger.error("Roap:request#attachReachabilityData --> Error in parsing reachability data: ".concat(e));
664
+ _loggerProxy.default.logger.error("Reachability:index#isWebexMediaBackendUnreachable --> Error in parsing reachability data: ".concat(e));
491
665
  }
492
666
  }
493
- return _context6.abrupt("return", unreachable);
667
+ return _context9.abrupt("return", unreachable);
494
668
  case 6:
495
669
  case "end":
496
- return _context6.stop();
670
+ return _context9.stop();
497
671
  }
498
- }, _callee6, this);
672
+ }, _callee9, this);
499
673
  }));
500
674
  function isWebexMediaBackendUnreachable() {
501
675
  return _isWebexMediaBackendUnreachable.apply(this, arguments);
@@ -540,6 +714,28 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
540
714
  return unreachableList;
541
715
  }
542
716
 
717
+ /**
718
+ * Gets the number of reachable clusters from last run reachability check
719
+ * @returns {number} reachable clusters count
720
+ * @private
721
+ * @memberof Reachability
722
+ */
723
+ }, {
724
+ key: "getNumberOfReachableClusters",
725
+ value: function getNumberOfReachableClusters() {
726
+ var count = 0;
727
+ (0, _entries.default)(this.clusterReachability).forEach(function (_ref3) {
728
+ var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
729
+ key = _ref4[0],
730
+ clusterReachability = _ref4[1];
731
+ var result = clusterReachability.getResult();
732
+ if (result.udp.result === 'reachable' || result.tcp.result === 'reachable' || result.xtls.result === 'reachable') {
733
+ count += 1;
734
+ }
735
+ });
736
+ return count;
737
+ }
738
+
543
739
  /**
544
740
  * Make a log of unreachable clusters.
545
741
  * @returns {undefined}
@@ -550,9 +746,9 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
550
746
  key: "logUnreachableClusters",
551
747
  value: function logUnreachableClusters() {
552
748
  var list = this.getUnreachableClusters();
553
- list.forEach(function (_ref3) {
554
- var name = _ref3.name,
555
- protocol = _ref3.protocol;
749
+ list.forEach(function (_ref5) {
750
+ var name = _ref5.name,
751
+ protocol = _ref5.protocol;
556
752
  _loggerProxy.default.logger.log("Reachability:index#logUnreachableClusters --> failed to reach ".concat(name, " over ").concat(protocol));
557
753
  });
558
754
  }
@@ -583,20 +779,26 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
583
779
 
584
780
  /**
585
781
  * Resolves the promise returned by gatherReachability() method
782
+ * @param {boolean} checkMinRequiredClusters - if true, it will check if we have reached the minimum required clusters and do a fallback if needed
586
783
  * @returns {void}
587
784
  */
588
785
  }, {
589
786
  key: "resolveReachabilityPromise",
590
787
  value: function resolveReachabilityPromise() {
591
788
  var _this$reachabilityDef;
592
- if (this.vmnTimer) {
593
- clearTimeout(this.vmnTimer);
594
- }
595
- if (this.publicCloudTimer) {
596
- clearTimeout(this.publicCloudTimer);
597
- }
789
+ var checkMinRequiredClusters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
790
+ this.totalDuration = performance.now() - this.startTime;
791
+ this.clearTimer('vmnTimer');
792
+ this.clearTimer('publicCloudTimer');
598
793
  this.logUnreachableClusters();
599
794
  (_this$reachabilityDef = this.reachabilityDefer) === null || _this$reachabilityDef === void 0 ? void 0 : _this$reachabilityDef.resolve();
795
+ if (checkMinRequiredClusters) {
796
+ var numReachableClusters = this.getNumberOfReachableClusters();
797
+ if (this.minRequiredClusters && numReachableClusters < this.minRequiredClusters) {
798
+ _loggerProxy.default.logger.log("Reachability:index#resolveReachabilityPromise --> minRequiredClusters not reached (".concat(numReachableClusters, " < ").concat(this.minRequiredClusters, "), doing reachability fallback"));
799
+ this.gatherReachabilityFallback();
800
+ }
801
+ }
600
802
  }
601
803
 
602
804
  /**
@@ -647,16 +849,21 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
647
849
  /**
648
850
  * Sends a metric with all the statistics about how long reachability took
649
851
  *
852
+ * @param {boolean} aborted true if the reachability checks were aborted
650
853
  * @returns {void}
651
854
  */
652
855
  }, {
653
856
  key: "sendMetric",
654
857
  value: (function () {
655
- var _sendMetric = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
656
- var results, stats;
657
- return _regenerator.default.wrap(function _callee7$(_context7) {
658
- while (1) switch (_context7.prev = _context7.next) {
858
+ var _sendMetric = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
859
+ var aborted,
860
+ results,
861
+ stats,
862
+ _args10 = arguments;
863
+ return _regenerator.default.wrap(function _callee10$(_context10) {
864
+ while (1) switch (_context10.prev = _context10.next) {
659
865
  case 0:
866
+ aborted = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : false;
660
867
  results = [];
661
868
  (0, _values.default)(this.clusterReachability).forEach(function (clusterReachability) {
662
869
  results.push(_objectSpread(_objectSpread({}, clusterReachability.getResult()), {}, {
@@ -664,6 +871,7 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
664
871
  }));
665
872
  });
666
873
  stats = {
874
+ aborted: aborted,
667
875
  vmn: {
668
876
  udp: this.getStatistics(results, 'udp', true)
669
877
  },
@@ -685,11 +893,11 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
685
893
  trigger: this.lastTrigger
686
894
  };
687
895
  _metrics.default.sendBehavioralMetric(_constants2.default.REACHABILITY_COMPLETED, _metrics.default.prepareMetricFields(stats));
688
- case 4:
896
+ case 5:
689
897
  case "end":
690
- return _context7.stop();
898
+ return _context10.stop();
691
899
  }
692
- }, _callee7, this);
900
+ }, _callee10, this);
693
901
  }));
694
902
  function sendMetric() {
695
903
  return _sendMetric.apply(this, arguments);
@@ -719,6 +927,8 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
719
927
  _this3.publicCloudTimer = undefined;
720
928
  _loggerProxy.default.logger.log("Reachability:index#startTimers --> Reachability checks timed out (".concat(DEFAULT_TIMEOUT, "s)"));
721
929
 
930
+ // check against minimum required clusters, do a new call if we don't have enough
931
+
722
932
  // resolve the promise, so that the client won't be blocked waiting on meetings.register() for too long
723
933
  _this3.resolveReachabilityPromise();
724
934
  }, DEFAULT_TIMEOUT * 1000);
@@ -743,19 +953,19 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
743
953
  }, {
744
954
  key: "storeResults",
745
955
  value: (function () {
746
- var _storeResults = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(results) {
747
- return _regenerator.default.wrap(function _callee8$(_context8) {
748
- while (1) switch (_context8.prev = _context8.next) {
956
+ var _storeResults = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(results) {
957
+ return _regenerator.default.wrap(function _callee11$(_context11) {
958
+ while (1) switch (_context11.prev = _context11.next) {
749
959
  case 0:
750
- _context8.next = 2;
960
+ _context11.next = 2;
751
961
  return this.webex.boundedStorage.put(this.namespace, _constants.REACHABILITY.localStorageResult, (0, _stringify.default)(results));
752
962
  case 2:
753
963
  case "end":
754
- return _context8.stop();
964
+ return _context11.stop();
755
965
  }
756
- }, _callee8, this);
966
+ }, _callee11, this);
757
967
  }));
758
- function storeResults(_x2) {
968
+ function storeResults(_x4) {
759
969
  return _storeResults.apply(this, arguments);
760
970
  }
761
971
  return storeResults;
@@ -779,6 +989,35 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
779
989
  this.resultsCount.public.xtls = 0;
780
990
  }
781
991
 
992
+ /**
993
+ * Clears the timer
994
+ *
995
+ * @param {string} timer name of the timer to clear
996
+ * @returns {void}
997
+ */
998
+ }, {
999
+ key: "clearTimer",
1000
+ value: function clearTimer(timer) {
1001
+ if (this[timer]) {
1002
+ clearTimeout(this[timer]);
1003
+ this[timer] = undefined;
1004
+ }
1005
+ }
1006
+
1007
+ /**
1008
+ * Aborts current checks that are in progress
1009
+ *
1010
+ * @returns {void}
1011
+ */
1012
+ }, {
1013
+ key: "abortCurrentChecks",
1014
+ value: function abortCurrentChecks() {
1015
+ this.clearTimer('vmnTimer');
1016
+ this.clearTimer('publicCloudTimer');
1017
+ this.clearTimer('overallTimer');
1018
+ this.abortClusterReachability();
1019
+ }
1020
+
782
1021
  /**
783
1022
  * Performs reachability checks for all clusters
784
1023
  * @param {ClusterList} clusterList
@@ -787,27 +1026,21 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
787
1026
  }, {
788
1027
  key: "performReachabilityChecks",
789
1028
  value: (function () {
790
- var _performReachabilityChecks = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(clusterList) {
1029
+ var _performReachabilityChecks = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(clusterList) {
791
1030
  var _this4 = this;
792
1031
  var results, isFirstResult;
793
- return _regenerator.default.wrap(function _callee11$(_context11) {
794
- while (1) switch (_context11.prev = _context11.next) {
1032
+ return _regenerator.default.wrap(function _callee14$(_context14) {
1033
+ while (1) switch (_context14.prev = _context14.next) {
795
1034
  case 0:
796
1035
  results = {};
797
1036
  this.clusterReachability = {};
798
- if (!(!clusterList || !(0, _keys.default)(clusterList).length)) {
799
- _context11.next = 4;
800
- break;
801
- }
802
- return _context11.abrupt("return");
803
- case 4:
1037
+ this.startTime = performance.now();
804
1038
  _loggerProxy.default.logger.log("Reachability:index#performReachabilityChecks --> doing UDP".concat(
805
1039
  // @ts-ignore
806
1040
  this.webex.config.meetings.experimental.enableTcpReachability ? ',TCP' : '').concat(
807
1041
  // @ts-ignore
808
1042
  this.webex.config.meetings.experimental.enableTlsReachability ? ',TLS' : '', " reachability checks"));
809
1043
  this.resetResultCounters();
810
- this.startTimers();
811
1044
 
812
1045
  // sanitize the urls in the clusterList
813
1046
  (0, _keys.default)(clusterList).forEach(function (key) {
@@ -855,18 +1088,32 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
855
1088
  tcp: true,
856
1089
  xtls: true
857
1090
  }; // save the initialized results (in case we don't get any "resultReady" events at all)
858
- _context11.next = 11;
1091
+ _context14.next = 9;
859
1092
  return this.storeResults(results);
860
- case 11:
1093
+ case 9:
1094
+ if (!(!clusterList || !(0, _keys.default)(clusterList).length)) {
1095
+ _context14.next = 13;
1096
+ break;
1097
+ }
1098
+ // nothing to do, finish immediately
1099
+ this.resolveReachabilityPromise(false);
1100
+ this.emit({
1101
+ file: 'reachability',
1102
+ function: 'performReachabilityChecks'
1103
+ }, 'reachability:done', {});
1104
+ return _context14.abrupt("return");
1105
+ case 13:
1106
+ this.startTimers();
1107
+
861
1108
  // now start the reachability on all the clusters
862
1109
  (0, _keys.default)(clusterList).forEach(function (key) {
863
1110
  var cluster = clusterList[key];
864
1111
  _this4.clusterReachability[key] = new _clusterReachability.ClusterReachability(key, cluster);
865
1112
  _this4.clusterReachability[key].on(_clusterReachability.Events.resultReady, /*#__PURE__*/function () {
866
- var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(data) {
1113
+ var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(data) {
867
1114
  var protocol, result, clientMediaIPs, latencyInMilliseconds, areAllResultsReady;
868
- return _regenerator.default.wrap(function _callee9$(_context9) {
869
- while (1) switch (_context9.prev = _context9.next) {
1115
+ return _regenerator.default.wrap(function _callee12$(_context12) {
1116
+ while (1) switch (_context12.prev = _context12.next) {
870
1117
  case 0:
871
1118
  protocol = data.protocol, result = data.result, clientMediaIPs = data.clientMediaIPs, latencyInMilliseconds = data.latencyInMilliseconds;
872
1119
  if (isFirstResult[protocol]) {
@@ -883,12 +1130,11 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
883
1130
  results[key][protocol].result = result;
884
1131
  results[key][protocol].clientMediaIPs = clientMediaIPs;
885
1132
  results[key][protocol].latencyInMilliseconds = latencyInMilliseconds;
886
- _context9.next = 9;
1133
+ _context12.next = 9;
887
1134
  return _this4.storeResults(results);
888
1135
  case 9:
889
1136
  if (areAllResultsReady) {
890
- clearTimeout(_this4.overallTimer);
891
- _this4.overallTimer = undefined;
1137
+ _this4.clearTimer('overallTimer');
892
1138
  _this4.emit({
893
1139
  file: 'reachability',
894
1140
  function: 'performReachabilityChecks'
@@ -899,46 +1145,131 @@ var Reachability = exports.default = /*#__PURE__*/function (_EventsScope) {
899
1145
  }
900
1146
  case 10:
901
1147
  case "end":
902
- return _context9.stop();
1148
+ return _context12.stop();
903
1149
  }
904
- }, _callee9);
1150
+ }, _callee12);
905
1151
  }));
906
- return function (_x4) {
907
- return _ref4.apply(this, arguments);
1152
+ return function (_x6) {
1153
+ return _ref6.apply(this, arguments);
908
1154
  };
909
1155
  }());
910
1156
 
911
1157
  // clientMediaIps can be updated independently from the results, so we need to listen for them too
912
1158
  _this4.clusterReachability[key].on(_clusterReachability.Events.clientMediaIpsUpdated, /*#__PURE__*/function () {
913
- var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(data) {
914
- return _regenerator.default.wrap(function _callee10$(_context10) {
915
- while (1) switch (_context10.prev = _context10.next) {
1159
+ var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(data) {
1160
+ return _regenerator.default.wrap(function _callee13$(_context13) {
1161
+ while (1) switch (_context13.prev = _context13.next) {
916
1162
  case 0:
917
1163
  results[key][data.protocol].clientMediaIPs = data.clientMediaIPs;
918
- _context10.next = 3;
1164
+ _context13.next = 3;
919
1165
  return _this4.storeResults(results);
920
1166
  case 3:
921
1167
  case "end":
922
- return _context10.stop();
1168
+ return _context13.stop();
923
1169
  }
924
- }, _callee10);
1170
+ }, _callee13);
925
1171
  }));
926
- return function (_x5) {
927
- return _ref5.apply(this, arguments);
1172
+ return function (_x7) {
1173
+ return _ref7.apply(this, arguments);
928
1174
  };
929
1175
  }());
930
1176
  _this4.clusterReachability[key].start(); // not awaiting on purpose
931
1177
  });
932
- case 12:
1178
+ case 15:
933
1179
  case "end":
934
- return _context11.stop();
1180
+ return _context14.stop();
935
1181
  }
936
- }, _callee11, this);
1182
+ }, _callee14, this);
937
1183
  }));
938
- function performReachabilityChecks(_x3) {
1184
+ function performReachabilityChecks(_x5) {
939
1185
  return _performReachabilityChecks.apply(this, arguments);
940
1186
  }
941
1187
  return performReachabilityChecks;
1188
+ }()
1189
+ /**
1190
+ * Returns the clientMediaPreferences object that needs to be sent to the backend
1191
+ * when joining a meeting
1192
+ *
1193
+ * @param {boolean} isMultistream
1194
+ * @param {IP_VERSION} ipver
1195
+ * @returns {Object}
1196
+ */
1197
+ )
1198
+ }, {
1199
+ key: "getClientMediaPreferences",
1200
+ value: (function () {
1201
+ var _getClientMediaPreferences = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(isMultistream, ipver) {
1202
+ var reachabilityReport;
1203
+ return _regenerator.default.wrap(function _callee15$(_context15) {
1204
+ while (1) switch (_context15.prev = _context15.next) {
1205
+ case 0:
1206
+ if (this.orpheusApiVersion) {
1207
+ _context15.next = 7;
1208
+ break;
1209
+ }
1210
+ _context15.t0 = ipver;
1211
+ _context15.next = 4;
1212
+ return this.getJoinCookie();
1213
+ case 4:
1214
+ _context15.t1 = _context15.sent;
1215
+ _context15.t2 = !isMultistream;
1216
+ return _context15.abrupt("return", {
1217
+ ipver: _context15.t0,
1218
+ joinCookie: _context15.t1,
1219
+ preferTranscoding: _context15.t2
1220
+ });
1221
+ case 7:
1222
+ _context15.next = 9;
1223
+ return this.getReachabilityReport();
1224
+ case 9:
1225
+ reachabilityReport = _context15.sent;
1226
+ return _context15.abrupt("return", _objectSpread({
1227
+ ipver: ipver,
1228
+ preferTranscoding: !isMultistream
1229
+ }, reachabilityReport));
1230
+ case 11:
1231
+ case "end":
1232
+ return _context15.stop();
1233
+ }
1234
+ }, _callee15, this);
1235
+ }));
1236
+ function getClientMediaPreferences(_x8, _x9) {
1237
+ return _getClientMediaPreferences.apply(this, arguments);
1238
+ }
1239
+ return getClientMediaPreferences;
1240
+ }()
1241
+ /**
1242
+ * Returns the reachability report that needs to be attached to the ROAP messages
1243
+ * that we send to the backend.
1244
+ * It may return undefined, if reachability is not needed to be attached to ROAP messages (that's the case for v1 or Orpheus API)
1245
+ *
1246
+ * @returns {Promise<ReachabilityReportV0>} object that needs to be attached to Roap messages
1247
+ */
1248
+ )
1249
+ }, {
1250
+ key: "getReachabilityReportToAttachToRoap",
1251
+ value: (function () {
1252
+ var _getReachabilityReportToAttachToRoap = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
1253
+ return _regenerator.default.wrap(function _callee16$(_context16) {
1254
+ while (1) switch (_context16.prev = _context16.next) {
1255
+ case 0:
1256
+ if (this.orpheusApiVersion) {
1257
+ _context16.next = 2;
1258
+ break;
1259
+ }
1260
+ return _context16.abrupt("return", this.getReachabilityResults());
1261
+ case 2:
1262
+ return _context16.abrupt("return", undefined);
1263
+ case 3:
1264
+ case "end":
1265
+ return _context16.stop();
1266
+ }
1267
+ }, _callee16, this);
1268
+ }));
1269
+ function getReachabilityReportToAttachToRoap() {
1270
+ return _getReachabilityReportToAttachToRoap.apply(this, arguments);
1271
+ }
1272
+ return getReachabilityReportToAttachToRoap;
942
1273
  }())
943
1274
  }]);
944
1275
  return Reachability;