UNPKG

p5.serialport

Version:
1,114 lines (239 loc) 12.2 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: Client</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: Client</h1> <section> <header> <h2><span class="attribs"><span class="type-signature"></span></span>Client<span class="signature">(ws)</span><span class="type-signature"></span></h2> <div class="class-description"><p>Represents a web socket client. Maintains <a href="SerialPort.html"><code>SerialPort</code></a> objects that the client subscribes to.</p></div> </header> <article> <div class="container-overview"> <h2>Constructor</h2> <h4 class="name" id="Client"><span class="type-signature"></span>new Client<span class="signature">(ws)</span><span class="type-signature"></span></h4> <div class="description"> <p>create a web socket client</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>ws</code></td> <td class="type"> <span class="param-type">ws</span> </td> <td class="description last"><p>Web socket object</p></td> </tr> </tbody> </table> <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>serialPorts</code></td> <td class="type"> <span class="param-type">Array.&lt;<a href="SerialPort.html">SerialPort</a>></span> </td> <td class="description last"><p>list of subscribed <a href="SerialPort.html"><code>SerialPort</code></a> objects</p></td> </tr> <tr> <td class="name"><code>serialPortsList</code></td> <td class="type"> <span class="param-type">Array.&lt;string></span> </td> <td class="description last"><p>list of string names of subscribed <a href="SerialPort.html"><code>SerialPort</code></a> objects. Used for checking whether duplicate serial port is requested to open.</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="classes_Client.js.html">classes/Client.js</a>, <a href="classes_Client.js.html#line27">line 27</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="close"><span class="type-signature"></span>close<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> <p>close client connection. Set serialPorts and serialPortsList array to null.</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="classes_Client.js.html">classes/Client.js</a>, <a href="classes_Client.js.html#line78">line 78</a> </li></ul></dd> </dl> <h4 class="name" id="echo"><span class="type-signature"></span>echo<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> <p>echo received message back to web client</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="classes_Client.js.html">classes/Client.js</a>, <a href="classes_Client.js.html#line38">line 38</a> </li></ul></dd> </dl> <h4 class="name" id="list"><span class="type-signature"></span>list<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> <p>list all available serial ports and send it to the client</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="classes_Client.js.html">classes/Client.js</a>, <a href="classes_Client.js.html#line43">line 43</a> </li></ul></dd> </dl> <h4 class="name" id="openSerial"><span class="type-signature"></span>openSerial<span class="signature">(port)</span><span class="type-signature"></span></h4> <div class="description"> <p>add opened SerialPort object and its name</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>port</code></td> <td class="type"> <span class="param-type"><a href="SerialPort.html">SerialPort</a></span> </td> <td class="description last"><p>SerialPort object opened by client</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="classes_Client.js.html">classes/Client.js</a>, <a href="classes_Client.js.html#line60">line 60</a> </li></ul></dd> </dl> <h4 class="name" id="sendit"><span class="type-signature"></span>sendit<span class="signature">(toSend)</span><span class="type-signature"></span></h4> <div class="description"> <p>send data via websocket to the client</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>toSend</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last"><p>JSON object received to be sent. Contains message method and data.</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="classes_Client.js.html">classes/Client.js</a>, <a href="classes_Client.js.html#line103">line 103</a> </li></ul></dd> </dl> <h4 class="name" id="write"><span class="type-signature"></span>write<span class="signature">(msg)</span><span class="type-signature"></span></h4> <div class="description"> <p>write received data to subscribed serial ports.</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>msg</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last"><p>received string data from client</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="classes_Client.js.html">classes/Client.js</a>, <a href="classes_Client.js.html#line69">line 69</a> </li></ul></dd> </dl> <h3 class="subsection-title">Events</h3> <h4 class="name" id="event:message">message</h4> <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>inmessage</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last"><p>Type of message emitted from <a href="Client.html"><code>Client</code></a>. Defined message types are: echo, list, openserial, write, close and error. Undefined message types are treated as error messages</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="p5.serialserver.js.html">p5.serialserver.js</a>, <a href="p5.serialserver.js.html#line58">line 58</a> </li></ul></dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.html">Client</a></li><li><a href="SerialPort.html">SerialPort</a></li></ul><h3>Events</h3><ul><li><a href="Client.html#event:message">message</a></li></ul><h3>Global</h3><ul><li><a href="global.html#clients">clients</a></li><li><a href="global.html#LOGGING">LOGGING</a></li><li><a href="global.html#logit">logit</a></li><li><a href="global.html#serialPorts">serialPorts</a></li><li><a href="global.html#serialPortsList">serialPortsList</a></li><li><a href="global.html#start">start</a></li><li><a href="global.html#stop">stop</a></li><li><a href="global.html#wss">wss</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Sun Jul 17 2022 21:38:31 GMT-0400 (Chile Standard Time) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>