UNPKG

thali

Version:
936 lines (256 loc) 18.1 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: PeerAction</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">Class: PeerAction</h1> <section> <header> <h2> <span class="ancestors"><a href="module-thaliPeerAction.html">thaliPeerAction</a>~</span>PeerAction</h2> </header> <article> <div class="container-overview"> <h4 class="name" id="PeerAction"><span class="type-signature"></span>new PeerAction<span class="signature">(peerIdentifier, connectionType, actionType)</span><span class="type-signature"></span></h4> <div class="description"> <p>An action that has been given to the pool to manage.</p> <p>When an action is created its state MUST be CREATED.</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>peerIdentifier</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>connectionType</code></td> <td class="type"> <span class="param-type"><a href="module-thaliMobile.html#.connectionTypes">module:thaliMobile.connectionTypes</a></span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>actionType</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="NextGeneration_thaliPeerAction.js.html">NextGeneration/thaliPeerAction.js</a>, <a href="NextGeneration_thaliPeerAction.js.html#line23">line 23</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Members</h3> <h4 class="name" id="actionState"><span class="type-signature">(private) </span>actionState<span class="type-signature"> :<a href="module-thaliPeerAction.html#.actionState">module:thaliPeerAction.actionState</a></span></h4> <div class="description"> <p>The current state of the action</p> </div> <h5>Type:</h5> <ul> <li> <span class="param-type"><a href="module-thaliPeerAction.html#.actionState">module:thaliPeerAction.actionState</a></span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="NextGeneration_thaliPeerAction.js.html">NextGeneration/thaliPeerAction.js</a>, <a href="NextGeneration_thaliPeerAction.js.html#line80">line 80</a> </li></ul></dd> </dl> <h4 class="name" id="actionType"><span class="type-signature">(private) </span>actionType<span class="type-signature"> :string</span></h4> <div class="description"> <p>The type of action that will be taken</p> </div> <h5>Type:</h5> <ul> <li> <span class="param-type">string</span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="NextGeneration_thaliPeerAction.js.html">NextGeneration/thaliPeerAction.js</a>, <a href="NextGeneration_thaliPeerAction.js.html#line69">line 69</a> </li></ul></dd> </dl> <h4 class="name" id="connectionType"><span class="type-signature">(private) </span>connectionType<span class="type-signature"> :<a href="module-thaliMobile.html#.connectionTypes">module:thaliMobile.connectionTypes</a></span></h4> <div class="description"> <p>The type of connection the requests will be sent over</p> </div> <h5>Type:</h5> <ul> <li> <span class="param-type"><a href="module-thaliMobile.html#.connectionTypes">module:thaliMobile.connectionTypes</a></span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="NextGeneration_thaliPeerAction.js.html">NextGeneration/thaliPeerAction.js</a>, <a href="NextGeneration_thaliPeerAction.js.html#line58">line 58</a> </li></ul></dd> </dl> <h4 class="name" id="peerIdentifier"><span class="type-signature">(private) </span>peerIdentifier<span class="type-signature"> :string</span></h4> <div class="description"> <p>The remote peer this action targets</p> </div> <h5>Type:</h5> <ul> <li> <span class="param-type">string</span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="NextGeneration_thaliPeerAction.js.html">NextGeneration/thaliPeerAction.js</a>, <a href="NextGeneration_thaliPeerAction.js.html#line47">line 47</a> </li></ul></dd> </dl> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="getActionState"><span class="type-signature"></span>getActionState<span class="signature">()</span><span class="type-signature"> &rarr; {*}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="NextGeneration_thaliPeerAction.js.html">NextGeneration/thaliPeerAction.js</a>, <a href="NextGeneration_thaliPeerAction.js.html#line155">line 155</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="kill"><span class="type-signature"></span>kill<span class="signature">()</span><span class="type-signature"> &rarr; (nullable) {Error}</span></h4> <div class="description"> <p>Tells an action to stop executing immediately and synchronously.</p> <p>If the action is already dead then there is no error. If the action isn't dead then once it is killed off it MUST return null to its promise as defined above.</p> <p>This method is idempotent so multiple calls MUST NOT directly cause a state change.</p> <p>When kill returns the action's state MUST be set to KILLED.</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="NextGeneration_thaliPeerAction.js.html">NextGeneration/thaliPeerAction.js</a>, <a href="NextGeneration_thaliPeerAction.js.html#line145">line 145</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Error</span> </dd> </dl> <h4 class="name" id="start"><span class="type-signature"></span>start<span class="signature">(httpAgentPool)</span><span class="type-signature"> &rarr; {Promise.&lt;?Error>}</span></h4> <div class="description"> <p>Tells the action to begin processing. When the action has completed it will resolve the returned promise successfully with a null value. Once the returned promise resolves then the pool MUST stop tracking this action. Errors from the promise results SHOULD be logged.</p> <p>Start is idempotent so multiple calls MUST NOT directly cause a state change. That is, if the action hasn't started then the first call to start will start it and further calls will accomplish nothing.</p> <p>If start is called on an action that has completed, successfully or not, then an error object MUST be returned with the value &quot;action has completed.&quot;</p> <p>If the action fails due to a network issue it is important that this be reported to the pool because it can use this information to decide how to schedule things. The pool is expected to have subscribed for events like <a href="module-thaliMobile.html#.event:event:networkChanged">module:thaliMobile.event:networkChanged</a> and <a href="module-thaliMobile.html#.event:event:discoveryAdvertisingStateUpdate">module:thaliMobile.event:discoveryAdvertisingStateUpdate</a> and so understand when there are general connections failures. The action MUST use the following error messages if the related errors occur.</p> <p>&quot;Could not establish TCP connection&quot; - This error indicates that the action gave up because it got too many errors trying to connect over TCP to its target peer.</p> <p>&quot;Could establish TCP connection but couldn't keep it running&quot; - In a HTTP context this primarily to cases where a connection appears to exist but all HTTP requests never seem to be able to successfully complete.</p> <p>When start returns the action's state MUST be STARTED.</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>httpAgentPool</code></td> <td class="type"> <span class="param-type">http.Agent</span> </td> <td class="description last"><p>The HTTP client connection pool to use when making requests to the requested peer.</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="NextGeneration_thaliPeerAction.js.html">NextGeneration/thaliPeerAction.js</a>, <a href="NextGeneration_thaliPeerAction.js.html#line125">line 125</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>returns a promise that will resolve when the action is done. Note that if kill is called on an action then it MUST still return success with null. After all, kill doesn't reflect a failure of the action but a change in outside circumstances.</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Promise.&lt;?Error></span> </dd> </dl> </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:32 GMT+0200 (EET) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>