@webex/plugin-meetings 3.0.0-beta.47 → 3.0.0-beta.48
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/reachability/index.js +47 -10
- package/dist/reachability/index.js.map +1 -1
- package/dist/types/reachability/index.d.ts +15 -3
- package/package.json +18 -18
- package/src/reachability/index.ts +50 -11
- package/test/unit/spec/reachability/index.ts +114 -8
package/dist/breakouts/index.js
CHANGED
|
@@ -12,6 +12,7 @@ var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/obj
|
|
|
12
12
|
var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
|
|
13
13
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
|
|
14
14
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
15
|
+
var _assign = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/assign"));
|
|
15
16
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
16
17
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
17
18
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
@@ -23,7 +24,6 @@ var _constants = require("../constants");
|
|
|
23
24
|
var _request = _interopRequireDefault(require("./request"));
|
|
24
25
|
var DEFAULT_TIMEOUT = 3000;
|
|
25
26
|
var VIDEO_MESH_TIMEOUT = 1000;
|
|
26
|
-
|
|
27
27
|
/**
|
|
28
28
|
* @class Reachability
|
|
29
29
|
* @export
|
|
@@ -343,6 +343,8 @@ var Reachability = /*#__PURE__*/function () {
|
|
|
343
343
|
var elapsed = _this3.getElapsedTime(peerConnection);
|
|
344
344
|
_loggerProxy.default.logger.log( // @ts-ignore
|
|
345
345
|
"Reachability:index#onIceCandidate --> Successfully pinged ".concat(peerConnection.key, ":"), elapsed);
|
|
346
|
+
// order is important
|
|
347
|
+
_this3.addPublicIP(peerConnection, e.candidate.address);
|
|
346
348
|
_this3.setLatencyAndClose(peerConnection, elapsed);
|
|
347
349
|
}
|
|
348
350
|
};
|
|
@@ -364,6 +366,7 @@ var Reachability = /*#__PURE__*/function () {
|
|
|
364
366
|
var ELAPSED = 'elapsed';
|
|
365
367
|
return new _promise.default(function (resolve) {
|
|
366
368
|
var peerConnectionProxy = new window.Proxy(peerConnection, {
|
|
369
|
+
// eslint-disable-next-line require-jsdoc
|
|
367
370
|
get: function get(target, property) {
|
|
368
371
|
var targetMember = target[property];
|
|
369
372
|
if (typeof targetMember === 'function') {
|
|
@@ -377,6 +380,7 @@ var Reachability = /*#__PURE__*/function () {
|
|
|
377
380
|
// @ts-ignore
|
|
378
381
|
resolve({
|
|
379
382
|
clusterId: peerConnection.key,
|
|
383
|
+
publicIPs: target.publicIPs,
|
|
380
384
|
elapsed: value
|
|
381
385
|
});
|
|
382
386
|
return true;
|
|
@@ -398,6 +402,8 @@ var Reachability = /*#__PURE__*/function () {
|
|
|
398
402
|
|
|
399
403
|
// Close any open peerConnections
|
|
400
404
|
if (peerConnectionProxy.connectionState !== CLOSED) {
|
|
405
|
+
// order is important
|
|
406
|
+
_this4.addPublicIP(peerConnectionProxy, null);
|
|
401
407
|
_this4.setLatencyAndClose(peerConnectionProxy, null);
|
|
402
408
|
}
|
|
403
409
|
}, timeout);
|
|
@@ -421,9 +427,9 @@ var Reachability = /*#__PURE__*/function () {
|
|
|
421
427
|
|
|
422
428
|
/**
|
|
423
429
|
* Calculates time to establish connection
|
|
424
|
-
* @param {
|
|
430
|
+
* @param {Array<ICECandidateResult>} iceResults iceResults
|
|
425
431
|
* @returns {object} reachabilityMap
|
|
426
|
-
* @
|
|
432
|
+
* @protected
|
|
427
433
|
* @memberof Reachability
|
|
428
434
|
*/
|
|
429
435
|
}, {
|
|
@@ -432,17 +438,23 @@ var Reachability = /*#__PURE__*/function () {
|
|
|
432
438
|
var reachabilityMap = {};
|
|
433
439
|
iceResults.forEach(function (_ref2) {
|
|
434
440
|
var clusterId = _ref2.clusterId,
|
|
435
|
-
elapsed = _ref2.elapsed
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
441
|
+
elapsed = _ref2.elapsed,
|
|
442
|
+
publicIPs = _ref2.publicIPs;
|
|
443
|
+
var latencyResult = {};
|
|
444
|
+
if (!elapsed) {
|
|
445
|
+
(0, _assign.default)(latencyResult, {
|
|
439
446
|
reachable: 'false'
|
|
440
|
-
};
|
|
447
|
+
});
|
|
441
448
|
} else {
|
|
442
|
-
latencyResult
|
|
449
|
+
(0, _assign.default)(latencyResult, {
|
|
443
450
|
reachable: 'true',
|
|
444
451
|
latencyInMilliseconds: elapsed.toString()
|
|
445
|
-
};
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
if (publicIPs) {
|
|
455
|
+
(0, _assign.default)(latencyResult, {
|
|
456
|
+
clientMediaIPs: publicIPs
|
|
457
|
+
});
|
|
446
458
|
}
|
|
447
459
|
reachabilityMap[clusterId] = {
|
|
448
460
|
udp: latencyResult,
|
|
@@ -482,6 +494,31 @@ var Reachability = /*#__PURE__*/function () {
|
|
|
482
494
|
});
|
|
483
495
|
}
|
|
484
496
|
|
|
497
|
+
/**
|
|
498
|
+
* Adds public IP (client media IPs)
|
|
499
|
+
* @param {RTCPeerConnection} peerConnection
|
|
500
|
+
* @param {string} publicIP
|
|
501
|
+
* @returns {void}
|
|
502
|
+
*/
|
|
503
|
+
}, {
|
|
504
|
+
key: "addPublicIP",
|
|
505
|
+
value: function addPublicIP(peerConnection, publicIP) {
|
|
506
|
+
var modifiedPeerConnection = peerConnection;
|
|
507
|
+
var CLOSED = _constants.CONNECTION_STATE.CLOSED;
|
|
508
|
+
if (modifiedPeerConnection.connectionState === CLOSED) {
|
|
509
|
+
_loggerProxy.default.logger.log("Reachability:index#addPublicIP --> Attempting to set publicIP of ".concat(publicIP, " on closed peerConnection."));
|
|
510
|
+
}
|
|
511
|
+
if (publicIP) {
|
|
512
|
+
if (modifiedPeerConnection.publicIPs) {
|
|
513
|
+
modifiedPeerConnection.publicIPs.push(publicIP);
|
|
514
|
+
} else {
|
|
515
|
+
modifiedPeerConnection.publicIPs = [publicIP];
|
|
516
|
+
}
|
|
517
|
+
} else {
|
|
518
|
+
modifiedPeerConnection.publicIPs = null;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
485
522
|
/**
|
|
486
523
|
* Records latency and closes the peerConnection
|
|
487
524
|
* @param {RTCPeerConnection} peerConnection
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_TIMEOUT","VIDEO_MESH_TIMEOUT","Reachability","webex","REACHABILITY","namespace","reachabilityRequest","ReachabilityRequest","clusterLatencyResults","setup","boundedStorage","del","localStorageResult","localStorageJoinCookie","getClusters","clusters","joinCookie","performReachabilityCheck","results","put","LoggerProxy","logger","log","error","reachable","get","catch","reachabilityData","reachabilityResults","JSON","parse","some","result","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","isVideoMesh","iceGatheringStateError","all","then","parseIceResultsToReachabilityResults","reachabilityLatencyResults","logUnreachableClusters","unreachableList","forEach","unreachable","push","onicegatheringstatechange","COMPLETE","ICE_GATHERING_STATE","iceConnectionState","elapsed","getElapsedTime","setLatencyAndClose","onicecandidate","SERVER_REFLEXIVE","candidate","String","type","toLowerCase","timeout","ELAPSED","resolve","peerConnectionProxy","Proxy","target","property","targetMember","bind","set","value","clusterId","Reflect","handleIceGatheringStateChange","handleOnIceCandidate","setTimeout","CLOSED","CONNECTION_STATE","connectionState","list","getUnreachablClusters","iceResults","reachabilityMap","latencyResult","latencyInMilliseconds","toString","length","getLocalSDPForClusters","localSDPData","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 _ from 'lodash';\n\nimport LoggerProxy from '../common/logs/logger-proxy';\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/**\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() {\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\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 * fetches reachability data and checks for cluster reachability\n * @returns {boolean}\n * @public\n * @memberof Reachability\n */\n async isAnyClusterReachable() {\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 = JSON.parse(reachabilityData);\n\n reachable = Object.values(reachabilityResults).some(\n (result: any) => 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, ...cluster.tcp]).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) {\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(\n peerConnection,\n cluster.isVideoMesh ? VIDEO_MESH_TIMEOUT : DEFAULT_TIMEOUT\n ).catch((iceGatheringStateError) => {\n LoggerProxy.logger.log(\n `Reachability:index#getLocalSDPForClusters --> Error in getLocalSDP : ${iceGatheringStateError}`\n );\n });\n });\n\n return Promise.all(clusters)\n .then(this.parseIceResultsToReachabilityResults)\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 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 {number} timeout\n * @returns {Promise}\n */\n private iceGatheringState(peerConnection: RTCPeerConnection, timeout: number) {\n const ELAPSED = 'elapsed';\n\n return new Promise((resolve) => {\n const peerConnectionProxy = new window.Proxy(peerConnection, {\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 // @ts-ignore\n resolve({clusterId: peerConnection.key, elapsed: value});\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 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} iceResults iceResults\n * @returns {object} reachabilityMap\n * @private\n * @memberof Reachability\n */\n private parseIceResultsToReachabilityResults(iceResults: Array<any>) {\n const reachabilityMap = {};\n\n iceResults.forEach(({clusterId, elapsed}) => {\n let latencyResult;\n\n if (elapsed === null) {\n latencyResult = {reachable: 'false'};\n } else {\n latencyResult = {\n reachable: 'true',\n latencyInMilliseconds: elapsed.toString(),\n };\n }\n\n reachabilityMap[clusterId] = {\n udp: latencyResult,\n tcp: latencyResult,\n };\n });\n\n return reachabilityMap;\n }\n\n /**\n * fetches reachability data\n * @param {object} clusterList\n * @returns {Promise<localSDPData>} reachability check results\n * @private\n * @memberof Reachability\n */\n private performReachabilityCheck(clusterList: object) {\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 * 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,IAAMA,eAAe,GAAG,IAAI;AAC5B,IAAMC,kBAAkB,GAAG,IAAI;;AAE/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;;cAE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C,SAAS,GAAG,WAAW;MAC7B,IAAMC,WAAW,GAAG,aAAa;MACjC,IAAOd,MAAM,GAAIC,2BAAgB,CAA1BD,MAAM;MACb;MACA,IAAOxD,GAAG,GAAIE,cAAc,CAArBF,GAAG;MACV,IAAMuE,SAAS,GAAGxC,OAAO,KAAK,IAAI,GAAGuC,WAAW,GAAGD,SAAS;MAC5D,IAAMG,WAAW,mEAAKH,SAAS,EAAG,CAAC,+CAAGC,WAAW,EAAG,CAAC,gBAAC;MAEtD,IAAIpE,cAAc,CAACwD,eAAe,KAAKF,MAAM,EAAE;QAC7CjF,oBAAW,CAACC,MAAM,CAACC,GAAG,kFACsDsD,OAAO,gCAClF;QAED;MACF;MAEA,IAAI,CAACpE,qBAAqB,CAACqC,GAAG,CAAC,GAAG,IAAI,CAACrC,qBAAqB,CAACqC,GAAG,CAAC,IAAIwE,WAAW;MAChF,IAAI,CAAC7G,qBAAqB,CAACqC,GAAG,CAAC,CAACuE,SAAS,CAAC,IAAI,CAAC;;MAE/C;MACA;MACArE,cAAc,CAACgC,cAAc,GAAG,IAAI;MACpChC,cAAc,CAACuE,KAAK,EAAE;MACtB;MACAvE,cAAc,CAAC6B,OAAO,GAAGA,OAAO;IAClC;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,iBAAgB;MACd,IAAI,CAACpE,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","clusters","joinCookie","performReachabilityCheck","results","put","LoggerProxy","logger","log","error","reachable","get","catch","reachabilityData","reachabilityResults","JSON","parse","some","result","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","isVideoMesh","iceGatheringStateError","all","then","parseIceResultsToReachabilityResults","reachabilityLatencyResults","logUnreachableClusters","unreachableList","forEach","unreachable","push","onicegatheringstatechange","COMPLETE","ICE_GATHERING_STATE","iceConnectionState","elapsed","getElapsedTime","setLatencyAndClose","onicecandidate","SERVER_REFLEXIVE","candidate","String","type","toLowerCase","addPublicIP","address","timeout","ELAPSED","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","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 _ from 'lodash';\n\nimport LoggerProxy from '../common/logs/logger-proxy';\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 ICECandidateResult = {clusterId: string; elapsed?: string | null; publicIPs?: string[]};\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() {\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\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 * fetches reachability data and checks for cluster reachability\n * @returns {boolean}\n * @public\n * @memberof Reachability\n */\n async isAnyClusterReachable() {\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 = JSON.parse(reachabilityData);\n\n reachable = Object.values(reachabilityResults).some(\n (result: any) => 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, ...cluster.tcp]).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) {\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(\n peerConnection,\n cluster.isVideoMesh ? VIDEO_MESH_TIMEOUT : DEFAULT_TIMEOUT\n ).catch((iceGatheringStateError) => {\n LoggerProxy.logger.log(\n `Reachability:index#getLocalSDPForClusters --> Error in getLocalSDP : ${iceGatheringStateError}`\n );\n });\n });\n\n return Promise.all(clusters)\n .then(this.parseIceResultsToReachabilityResults)\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 {number} timeout\n * @returns {Promise}\n */\n private iceGatheringState(peerConnection: RTCPeerConnection, timeout: number) {\n const ELAPSED = 'elapsed';\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 // @ts-ignore\n resolve({clusterId: peerConnection.key, publicIPs: target.publicIPs, elapsed: value});\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 parseIceResultsToReachabilityResults(iceResults: Array<ICECandidateResult>) {\n const reachabilityMap = {};\n\n iceResults.forEach(({clusterId, 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: latencyResult,\n };\n });\n\n return reachabilityMap;\n }\n\n /**\n * fetches reachability data\n * @param {object} clusterList\n * @returns {Promise<localSDPData>} reachability check results\n * @private\n * @memberof Reachability\n */\n private performReachabilityCheck(clusterList: object) {\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,IAAMA,eAAe,GAAG,IAAI;AAC5B,IAAMC,kBAAkB,GAAG,IAAI;AAG/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;c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AAKH,SAAS,EAAG,CAAC,+CAAGC,WAAW,EAAG,CAAC,gBAAC;MAEtD,IAAI1E,cAAc,CAAC2D,eAAe,KAAKF,MAAM,EAAE;QAC7CpF,oBAAW,CAACC,MAAM,CAACC,GAAG,kFACsDsD,OAAO,gCAClF;QAED;MACF;MAEA,IAAI,CAACpE,qBAAqB,CAACqC,GAAG,CAAC,GAAG,IAAI,CAACrC,qBAAqB,CAACqC,GAAG,CAAC,IAAI8E,WAAW;MAChF,IAAI,CAACnH,qBAAqB,CAACqC,GAAG,CAAC,CAAC6E,SAAS,CAAC,IAAI,CAAC;;MAE/C;MACA;MACA3E,cAAc,CAACgC,cAAc,GAAG,IAAI;MACpChC,cAAc,CAAC6E,KAAK,EAAE;MACtB;MACA7E,cAAc,CAAC6B,OAAO,GAAGA,OAAO;IAClC;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,iBAAgB;MACd,IAAI,CAACpE,qBAAqB,GAAG,CAAC,CAAC;IACjC;EAAC;EAAA;AAAA;AAAA"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
3
|
*/
|
|
4
|
+
export type ICECandidateResult = {
|
|
5
|
+
clusterId: string;
|
|
6
|
+
elapsed?: string | null;
|
|
7
|
+
publicIPs?: string[];
|
|
8
|
+
};
|
|
4
9
|
/**
|
|
5
10
|
* @class Reachability
|
|
6
11
|
* @export
|
|
@@ -107,12 +112,12 @@ export default class Reachability {
|
|
|
107
112
|
private logUnreachableClusters;
|
|
108
113
|
/**
|
|
109
114
|
* Calculates time to establish connection
|
|
110
|
-
* @param {
|
|
115
|
+
* @param {Array<ICECandidateResult>} iceResults iceResults
|
|
111
116
|
* @returns {object} reachabilityMap
|
|
112
|
-
* @
|
|
117
|
+
* @protected
|
|
113
118
|
* @memberof Reachability
|
|
114
119
|
*/
|
|
115
|
-
|
|
120
|
+
protected parseIceResultsToReachabilityResults(iceResults: Array<ICECandidateResult>): {};
|
|
116
121
|
/**
|
|
117
122
|
* fetches reachability data
|
|
118
123
|
* @param {object} clusterList
|
|
@@ -121,6 +126,13 @@ export default class Reachability {
|
|
|
121
126
|
* @memberof Reachability
|
|
122
127
|
*/
|
|
123
128
|
private performReachabilityCheck;
|
|
129
|
+
/**
|
|
130
|
+
* Adds public IP (client media IPs)
|
|
131
|
+
* @param {RTCPeerConnection} peerConnection
|
|
132
|
+
* @param {string} publicIP
|
|
133
|
+
* @returns {void}
|
|
134
|
+
*/
|
|
135
|
+
protected addPublicIP(peerConnection: RTCPeerConnection, publicIP?: string | null): void;
|
|
124
136
|
/**
|
|
125
137
|
* Records latency and closes the peerConnection
|
|
126
138
|
* @param {RTCPeerConnection} peerConnection
|
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.48",
|
|
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.48",
|
|
36
|
+
"@webex/test-helper-chai": "3.0.0-beta.48",
|
|
37
|
+
"@webex/test-helper-mocha": "3.0.0-beta.48",
|
|
38
|
+
"@webex/test-helper-mock-webex": "3.0.0-beta.48",
|
|
39
|
+
"@webex/test-helper-retry": "3.0.0-beta.48",
|
|
40
|
+
"@webex/test-helper-test-users": "3.0.0-beta.48",
|
|
41
41
|
"chai": "^4.3.4",
|
|
42
42
|
"chai-as-promised": "^7.1.1",
|
|
43
43
|
"jsdom-global": "3.0.2",
|
|
@@ -46,18 +46,18 @@
|
|
|
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.48",
|
|
50
50
|
"@webex/internal-media-core": "1.35.2",
|
|
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/plugin-people": "3.0.0-beta.
|
|
59
|
-
"@webex/plugin-rooms": "3.0.0-beta.
|
|
60
|
-
"@webex/webex-core": "3.0.0-beta.
|
|
51
|
+
"@webex/internal-plugin-conversation": "3.0.0-beta.48",
|
|
52
|
+
"@webex/internal-plugin-device": "3.0.0-beta.48",
|
|
53
|
+
"@webex/internal-plugin-llm": "3.0.0-beta.48",
|
|
54
|
+
"@webex/internal-plugin-mercury": "3.0.0-beta.48",
|
|
55
|
+
"@webex/internal-plugin-metrics": "3.0.0-beta.48",
|
|
56
|
+
"@webex/internal-plugin-support": "3.0.0-beta.48",
|
|
57
|
+
"@webex/internal-plugin-user": "3.0.0-beta.48",
|
|
58
|
+
"@webex/plugin-people": "3.0.0-beta.48",
|
|
59
|
+
"@webex/plugin-rooms": "3.0.0-beta.48",
|
|
60
|
+
"@webex/webex-core": "3.0.0-beta.48",
|
|
61
61
|
"ampersand-collection": "^2.0.2",
|
|
62
62
|
"bowser": "^2.11.0",
|
|
63
63
|
"btoa": "^1.2.1",
|
|
@@ -14,6 +14,7 @@ import ReachabilityRequest from './request';
|
|
|
14
14
|
const DEFAULT_TIMEOUT = 3000;
|
|
15
15
|
const VIDEO_MESH_TIMEOUT = 1000;
|
|
16
16
|
|
|
17
|
+
export type ICECandidateResult = {clusterId: string; elapsed?: string | null; publicIPs?: string[]};
|
|
17
18
|
/**
|
|
18
19
|
* @class Reachability
|
|
19
20
|
* @export
|
|
@@ -300,6 +301,8 @@ export default class Reachability {
|
|
|
300
301
|
`Reachability:index#onIceCandidate --> Successfully pinged ${peerConnection.key}:`,
|
|
301
302
|
elapsed
|
|
302
303
|
);
|
|
304
|
+
// order is important
|
|
305
|
+
this.addPublicIP(peerConnection, e.candidate.address);
|
|
303
306
|
this.setLatencyAndClose(peerConnection, elapsed);
|
|
304
307
|
}
|
|
305
308
|
};
|
|
@@ -317,8 +320,9 @@ export default class Reachability {
|
|
|
317
320
|
private iceGatheringState(peerConnection: RTCPeerConnection, timeout: number) {
|
|
318
321
|
const ELAPSED = 'elapsed';
|
|
319
322
|
|
|
320
|
-
return new Promise((resolve) => {
|
|
323
|
+
return new Promise<ICECandidateResult>((resolve) => {
|
|
321
324
|
const peerConnectionProxy = new window.Proxy(peerConnection, {
|
|
325
|
+
// eslint-disable-next-line require-jsdoc
|
|
322
326
|
get(target, property) {
|
|
323
327
|
const targetMember = target[property];
|
|
324
328
|
|
|
@@ -332,7 +336,7 @@ export default class Reachability {
|
|
|
332
336
|
// only intercept elapsed property
|
|
333
337
|
if (property === ELAPSED) {
|
|
334
338
|
// @ts-ignore
|
|
335
|
-
resolve({clusterId: peerConnection.key, elapsed: value});
|
|
339
|
+
resolve({clusterId: peerConnection.key, publicIPs: target.publicIPs, elapsed: value});
|
|
336
340
|
|
|
337
341
|
return true;
|
|
338
342
|
}
|
|
@@ -353,6 +357,8 @@ export default class Reachability {
|
|
|
353
357
|
|
|
354
358
|
// Close any open peerConnections
|
|
355
359
|
if (peerConnectionProxy.connectionState !== CLOSED) {
|
|
360
|
+
// order is important
|
|
361
|
+
this.addPublicIP(peerConnectionProxy, null);
|
|
356
362
|
this.setLatencyAndClose(peerConnectionProxy, null);
|
|
357
363
|
}
|
|
358
364
|
}, timeout);
|
|
@@ -377,24 +383,30 @@ export default class Reachability {
|
|
|
377
383
|
|
|
378
384
|
/**
|
|
379
385
|
* Calculates time to establish connection
|
|
380
|
-
* @param {
|
|
386
|
+
* @param {Array<ICECandidateResult>} iceResults iceResults
|
|
381
387
|
* @returns {object} reachabilityMap
|
|
382
|
-
* @
|
|
388
|
+
* @protected
|
|
383
389
|
* @memberof Reachability
|
|
384
390
|
*/
|
|
385
|
-
|
|
391
|
+
protected parseIceResultsToReachabilityResults(iceResults: Array<ICECandidateResult>) {
|
|
386
392
|
const reachabilityMap = {};
|
|
387
393
|
|
|
388
|
-
iceResults.forEach(({clusterId, elapsed}) => {
|
|
389
|
-
|
|
394
|
+
iceResults.forEach(({clusterId, elapsed, publicIPs}) => {
|
|
395
|
+
const latencyResult = {};
|
|
390
396
|
|
|
391
|
-
if (elapsed
|
|
392
|
-
latencyResult
|
|
397
|
+
if (!elapsed) {
|
|
398
|
+
Object.assign(latencyResult, {reachable: 'false'});
|
|
393
399
|
} else {
|
|
394
|
-
latencyResult
|
|
400
|
+
Object.assign(latencyResult, {
|
|
395
401
|
reachable: 'true',
|
|
396
402
|
latencyInMilliseconds: elapsed.toString(),
|
|
397
|
-
};
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if (publicIPs) {
|
|
407
|
+
Object.assign(latencyResult, {
|
|
408
|
+
clientMediaIPs: publicIPs,
|
|
409
|
+
});
|
|
398
410
|
}
|
|
399
411
|
|
|
400
412
|
reachabilityMap[clusterId] = {
|
|
@@ -440,6 +452,33 @@ export default class Reachability {
|
|
|
440
452
|
});
|
|
441
453
|
}
|
|
442
454
|
|
|
455
|
+
/**
|
|
456
|
+
* Adds public IP (client media IPs)
|
|
457
|
+
* @param {RTCPeerConnection} peerConnection
|
|
458
|
+
* @param {string} publicIP
|
|
459
|
+
* @returns {void}
|
|
460
|
+
*/
|
|
461
|
+
protected addPublicIP(peerConnection: RTCPeerConnection, publicIP?: string | null) {
|
|
462
|
+
const modifiedPeerConnection: RTCPeerConnection & {publicIPs?: string[]} = peerConnection;
|
|
463
|
+
const {CLOSED} = CONNECTION_STATE;
|
|
464
|
+
|
|
465
|
+
if (modifiedPeerConnection.connectionState === CLOSED) {
|
|
466
|
+
LoggerProxy.logger.log(
|
|
467
|
+
`Reachability:index#addPublicIP --> Attempting to set publicIP of ${publicIP} on closed peerConnection.`
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (publicIP) {
|
|
472
|
+
if (modifiedPeerConnection.publicIPs) {
|
|
473
|
+
modifiedPeerConnection.publicIPs.push(publicIP);
|
|
474
|
+
} else {
|
|
475
|
+
modifiedPeerConnection.publicIPs = [publicIP];
|
|
476
|
+
}
|
|
477
|
+
} else {
|
|
478
|
+
modifiedPeerConnection.publicIPs = null;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
443
482
|
/**
|
|
444
483
|
* Records latency and closes the peerConnection
|
|
445
484
|
* @param {RTCPeerConnection} peerConnection
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {assert} from '@webex/test-helper-chai';
|
|
2
2
|
import MockWebex from '@webex/test-helper-mock-webex';
|
|
3
3
|
import sinon from 'sinon';
|
|
4
|
-
import Reachability from '@webex/plugin-meetings/src/reachability/';
|
|
4
|
+
import Reachability, {ICECandidateResult} from '@webex/plugin-meetings/src/reachability/';
|
|
5
5
|
|
|
6
6
|
describe('isAnyClusterReachable', () => {
|
|
7
7
|
let webex;
|
|
@@ -22,8 +22,8 @@ describe('isAnyClusterReachable', () => {
|
|
|
22
22
|
|
|
23
23
|
const result = await reachability.isAnyClusterReachable();
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
assert.equal(result, expectedValue);
|
|
26
|
+
};
|
|
27
27
|
|
|
28
28
|
it('returns true when udp is reachable', async () => {
|
|
29
29
|
await checkIsClusterReachable({x: {udp: {reachable: 'true'}, tcp: {reachable: 'false'}}}, true);
|
|
@@ -72,24 +72,130 @@ describe('gatherReachability', () => {
|
|
|
72
72
|
udp: 'testUDP',
|
|
73
73
|
},
|
|
74
74
|
},
|
|
75
|
-
}
|
|
75
|
+
};
|
|
76
76
|
const getClustersResult = {
|
|
77
77
|
clusters: {clusterId: 'cluster'},
|
|
78
|
-
joinCookie: {id: 'id'}
|
|
78
|
+
joinCookie: {id: 'id'},
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
reachability.reachabilityRequest.getClusters = sinon.stub().returns(getClustersResult);
|
|
82
|
-
(reachability as any).performReachabilityCheck = sinon.stub().returns(reachabilityResults)
|
|
82
|
+
(reachability as any).performReachabilityCheck = sinon.stub().returns(reachabilityResults);
|
|
83
83
|
|
|
84
84
|
const result = await reachability.gatherReachability();
|
|
85
85
|
|
|
86
86
|
assert.equal(result, reachabilityResults);
|
|
87
87
|
|
|
88
|
-
const storedResultForReachabilityResult = await webex.boundedStorage.get(
|
|
89
|
-
|
|
88
|
+
const storedResultForReachabilityResult = await webex.boundedStorage.get(
|
|
89
|
+
'Reachability',
|
|
90
|
+
'reachability.result'
|
|
91
|
+
);
|
|
92
|
+
const storedResultForJoinCookie = await webex.boundedStorage.get(
|
|
93
|
+
'Reachability',
|
|
94
|
+
'reachability.joinCookie'
|
|
95
|
+
);
|
|
90
96
|
|
|
91
97
|
assert.equal(JSON.stringify(result), storedResultForReachabilityResult);
|
|
92
98
|
assert.equal(JSON.stringify(getClustersResult.joinCookie), storedResultForJoinCookie);
|
|
93
99
|
});
|
|
94
100
|
|
|
101
|
+
describe('clientMediaIPs', () => {
|
|
102
|
+
let testingClass: TestReachability;
|
|
103
|
+
|
|
104
|
+
class TestReachability extends Reachability {
|
|
105
|
+
public testParseIceResultsToReachabilityResults(iceResults: Array<ICECandidateResult>) {
|
|
106
|
+
return this.parseIceResultsToReachabilityResults(iceResults);
|
|
107
|
+
}
|
|
108
|
+
public testAddPublicIP(peerConnection: RTCPeerConnection, publicIP?: string | null) {
|
|
109
|
+
return this.addPublicIP(peerConnection, publicIP);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
beforeEach(() => {
|
|
113
|
+
testingClass = new TestReachability({webex});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('calls parseIceResultsToReachabilityResults correctly', () => {
|
|
117
|
+
const res = testingClass.testParseIceResultsToReachabilityResults([
|
|
118
|
+
{
|
|
119
|
+
clusterId: 'id1',
|
|
120
|
+
elapsed: '12312',
|
|
121
|
+
publicIPs: ['1.1.1.1'],
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
clusterId: 'id2',
|
|
125
|
+
elapsed: null,
|
|
126
|
+
publicIPs: ['1.1.1.1'],
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
clusterId: 'id2',
|
|
130
|
+
elapsed: '14123',
|
|
131
|
+
publicIPs: undefined,
|
|
132
|
+
},
|
|
133
|
+
]);
|
|
134
|
+
|
|
135
|
+
assert.deepEqual(res, {
|
|
136
|
+
id1: {
|
|
137
|
+
tcp: {
|
|
138
|
+
clientMediaIPs: ['1.1.1.1'],
|
|
139
|
+
latencyInMilliseconds: '12312',
|
|
140
|
+
reachable: 'true',
|
|
141
|
+
},
|
|
142
|
+
udp: {
|
|
143
|
+
clientMediaIPs: ['1.1.1.1'],
|
|
144
|
+
latencyInMilliseconds: '12312',
|
|
145
|
+
reachable: 'true',
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
id2: {
|
|
149
|
+
tcp: {
|
|
150
|
+
latencyInMilliseconds: '14123',
|
|
151
|
+
reachable: 'true',
|
|
152
|
+
},
|
|
153
|
+
udp: {
|
|
154
|
+
latencyInMilliseconds: '14123',
|
|
155
|
+
reachable: 'true',
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('calls addPublicIP correctly with no existing public APIs', () => {
|
|
162
|
+
const peerConnection = {
|
|
163
|
+
connectionState: 'not_closed',
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
testingClass.testAddPublicIP(peerConnection as RTCPeerConnection, '1.1.1.1');
|
|
167
|
+
|
|
168
|
+
assert.deepEqual(peerConnection, {
|
|
169
|
+
connectionState: 'not_closed',
|
|
170
|
+
publicIPs: ['1.1.1.1'],
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('calls addPublicIP correctly with existing public APIs', () => {
|
|
175
|
+
const peerConnection = {
|
|
176
|
+
connectionState: 'not_closed',
|
|
177
|
+
publicIPs: ['2.2.2.2'],
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
testingClass.testAddPublicIP(peerConnection as any, '1.1.1.1');
|
|
181
|
+
|
|
182
|
+
assert.deepEqual(peerConnection, {
|
|
183
|
+
connectionState: 'not_closed',
|
|
184
|
+
publicIPs: ['2.2.2.2', '1.1.1.1'],
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('calls addPublicIP correctly null publicAPI', () => {
|
|
189
|
+
const peerConnection = {
|
|
190
|
+
connectionState: 'not_closed',
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
testingClass.testAddPublicIP(peerConnection as RTCPeerConnection, null);
|
|
194
|
+
|
|
195
|
+
assert.deepEqual(peerConnection, {
|
|
196
|
+
connectionState: 'not_closed',
|
|
197
|
+
publicIPs: null,
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
});
|
|
95
201
|
});
|