thali
Version:
239 lines (197 loc) • 12 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: NextGeneration/thaliPeerDictionary.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: NextGeneration/thaliPeerDictionary.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>'use strict';
/** @module thaliPeerDictionary */
/**
* @file
*
* Defines a dictionary for use by {@link module:thaliNotificationClient} that
* makes sure we only track a fixed number of peers and will forget peers in
* a defined order if we get too many of them.
*/
/**
* Enum to record the state of trying to get the notification beacons for the
* associated peerIdentifier
*
* @public
* @readonly
* @enum {string}
*/
module.exports.peerState = {
/** The notification beacons for this peerID have been successfully
* retrieved.
*/
RESOLVED: 'resolved',
/** The notification action is under the control of the peer pool so we have
* to check the notification action to find out its current state.
*/
CONTROLLED_BY_POOL: 'controlledByPool',
/** A request to get the notification beacons for this peer failed and we
* are now waiting before enqueuing a new request.
*/
WAITING: 'waiting'
};
/**
* Records information about how to connect to a peer over a particular
* connectionType.
*
* @public
* @constructor
* @param {string} hostAddress
* @param {number} portNumber
* @param {number} suggestedTCPTimeout
*/
function PeerConnectionInformation (hostAddress, portNumber,
suggestedTCPTimeout) {
this.hostAddress = hostAddress;
this.portNumber = portNumber;
this.suggestedTCPTimeout = suggestedTCPTimeout;
}
/**
* Peer's host address, either IP or DNS
*
* @private
* @type {string}
*/
PeerConnectionInformation.prototype.hostAddress = null;
PeerConnectionInformation.prototype.getHostAddress = function() {
return this.hostAddress;
};
/**
* The port to use with the supplied host address
*
* @private
* @type {number}
*/
PeerConnectionInformation.prototype.portNumber = null;
PeerConnectionInformation.prototype.getPortNumber = function() {
return this.portNumber;
};
/**
* The TCP time out to use when establishing a TCP connection with the peer.
*
* @private
* @type {number}
*/
PeerConnectionInformation.prototype.suggestedTCPTimeout = null;
PeerConnectionInformation.prototype.getSuggestedTCPTimeout = function() {
return this.suggestedTCPTimeout;
};
module.exports.PeerConnectionInformation = PeerConnectionInformation;
// jscs:disable maximumLineLength
/**
* A dictionary of different connectionTypes and their associated connection
* information.
*
* @typedef {Object.<module:thaliMobile.connectionTypes, module:thaliPeerDictionary~PeerConnectionInformation>} PeerConnectionDictionary
*/
// jscs:enable maximumLineLength
/**
* An entry to be put into the peerDictionary.
*
* @public
* @param {module:thaliPeerDictionary.peerState} peerState The
* state of the peer.
* @param {module:thaliPeerDictionary~PeerConnectionDictionary} peerConnectionDictionary A dictionary
* of different connection types we know about for this peerIdentity
* @param {module:thaliNotificationAction~NotificationAction} notificationAction
* @constructor
*/
function NotificationPeerDictionaryEntry (peerState, peerConnectionDictionary,
notificationAction) {
this.peerState = peerState;
this.peerConnectionDictionary = peerConnectionDictionary;
this.notificationAction = notificationAction;
}
/**
* The current state of the peer
*
* @private
* @type {module:thaliPeerDictionary.peerState}
*/
NotificationPeerDictionaryEntry.prototype.peerState = null;
/**
* The current peer connection dictionary
*
* @private
* @type {module:thaliPeerDictionary~PeerConnectionDictionary}
*/
NotificationPeerDictionaryEntry.prototype.peerConnectionDictionary = null;
/**
* The notification action (if any) associated with the peer.
*
* @type {?module:thaliNotificationAction~NotificationAction}
*/
NotificationPeerDictionaryEntry.prototype.notificationAction = null;
module.exports.NotificationPeerDictionaryEntry =
NotificationPeerDictionaryEntry;
/**
* A dictionary used to manage information discovered about peers. It's only
* difference from a typical dictionary is that we have to manage how many
* entries are in the dictionary so that we don't overflow memory. Therefore
* once we reach a certain number of entries any new entries will require old
* entries to be removed.
* @public
* @constructor
*/
function PeerDictionary() {
}
/**
* Adds the entry if the peerId isn't yet in the table otherwise updates the
* existing entry. If the new entry will increase the size of the dictionary
* beyond the fixed maximum then the oldest resolved entry MUST be removed.
* If there are no remaining resolved entries to remove then the oldest
* waiting entry MUST be removed (and the associated timer killed). If there
* are no remaining resolved entries to remove then kill MUST be called on the
* oldest CONTROLLED_BY_POOL entry and it MUST be removed.
*
* @public
* @param {string} peerId
* @param {module:thaliPeerDictionary~NotificationPeerDictionaryEntry} peerTableEntry
* @returns {?error} Null if all went well otherwise an error.
*/
PeerDictionary.prototype.addUpdateEntry =
function (peerId, peerTableEntry) {
return null;
};
/**
* Removes the identified entry. It is not an error to specify a peerId that
* is not in the dictionary.
* @public
* @param {string} peerId
*/
PeerDictionary.prototype.removeEntry =
function(peerId) {
};
module.exports.PeerDictionary = PeerDictionary;
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-TCPServersManager.html">TCPServersManager</a></li><li><a href="module-thaliMobile.html">thaliMobile</a></li><li><a href="module-thaliMobileNative.html">thaliMobileNative</a></li><li><a href="module-thaliMobileNativeWrapper.html">thaliMobileNativeWrapper</a></li><li><a href="module-thaliNotificationAction.html">thaliNotificationAction</a></li><li><a href="module-thaliNotificationBeacons.html">thaliNotificationBeacons</a></li><li><a href="module-thaliNotificationClient.html">thaliNotificationClient</a></li><li><a href="module-thaliNotificationServer.html">thaliNotificationServer</a></li><li><a href="module-thaliPeerAction.html">thaliPeerAction</a></li><li><a href="module-thaliPeerDictionary.html">thaliPeerDictionary</a></li><li><a href="module-thaliPeerPoolInterface.html">thaliPeerPoolInterface</a></li><li><a href="module-ThaliWifiInfrastructure.html">ThaliWifiInfrastructure</a></li><li><a href="module-WifiBasedNativeMock.html">WifiBasedNativeMock</a></li></ul><h3>Externals</h3><ul><li><a href="external-_Mobile(_connect_)_.html">Mobile('connect')</a></li><li><a href="external-_Mobile(_discoveryAdvertisingStateUpdateNonTCP_)_.html">Mobile('discoveryAdvertisingStateUpdateNonTCP')</a></li><li><a href="external-_Mobile(_incomingConnectionToPortNumberFailed_)_.html">Mobile('incomingConnectionToPortNumberFailed')</a></li><li><a href="external-_Mobile(_killConnections_)_.html">Mobile('killConnections')</a></li><li><a href="external-_Mobile(_networkChanged_)_.html">Mobile('networkChanged')</a></li><li><a href="external-_Mobile(_peerAvailabilityChanged_)_.html">Mobile('peerAvailabilityChanged')</a></li><li><a href="external-_Mobile(_startListeningForAdvertisements_)_.html">Mobile('startListeningForAdvertisements')</a></li><li><a href="external-_Mobile(_startUpdateAdvertisingAndListening_)_.html">Mobile('startUpdateAdvertisingAndListening')</a></li><li><a href="external-_Mobile(_stopAdvertisingAndListening_)_.html">Mobile('stopAdvertisingAndListening')</a></li><li><a href="external-_Mobile(_stopListeningForAdvertisements_)_.html">Mobile('stopListeningForAdvertisements')</a></li></ul><h3>Classes</h3><ul><li><a href="ConnectionTable.html">ConnectionTable</a></li><li><a href="module-TCPServersManager-TCPServersManager.html">TCPServersManager</a></li><li><a href="module-thaliNotificationAction-NotificationAction.html">NotificationAction</a></li><li><a href="module-thaliNotificationBeacons-ParseBeaconsResponse.html">ParseBeaconsResponse</a></li><li><a href="module-thaliNotificationClient-ThaliNotificationClient.html">ThaliNotificationClient</a></li><li><a href="module-thaliNotificationServer-ThaliNotificationServer.html">ThaliNotificationServer</a></li><li><a href="module-thaliPeerAction-PeerAction.html">PeerAction</a></li><li><a href="module-thaliPeerDictionary-NotificationPeerDictionaryEntry.html">NotificationPeerDictionaryEntry</a></li><li><a href="module-thaliPeerDictionary-PeerConnectionInformation.html">PeerConnectionInformation</a></li><li><a href="module-thaliPeerDictionary-PeerDictionary.html">PeerDictionary</a></li><li><a href="module-thaliPeerPoolInterface-ThaliPeerPoolInterface.html">ThaliPeerPoolInterface</a></li><li><a href="module-ThaliWifiInfrastructure-ThaliWifiInfrastructure.html">ThaliWifiInfrastructure</a></li><li><a href="module-WifiBasedNativeMock-MobileCallInstance.html">MobileCallInstance</a></li><li><a href="module-WifiBasedNativeMock-WifiBasedNativeMock.html">WifiBasedNativeMock</a></li></ul><h3>Events</h3><ul><li><a href="module-thaliMobileNativeWrapper.html#~event:discoveryAdvertisingStateUpdateNonTCPEvent">discoveryAdvertisingStateUpdateNonTCPEvent</a></li><li><a href="module-ThaliWifiInfrastructure.html#~event:discoveryAdvertisingStateUpdateWifiEvent">discoveryAdvertisingStateUpdateWifiEvent</a></li><li><a href="module-TCPServersManager.html#~event:failedConnection">failedConnection</a></li><li><a href="module-thaliMobileNativeWrapper.html#~event:incomingConnectionToPortNumberFailed">incomingConnectionToPortNumberFailed</a></li><li><a href="module-thaliMobileNativeWrapper.html#~event:networkChangedNonTCP">networkChangedNonTCP</a></li><li><a href="module-ThaliWifiInfrastructure.html#~event:networkChangedWifi">networkChangedWifi</a></li><li><a href="module-thaliMobileNativeWrapper.html#~event:nonTCPPeerAvailabilityChangedEvent">nonTCPPeerAvailabilityChangedEvent</a></li><li><a href="module-TCPServersManager.html#~event:routerPortConnectionFailed">routerPortConnectionFailed</a></li><li><a href="module-ThaliWifiInfrastructure.html#~event:wifiPeerAvailabilityChanged">wifiPeerAvailabilityChanged</a></li><li><a href="module-thaliMobile.html#.event:event:discoveryAdvertisingStateUpdate">discoveryAdvertisingStateUpdate</a></li><li><a href="module-thaliMobile.html#.event:event:networkChanged">networkChanged</a></li><li><a href="module-thaliMobile.html#.event:event:peerAvailabilityChanged">peerAvailabilityChanged</a></li><li><a href="module-thaliNotificationAction-NotificationAction.html#.event:event:Resolved">Resolved</a></li><li><a href="module-thaliNotificationClient.html#.event:event:peerAdvertisesDataForUs">peerAdvertisesDataForUs</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getPKCS12Content">getPKCS12Content</a></li><li><a href="global.html#getPublicKeyHash">getPublicKeyHash</a></li><li><a href="global.html#stopThaliReplicationManager">stopThaliReplicationManager</a></li><li><a href="global.html#ThaliEmitter">ThaliEmitter</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Mon Jan 18 2016 11:19:31 GMT+0200 (EET)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>