thali
Version:
989 lines (287 loc) • 20.7 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: NotificationAction</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: NotificationAction</h1>
<section>
<header>
<h2>
<span class="ancestors"><a href="module-thaliNotificationAction.html">thaliNotificationAction</a>~</span>NotificationAction</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="NotificationAction"><span class="type-signature"></span>new NotificationAction<span class="signature">(peerIdentifier, connectionType, actionType, ecdhForLocalDevice, addressBookCallback)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Creates a sub-type of the module:thaliPeerPoolInterface~PeerAction
class to represent actions for retrieving notifications. We MUST default
ActionState to queued. We are explicitly assuming that all created actions
will be added to the queue.</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>
<tr>
<td class="name"><code>ecdhForLocalDevice</code></td>
<td class="type">
<span class="param-type">Crypto.ECDH</span>
</td>
<td class="description last"><p>A Crypto.ECDH object initialized
with the local device's public and private keys.</p></td>
</tr>
<tr>
<td class="name"><code>addressBookCallback</code></td>
<td class="type">
<span class="param-type">addressBookCallback</span>
</td>
<td class="description last"><p>An object used to validate
which peers we are interested in talking to.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="implements">Implements:</dt>
<dd class="implements"><ul>
<li><a href="module-thaliPeerAction-PeerAction.html">module:thaliPeerAction~PeerAction</a></li>
</ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="NextGeneration_thaliNotificationAction.js.html">NextGeneration/thaliNotificationAction.js</a>, <a href="NextGeneration_thaliNotificationAction.js.html#line23">line 23</a>
</li></ul></dd>
</dl>
<h5>Fires:</h5>
<ul>
<li><a href="module-thaliNotificationAction-NotificationAction.html#.event:event:Resolved">module:thaliNotificationAction~NotificationAction.event:Resolved</a></li>
</ul>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id=".ActionResolution"><span class="type-signature">(static, readonly) </span>ActionResolution<span class="type-signature"> :string</span></h4>
<div class="description">
<p>Records the final outcome of the action.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">string</span>
</li>
</ul>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>BEACONS_RETRIEVED_AND_PARSED</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>The beacon values were successfully retrieved and parsed.</p></td>
</tr>
<tr>
<td class="name"><code>BEACONS_RETRIEVED_BUT_BAD</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>A connection was successfully created to the remote peer and a HTTP request
was successfully delivered and responded to with a 200 but the beacons
were not parsable.</p></td>
</tr>
<tr>
<td class="name"><code>HTTP_BAD_RESPONSE</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>A HTTP response other than 200 was returned.</p></td>
</tr>
<tr>
<td class="name"><code>NETWORK_PROBLEM</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>We weren't able to successfully create a network connection to the remote
peer or we were able to create a connection but we weren't able to complete
the beacon HTTP request.</p></td>
</tr>
<tr>
<td class="name"><code>KILLED</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>The action was killed before it completed.</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_thaliNotificationAction.js.html">NextGeneration/thaliNotificationAction.js</a>, <a href="NextGeneration_thaliNotificationAction.js.html#line75">line 75</a>
</li></ul></dd>
</dl>
<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="implements">Implements:</dt>
<dd class="implements"><ul>
<li><a href="module-thaliPeerAction-PeerAction.html#actionState">module:thaliPeerAction~PeerAction#actionState</a></li>
</ul></dd>
<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>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="kill"><span class="type-signature"></span>kill<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
<p>In addition to the inherited behavior also make sure to fire the
<a href="module-thaliNotificationAction-NotificationAction.html#.event:event:Resolved">module:thaliNotificationAction~NotificationAction.event:Resolved</a>
event.</p>
</div>
<dl class="details">
<dt class="implements">Implements:</dt>
<dd class="implements"><ul>
<li><a href="module-thaliPeerAction-PeerAction.html#kill">module:thaliPeerAction~PeerAction#kill</a></li>
</ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="NextGeneration_thaliNotificationAction.js.html">NextGeneration/thaliNotificationAction.js</a>, <a href="NextGeneration_thaliNotificationAction.js.html#line65">line 65</a>
</li></ul></dd>
</dl>
<h4 class="name" id="start"><span class="type-signature"></span>start<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
<p>Once started we MUST make a HTTP GET request to
http://[hostAddress]:[portNumber]/NotificationBeacons. Make sure to set the
TCP/IP timeout using suggestedTCPTimeout.</p>
<p>The logic for the GET request MUST asynchronous read the response to the
GET request and ensure that it is not beyond a prefixed maximum size. Note
that node does not validate that the length of a response body and the
content-length header match so we MUST read the response in chunks
asynchronously and if the total data read exceeds our predefined limit
then we MUST abort the request object.</p>
<p>If we do get a successful beacon response then we MUST submit the beacon
stream along with ecdhForLocalDevice and addressBookCallback to the <a href="module-thaliNotificationBeacons.html#.parseBeacons">module:thaliNotificationBeacons.parseBeacons</a> method.</p>
<p>When completed fire
<a href="module-thaliNotificationAction-NotificationAction.html#.event:event:Resolved">module:thaliNotificationAction~NotificationAction.event:Resolved</a> with
whatever value makes the most sense.</p>
<p>Note that if we receive a kill method while waiting for the response then we
MUST call abort the HTTP request, set our ActionState to KILLED and fire off
a Resolved event.</p>
<p><strong>Open Issue:</strong> Is abort truly synchronous? In other words is it ever
possible to call abort, get back a response and then still have the response
object show up? I should hope not.</p>
</div>
<dl class="details">
<dt class="implements">Implements:</dt>
<dd class="implements"><ul>
<li><a href="module-thaliPeerAction-PeerAction.html#start">module:thaliPeerAction~PeerAction#start</a></li>
</ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="NextGeneration_thaliNotificationAction.js.html">NextGeneration/thaliNotificationAction.js</a>, <a href="NextGeneration_thaliNotificationAction.js.html#line56">line 56</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Events</h3>
<h4 class="name" id=".event:event:Resolved">event:Resolved</h4>
<div class="description">
<p>When the action has completed this event MUST be fired. If the action
was able to retrieve the beacon</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>actionResolution</code></td>
<td class="type">
<span class="param-type">ActionResolution</span>
</td>
<td class="description last"><p>Explains how the action was
completed.</p></td>
</tr>
<tr>
<td class="name"><code>beacon</code></td>
<td class="type">
<span class="param-type"><a href="module-thaliNotificationBeacons-ParseBeaconsResponse.html">module:thaliNotificationBeacons~ParseBeaconsResponse</a></span>
</td>
<td class="description last"><p>If actionResolution is BEACONS_RETRIEVED_AND_PARSED then this object will be
returned. If the beacons were parsed and there were no values directed at
this peer then the beacon object MUST be null.</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_thaliNotificationAction.js.html">NextGeneration/thaliNotificationAction.js</a>, <a href="NextGeneration_thaliNotificationAction.js.html#line102">line 102</a>
</li></ul></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>