UNPKG

qz-tray

Version:

Connects a web client to the QZ Tray software. Enables printing and device communication from javascript.

1,006 lines (276 loc) 12.7 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Namespace: socket</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">Namespace: socket</h1> <section> <header> <h2> <span class="ancestors"><a href="qz.html">qz</a>.</span>socket</h2> </header> <article> <div class="container-overview"> <div class="description">Calls related to interaction with communication sockets.</div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line1904">line 1904</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id=".close"><span class="type-signature">(static) </span>close<span class="signature">(host, port)</span><span class="type-signature"></span></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>host</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The connection hostname.</td> </tr> <tr> <td class="name"><code>port</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">The connection port number.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line1934">line 1934</a> </li></ul></dd> </dl> <h4 class="name" id=".open"><span class="type-signature">(static) </span>open<span class="signature">(host, port, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <div class="description"> Opens a network port for sending and receiving data. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>host</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="description last">The connection hostname.</td> </tr> <tr> <td class="name"><code>port</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> </td> <td class="description last">The connection port number.</td> </tr> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">Network socket configuration. <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>encoding</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'UTF-8' </td> <td class="description last">Character set for communications.</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line1919">line 1919</a> </li></ul></dd> </dl> <h4 class="name" id=".sendData"><span class="type-signature">(static) </span>sendData<span class="signature">(host, port, data)</span><span class="type-signature"></span></h4> <div class="description"> Send data over an open socket. </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>host</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The connection hostname.</td> </tr> <tr> <td class="name"><code>port</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">The connection port number.</td> </tr> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">string</span> | <span class="param-type">Object</span> </td> <td class="description last">Data to be sent over the port. <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>type</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'PLAIN' </td> <td class="description last">Valid values <code>[PLAIN]</code></td> </tr> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">Data to be sent over the port.</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line1953">line 1953</a> </li></ul></dd> </dl> <h4 class="name" id=".setSocketCallbacks"><span class="type-signature">(static) </span>setSocketCallbacks<span class="signature">(calls)</span><span class="type-signature"></span></h4> <div class="description"> List of functions called for any response from open network sockets. Event data will contain <code>{string} host</code> and <code>{number} port</code> for all types. For RECEIVE types, <code>{string} response</code>. For ERROR types, <code>{string} exception</code>. </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>calls</code></td> <td class="type"> <span class="param-type">function</span> | <span class="param-type">Array.&lt;function()></span> </td> <td class="description last">Single or array of <code>Function({Object} eventData)</code> calls.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line1979">line 1979</a> </li></ul></dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="qz.html">qz</a></li><li><a href="qz.api.html">api</a></li><li><a href="qz.configs.html">configs</a></li><li><a href="qz.file.html">file</a></li><li><a href="qz.hid.html">hid</a></li><li><a href="qz.networking.html">networking</a></li><li><a href="qz.printers.html">printers</a></li><li><a href="qz.security.html">security</a></li><li><a href="qz.serial.html">serial</a></li><li><a href="qz.socket.html">socket</a></li><li><a href="qz.usb.html">usb</a></li><li><a href="qz.websocket.html">websocket</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a> on Thu Apr 02 2026 13:01:02 GMT-0400 (Eastern Daylight Time) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>