mikronode-ng
Version:
Mikrotik API implemented in Node
2,028 lines (693 loc) • 34.8 kB
HTML
<html>
<head>
<meta charset="utf-8">
<title>Class: Channel</title>
<meta property="og:title" content=""/>
<meta property="og:type" content="website"/>
<meta property="og:image" content=""/>
<meta property="og:url" content=""/>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<script src="scripts/jquery.min.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/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="styles/jaguar.css">
<script>
var config = {"monospaceLinks":true,"cleverLinks":true,"default":{"outputSourceFiles":true},"applicationName":"MikroNode","disqus":"","googleAnalytics":"","openGraph":{"title":"","type":"website","image":"","site_name":"","url":""},"meta":{"title":"","description":"","keyword":""},"linenums":false};
</script>
</head>
<body>
<div id="wrap" class="clearfix">
<div class="navigation">
<h3 class="applicationName"><a href="index.html">MikroNode</a></h3>
<div class="search">
<input id="search" type="text" class="form-control input-sm" placeholder="Search Documentations">
</div>
<ul class="list">
<li class="item" data-name="mikronode-ng">
<span class="title">
<a href="mikronode-ng.html">mikronode-ng</a>
<span class="static">static</span>
</span>
<ul class="members itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="methods itemMembers">
<span class="subtitle">Methods</span>
<li data-name="mikronode-ng.getConnection"><a href="mikronode-ng.html#.getConnection">getConnection</a></li>
<li data-name="mikronode-ng.parseItems"><a href="mikronode-ng.html#.parseItems">parseItems</a></li>
</ul>
<ul class="events itemMembers">
</ul>
</li>
<li class="item" data-name="mikronode-ng.Channel">
<span class="title">
<a href="mikronode-ng.Channel.html">mikronode-ng.Channel</a>
</span>
<ul class="members itemMembers">
<span class="subtitle">Members</span>
<li data-name="mikronode-ng.Channel#clearEvents"><a href="mikronode-ng.Channel.html#clearEvents">clearEvents</a></li>
<li data-name="mikronode-ng.Channel#closed"><a href="mikronode-ng.Channel.html#closed">closed</a></li>
<li data-name="mikronode-ng.Channel#closeOnDone"><a href="mikronode-ng.Channel.html#closeOnDone">closeOnDone</a></li>
<li data-name="mikronode-ng.Channel#closing"><a href="mikronode-ng.Channel.html#closing">closing</a></li>
<li data-name="mikronode-ng.Channel#id"><a href="mikronode-ng.Channel.html#id">id</a></li>
<li data-name="mikronode-ng.Channel#lastCommand"><a href="mikronode-ng.Channel.html#lastCommand">lastCommand</a></li>
<li data-name="mikronode-ng.Channel#running"><a href="mikronode-ng.Channel.html#running">running</a></li>
<li data-name="mikronode-ng.Channel#saveBuffer"><a href="mikronode-ng.Channel.html#saveBuffer">saveBuffer</a></li>
</ul>
<ul class="typedefs itemMembers">
<span class="subtitle">Typedefs</span>
<li data-name="mikronode-ng.Channel.writeCallback"><a href="mikronode-ng.Channel.html#.writeCallback">writeCallback</a></li>
</ul>
<ul class="methods itemMembers">
<span class="subtitle">Methods</span>
<li data-name="mikronode-ng.Channel#close"><a href="mikronode-ng.Channel.html#close">close</a></li>
<li data-name="mikronode-ng.Channel#finalize"><a href="mikronode-ng.Channel.html#finalize">finalize</a></li>
<li data-name="mikronode-ng.Channel#write"><a href="mikronode-ng.Channel.html#write">write</a></li>
</ul>
<ul class="events itemMembers">
<span class="subtitle">Events</span>
<li data-name="mikronode-ng.Channel#event:close"><a href="mikronode-ng.Channel.html#event:event:close">event:close</a></li>
<li data-name="mikronode-ng.Channel#event:done"><a href="mikronode-ng.Channel.html#event:event:done">event:done</a></li>
<li data-name="mikronode-ng.Channel#event:error"><a href="mikronode-ng.Channel.html#event:event:error">event:error</a></li>
<li data-name="mikronode-ng.Channel#event:timeout"><a href="mikronode-ng.Channel.html#event:event:timeout">event:timeout</a></li>
<li data-name="mikronode-ng.Channel#event:trap"><a href="mikronode-ng.Channel.html#event:event:trap">event:trap</a></li>
</ul>
</li>
<li class="item" data-name="mikronode-ng.Connection">
<span class="title">
<a href="mikronode-ng.Connection.html">mikronode-ng.Connection</a>
</span>
<ul class="members itemMembers">
<span class="subtitle">Members</span>
<li data-name="mikronode-ng.Connection#channels"><a href="mikronode-ng.Connection.html#channels">channels</a></li>
<li data-name="mikronode-ng.Connection#closeOnDone"><a href="mikronode-ng.Connection.html#closeOnDone">closeOnDone</a></li>
<li data-name="mikronode-ng.Connection#host"><a href="mikronode-ng.Connection.html#host">host</a></li>
<li data-name="mikronode-ng.Connection#password"><a href="mikronode-ng.Connection.html#password">password</a></li>
<li data-name="mikronode-ng.Connection#port"><a href="mikronode-ng.Connection.html#port">port</a></li>
<li data-name="mikronode-ng.Connection#status"><a href="mikronode-ng.Connection.html#status">status</a></li>
<li data-name="mikronode-ng.Connection#timeout"><a href="mikronode-ng.Connection.html#timeout">timeout</a></li>
<li data-name="mikronode-ng.Connection#tls"><a href="mikronode-ng.Connection.html#tls">tls</a></li>
<li data-name="mikronode-ng.Connection#user"><a href="mikronode-ng.Connection.html#user">user</a></li>
</ul>
<ul class="typedefs itemMembers">
<span class="subtitle">Typedefs</span>
<li data-name="mikronode-ng.Connection.connectCallback"><a href="mikronode-ng.Connection.html#.connectCallback">connectCallback</a></li>
</ul>
<ul class="methods itemMembers">
<span class="subtitle">Methods</span>
<li data-name="mikronode-ng.Connection.parseItems"><a href="mikronode-ng.Connection.html#.parseItems">parseItems</a></li>
<li data-name="mikronode-ng.Connection#closeChannel"><a href="mikronode-ng.Connection.html#closeChannel">closeChannel</a></li>
<li data-name="mikronode-ng.Connection#connect"><a href="mikronode-ng.Connection.html#connect">connect</a></li>
<li data-name="mikronode-ng.Connection#getChannel"><a href="mikronode-ng.Connection.html#getChannel">getChannel</a></li>
<li data-name="mikronode-ng.Connection#getCommandPromise"><a href="mikronode-ng.Connection.html#getCommandPromise">getCommandPromise</a></li>
<li data-name="mikronode-ng.Connection#getConnectPromise"><a href="mikronode-ng.Connection.html#getConnectPromise">getConnectPromise</a></li>
<li data-name="mikronode-ng.Connection#openChannel"><a href="mikronode-ng.Connection.html#openChannel">openChannel</a></li>
</ul>
<ul class="events itemMembers">
<span class="subtitle">Events</span>
<li data-name="mikronode-ng.Connection#event:close"><a href="mikronode-ng.Connection.html#event:event:close">event:close</a></li>
<li data-name="mikronode-ng.Connection#event:error"><a href="mikronode-ng.Connection.html#event:event:error">event:error</a></li>
<li data-name="mikronode-ng.Connection#event:timeout"><a href="mikronode-ng.Connection.html#event:event:timeout">event:timeout</a></li>
<li data-name="mikronode-ng.Connection#event:trap"><a href="mikronode-ng.Connection.html#event:event:trap">event:trap</a></li>
</ul>
</li>
<li class="item" data-name="mikronode-ng.Trap">
<span class="title">
<a href="mikronode-ng.Trap.html">mikronode-ng.Trap</a>
</span>
<ul class="members itemMembers">
<span class="subtitle">Members</span>
<li data-name="mikronode-ng.Trap#channel"><a href="mikronode-ng.Trap.html#channel">channel</a></li>
<li data-name="mikronode-ng.Trap#channelId"><a href="mikronode-ng.Trap.html#channelId">channelId</a></li>
<li data-name="mikronode-ng.Trap#errors"><a href="mikronode-ng.Trap.html#errors">errors</a></li>
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="methods itemMembers">
</ul>
<ul class="events itemMembers">
</ul>
</li>
<li class="item" data-name="mikronode-ng.TrapError">
<span class="title">
<a href="mikronode-ng.TrapError.html">mikronode-ng.TrapError</a>
</span>
<ul class="members itemMembers">
<span class="subtitle">Members</span>
<li data-name="mikronode-ng.TrapError#category"><a href="mikronode-ng.TrapError.html#category">category</a></li>
<li data-name="mikronode-ng.TrapError#message"><a href="mikronode-ng.TrapError.html#message">message</a></li>
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="methods itemMembers">
</ul>
<ul class="events itemMembers">
</ul>
</li>
</ul>
</div>
<div class="main">
<h1 class="page-title" data-filename="mikronode-ng.Channel.html">Class: Channel</h1>
<section>
<header>
<h2>
<span class="ancestors"><a href="mikronode-ng.html">mikronode-ng</a>.</span>
Channel
</h2>
</header>
<article>
<div class="container-overview">
<dt>
<div class="nameContainer">
<h4 class="name" id="Channel">
new mikronode-ng.Channel<span class="signature">(id, conn)</span>
</h4>
<div class="tag-source">
<a href="channel.js.html">channel.js</a>, <a href="channel.js.html#line66">line 66</a>
</div>
</div>
</dt>
<dd>
<div class="description">
<p>Channel (should not be instantiated directly)</p>
</div>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>id</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">
</td>
</tr>
<tr>
<td class="name"><code>conn</code></td>
<td class="type">
<span class="param-type"><a href="mikronode-ng.Connection.html">mikronode-ng.Connection</a></span>
</td>
<td class="description last">
</td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Fires:</h5>
<ul>
<li><a href="mikronode-ng.Channel.html#event:event:done">mikronode-ng.Channel#event:done</a></li>
<li><a href="mikronode-ng.Channel.html#event:event:trap">mikronode-ng.Channel#event:trap</a></li>
<li><a href="mikronode-ng.Channel.html#event:event:error">mikronode-ng.Channel#event:error</a></li>
<li><a href="mikronode-ng.Channel.html#event:event:timeout">mikronode-ng.Channel#event:timeout</a></li>
<li>{<a href="mikronode-ng.Channel.html#event:event:close">mikronode-ng.Channel#event:close</a>}</li>
</ul>
</dd>
</div>
<h3 class="subsection-title">Members</h3>
<dl>
<dt>
<div class="nameContainer">
<h4 class="name" id="clearEvents">clearEvents<span class="type-signature type boolean">boolean</span> </h4>
</div>
</dt>
<dd>
<div class="description">
<p>Clear event listeners on done</p>
</div>
<dl class="details">
</dl>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="closed"><span class="type-signature ">readonly</span>closed<span class="type-signature type boolean">boolean</span> </h4>
</div>
</dt>
<dd>
<dl class="details">
</dl>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="closeOnDone">closeOnDone<span class="type-signature type boolean">boolean</span> </h4>
</div>
</dt>
<dd>
<div class="description">
<p>Close channel on done</p>
</div>
<dl class="details">
</dl>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="closing"><span class="type-signature ">readonly</span>closing<span class="type-signature type boolean">boolean</span> </h4>
</div>
</dt>
<dd>
<dl class="details">
</dl>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="id"><span class="type-signature ">readonly</span>id<span class="type-signature type number">number</span> </h4>
</div>
</dt>
<dd>
<div class="description">
<p>Channel ID</p>
</div>
<dl class="details">
</dl>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="lastCommand"><span class="type-signature ">readonly</span>lastCommand<span class="type-signature type array.<string>">Array.<string></span> </h4>
</div>
</dt>
<dd>
<dl class="details">
</dl>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="running"><span class="type-signature ">readonly</span>running<span class="type-signature type boolean">boolean</span> </h4>
</div>
</dt>
<dd>
<dl class="details">
</dl>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="saveBuffer">saveBuffer<span class="type-signature type boolean">boolean</span> </h4>
</div>
</dt>
<dd>
<div class="description">
<p>Save each line received in a buffer and pass the entire buffer to the done event.<br>Otherwise the done event will not get all the lines, only the last line. This is<br>handy when following trailing output from a listen command, where the data could<br>be endless.</p>
</div>
<dl class="details">
</dl>
</dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<dl>
<dt>
<div class="nameContainer">
<h4 class="name" id="close">
close<span class="signature">(force)</span>
</h4>
<div class="tag-source">
<a href="channel.js.html">channel.js</a>, <a href="channel.js.html#line370">line 370</a>
</div>
</div>
</dt>
<dd>
<div class="description">
<p>Closes the channel This will close the connection if<br><a href="mikronode-ng.Connection.html#closeOnDone"><code>mikronode-ng.Connection#closeOnDone</code></a> was set and this was the last channel to<br>close.</p>
</div>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>force</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="description last">
<p>Force close even of there are other commands pending.<br> Otherwise mark the channel as 'closing' which will prevent new commands<br> from being started but will let queued ones finish.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="finalize">
finalize<span class="signature">()</span>
</h4>
<div class="tag-source">
<a href="channel.js.html">channel.js</a>, <a href="channel.js.html#line399">line 399</a>
</div>
</div>
</dt>
<dd>
<div class="description">
<p>Calls <a href="mikronode-ng.Channel.html#close"><code>mikronode-ng.Channel#close</code></a>(false)</p>
</div>
<dl class="details">
</dl>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="write">
write<span class="signature">(data, <span class="optional">parameters</span>, <span class="optional">writeCallback</span>)</span>
</h4>
<div class="tag-source">
<a href="channel.js.html">channel.js</a>, <a href="channel.js.html#line240">line 240</a>
</div>
</div>
</dt>
<dd>
<div class="description">
<p>Writes data to the channel</p>
</div>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">string</span>
|
<span class="param-type">Array.<string></span>
</td>
<td class="description last">
<p>Can be a single string with the command and<br> optional parameters separated by '\n' or an array of strings with the<br> command in the first position and the parameters in the rest.</p></td>
</tr>
<tr>
<td class="name"><code>parameters</code></td>
<td class="type">
<span class="param-type">object</span>
|
<span class="param-type">Array.<string></span>
</td>
<td class="description last">
<span class="optional">optional</span>
<p>If the first parameter is a command<br> string, this object will be treated as the parameters for the command.<br> <p><br> It can be an array or strings...</p>
<pre>
['name=value','name=value'...]
</pre>
<p>or an Object...</p>
<pre>
{'name': 'value', 'name': 'value'...}
</pre></td>
</tr>
<tr>
<td class="name"><code>writeCallback</code></td>
<td class="type">
<span class="param-type"><a href="mikronode-ng.Channel.html#.writeCallback">mikronode-ng.Channel.writeCallback</a></span>
</td>
<td class="description last">
<span class="optional">optional</span>
<p>This will be called<br> just before write actually writes the data to the connection.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
</dd>
</dl>
<h3 class="subsection-title">Type Definitions</h3>
<dl>
<dt>
<div class="nameContainer">
<h4 class="name" id=".writeCallback">
mikronode-ng.Channel.writeCallback<span class="signature">()</span>
</h4>
<div class="tag-source">
<a href="channel.js.html">channel.js</a>, <a href="channel.js.html#line14">line 14</a>
</div>
</div>
</dt>
<dd>
<div class="description">
<p>writeCallback</p>
</div>
<table class="params">
<thead>
<tr>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="type">
<span class="param-type">Channel</span>
</td>
<td class="description last">
</td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
</dd>
</dl>
<h3 class="subsection-title">Events</h3>
<dl>
<dt>
<div class="nameContainer">
<h4 class="name" id="event:event:close">
event:close
</h4>
<div class="tag-source">
<a href="channel.js.html">channel.js</a>, <a href="channel.js.html#line40">line 40</a>
</div>
</div>
</dt>
<dd>
<div class="description">
<p>Emitted when the channel is closed either by an explicit call to<br><a href="mikronode-ng.Channel.html#close"><code>mikronode-ng.Channel#close</code></a> or when the channel is closed automatically via<br><a href="mikronode-ng.Channel.html#closeOnDone"><code>mikronode-ng.Channel#closeOnDone</code></a></p>
</div>
<dl class="details">
<h5 class="subsection-title">Properties:</h5>
<dl>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>channel</code></td>
<td class="type">
<span class="param-type">Channel</span>
</td>
<td class="description last"><p>The channel originating the event</p></td>
</tr>
</tbody>
</table></dl>
</dl>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="event:event:done">
event:done
</h4>
<div class="tag-source">
<a href="channel.js.html">channel.js</a>, <a href="channel.js.html#line20">line 20</a>
</div>
</div>
</dt>
<dd>
<div class="description">
<p>Emitted when a command has finished successfully.</p>
</div>
<dl class="details">
<h5 class="subsection-title">Properties:</h5>
<dl>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">string</span>
|
<span class="param-type">Array.<string></span>
</td>
<td class="description last"><p>The data returned by the channel</p></td>
</tr>
<tr>
<td class="name"><code>channel</code></td>
<td class="type">
<span class="param-type">Channel</span>
</td>
<td class="description last"><p>The channel originating the event Fatal event.</p></td>
</tr>
</tbody>
</table></dl>
</dl>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="event:event:error">
event:error
</h4>
<div class="tag-source">
<a href="channel.js.html">channel.js</a>, <a href="channel.js.html#line26">line 26</a>
</div>
</div>
</dt>
<dd>
<div class="description">
<p>Emitted when a non-recoverable error has occurred on the socket. No further commands<br>can be processed on any channel.</p>
</div>
<dl class="details">
<h5 class="subsection-title">Properties:</h5>
<dl>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>error</code></td>
<td class="type">
<span class="param-type">error</span>
</td>
<td class="description last"><p>The error object</p></td>
</tr>
<tr>
<td class="name"><code>channel</code></td>
<td class="type">
<span class="param-type">Channel</span>
</td>
<td class="description last"><p>The channel originating the event</p></td>
</tr>
</tbody>
</table></dl>
</dl>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="event:event:timeout">
event:timeout
</h4>
<div class="tag-source">
<a href="channel.js.html">channel.js</a>, <a href="channel.js.html#line33">line 33</a>
</div>
</div>
</dt>
<dd>
<div class="description">
<p>Emitted when a socket has been idle too long.</p>
</div>
<dl class="details">
<h5 class="subsection-title">Properties:</h5>
<dl>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>message</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>'Socket Timeout'</p></td>
</tr>
<tr>
<td class="name"><code>socketStillOpen</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="description last"><p>If true, communications can continue</p></td>
</tr>
<tr>
<td class="name"><code>channel</code></td>
<td class="type">
<span class="param-type">Channel</span>
</td>
<td class="description last"><p>The channel originating the event</p></td>
</tr>
</tbody>
</table></dl>
</dl>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="event:event:trap">
event:trap
</h4>
<div class="tag-source">
<a href="channel.js.html">channel.js</a>, <a href="channel.js.html#line47">line 47</a>
</div>
</div>
</dt>
<dd>
<div class="description">
<p>Emitted when a command has failed. Subsequent commands may succeed.</p>
</div>
<dl class="details">
<h5 class="subsection-title">Properties:</h5>
<dl>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>trap</code></td>
<td class="type">
<span class="param-type"><a href="mikronode-ng.Trap.html">mikronode-ng.Trap</a></span>
</td>
<td class="description last"><p>The trap object</p></td>
</tr>
</tbody>
</table></dl>
</dl>
</dd>
</dl>
</article>
</section>
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jul 06 2016 06:45:18 GMT-0600 (MDT)
</footer>
</div>
</div>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/main.js"></script>
</body>
</html>