thali
Version:
2,037 lines (664 loc) • 38.3 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Module: thaliMobileNativeWrapper</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">Module: thaliMobileNativeWrapper</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id=".emitter"><span class="type-signature">(static) </span>emitter<span class="type-signature"></span></h4>
<div class="description">
<p>Use this emitter to subscribe to events.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="NextGeneration_thaliMobileNativeWrapper.js.html">NextGeneration/thaliMobileNativeWrapper.js</a>, <a href="NextGeneration_thaliMobileNativeWrapper.js.html#line390">line 390</a>
</li></ul></dd>
</dl>
<h5>Fires:</h5>
<ul>
<li><a href="module-thaliMobileNativeWrapper.html#~event:nonTCPPeerAvailabilityChangedEvent">event:nonTCPPeerAvailabilityChangedEvent</a></li>
<li><a href="module-thaliMobileNativeWrapper.html#~event:networkChangedNonTCP">event:networkChangedNonTCP</a></li>
<li><a href="module-thaliMobileNativeWrapper.html#~event:incomingConnectionToPortNumberFailed">event:incomingConnectionToPortNumberFailed</a></li>
<li><a href="module-thaliMobileNativeWrapper.html#~event:discoveryAdvertisingStateUpdateNonTCPEvent">event:discoveryAdvertisingStateUpdateNonTCPEvent</a></li>
<li>module:TCPServersManager~event:failedConnection We repeat these events</li>
</ul>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".getNonTCPNetworkStatus"><span class="type-signature">(static) </span>getNonTCPNetworkStatus<span class="signature">()</span><span class="type-signature"> → {Promise.<<a href="module-thaliMobileNative.html#~networkChanged">module:thaliMobileNative~networkChanged</a>>}</span></h4>
<div class="description">
<p>This method returns the last value sent by the
module:thaliMobileNativeWrapper.event:networkChangedNonTCP
event.</p>
<p>The reason we use a promise is that there is a race condition where
someone could call this before we have gotten the first network
status event. Rather than force everyone to play the game
where they have to subscribe to the event and call this method
just to figure out the status for things like UX that says
"Hey you don't have the right radio!" we just use a promise that
won't return until we have a value.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="NextGeneration_thaliMobileNativeWrapper.js.html">NextGeneration/thaliMobileNativeWrapper.js</a>, <a href="NextGeneration_thaliMobileNativeWrapper.js.html#line236">line 236</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<<a href="module-thaliMobileNative.html#~networkChanged">module:thaliMobileNative~networkChanged</a>></span>
</dd>
</dl>
<h4 class="name" id=".killConnections"><span class="type-signature">(private, static) </span>killConnections<span class="signature">()</span><span class="type-signature"> → {Promise.<?Error>}</span></h4>
<div class="description">
<h1>WARNING: This method is intended for internal Thali testing only. DO NOT</h1><p>USE!</p>
<p>This method is only intended for iOS. It's job is to terminate all incoming
and outgoing multipeer connectivity framework browser, advertiser, MCSession
and stream connections immediately without using the normal stop and start
interfaces or TCP/IP level connections. The goal is to simulate what would
happen if we switched the phone to something like airplane mode. This
simulates what would happen if peers went out of range.</p>
<p>This method MUST return "Not Supported" if called on Android. On Android we
can get this functionality by using JXCore's ability to disable the local
radios.</p>
<table>
<thead>
<tr>
<th>Error String</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>Failed</td>
<td>Somehow the stop method couldn't do its job. Check the logs.</td>
</tr>
<tr>
<td>Not Supported</td>
<td>This method is not support on this platform.</td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="NextGeneration_thaliMobileNativeWrapper.js.html">NextGeneration/thaliMobileNativeWrapper.js</a>, <a href="NextGeneration_thaliMobileNativeWrapper.js.html#line263">line 263</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<?Error></span>
</dd>
</dl>
<h4 class="name" id=".start"><span class="type-signature">(static) </span>start<span class="signature">(router)</span><span class="type-signature"> → {Promise.<?Error>}</span></h4>
<div class="description">
<p>This method MUST be called before any other method here other than
registering for events on the emitter. This method will cause us to:</p>
<ul>
<li>create a TCP server on a random port and host the router on that server.</li>
<li>create a <a href="module-TCPServersManager.html">module:TCPServersManager</a>.</li>
<li>listen for the module:TCPServersManager~failedConnection event and
then repeat it.</li>
<li>listen for the module:TCPServersManager~routerPortConnectionFailed
event which we will then cause us to fire a <a href="module-thaliMobileNativeWrapper.html#~event:incomingConnectionToPortNumberFailed">event:incomingConnectionToPortNumberFailed</a>.</li>
<li>call start on the <a href="module-TCPServersManager.html">module:TCPServersManager</a> object and record the
returned port.</li>
</ul>
<p>We MUST register for the native layer handlers exactly once.</p>
<p>If the start fails then the object is not in start state and vice versa.</p>
<p>This method is not idempotent. If called two times in a row without an
intervening stop a "Call Stop!" Error MUST be returned.</p>
<p>This method can be called after stop since this is a singleton object.</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>router</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>This is an Express Router object (for example,
express-pouchdb is a router object) that the caller wants the non-TCP
connections to be terminated with. This code will put that router at '/' so
make sure your paths are set up appropriately.</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_thaliMobileNativeWrapper.js.html">NextGeneration/thaliMobileNativeWrapper.js</a>, <a href="NextGeneration_thaliMobileNativeWrapper.js.html#line67">line 67</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<?Error></span>
</dd>
</dl>
<h4 class="name" id=".startListeningForAdvertisements"><span class="type-signature">(static) </span>startListeningForAdvertisements<span class="signature">()</span><span class="type-signature"> → {Promise.<?Error>}</span></h4>
<div class="description">
<p>This method instructs the native layer to discover what other devices are
within range using the platform's non-TCP P2P capabilities. When a device is
discovered its information will be published via <a href="module-thaliMobileNativeWrapper.html#~event:nonTCPPeerAvailabilityChangedEvent">event:nonTCPPeerAvailabilityChangedEvent</a>.</p>
<p>This method is idempotent so multiple consecutive calls without an
intervening call to stop will not cause a state change.</p>
<p>This method MUST NOT be called if the object is not in start state or a "Call
Start!" error MUST be returned.</p>
<table>
<thead>
<tr>
<th>Error String</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>No Native Non-TCP Support</td>
<td>There are no non-TCP radios on this platform.</td>
</tr>
<tr>
<td>Radio Turned Off</td>
<td>The radio(s) needed for this method are not turned on.</td>
</tr>
<tr>
<td>Unspecified Error with Radio infrastructure</td>
<td>Something went wrong with the radios. Check the logs.</td>
</tr>
<tr>
<td>Call Start!</td>
<td>The object is not in start state.</td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="NextGeneration_thaliMobileNativeWrapper.js.html">NextGeneration/thaliMobileNativeWrapper.js</a>, <a href="NextGeneration_thaliMobileNativeWrapper.js.html#line109">line 109</a>
</li></ul></dd>
</dl>
<h5>Throws:</h5>
<div class="param-desc">
<span class="param-type">Error</span>
</div>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<?Error></span>
</dd>
</dl>
<h4 class="name" id=".startUpdateAdvertisingAndListening"><span class="type-signature">(static) </span>startUpdateAdvertisingAndListening<span class="signature">()</span><span class="type-signature"> → {Promise.<?Error>}</span></h4>
<div class="description">
<p>This method has two separate but related functions. It's first function is to
begin advertising the Thali peer's presence to other peers. The second
purpose is to accept incoming non-TCP/IP connections (that will then be
bridged to TCP/IP) from other peers.</p>
<p>In Android these functions can be separated but with iOS the multi-peer
connectivity framework is designed such that it is only possible for remote
peers to connect to the current peer if and only if the current peer is
advertising its presence. So we therefore have put the two functions together
into a single method.</p>
<p>This method MUST NOT be called unless in the start state otherwise a "Call
Start!" error MUST be returned.</p>
<h2>Discovery</h2><p>Thali currently handles discovery by announcing over the discovery channel
that the Thali peer has had a state change without providing any additional
information, such as who the peer is or who the state changes are relevant
to. The remote peers, when they get the state change notification, will have
to connect to this peer in order to retrieve information about the state
change.</p>
<p>Therefore the purpose of this method is just to raise the "state changed"
flag. Each time it is called a new event will be generated that will tell
listeners that the system has changed state since the last call. Therefore
this method is not idempotent since each call causes a state change.</p>
<p>Once an advertisement is sent out as a result of calling this method
typically any new peers who come in range will be able to retrieve the
existing advertisement. So this is not a one time event but rather more of a
case of publishing an ongoing advertisement regarding the peer's state.</p>
<h2>Incoming Connections</h2><p>By default all incoming TCP connections generated by llNative MUST be passed through a multiplex layer. The details of how this
layer works are given in <a href="module-TCPServersManager.html">module:TCPServersManager</a>. This method will
pass the port from module:TCPServersManager.start output to llNative.</p>
<h2>Repeated calls</h2><p>By design this method is intended to be called multiple times without calling
stop as each call causes the currently notification flag to change.</p>
<table>
<thead>
<tr>
<th>Error String</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>No Native Non-TCP Support</td>
<td>There are no non-TCP radios on this platform.</td>
</tr>
<tr>
<td>Radio Turned Off</td>
<td>The radio(s) needed for this method are not turned on.</td>
</tr>
<tr>
<td>Unspecified Error with Radio infrastructure</td>
<td>Something went wrong with the radios. Check the logs.</td>
</tr>
<tr>
<td>Call Start!</td>
<td>The object is not in start state.</td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="NextGeneration_thaliMobileNativeWrapper.js.html">NextGeneration/thaliMobileNativeWrapper.js</a>, <a href="NextGeneration_thaliMobileNativeWrapper.js.html#line194">line 194</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<?Error></span>
</dd>
</dl>
<h4 class="name" id=".stop"><span class="type-signature">(static) </span>stop<span class="signature">()</span><span class="type-signature"> → {Promise.<?Error>}</span></h4>
<div class="description">
<p>This method will call all the stop methods, call stop on the <a href="module-TCPServersManager.html">module:TCPServersManager</a> object and close the TCP server hosting the router.</p>
<p>Once called the object is in stop state.</p>
<p>This method is idempotent and so MUST be able to be called multiple times in
a row without changing state.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="NextGeneration_thaliMobileNativeWrapper.js.html">NextGeneration/thaliMobileNativeWrapper.js</a>, <a href="NextGeneration_thaliMobileNativeWrapper.js.html#line82">line 82</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<?Error></span>
</dd>
</dl>
<h4 class="name" id=".stopAdvertisingAndListening"><span class="type-signature">(static) </span>stopAdvertisingAndListening<span class="signature">()</span><span class="type-signature"> → {Promise.<?Error>}</span></h4>
<div class="description">
<p>This method tells the native layer to stop advertising the presence of the
peer, stop accepting incoming connections over the non-TCP/IP transport and
to disconnect all existing non-TCP/IP transport incoming connections.</p>
<p>Note that so long as advertising has stopped and there are no incoming
connections or the ability to accept them then this method will return
success. So, for example, if advertising was never started then this method
will return success.</p>
<table>
<thead>
<tr>
<th>Error String</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>Failed</td>
<td>Somehow the stop method couldn't do its job. Check the logs.</td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="NextGeneration_thaliMobileNativeWrapper.js.html">NextGeneration/thaliMobileNativeWrapper.js</a>, <a href="NextGeneration_thaliMobileNativeWrapper.js.html#line216">line 216</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<?Error></span>
</dd>
</dl>
<h4 class="name" id=".stopListeningForAdvertisements"><span class="type-signature">(static) </span>stopListeningForAdvertisements<span class="signature">()</span><span class="type-signature"> → {Promise.<?Error>}</span></h4>
<div class="description">
<p>This method instructs the native layer to stop listening for discovery
advertisements. Note that so long as discovery isn't occurring (because, for
example, the radio needed isn't on) this method will return success.</p>
<p>This method is idempotent and MAY be called even if
startListeningForAdvertisements has not been called.</p>
<p>This method MUST NOT terminate any existing connections created locally using
module:thaliMobileNativeWrapper.connect.</p>
<table>
<thead>
<tr>
<th>Error String</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>Failed</td>
<td>Somehow the stop method couldn't do its job. Check the logs.</td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="NextGeneration_thaliMobileNativeWrapper.js.html">NextGeneration/thaliMobileNativeWrapper.js</a>, <a href="NextGeneration_thaliMobileNativeWrapper.js.html#line131">line 131</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<?Error></span>
</dd>
</dl>
<h3 class="subsection-title">Type Definitions</h3>
<h4 class="name" id="~nonTCPPeerAvailabilityChanged">nonTCPPeerAvailabilityChanged</h4>
<div class="description">
<p>When a <a href="module-thaliMobileNative.html#~peerAvailabilityChangedCallback">module:thaliMobileNative~peerAvailabilityChangedCallback</a>
occurs each peer MUST be placed into a queue. Each peer in the queue MUST be
processed as given below and only once all processing related to that peer
has completed MAY the next peer be taken from the queue.</p>
<p>If a peer's peerAvailable is set to false then we MUST use platform specific
heuristics to decide how to process this. For example, on Android it is
possible for a peer to go into the background at which point their BLE radio
will go to low power even though their Bluetooth radio may still be
reachable. So the system might decide to wait for a bit before issuing a
peerAvailable = false for that peer. But when the system decides to issue a
peer not available event it MUST issue a <a href="module-thaliMobileNativeWrapper.html#~event:nonTCPPeerAvailabilityChangedEvent">event:nonTCPPeerAvailabilityChangedEvent</a> with peerIdentifier set to the
value in the peer object, portNumber set to null and suggestedTCPTimeout not
set.</p>
<p>If a peer's peerAvailable is set to true then we MUST call module:TCPServersManager.createPeerListener. If an error is returned then
the error MUST be logged and we MUST treat this as if we received the value
with peerAvailable equal to false. If the call is a success then we MUST
issue a <a href="module-thaliMobileNativeWrapper.html#~event:nonTCPPeerAvailabilityChangedEvent">event:nonTCPPeerAvailabilityChangedEvent</a> with peerIdentifier
set to the value in the peer object, portNumber set to the returned value and
suggestedTCPTimeout set based on the behavior we have seen on the platform.
That is, some non-TCP technologies can take longer to set up a connection
than others so we need to warn those upstream of that.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Object</span>
</li>
</ul>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</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="attributes">
</td>
<td class="description last"><p>See module:thaliMobileNative~peer.peerIdentifier.</p></td>
</tr>
<tr>
<td class="name"><code>portNumber</code></td>
<td class="type">
<span class="param-type">number</span>
|
<span class="param-type">null</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>If this value is null then the system is advertising that it no longer believes
this peer is available. If this value is non-null then it is a port on 127.0.0.1 at which the local peer can
connect in order to establish a TCP/IP connection to the remote peer.</p></td>
</tr>
<tr>
<td class="name"><code>suggestedTCPTimeout</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>Based on the characteristics of the underlying non-TCP transport how long
the system suggests that the caller be prepared to wait before the TCP/IP connection to the remote peer can be
set up. This is measured in milliseconds.</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_thaliMobileNativeWrapper.js.html">NextGeneration/thaliMobileNativeWrapper.js</a>, <a href="NextGeneration_thaliMobileNativeWrapper.js.html#line271">line 271</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Events</h3>
<h4 class="name" id="~event:discoveryAdvertisingStateUpdateNonTCPEvent">discoveryAdvertisingStateUpdateNonTCPEvent</h4>
<div class="description">
<p>This is used whenever discovery or advertising starts or stops. Since it's
possible for these to be stopped (in particular) due to events outside of
node.js's control (for example, someone turned off a radio) we provide a
callback to track these changes. Note that there is no guarantee that the
same callback value couldn't be sent multiple times in a row.</p>
<p>But the general rule we will only fire this event in response to receiving
the event from the native layer. That is, we won't fire it ourselves when
someone calls start or stop advertising/incoming on the wrapper.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Object</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>discoveryAdvertisingStateUpdateValue</code></td>
<td class="type">
<span class="param-type"><a href="module-thaliMobileNative.html#~discoveryAdvertisingStateUpdate">module:thaliMobileNative~discoveryAdvertisingStateUpdate</a></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_thaliMobileNativeWrapper.js.html">NextGeneration/thaliMobileNativeWrapper.js</a>, <a href="NextGeneration_thaliMobileNativeWrapper.js.html#line338">line 338</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~event:incomingConnectionToPortNumberFailed">incomingConnectionToPortNumberFailed</h4>
<div class="description">
<p>This event specifies that our internal TCP servers are no longer accepting
connections so we are in serious trouble. Stopping and restarting is almost
certainly necessary at this point. We can discover this either because of an
error in <a href="module-TCPServersManager.html">module:TCPServersManager</a> or because of external:"Mobile('incomingConnectionToPortNumberFailed')".registerToNative.</p>
</div>
<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>portNumber</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>the 127.0.0.1 port that the TCP/IP bridge tried
to connect to.</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_thaliMobileNativeWrapper.js.html">NextGeneration/thaliMobileNativeWrapper.js</a>, <a href="NextGeneration_thaliMobileNativeWrapper.js.html#line367">line 367</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~event:networkChangedNonTCP">networkChangedNonTCP</h4>
<div class="description">
<p>Provides a notification when the network's state changes as well as when our
use of the network changes, specifically when discovery or
advertising/listening starts and stops. This event can start firing as soon
as the system starts.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Object</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>networkChangedValue</code></td>
<td class="type">
<span class="param-type"><a href="module-thaliMobileNative.html#~networkChanged">module:thaliMobileNative~networkChanged</a></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_thaliMobileNativeWrapper.js.html">NextGeneration/thaliMobileNativeWrapper.js</a>, <a href="NextGeneration_thaliMobileNativeWrapper.js.html#line355">line 355</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~event:nonTCPPeerAvailabilityChangedEvent">nonTCPPeerAvailabilityChangedEvent</h4>
<div class="description">
<p>This event MAY start firing as soon as either of the start methods is called.
Start listening for advertisements obviously looks for new peers but in some
cases so does start advertising. This is because in some cases it's possible
for peer A to discover peer B but not vice versa. This can result in peer A
connecting to peer B who previously didn't know peer A exists. When that
happens we will fire a discovery event.</p>
<p>This event MUST stop firing when both stop methods have been called.</p>
<p>The native layer does not guarantee that it will filter out duplicate
peerAvailabilityChanged callbacks. This means it is possible to receive
multiple announcements about the same peer in the same state.</p>
<p>While the native layer can return multiple peers in a single callback the
wrapper breaks them into individual events. See <a href="module-thaliMobileNativeWrapper.html#~nonTCPPeerAvailabilityChanged">module:thaliMobileNativeWrapper~nonTCPPeerAvailabilityChanged</a> for details on
how to process each peer.</p>
<p>If we receive a module:TCPServersManager~failedConnection then we
MUST treat that as the equivalent of having received a peer for
nonTCPPeerAvailabilityChanged with peerAvailable set to false.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Object</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>peer</code></td>
<td class="type">
<span class="param-type"><a href="module-thaliMobileNativeWrapper.html#~nonTCPPeerAvailabilityChanged">module:thaliMobileNativeWrapper~nonTCPPeerAvailabilityChanged</a></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_thaliMobileNativeWrapper.js.html">NextGeneration/thaliMobileNativeWrapper.js</a>, <a href="NextGeneration_thaliMobileNativeWrapper.js.html#line309">line 309</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:31 GMT+0200 (EET)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>