@webex/plugin-meetings 3.0.0-beta.262 → 3.0.0-beta.263
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/dist/breakouts/breakout.js +1 -1
- package/dist/breakouts/index.js +1 -1
- package/dist/interpretation/index.js +1 -1
- package/dist/interpretation/siLanguage.js +1 -1
- package/dist/meeting/index.js +171 -129
- package/dist/meeting/index.js.map +1 -1
- package/dist/reachability/index.js +95 -33
- package/dist/reachability/index.js.map +1 -1
- package/dist/types/meeting/index.d.ts +2 -2
- package/dist/types/reachability/index.d.ts +18 -1
- package/package.json +19 -19
- package/src/meeting/index.ts +32 -26
- package/src/reachability/index.ts +64 -1
- package/test/unit/spec/meeting/index.js +23 -13
- package/test/unit/spec/reachability/index.ts +208 -2
|
@@ -27,8 +27,6 @@ var _constants = require("../constants");
|
|
|
27
27
|
var _request = _interopRequireDefault(require("./request"));
|
|
28
28
|
var DEFAULT_TIMEOUT = 3000;
|
|
29
29
|
var VIDEO_MESH_TIMEOUT = 1000;
|
|
30
|
-
|
|
31
|
-
// result for a specific transport protocol (like udp or tcp)
|
|
32
30
|
/**
|
|
33
31
|
* @class Reachability
|
|
34
32
|
* @export
|
|
@@ -126,6 +124,70 @@ var Reachability = /*#__PURE__*/function () {
|
|
|
126
124
|
}
|
|
127
125
|
return gatherReachability;
|
|
128
126
|
}()
|
|
127
|
+
/**
|
|
128
|
+
* Returns statistics about last reachability results. The returned value is an object
|
|
129
|
+
* with a flat list of properties so that it can be easily sent with metrics
|
|
130
|
+
*
|
|
131
|
+
* @returns {Promise} Promise with metrics values, it never rejects/throws.
|
|
132
|
+
*/
|
|
133
|
+
}, {
|
|
134
|
+
key: "getReachabilityMetrics",
|
|
135
|
+
value: function () {
|
|
136
|
+
var _getReachabilityMetrics = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
137
|
+
var stats, updateStats, resultsJson, internalResults;
|
|
138
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
139
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
140
|
+
case 0:
|
|
141
|
+
stats = {
|
|
142
|
+
reachability_public_udp_success: 0,
|
|
143
|
+
reachability_public_udp_failed: 0,
|
|
144
|
+
reachability_public_tcp_success: 0,
|
|
145
|
+
reachability_public_tcp_failed: 0,
|
|
146
|
+
reachability_vmn_udp_success: 0,
|
|
147
|
+
reachability_vmn_udp_failed: 0,
|
|
148
|
+
reachability_vmn_tcp_success: 0,
|
|
149
|
+
reachability_vmn_tcp_failed: 0
|
|
150
|
+
};
|
|
151
|
+
updateStats = function updateStats(clusterType, result) {
|
|
152
|
+
var _result$udp, _result$tcp;
|
|
153
|
+
if ((_result$udp = result.udp) !== null && _result$udp !== void 0 && _result$udp.reachable) {
|
|
154
|
+
var outcome = result.udp.reachable === 'true' ? 'success' : 'failed';
|
|
155
|
+
stats["reachability_".concat(clusterType, "_udp_").concat(outcome)] += 1;
|
|
156
|
+
}
|
|
157
|
+
if ((_result$tcp = result.tcp) !== null && _result$tcp !== void 0 && _result$tcp.reachable) {
|
|
158
|
+
var _outcome = result.tcp.reachable === 'true' ? 'success' : 'failed';
|
|
159
|
+
stats["reachability_".concat(clusterType, "_tcp_").concat(_outcome)] += 1;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
_context2.prev = 2;
|
|
163
|
+
_context2.next = 5;
|
|
164
|
+
return this.webex.boundedStorage.get(_constants.REACHABILITY.namespace, _constants.REACHABILITY.localStorageResult);
|
|
165
|
+
case 5:
|
|
166
|
+
resultsJson = _context2.sent;
|
|
167
|
+
internalResults = JSON.parse(resultsJson);
|
|
168
|
+
(0, _values.default)(internalResults).forEach(function (result) {
|
|
169
|
+
updateStats(result.isVideoMesh ? 'vmn' : 'public', result);
|
|
170
|
+
});
|
|
171
|
+
_context2.next = 13;
|
|
172
|
+
break;
|
|
173
|
+
case 10:
|
|
174
|
+
_context2.prev = 10;
|
|
175
|
+
_context2.t0 = _context2["catch"](2);
|
|
176
|
+
// empty storage, that's ok
|
|
177
|
+
_loggerProxy.default.logger.warn('Roap:request#getReachabilityMetrics --> Error parsing reachability data: ', _context2.t0);
|
|
178
|
+
case 13:
|
|
179
|
+
return _context2.abrupt("return", stats);
|
|
180
|
+
case 14:
|
|
181
|
+
case "end":
|
|
182
|
+
return _context2.stop();
|
|
183
|
+
}
|
|
184
|
+
}, _callee2, this, [[2, 10]]);
|
|
185
|
+
}));
|
|
186
|
+
function getReachabilityMetrics() {
|
|
187
|
+
return _getReachabilityMetrics.apply(this, arguments);
|
|
188
|
+
}
|
|
189
|
+
return getReachabilityMetrics;
|
|
190
|
+
}()
|
|
129
191
|
/**
|
|
130
192
|
* Reachability results as an object in the format that backend expects
|
|
131
193
|
*
|
|
@@ -134,36 +196,36 @@ var Reachability = /*#__PURE__*/function () {
|
|
|
134
196
|
}, {
|
|
135
197
|
key: "getReachabilityResults",
|
|
136
198
|
value: function () {
|
|
137
|
-
var _getReachabilityResults = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
199
|
+
var _getReachabilityResults = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
138
200
|
var results, reachabilityResultsProps, resultsJson, internalResults;
|
|
139
|
-
return _regenerator.default.wrap(function
|
|
140
|
-
while (1) switch (
|
|
201
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
202
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
141
203
|
case 0:
|
|
142
204
|
// these are the only props that backend needs in the reachability results:
|
|
143
205
|
reachabilityResultsProps = ['udp', 'tcp', 'xtls'];
|
|
144
|
-
|
|
145
|
-
|
|
206
|
+
_context3.prev = 1;
|
|
207
|
+
_context3.next = 4;
|
|
146
208
|
return this.webex.boundedStorage.get(_constants.REACHABILITY.namespace, _constants.REACHABILITY.localStorageResult);
|
|
147
209
|
case 4:
|
|
148
|
-
resultsJson =
|
|
210
|
+
resultsJson = _context3.sent;
|
|
149
211
|
internalResults = JSON.parse(resultsJson);
|
|
150
212
|
results = (0, _mapValues2.default)(internalResults, function (result) {
|
|
151
213
|
return (0, _pick2.default)(result, reachabilityResultsProps);
|
|
152
214
|
});
|
|
153
|
-
|
|
215
|
+
_context3.next = 12;
|
|
154
216
|
break;
|
|
155
217
|
case 9:
|
|
156
|
-
|
|
157
|
-
|
|
218
|
+
_context3.prev = 9;
|
|
219
|
+
_context3.t0 = _context3["catch"](1);
|
|
158
220
|
// empty storage, that's ok
|
|
159
|
-
_loggerProxy.default.logger.warn('Roap:request#attachReachabilityData --> Error parsing reachability data: ',
|
|
221
|
+
_loggerProxy.default.logger.warn('Roap:request#attachReachabilityData --> Error parsing reachability data: ', _context3.t0);
|
|
160
222
|
case 12:
|
|
161
|
-
return
|
|
223
|
+
return _context3.abrupt("return", results);
|
|
162
224
|
case 13:
|
|
163
225
|
case "end":
|
|
164
|
-
return
|
|
226
|
+
return _context3.stop();
|
|
165
227
|
}
|
|
166
|
-
},
|
|
228
|
+
}, _callee3, this, [[1, 9]]);
|
|
167
229
|
}));
|
|
168
230
|
function getReachabilityResults() {
|
|
169
231
|
return _getReachabilityResults.apply(this, arguments);
|
|
@@ -179,33 +241,33 @@ var Reachability = /*#__PURE__*/function () {
|
|
|
179
241
|
}, {
|
|
180
242
|
key: "isAnyPublicClusterReachable",
|
|
181
243
|
value: function () {
|
|
182
|
-
var _isAnyPublicClusterReachable = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
244
|
+
var _isAnyPublicClusterReachable = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
183
245
|
var reachable, reachabilityData, reachabilityResults;
|
|
184
|
-
return _regenerator.default.wrap(function
|
|
185
|
-
while (1) switch (
|
|
246
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
247
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
186
248
|
case 0:
|
|
187
249
|
reachable = false; // @ts-ignore
|
|
188
|
-
|
|
250
|
+
_context4.next = 3;
|
|
189
251
|
return this.webex.boundedStorage.get(this.namespace, _constants.REACHABILITY.localStorageResult).catch(function () {});
|
|
190
252
|
case 3:
|
|
191
|
-
reachabilityData =
|
|
253
|
+
reachabilityData = _context4.sent;
|
|
192
254
|
if (reachabilityData) {
|
|
193
255
|
try {
|
|
194
256
|
reachabilityResults = JSON.parse(reachabilityData);
|
|
195
257
|
reachable = (0, _values.default)(reachabilityResults).some(function (result) {
|
|
196
|
-
var _result$
|
|
197
|
-
return !result.isVideoMesh && (((_result$
|
|
258
|
+
var _result$udp2, _result$tcp2;
|
|
259
|
+
return !result.isVideoMesh && (((_result$udp2 = result.udp) === null || _result$udp2 === void 0 ? void 0 : _result$udp2.reachable) === 'true' || ((_result$tcp2 = result.tcp) === null || _result$tcp2 === void 0 ? void 0 : _result$tcp2.reachable) === 'true');
|
|
198
260
|
});
|
|
199
261
|
} catch (e) {
|
|
200
262
|
_loggerProxy.default.logger.error("Roap:request#attachReachabilityData --> Error in parsing reachability data: ".concat(e));
|
|
201
263
|
}
|
|
202
264
|
}
|
|
203
|
-
return
|
|
265
|
+
return _context4.abrupt("return", reachable);
|
|
204
266
|
case 6:
|
|
205
267
|
case "end":
|
|
206
|
-
return
|
|
268
|
+
return _context4.stop();
|
|
207
269
|
}
|
|
208
|
-
},
|
|
270
|
+
}, _callee4, this);
|
|
209
271
|
}));
|
|
210
272
|
function isAnyPublicClusterReachable() {
|
|
211
273
|
return _isAnyPublicClusterReachable.apply(this, arguments);
|
|
@@ -288,10 +350,10 @@ var Reachability = /*#__PURE__*/function () {
|
|
|
288
350
|
var _this = this;
|
|
289
351
|
var clusters = (0, _toConsumableArray2.default)((0, _keys.default)(clusterList));
|
|
290
352
|
clusters = clusters.map( /*#__PURE__*/function () {
|
|
291
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
353
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(key) {
|
|
292
354
|
var cluster, config, peerConnection, description;
|
|
293
|
-
return _regenerator.default.wrap(function
|
|
294
|
-
while (1) switch (
|
|
355
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
356
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
295
357
|
case 0:
|
|
296
358
|
cluster = clusterList[key];
|
|
297
359
|
config = _this.buildPeerConnectionConfig(cluster);
|
|
@@ -299,23 +361,23 @@ var Reachability = /*#__PURE__*/function () {
|
|
|
299
361
|
key: key,
|
|
300
362
|
config: config
|
|
301
363
|
});
|
|
302
|
-
|
|
364
|
+
_context5.next = 5;
|
|
303
365
|
return peerConnection.createOffer({
|
|
304
366
|
offerToReceiveAudio: true
|
|
305
367
|
});
|
|
306
368
|
case 5:
|
|
307
|
-
description =
|
|
369
|
+
description = _context5.sent;
|
|
308
370
|
// @ts-ignore
|
|
309
371
|
peerConnection.begin = (0, _now.default)();
|
|
310
372
|
peerConnection.setLocalDescription(description);
|
|
311
|
-
return
|
|
373
|
+
return _context5.abrupt("return", _this.iceGatheringState(peerConnection, cluster.isVideoMesh).catch(function (iceGatheringStateError) {
|
|
312
374
|
_loggerProxy.default.logger.log("Reachability:index#getLocalSDPForClusters --> Error in getLocalSDP : ".concat(iceGatheringStateError));
|
|
313
375
|
}));
|
|
314
376
|
case 9:
|
|
315
377
|
case "end":
|
|
316
|
-
return
|
|
378
|
+
return _context5.stop();
|
|
317
379
|
}
|
|
318
|
-
},
|
|
380
|
+
}, _callee5);
|
|
319
381
|
}));
|
|
320
382
|
return function (_x) {
|
|
321
383
|
return _ref.apply(this, arguments);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_TIMEOUT","VIDEO_MESH_TIMEOUT","Reachability","webex","REACHABILITY","namespace","reachabilityRequest","ReachabilityRequest","clusterLatencyResults","setup","boundedStorage","del","localStorageResult","localStorageJoinCookie","getClusters","MeetingUtil","getIpVersion","clusters","joinCookie","performReachabilityCheck","results","put","LoggerProxy","logger","log","error","reachabilityResultsProps","get","resultsJson","internalResults","JSON","parse","result","warn","reachable","catch","reachabilityData","reachabilityResults","some","isVideoMesh","udp","tcp","e","cluster","iceServers","map","url","username","credential","urls","iceCandidatePoolSize","iceTransportPolicy","key","config","peerConnection","window","RTCPeerConnection","peerConnectionError","startTime","begin","clusterList","buildPeerConnectionConfig","createPeerConnection","createOffer","offerToReceiveAudio","description","setLocalDescription","iceGatheringState","iceGatheringStateError","all","then","parseIceResultsToInternalReachabilityResults","reachabilityLatencyResults","logUnreachableClusters","unreachableList","forEach","unreachable","push","onicegatheringstatechange","COMPLETE","ICE_GATHERING_STATE","iceConnectionState","elapsed","getElapsedTime","setLatencyAndClose","onicecandidate","SERVER_REFLEXIVE","candidate","String","type","toLowerCase","addPublicIP","address","ELAPSED","timeout","resolve","peerConnectionProxy","Proxy","target","property","targetMember","bind","set","value","clusterId","publicIPs","Reflect","handleIceGatheringStateChange","handleOnIceCandidate","setTimeout","CLOSED","CONNECTION_STATE","connectionState","list","getUnreachablClusters","iceResults","reachabilityMap","latencyResult","latencyInMilliseconds","toString","clientMediaIPs","untested","xtls","length","getLocalSDPForClusters","localSDPData","publicIP","modifiedPeerConnection","REACHABLE","UNREACHABLE","resultKey","intialState","close"],"sources":["index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-disable class-methods-use-this */\n/* globals window */\nimport {uniq, mapValues, pick} from 'lodash';\n\nimport LoggerProxy from '../common/logs/logger-proxy';\nimport MeetingUtil from '../meeting/util';\n\nimport {ICE_GATHERING_STATE, CONNECTION_STATE, REACHABILITY} from '../constants';\n\nimport ReachabilityRequest from './request';\n\nconst DEFAULT_TIMEOUT = 3000;\nconst VIDEO_MESH_TIMEOUT = 1000;\n\n// result for a specific transport protocol (like udp or tcp)\nexport type TransportResult = {\n reachable: 'true' | 'false';\n latencyInMilliseconds?: string;\n clientMediaIPs?: string[];\n untested?: 'true';\n};\n\n// reachability result for a specifc media cluster\ntype ReachabilityResult = {\n udp: TransportResult;\n tcp: TransportResult;\n xtls: {\n untested: 'true';\n };\n};\n// this is the type that is required by the backend when we send them reachability results\nexport type ReachabilityResults = Record<string, ReachabilityResult>;\n\n// this is the type used by Reachability class internally and stored in local storage\ntype InternalReachabilityResults = Record<\n string,\n ReachabilityResult & {\n isVideoMesh?: boolean;\n }\n>;\n\nexport type ICECandidateResult = {\n clusterId: string;\n isVideoMesh: boolean;\n elapsed?: string | null;\n publicIPs?: string[];\n};\n/**\n * @class Reachability\n * @export\n */\nexport default class Reachability {\n namespace = REACHABILITY.namespace;\n webex: object;\n reachabilityRequest: any;\n clusterLatencyResults: any;\n\n /**\n * Creates an instance of Reachability.\n * @param {object} webex\n * @memberof Reachability\n */\n constructor(webex: object) {\n this.webex = webex;\n\n /**\n * internal request object for the server\n * @instance\n * @type {Array}\n * @private\n * @memberof Reachability\n */\n this.reachabilityRequest = new ReachabilityRequest(this.webex);\n\n /**\n * internal object of clusters latency results\n * @instance\n * @type {object}\n * @private\n * @memberof Reachability\n */\n this.clusterLatencyResults = {};\n }\n\n /**\n * fetches reachability data\n * @returns {Object} reachability data\n * @public\n * @async\n * @memberof Reachability\n */\n public async gatherReachability(): Promise<InternalReachabilityResults> {\n this.setup();\n\n // Remove stored reachability results to ensure no stale data\n // @ts-ignore\n await this.webex.boundedStorage.del(this.namespace, REACHABILITY.localStorageResult);\n // @ts-ignore\n await this.webex.boundedStorage.del(this.namespace, REACHABILITY.localStorageJoinCookie);\n\n // Fetch clusters and measure latency\n try {\n const {clusters, joinCookie} = await this.reachabilityRequest.getClusters(\n MeetingUtil.getIpVersion(this.webex)\n );\n\n // Perform Reachability Check\n const results = await this.performReachabilityCheck(clusters);\n\n // @ts-ignore\n await this.webex.boundedStorage.put(\n this.namespace,\n REACHABILITY.localStorageResult,\n JSON.stringify(results)\n );\n // @ts-ignore\n await this.webex.boundedStorage.put(\n this.namespace,\n REACHABILITY.localStorageJoinCookie,\n JSON.stringify(joinCookie)\n );\n\n LoggerProxy.logger.log(\n 'Reachability:index#gatherReachability --> Reachability checks completed'\n );\n\n return results;\n } catch (getClusterError) {\n LoggerProxy.logger.error(\n `Reachability:index#gatherReachability --> Error in calling getClusters(): ${getClusterError}`\n );\n\n return {};\n }\n }\n\n /**\n * Reachability results as an object in the format that backend expects\n *\n * @returns {any} reachability results that need to be sent to the backend\n */\n async getReachabilityResults(): Promise<ReachabilityResults | undefined> {\n let results: ReachabilityResults;\n\n // these are the only props that backend needs in the reachability results:\n const reachabilityResultsProps: Array<keyof ReachabilityResult> = ['udp', 'tcp', 'xtls'];\n\n try {\n // @ts-ignore\n const resultsJson = await this.webex.boundedStorage.get(\n REACHABILITY.namespace,\n REACHABILITY.localStorageResult\n );\n\n const internalResults: InternalReachabilityResults = JSON.parse(resultsJson);\n\n results = mapValues(internalResults, (result) => pick(result, reachabilityResultsProps));\n } catch (e) {\n // empty storage, that's ok\n LoggerProxy.logger.warn(\n 'Roap:request#attachReachabilityData --> Error parsing reachability data: ',\n e\n );\n }\n\n return results;\n }\n\n /**\n * fetches reachability data and checks for cluster reachability\n * @returns {boolean}\n * @public\n * @memberof Reachability\n */\n async isAnyPublicClusterReachable() {\n let reachable = false;\n // @ts-ignore\n const reachabilityData = await this.webex.boundedStorage\n .get(this.namespace, REACHABILITY.localStorageResult)\n .catch(() => {});\n\n if (reachabilityData) {\n try {\n const reachabilityResults: InternalReachabilityResults = JSON.parse(reachabilityData);\n\n reachable = Object.values(reachabilityResults).some(\n (result) =>\n !result.isVideoMesh &&\n (result.udp?.reachable === 'true' || result.tcp?.reachable === 'true')\n );\n } catch (e) {\n LoggerProxy.logger.error(\n `Roap:request#attachReachabilityData --> Error in parsing reachability data: ${e}`\n );\n }\n }\n\n return reachable;\n }\n\n /**\n * Generate peerConnection config settings\n * @param {object} cluster\n * @returns {object} peerConnectionConfig\n * @private\n * @memberof Reachability\n */\n private buildPeerConnectionConfig(cluster: any) {\n const iceServers = uniq(cluster.udp).map((url) => ({\n username: '',\n credential: '',\n urls: [url],\n }));\n\n return {\n iceServers: [...iceServers],\n iceCandidatePoolSize: '0',\n iceTransportPolicy: 'all',\n };\n }\n\n /**\n * Creates an RTCPeerConnection\n * @param {object} cluster\n * @returns {RTCPeerConnection} peerConnection\n * @private\n * @memberof Reachability\n */\n private createPeerConnection(cluster: any) {\n const {key, config} = cluster;\n\n try {\n const peerConnection = new window.RTCPeerConnection(config);\n\n // @ts-ignore\n peerConnection.key = key;\n\n return peerConnection;\n } catch (peerConnectionError) {\n LoggerProxy.logger.log(\n `Reachability:index#createPeerConnection --> Error creating peerConnection: ${peerConnectionError}`\n );\n\n return null;\n }\n }\n\n /**\n * Gets total elapsed time\n * @param {RTCPeerConnection} peerConnection\n * @returns {Number} Milliseconds\n * @private\n * @memberof Reachability\n */\n private getElapsedTime(peerConnection: any) {\n const startTime = peerConnection.begin;\n\n delete peerConnection.begin;\n\n return Date.now() - startTime;\n }\n\n /**\n * creates offer and generates localSDP\n * @param {object} clusterList cluster List\n * @returns {Promise} Reachability latency results\n * @private\n * @memberof Reachability\n */\n private getLocalSDPForClusters(clusterList: object): Promise<InternalReachabilityResults> {\n let clusters: any[] = [...Object.keys(clusterList)];\n\n clusters = clusters.map(async (key) => {\n const cluster = clusterList[key];\n const config = this.buildPeerConnectionConfig(cluster);\n const peerConnection = this.createPeerConnection({key, config});\n const description = await peerConnection.createOffer({offerToReceiveAudio: true});\n\n // @ts-ignore\n peerConnection.begin = Date.now();\n peerConnection.setLocalDescription(description);\n\n return this.iceGatheringState(peerConnection, cluster.isVideoMesh).catch(\n (iceGatheringStateError) => {\n LoggerProxy.logger.log(\n `Reachability:index#getLocalSDPForClusters --> Error in getLocalSDP : ${iceGatheringStateError}`\n );\n }\n );\n });\n\n return Promise.all(clusters)\n .then(this.parseIceResultsToInternalReachabilityResults)\n .then((reachabilityLatencyResults) => {\n this.logUnreachableClusters();\n\n // return results\n return reachabilityLatencyResults;\n });\n }\n\n /**\n * Get list of all unreachable clusters\n * @returns {array} Unreachable clusters\n * @private\n * @memberof Reachability\n */\n private getUnreachablClusters() {\n const unreachableList = [];\n const clusters = this.clusterLatencyResults;\n\n Object.keys(clusters).forEach((key) => {\n const cluster = clusters[key];\n\n if (cluster.unreachable && !cluster.reachable) {\n unreachableList.push(key);\n }\n });\n\n return unreachableList;\n }\n\n /**\n * Attach an event handler for the icegatheringstatechange\n * event and measure latency.\n * @param {RTCPeerConnection} peerConnection\n * @returns {undefined}\n * @private\n * @memberof Reachability\n */\n private handleIceGatheringStateChange(peerConnection: RTCPeerConnection) {\n peerConnection.onicegatheringstatechange = () => {\n const {COMPLETE} = ICE_GATHERING_STATE;\n\n if (peerConnection.iceConnectionState === COMPLETE) {\n const elapsed = this.getElapsedTime(peerConnection);\n\n // @ts-ignore\n LoggerProxy.logger.log(\n // @ts-ignore\n `Reachability:index#onIceGatheringStateChange --> Successfully pinged ${peerConnection.key}:`,\n elapsed\n );\n this.setLatencyAndClose(peerConnection, elapsed);\n }\n };\n }\n\n /**\n * Attach an event handler for the icecandidate\n * event and measure latency.\n * @param {RTCPeerConnection} peerConnection\n * @returns {undefined}\n * @private\n * @memberof Reachability\n */\n private handleOnIceCandidate(peerConnection: RTCPeerConnection) {\n peerConnection.onicecandidate = (e) => {\n const SERVER_REFLEXIVE = 'srflx';\n\n if (e.candidate && String(e.candidate.type).toLowerCase() === SERVER_REFLEXIVE) {\n const elapsed = this.getElapsedTime(peerConnection);\n\n LoggerProxy.logger.log(\n // @ts-ignore\n `Reachability:index#onIceCandidate --> Successfully pinged ${peerConnection.key}:`,\n elapsed\n );\n // order is important\n this.addPublicIP(peerConnection, e.candidate.address);\n this.setLatencyAndClose(peerConnection, elapsed);\n }\n };\n }\n\n /**\n * An event handler on an RTCPeerConnection when the state of the ICE\n * candidate gathering process changes. Used to measure connection\n * speed.\n * @private\n * @param {RTCPeerConnection} peerConnection\n * @param {boolean} isVideoMesh\n * @returns {Promise}\n */\n private iceGatheringState(peerConnection: RTCPeerConnection, isVideoMesh: boolean) {\n const ELAPSED = 'elapsed';\n\n const timeout = isVideoMesh ? VIDEO_MESH_TIMEOUT : DEFAULT_TIMEOUT;\n\n return new Promise<ICECandidateResult>((resolve) => {\n const peerConnectionProxy = new window.Proxy(peerConnection, {\n // eslint-disable-next-line require-jsdoc\n get(target, property) {\n const targetMember = target[property];\n\n if (typeof targetMember === 'function') {\n return targetMember.bind(target);\n }\n\n return targetMember;\n },\n set: (target, property, value) => {\n // only intercept elapsed property\n if (property === ELAPSED) {\n resolve({\n // @ts-ignore\n clusterId: peerConnection.key,\n isVideoMesh,\n // @ts-ignore\n publicIPs: target.publicIPs,\n elapsed: value,\n });\n\n return true;\n }\n\n // pass thru\n return window.Reflect.set(target, property, value);\n },\n });\n\n // Using peerConnection proxy so handle functions below\n // won't be coupled to our promise implementation\n this.handleIceGatheringStateChange(peerConnectionProxy);\n this.handleOnIceCandidate(peerConnectionProxy);\n\n // Set maximum timeout\n window.setTimeout(() => {\n const {CLOSED} = CONNECTION_STATE;\n\n // Close any open peerConnections\n if (peerConnectionProxy.connectionState !== CLOSED) {\n // order is important\n this.addPublicIP(peerConnectionProxy, null);\n this.setLatencyAndClose(peerConnectionProxy, null);\n }\n }, timeout);\n });\n }\n\n /**\n * Make a log of unreachable clusters.\n * @returns {undefined}\n * @private\n * @memberof Reachability\n */\n private logUnreachableClusters() {\n const list = this.getUnreachablClusters();\n\n list.forEach((cluster) => {\n LoggerProxy.logger.log(\n `Reachability:index#logUnreachableClusters --> No ice candidate for ${cluster}.`\n );\n });\n }\n\n /**\n * Calculates time to establish connection\n * @param {Array<ICECandidateResult>} iceResults iceResults\n * @returns {object} reachabilityMap\n * @protected\n * @memberof Reachability\n */\n protected parseIceResultsToInternalReachabilityResults(\n iceResults: Array<ICECandidateResult>\n ): InternalReachabilityResults {\n const reachabilityMap = {};\n\n iceResults.forEach(({clusterId, isVideoMesh, elapsed, publicIPs}) => {\n const latencyResult = {};\n\n if (!elapsed) {\n Object.assign(latencyResult, {reachable: 'false'});\n } else {\n Object.assign(latencyResult, {\n reachable: 'true',\n latencyInMilliseconds: elapsed.toString(),\n });\n }\n\n if (publicIPs) {\n Object.assign(latencyResult, {\n clientMediaIPs: publicIPs,\n });\n }\n\n reachabilityMap[clusterId] = {\n udp: latencyResult,\n tcp: {untested: 'true'},\n xtls: {untested: 'true'},\n isVideoMesh,\n };\n });\n\n return reachabilityMap;\n }\n\n /**\n * fetches reachability data\n * @param {object} clusterList\n * @returns {Promise<InternalReachabilityResults>} reachability check results\n * @private\n * @memberof Reachability\n */\n private performReachabilityCheck(clusterList: object): Promise<InternalReachabilityResults> {\n if (!clusterList || !Object.keys(clusterList).length) {\n return Promise.resolve({});\n }\n\n return new Promise((resolve) => {\n this.getLocalSDPForClusters(clusterList)\n .then((localSDPData) => {\n if (!localSDPData || !Object.keys(localSDPData).length) {\n // TODO: handle the error condition properly and try retry\n LoggerProxy.logger.log(\n 'Reachability:index#performReachabilityCheck --> Local SDP is empty or has missing elements..returning'\n );\n resolve({});\n } else {\n resolve(localSDPData);\n }\n })\n .catch((error) => {\n LoggerProxy.logger.error(\n `Reachability:index#performReachabilityCheck --> Error in getLocalSDPForClusters: ${error}`\n );\n resolve({});\n });\n });\n }\n\n /**\n * Adds public IP (client media IPs)\n * @param {RTCPeerConnection} peerConnection\n * @param {string} publicIP\n * @returns {void}\n */\n protected addPublicIP(peerConnection: RTCPeerConnection, publicIP?: string | null) {\n const modifiedPeerConnection: RTCPeerConnection & {publicIPs?: string[]} = peerConnection;\n const {CLOSED} = CONNECTION_STATE;\n\n if (modifiedPeerConnection.connectionState === CLOSED) {\n LoggerProxy.logger.log(\n `Reachability:index#addPublicIP --> Attempting to set publicIP of ${publicIP} on closed peerConnection.`\n );\n }\n\n if (publicIP) {\n if (modifiedPeerConnection.publicIPs) {\n modifiedPeerConnection.publicIPs.push(publicIP);\n } else {\n modifiedPeerConnection.publicIPs = [publicIP];\n }\n } else {\n modifiedPeerConnection.publicIPs = null;\n }\n }\n\n /**\n * Records latency and closes the peerConnection\n * @param {RTCPeerConnection} peerConnection\n * @param {number} elapsed Latency in milliseconds\n * @returns {undefined}\n * @private\n * @memberof Reachability\n */\n private setLatencyAndClose(peerConnection: RTCPeerConnection, elapsed: number) {\n const REACHABLE = 'reachable';\n const UNREACHABLE = 'unreachable';\n const {CLOSED} = CONNECTION_STATE;\n // @ts-ignore\n const {key} = peerConnection;\n const resultKey = elapsed === null ? UNREACHABLE : REACHABLE;\n const intialState = {[REACHABLE]: 0, [UNREACHABLE]: 0};\n\n if (peerConnection.connectionState === CLOSED) {\n LoggerProxy.logger.log(\n `Reachability:index#setLatencyAndClose --> Attempting to set latency of ${elapsed} on closed peerConnection.`\n );\n\n return;\n }\n\n this.clusterLatencyResults[key] = this.clusterLatencyResults[key] || intialState;\n this.clusterLatencyResults[key][resultKey] += 1;\n\n // Set to null in case this fired from\n // an event other than onIceCandidate\n peerConnection.onicecandidate = null;\n peerConnection.close();\n // @ts-ignore\n peerConnection.elapsed = elapsed;\n }\n\n /**\n * utility function\n * @returns {undefined}\n * @private\n * @memberof Reachability\n */\n private setup() {\n this.clusterLatencyResults = {};\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQA;AACA;AAEA;AAEA;AAEA,IAAMA,eAAe,GAAG,IAAI;AAC5B,IAAMC,kBAAkB,GAAG,IAAI;;AAE/B;AAiCA;AACA;AACA;AACA;AAHA,IAIqBC,YAAY;EAM/B;AACF;AACA;AACA;AACA;EACE,sBAAYC,KAAa,EAAE;IAAA;IAAA,iDAVfC,uBAAY,CAACC,SAAS;IAAA;IAAA;IAAA;IAWhC,IAAI,CAACF,KAAK,GAAGA,KAAK;;IAElB;AACJ;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACG,mBAAmB,GAAG,IAAIC,gBAAmB,CAAC,IAAI,CAACJ,KAAK,CAAC;;I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E;QAC7CxF,oBAAW,CAACC,MAAM,CAACC,GAAG,kFACsD0D,OAAO,gCAClF;QAED;MACF;MAEA,IAAI,CAAC1E,qBAAqB,CAAC4C,GAAG,CAAC,GAAG,IAAI,CAAC5C,qBAAqB,CAAC4C,GAAG,CAAC,IAAI+E,WAAW;MAChF,IAAI,CAAC3H,qBAAqB,CAAC4C,GAAG,CAAC,CAAC8E,SAAS,CAAC,IAAI,CAAC;;MAE/C;MACA;MACA5E,cAAc,CAAC+B,cAAc,GAAG,IAAI;MACpC/B,cAAc,CAAC8E,KAAK,EAAE;MACtB;MACA9E,cAAc,CAAC4B,OAAO,GAAGA,OAAO;IAClC;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,iBAAgB;MACd,IAAI,CAAC1E,qBAAqB,GAAG,CAAC,CAAC;IACjC;EAAC;EAAA;AAAA;AAAA"}
|
|
1
|
+
{"version":3,"names":["DEFAULT_TIMEOUT","VIDEO_MESH_TIMEOUT","Reachability","webex","REACHABILITY","namespace","reachabilityRequest","ReachabilityRequest","clusterLatencyResults","setup","boundedStorage","del","localStorageResult","localStorageJoinCookie","getClusters","MeetingUtil","getIpVersion","clusters","joinCookie","performReachabilityCheck","results","put","LoggerProxy","logger","log","error","stats","reachability_public_udp_success","reachability_public_udp_failed","reachability_public_tcp_success","reachability_public_tcp_failed","reachability_vmn_udp_success","reachability_vmn_udp_failed","reachability_vmn_tcp_success","reachability_vmn_tcp_failed","updateStats","clusterType","result","udp","reachable","outcome","tcp","get","resultsJson","internalResults","JSON","parse","forEach","isVideoMesh","warn","reachabilityResultsProps","catch","reachabilityData","reachabilityResults","some","e","cluster","iceServers","map","url","username","credential","urls","iceCandidatePoolSize","iceTransportPolicy","key","config","peerConnection","window","RTCPeerConnection","peerConnectionError","startTime","begin","clusterList","buildPeerConnectionConfig","createPeerConnection","createOffer","offerToReceiveAudio","description","setLocalDescription","iceGatheringState","iceGatheringStateError","all","then","parseIceResultsToInternalReachabilityResults","reachabilityLatencyResults","logUnreachableClusters","unreachableList","unreachable","push","onicegatheringstatechange","COMPLETE","ICE_GATHERING_STATE","iceConnectionState","elapsed","getElapsedTime","setLatencyAndClose","onicecandidate","SERVER_REFLEXIVE","candidate","String","type","toLowerCase","addPublicIP","address","ELAPSED","timeout","resolve","peerConnectionProxy","Proxy","target","property","targetMember","bind","set","value","clusterId","publicIPs","Reflect","handleIceGatheringStateChange","handleOnIceCandidate","setTimeout","CLOSED","CONNECTION_STATE","connectionState","list","getUnreachablClusters","iceResults","reachabilityMap","latencyResult","latencyInMilliseconds","toString","clientMediaIPs","untested","xtls","length","getLocalSDPForClusters","localSDPData","publicIP","modifiedPeerConnection","REACHABLE","UNREACHABLE","resultKey","intialState","close"],"sources":["index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-disable class-methods-use-this */\n/* globals window */\nimport {uniq, mapValues, pick} from 'lodash';\n\nimport LoggerProxy from '../common/logs/logger-proxy';\nimport MeetingUtil from '../meeting/util';\n\nimport {ICE_GATHERING_STATE, CONNECTION_STATE, REACHABILITY} from '../constants';\n\nimport ReachabilityRequest from './request';\n\nconst DEFAULT_TIMEOUT = 3000;\nconst VIDEO_MESH_TIMEOUT = 1000;\n\nexport type ReachabilityMetrics = {\n reachability_public_udp_success: number;\n reachability_public_udp_failed: number;\n reachability_public_tcp_success: number;\n reachability_public_tcp_failed: number;\n reachability_vmn_udp_success: number;\n reachability_vmn_udp_failed: number;\n reachability_vmn_tcp_success: number;\n reachability_vmn_tcp_failed: number;\n};\n\n// result for a specific transport protocol (like udp or tcp)\nexport type TransportResult = {\n reachable?: 'true' | 'false';\n latencyInMilliseconds?: string;\n clientMediaIPs?: string[];\n untested?: 'true';\n};\n\n// reachability result for a specifc media cluster\ntype ReachabilityResult = {\n udp: TransportResult;\n tcp: TransportResult;\n xtls: {\n untested: 'true';\n };\n};\n// this is the type that is required by the backend when we send them reachability results\nexport type ReachabilityResults = Record<string, ReachabilityResult>;\n\n// this is the type used by Reachability class internally and stored in local storage\ntype InternalReachabilityResults = Record<\n string,\n ReachabilityResult & {\n isVideoMesh?: boolean;\n }\n>;\n\nexport type ICECandidateResult = {\n clusterId: string;\n isVideoMesh: boolean;\n elapsed?: string | null;\n publicIPs?: string[];\n};\n/**\n * @class Reachability\n * @export\n */\nexport default class Reachability {\n namespace = REACHABILITY.namespace;\n webex: object;\n reachabilityRequest: any;\n clusterLatencyResults: any;\n\n /**\n * Creates an instance of Reachability.\n * @param {object} webex\n * @memberof Reachability\n */\n constructor(webex: object) {\n this.webex = webex;\n\n /**\n * internal request object for the server\n * @instance\n * @type {Array}\n * @private\n * @memberof Reachability\n */\n this.reachabilityRequest = new ReachabilityRequest(this.webex);\n\n /**\n * internal object of clusters latency results\n * @instance\n * @type {object}\n * @private\n * @memberof Reachability\n */\n this.clusterLatencyResults = {};\n }\n\n /**\n * fetches reachability data\n * @returns {Object} reachability data\n * @public\n * @async\n * @memberof Reachability\n */\n public async gatherReachability(): Promise<InternalReachabilityResults> {\n this.setup();\n\n // Remove stored reachability results to ensure no stale data\n // @ts-ignore\n await this.webex.boundedStorage.del(this.namespace, REACHABILITY.localStorageResult);\n // @ts-ignore\n await this.webex.boundedStorage.del(this.namespace, REACHABILITY.localStorageJoinCookie);\n\n // Fetch clusters and measure latency\n try {\n const {clusters, joinCookie} = await this.reachabilityRequest.getClusters(\n MeetingUtil.getIpVersion(this.webex)\n );\n\n // Perform Reachability Check\n const results = await this.performReachabilityCheck(clusters);\n\n // @ts-ignore\n await this.webex.boundedStorage.put(\n this.namespace,\n REACHABILITY.localStorageResult,\n JSON.stringify(results)\n );\n // @ts-ignore\n await this.webex.boundedStorage.put(\n this.namespace,\n REACHABILITY.localStorageJoinCookie,\n JSON.stringify(joinCookie)\n );\n\n LoggerProxy.logger.log(\n 'Reachability:index#gatherReachability --> Reachability checks completed'\n );\n\n return results;\n } catch (getClusterError) {\n LoggerProxy.logger.error(\n `Reachability:index#gatherReachability --> Error in calling getClusters(): ${getClusterError}`\n );\n\n return {};\n }\n }\n\n /**\n * Returns statistics about last reachability results. The returned value is an object\n * with a flat list of properties so that it can be easily sent with metrics\n *\n * @returns {Promise} Promise with metrics values, it never rejects/throws.\n */\n async getReachabilityMetrics(): Promise<ReachabilityMetrics> {\n const stats: ReachabilityMetrics = {\n reachability_public_udp_success: 0,\n reachability_public_udp_failed: 0,\n reachability_public_tcp_success: 0,\n reachability_public_tcp_failed: 0,\n reachability_vmn_udp_success: 0,\n reachability_vmn_udp_failed: 0,\n reachability_vmn_tcp_success: 0,\n reachability_vmn_tcp_failed: 0,\n };\n\n const updateStats = (clusterType: 'public' | 'vmn', result: ReachabilityResult) => {\n if (result.udp?.reachable) {\n const outcome = result.udp.reachable === 'true' ? 'success' : 'failed';\n stats[`reachability_${clusterType}_udp_${outcome}`] += 1;\n }\n if (result.tcp?.reachable) {\n const outcome = result.tcp.reachable === 'true' ? 'success' : 'failed';\n stats[`reachability_${clusterType}_tcp_${outcome}`] += 1;\n }\n };\n\n try {\n // @ts-ignore\n const resultsJson = await this.webex.boundedStorage.get(\n REACHABILITY.namespace,\n REACHABILITY.localStorageResult\n );\n\n const internalResults: InternalReachabilityResults = JSON.parse(resultsJson);\n\n Object.values(internalResults).forEach((result) => {\n updateStats(result.isVideoMesh ? 'vmn' : 'public', result);\n });\n } catch (e) {\n // empty storage, that's ok\n LoggerProxy.logger.warn(\n 'Roap:request#getReachabilityMetrics --> Error parsing reachability data: ',\n e\n );\n }\n\n return stats;\n }\n\n /**\n * Reachability results as an object in the format that backend expects\n *\n * @returns {any} reachability results that need to be sent to the backend\n */\n async getReachabilityResults(): Promise<ReachabilityResults | undefined> {\n let results: ReachabilityResults;\n\n // these are the only props that backend needs in the reachability results:\n const reachabilityResultsProps: Array<keyof ReachabilityResult> = ['udp', 'tcp', 'xtls'];\n\n try {\n // @ts-ignore\n const resultsJson = await this.webex.boundedStorage.get(\n REACHABILITY.namespace,\n REACHABILITY.localStorageResult\n );\n\n const internalResults: InternalReachabilityResults = JSON.parse(resultsJson);\n\n results = mapValues(internalResults, (result) => pick(result, reachabilityResultsProps));\n } catch (e) {\n // empty storage, that's ok\n LoggerProxy.logger.warn(\n 'Roap:request#attachReachabilityData --> Error parsing reachability data: ',\n e\n );\n }\n\n return results;\n }\n\n /**\n * fetches reachability data and checks for cluster reachability\n * @returns {boolean}\n * @public\n * @memberof Reachability\n */\n async isAnyPublicClusterReachable() {\n let reachable = false;\n // @ts-ignore\n const reachabilityData = await this.webex.boundedStorage\n .get(this.namespace, REACHABILITY.localStorageResult)\n .catch(() => {});\n\n if (reachabilityData) {\n try {\n const reachabilityResults: InternalReachabilityResults = JSON.parse(reachabilityData);\n\n reachable = Object.values(reachabilityResults).some(\n (result) =>\n !result.isVideoMesh &&\n (result.udp?.reachable === 'true' || result.tcp?.reachable === 'true')\n );\n } catch (e) {\n LoggerProxy.logger.error(\n `Roap:request#attachReachabilityData --> Error in parsing reachability data: ${e}`\n );\n }\n }\n\n return reachable;\n }\n\n /**\n * Generate peerConnection config settings\n * @param {object} cluster\n * @returns {object} peerConnectionConfig\n * @private\n * @memberof Reachability\n */\n private buildPeerConnectionConfig(cluster: any) {\n const iceServers = uniq(cluster.udp).map((url) => ({\n username: '',\n credential: '',\n urls: [url],\n }));\n\n return {\n iceServers: [...iceServers],\n iceCandidatePoolSize: '0',\n iceTransportPolicy: 'all',\n };\n }\n\n /**\n * Creates an RTCPeerConnection\n * @param {object} cluster\n * @returns {RTCPeerConnection} peerConnection\n * @private\n * @memberof Reachability\n */\n private createPeerConnection(cluster: any) {\n const {key, config} = cluster;\n\n try {\n const peerConnection = new window.RTCPeerConnection(config);\n\n // @ts-ignore\n peerConnection.key = key;\n\n return peerConnection;\n } catch (peerConnectionError) {\n LoggerProxy.logger.log(\n `Reachability:index#createPeerConnection --> Error creating peerConnection: ${peerConnectionError}`\n );\n\n return null;\n }\n }\n\n /**\n * Gets total elapsed time\n * @param {RTCPeerConnection} peerConnection\n * @returns {Number} Milliseconds\n * @private\n * @memberof Reachability\n */\n private getElapsedTime(peerConnection: any) {\n const startTime = peerConnection.begin;\n\n delete peerConnection.begin;\n\n return Date.now() - startTime;\n }\n\n /**\n * creates offer and generates localSDP\n * @param {object} clusterList cluster List\n * @returns {Promise} Reachability latency results\n * @private\n * @memberof Reachability\n */\n private getLocalSDPForClusters(clusterList: object): Promise<InternalReachabilityResults> {\n let clusters: any[] = [...Object.keys(clusterList)];\n\n clusters = clusters.map(async (key) => {\n const cluster = clusterList[key];\n const config = this.buildPeerConnectionConfig(cluster);\n const peerConnection = this.createPeerConnection({key, config});\n const description = await peerConnection.createOffer({offerToReceiveAudio: true});\n\n // @ts-ignore\n peerConnection.begin = Date.now();\n peerConnection.setLocalDescription(description);\n\n return this.iceGatheringState(peerConnection, cluster.isVideoMesh).catch(\n (iceGatheringStateError) => {\n LoggerProxy.logger.log(\n `Reachability:index#getLocalSDPForClusters --> Error in getLocalSDP : ${iceGatheringStateError}`\n );\n }\n );\n });\n\n return Promise.all(clusters)\n .then(this.parseIceResultsToInternalReachabilityResults)\n .then((reachabilityLatencyResults) => {\n this.logUnreachableClusters();\n\n // return results\n return reachabilityLatencyResults;\n });\n }\n\n /**\n * Get list of all unreachable clusters\n * @returns {array} Unreachable clusters\n * @private\n * @memberof Reachability\n */\n private getUnreachablClusters() {\n const unreachableList = [];\n const clusters = this.clusterLatencyResults;\n\n Object.keys(clusters).forEach((key) => {\n const cluster = clusters[key];\n\n if (cluster.unreachable && !cluster.reachable) {\n unreachableList.push(key);\n }\n });\n\n return unreachableList;\n }\n\n /**\n * Attach an event handler for the icegatheringstatechange\n * event and measure latency.\n * @param {RTCPeerConnection} peerConnection\n * @returns {undefined}\n * @private\n * @memberof Reachability\n */\n private handleIceGatheringStateChange(peerConnection: RTCPeerConnection) {\n peerConnection.onicegatheringstatechange = () => {\n const {COMPLETE} = ICE_GATHERING_STATE;\n\n if (peerConnection.iceConnectionState === COMPLETE) {\n const elapsed = this.getElapsedTime(peerConnection);\n\n // @ts-ignore\n LoggerProxy.logger.log(\n // @ts-ignore\n `Reachability:index#onIceGatheringStateChange --> Successfully pinged ${peerConnection.key}:`,\n elapsed\n );\n this.setLatencyAndClose(peerConnection, elapsed);\n }\n };\n }\n\n /**\n * Attach an event handler for the icecandidate\n * event and measure latency.\n * @param {RTCPeerConnection} peerConnection\n * @returns {undefined}\n * @private\n * @memberof Reachability\n */\n private handleOnIceCandidate(peerConnection: RTCPeerConnection) {\n peerConnection.onicecandidate = (e) => {\n const SERVER_REFLEXIVE = 'srflx';\n\n if (e.candidate && String(e.candidate.type).toLowerCase() === SERVER_REFLEXIVE) {\n const elapsed = this.getElapsedTime(peerConnection);\n\n LoggerProxy.logger.log(\n // @ts-ignore\n `Reachability:index#onIceCandidate --> Successfully pinged ${peerConnection.key}:`,\n elapsed\n );\n // order is important\n this.addPublicIP(peerConnection, e.candidate.address);\n this.setLatencyAndClose(peerConnection, elapsed);\n }\n };\n }\n\n /**\n * An event handler on an RTCPeerConnection when the state of the ICE\n * candidate gathering process changes. Used to measure connection\n * speed.\n * @private\n * @param {RTCPeerConnection} peerConnection\n * @param {boolean} isVideoMesh\n * @returns {Promise}\n */\n private iceGatheringState(peerConnection: RTCPeerConnection, isVideoMesh: boolean) {\n const ELAPSED = 'elapsed';\n\n const timeout = isVideoMesh ? VIDEO_MESH_TIMEOUT : DEFAULT_TIMEOUT;\n\n return new Promise<ICECandidateResult>((resolve) => {\n const peerConnectionProxy = new window.Proxy(peerConnection, {\n // eslint-disable-next-line require-jsdoc\n get(target, property) {\n const targetMember = target[property];\n\n if (typeof targetMember === 'function') {\n return targetMember.bind(target);\n }\n\n return targetMember;\n },\n set: (target, property, value) => {\n // only intercept elapsed property\n if (property === ELAPSED) {\n resolve({\n // @ts-ignore\n clusterId: peerConnection.key,\n isVideoMesh,\n // @ts-ignore\n publicIPs: target.publicIPs,\n elapsed: value,\n });\n\n return true;\n }\n\n // pass thru\n return window.Reflect.set(target, property, value);\n },\n });\n\n // Using peerConnection proxy so handle functions below\n // won't be coupled to our promise implementation\n this.handleIceGatheringStateChange(peerConnectionProxy);\n this.handleOnIceCandidate(peerConnectionProxy);\n\n // Set maximum timeout\n window.setTimeout(() => {\n const {CLOSED} = CONNECTION_STATE;\n\n // Close any open peerConnections\n if (peerConnectionProxy.connectionState !== CLOSED) {\n // order is important\n this.addPublicIP(peerConnectionProxy, null);\n this.setLatencyAndClose(peerConnectionProxy, null);\n }\n }, timeout);\n });\n }\n\n /**\n * Make a log of unreachable clusters.\n * @returns {undefined}\n * @private\n * @memberof Reachability\n */\n private logUnreachableClusters() {\n const list = this.getUnreachablClusters();\n\n list.forEach((cluster) => {\n LoggerProxy.logger.log(\n `Reachability:index#logUnreachableClusters --> No ice candidate for ${cluster}.`\n );\n });\n }\n\n /**\n * Calculates time to establish connection\n * @param {Array<ICECandidateResult>} iceResults iceResults\n * @returns {object} reachabilityMap\n * @protected\n * @memberof Reachability\n */\n protected parseIceResultsToInternalReachabilityResults(\n iceResults: Array<ICECandidateResult>\n ): InternalReachabilityResults {\n const reachabilityMap = {};\n\n iceResults.forEach(({clusterId, isVideoMesh, elapsed, publicIPs}) => {\n const latencyResult = {};\n\n if (!elapsed) {\n Object.assign(latencyResult, {reachable: 'false'});\n } else {\n Object.assign(latencyResult, {\n reachable: 'true',\n latencyInMilliseconds: elapsed.toString(),\n });\n }\n\n if (publicIPs) {\n Object.assign(latencyResult, {\n clientMediaIPs: publicIPs,\n });\n }\n\n reachabilityMap[clusterId] = {\n udp: latencyResult,\n tcp: {untested: 'true'},\n xtls: {untested: 'true'},\n isVideoMesh,\n };\n });\n\n return reachabilityMap;\n }\n\n /**\n * fetches reachability data\n * @param {object} clusterList\n * @returns {Promise<InternalReachabilityResults>} reachability check results\n * @private\n * @memberof Reachability\n */\n private performReachabilityCheck(clusterList: object): Promise<InternalReachabilityResults> {\n if (!clusterList || !Object.keys(clusterList).length) {\n return Promise.resolve({});\n }\n\n return new Promise((resolve) => {\n this.getLocalSDPForClusters(clusterList)\n .then((localSDPData) => {\n if (!localSDPData || !Object.keys(localSDPData).length) {\n // TODO: handle the error condition properly and try retry\n LoggerProxy.logger.log(\n 'Reachability:index#performReachabilityCheck --> Local SDP is empty or has missing elements..returning'\n );\n resolve({});\n } else {\n resolve(localSDPData);\n }\n })\n .catch((error) => {\n LoggerProxy.logger.error(\n `Reachability:index#performReachabilityCheck --> Error in getLocalSDPForClusters: ${error}`\n );\n resolve({});\n });\n });\n }\n\n /**\n * Adds public IP (client media IPs)\n * @param {RTCPeerConnection} peerConnection\n * @param {string} publicIP\n * @returns {void}\n */\n protected addPublicIP(peerConnection: RTCPeerConnection, publicIP?: string | null) {\n const modifiedPeerConnection: RTCPeerConnection & {publicIPs?: string[]} = peerConnection;\n const {CLOSED} = CONNECTION_STATE;\n\n if (modifiedPeerConnection.connectionState === CLOSED) {\n LoggerProxy.logger.log(\n `Reachability:index#addPublicIP --> Attempting to set publicIP of ${publicIP} on closed peerConnection.`\n );\n }\n\n if (publicIP) {\n if (modifiedPeerConnection.publicIPs) {\n modifiedPeerConnection.publicIPs.push(publicIP);\n } else {\n modifiedPeerConnection.publicIPs = [publicIP];\n }\n } else {\n modifiedPeerConnection.publicIPs = null;\n }\n }\n\n /**\n * Records latency and closes the peerConnection\n * @param {RTCPeerConnection} peerConnection\n * @param {number} elapsed Latency in milliseconds\n * @returns {undefined}\n * @private\n * @memberof Reachability\n */\n private setLatencyAndClose(peerConnection: RTCPeerConnection, elapsed: number) {\n const REACHABLE = 'reachable';\n const UNREACHABLE = 'unreachable';\n const {CLOSED} = CONNECTION_STATE;\n // @ts-ignore\n const {key} = peerConnection;\n const resultKey = elapsed === null ? UNREACHABLE : REACHABLE;\n const intialState = {[REACHABLE]: 0, [UNREACHABLE]: 0};\n\n if (peerConnection.connectionState === CLOSED) {\n LoggerProxy.logger.log(\n `Reachability:index#setLatencyAndClose --> Attempting to set latency of ${elapsed} on closed peerConnection.`\n );\n\n return;\n }\n\n this.clusterLatencyResults[key] = this.clusterLatencyResults[key] || intialState;\n this.clusterLatencyResults[key][resultKey] += 1;\n\n // Set to null in case this fired from\n // an event other than onIceCandidate\n peerConnection.onicecandidate = null;\n peerConnection.close();\n // @ts-ignore\n peerConnection.elapsed = elapsed;\n }\n\n /**\n * utility function\n * @returns {undefined}\n * @private\n * @memberof Reachability\n */\n private setup() {\n this.clusterLatencyResults = {};\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQA;AACA;AAEA;AAEA;AAEA,IAAMA,eAAe,GAAG,IAAI;AAC5B,IAAMC,kBAAkB,GAAG,IAAI;AA8C/B;AACA;AACA;AACA;AAHA,IAIqBC,YAAY;EAM/B;AACF;AACA;AACA;AACA;EACE,sBAAYC,KAAa,EAAE;IAAA;IAAA,iDAVfC,uBAAY,CAACC,SAAS;IAAA;IAAA;IAAA;IAWhC,IAAI,CAACF,KAAK,GAAGA,KAAK;;IAElB;AACJ;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACG,mBAAmB,GAAG,IAAIC,gBAAmB,CAAC,IAAI,CAACJ,KAAK,CAAC;;IAE9D;AACJ;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACK,qBAAqB,GAAG,CAAC,CAAC;EACjC;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EANE;IAAA;IAAA;MAAA,kGAOA;QAAA;QAAA;UAAA;YAAA;cACE,IAAI,CAACC,KAAK,EAAE;;cAEZ;cACA;cAAA;cAAA,OACM,IAAI,CAACN,KAAK,CAACO,cAAc,CAACC,GAAG,CAAC,IAAI,CAACN,SAAS,EAAED,uBAAY,CAACQ,kBAAkB,CAAC;YAAA;cAAA;cAAA,OAE9E,IAAI,CAACT,KAAK,CAACO,cAAc,CAACC,GAAG,CAAC,IAAI,CAACN,SAAS,EAAED,uBAAY,CAACS,sBAAsB,CAAC;YAAA;cAAA;cAAA;cAAA,OAIjD,IAAI,CAACP,mBAAmB,CAACQ,W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A3E,cAAc,CAAC8B,cAAc,GAAG,IAAI;MACpC9B,cAAc,CAAC6E,KAAK,EAAE;MACtB;MACA7E,cAAc,CAAC2B,OAAO,GAAGA,OAAO;IAClC;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,iBAAgB;MACd,IAAI,CAACtF,qBAAqB,GAAG,CAAC,CAAC;IACjC;EAAC;EAAA;AAAA;AAAA"}
|
|
@@ -966,7 +966,7 @@ export default class Meeting extends StatelessWebexPlugin {
|
|
|
966
966
|
mediaOptions?: AddMediaOptions;
|
|
967
967
|
}): Promise<{
|
|
968
968
|
join: any;
|
|
969
|
-
media:
|
|
969
|
+
media: void;
|
|
970
970
|
}>;
|
|
971
971
|
/**
|
|
972
972
|
* Initiates the reconnection of the media in the meeting
|
|
@@ -1138,7 +1138,7 @@ export default class Meeting extends StatelessWebexPlugin {
|
|
|
1138
1138
|
* @public
|
|
1139
1139
|
* @memberof Meeting
|
|
1140
1140
|
*/
|
|
1141
|
-
addMedia(options?: AddMediaOptions): Promise<
|
|
1141
|
+
addMedia(options?: AddMediaOptions): Promise<void>;
|
|
1142
1142
|
/**
|
|
1143
1143
|
* Informs if the peer connection is in a state that can be updated with updateMedia (audio/video/share)
|
|
1144
1144
|
* @returns {Boolean}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
3
|
*/
|
|
4
|
+
export type ReachabilityMetrics = {
|
|
5
|
+
reachability_public_udp_success: number;
|
|
6
|
+
reachability_public_udp_failed: number;
|
|
7
|
+
reachability_public_tcp_success: number;
|
|
8
|
+
reachability_public_tcp_failed: number;
|
|
9
|
+
reachability_vmn_udp_success: number;
|
|
10
|
+
reachability_vmn_udp_failed: number;
|
|
11
|
+
reachability_vmn_tcp_success: number;
|
|
12
|
+
reachability_vmn_tcp_failed: number;
|
|
13
|
+
};
|
|
4
14
|
export type TransportResult = {
|
|
5
|
-
reachable
|
|
15
|
+
reachable?: 'true' | 'false';
|
|
6
16
|
latencyInMilliseconds?: string;
|
|
7
17
|
clientMediaIPs?: string[];
|
|
8
18
|
untested?: 'true';
|
|
@@ -47,6 +57,13 @@ export default class Reachability {
|
|
|
47
57
|
* @memberof Reachability
|
|
48
58
|
*/
|
|
49
59
|
gatherReachability(): Promise<InternalReachabilityResults>;
|
|
60
|
+
/**
|
|
61
|
+
* Returns statistics about last reachability results. The returned value is an object
|
|
62
|
+
* with a flat list of properties so that it can be easily sent with metrics
|
|
63
|
+
*
|
|
64
|
+
* @returns {Promise} Promise with metrics values, it never rejects/throws.
|
|
65
|
+
*/
|
|
66
|
+
getReachabilityMetrics(): Promise<ReachabilityMetrics>;
|
|
50
67
|
/**
|
|
51
68
|
* Reachability results as an object in the format that backend expects
|
|
52
69
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/plugin-meetings",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.263",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Cisco EULA (https://www.cisco.com/c/en/us/products/end-user-license-agreement.html)",
|
|
6
6
|
"contributors": [
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"build": "yarn run -T tsc --declaration true --declarationDir ./dist/types"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@webex/plugin-meetings": "3.0.0-beta.
|
|
36
|
-
"@webex/test-helper-chai": "3.0.0-beta.
|
|
37
|
-
"@webex/test-helper-mocha": "3.0.0-beta.
|
|
38
|
-
"@webex/test-helper-mock-webex": "3.0.0-beta.
|
|
39
|
-
"@webex/test-helper-retry": "3.0.0-beta.
|
|
40
|
-
"@webex/test-helper-test-users": "3.0.0-beta.
|
|
35
|
+
"@webex/plugin-meetings": "3.0.0-beta.263",
|
|
36
|
+
"@webex/test-helper-chai": "3.0.0-beta.263",
|
|
37
|
+
"@webex/test-helper-mocha": "3.0.0-beta.263",
|
|
38
|
+
"@webex/test-helper-mock-webex": "3.0.0-beta.263",
|
|
39
|
+
"@webex/test-helper-retry": "3.0.0-beta.263",
|
|
40
|
+
"@webex/test-helper-test-users": "3.0.0-beta.263",
|
|
41
41
|
"chai": "^4.3.4",
|
|
42
42
|
"chai-as-promised": "^7.1.1",
|
|
43
43
|
"jsdom-global": "3.0.2",
|
|
@@ -46,19 +46,19 @@
|
|
|
46
46
|
"typescript": "^4.7.4"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@webex/common": "3.0.0-beta.
|
|
49
|
+
"@webex/common": "3.0.0-beta.263",
|
|
50
50
|
"@webex/internal-media-core": "2.0.4",
|
|
51
|
-
"@webex/internal-plugin-conversation": "3.0.0-beta.
|
|
52
|
-
"@webex/internal-plugin-device": "3.0.0-beta.
|
|
53
|
-
"@webex/internal-plugin-llm": "3.0.0-beta.
|
|
54
|
-
"@webex/internal-plugin-mercury": "3.0.0-beta.
|
|
55
|
-
"@webex/internal-plugin-metrics": "3.0.0-beta.
|
|
56
|
-
"@webex/internal-plugin-support": "3.0.0-beta.
|
|
57
|
-
"@webex/internal-plugin-user": "3.0.0-beta.
|
|
58
|
-
"@webex/media-helpers": "3.0.0-beta.
|
|
59
|
-
"@webex/plugin-people": "3.0.0-beta.
|
|
60
|
-
"@webex/plugin-rooms": "3.0.0-beta.
|
|
61
|
-
"@webex/webex-core": "3.0.0-beta.
|
|
51
|
+
"@webex/internal-plugin-conversation": "3.0.0-beta.263",
|
|
52
|
+
"@webex/internal-plugin-device": "3.0.0-beta.263",
|
|
53
|
+
"@webex/internal-plugin-llm": "3.0.0-beta.263",
|
|
54
|
+
"@webex/internal-plugin-mercury": "3.0.0-beta.263",
|
|
55
|
+
"@webex/internal-plugin-metrics": "3.0.0-beta.263",
|
|
56
|
+
"@webex/internal-plugin-support": "3.0.0-beta.263",
|
|
57
|
+
"@webex/internal-plugin-user": "3.0.0-beta.263",
|
|
58
|
+
"@webex/media-helpers": "3.0.0-beta.263",
|
|
59
|
+
"@webex/plugin-people": "3.0.0-beta.263",
|
|
60
|
+
"@webex/plugin-rooms": "3.0.0-beta.263",
|
|
61
|
+
"@webex/webex-core": "3.0.0-beta.263",
|
|
62
62
|
"ampersand-collection": "^2.0.2",
|
|
63
63
|
"bowser": "^2.11.0",
|
|
64
64
|
"btoa": "^1.2.1",
|
package/src/meeting/index.ts
CHANGED
|
@@ -5817,12 +5817,16 @@ export default class Meeting extends StatelessWebexPlugin {
|
|
|
5817
5817
|
return Promise.resolve();
|
|
5818
5818
|
})
|
|
5819
5819
|
.then(() => this.mediaProperties.getCurrentConnectionType())
|
|
5820
|
-
.then((connectionType) => {
|
|
5820
|
+
.then(async (connectionType) => {
|
|
5821
|
+
// @ts-ignore
|
|
5822
|
+
const reachabilityStats = await this.webex.meetings.reachability.getReachabilityMetrics();
|
|
5823
|
+
|
|
5821
5824
|
Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.ADD_MEDIA_SUCCESS, {
|
|
5822
5825
|
correlation_id: this.correlationId,
|
|
5823
5826
|
locus_id: this.locusUrl.split('/').pop(),
|
|
5824
5827
|
connectionType,
|
|
5825
5828
|
isMultistream: this.isMultistream,
|
|
5829
|
+
...reachabilityStats,
|
|
5826
5830
|
});
|
|
5827
5831
|
// @ts-ignore
|
|
5828
5832
|
this.webex.internal.newMetrics.submitClientEvent({
|
|
@@ -5838,9 +5842,12 @@ export default class Meeting extends StatelessWebexPlugin {
|
|
|
5838
5842
|
// We can log ReceiveSlot SSRCs only after the SDP exchange, so doing it here:
|
|
5839
5843
|
this.remoteMediaManager?.logAllReceiveSlots();
|
|
5840
5844
|
})
|
|
5841
|
-
.catch((error) => {
|
|
5845
|
+
.catch(async (error) => {
|
|
5842
5846
|
LoggerProxy.logger.error(`${LOG_HEADER} failed to establish media connection: `, error);
|
|
5843
5847
|
|
|
5848
|
+
// @ts-ignore
|
|
5849
|
+
const reachabilityMetrics = await this.webex.meetings.reachability.getReachabilityMetrics();
|
|
5850
|
+
|
|
5844
5851
|
Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.ADD_MEDIA_FAILURE, {
|
|
5845
5852
|
correlation_id: this.correlationId,
|
|
5846
5853
|
locus_id: this.locusUrl.split('/').pop(),
|
|
@@ -5865,38 +5872,37 @@ export default class Meeting extends StatelessWebexPlugin {
|
|
|
5865
5872
|
?.iceConnectionState ||
|
|
5866
5873
|
this.mediaProperties.webrtcMediaConnection?.mediaConnection?.pc?.iceConnectionState ||
|
|
5867
5874
|
'unknown',
|
|
5875
|
+
...reachabilityMetrics,
|
|
5868
5876
|
});
|
|
5869
5877
|
|
|
5870
5878
|
// Clean up stats analyzer, peer connection, and turn off listeners
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5879
|
+
if (this.statsAnalyzer) {
|
|
5880
|
+
await this.statsAnalyzer.stopAnalyzer();
|
|
5881
|
+
}
|
|
5874
5882
|
|
|
5875
|
-
|
|
5876
|
-
this.statsAnalyzer = null;
|
|
5883
|
+
this.statsAnalyzer = null;
|
|
5877
5884
|
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5885
|
+
if (this.mediaProperties.webrtcMediaConnection) {
|
|
5886
|
+
this.closePeerConnections();
|
|
5887
|
+
this.unsetPeerConnections();
|
|
5888
|
+
}
|
|
5882
5889
|
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5890
|
+
// Upload logs on error while adding media
|
|
5891
|
+
Trigger.trigger(
|
|
5892
|
+
this,
|
|
5893
|
+
{
|
|
5894
|
+
file: 'meeting/index',
|
|
5895
|
+
function: 'addMedia',
|
|
5896
|
+
},
|
|
5897
|
+
EVENTS.REQUEST_UPLOAD_LOGS,
|
|
5898
|
+
this
|
|
5899
|
+
);
|
|
5893
5900
|
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5901
|
+
if (error instanceof Errors.SdpError) {
|
|
5902
|
+
this.leave({reason: MEETING_REMOVED_REASON.MEETING_CONNECTION_FAILED});
|
|
5903
|
+
}
|
|
5897
5904
|
|
|
5898
|
-
|
|
5899
|
-
});
|
|
5905
|
+
throw error;
|
|
5900
5906
|
});
|
|
5901
5907
|
}
|
|
5902
5908
|
|