Namespace: websocket

qz.websocket

Calls related specifically to the web socket connection.
Source:

Methods

(static) connect(optionsopt) → {Promise.<(null|Error)>}

Call to setup connection with QZ Tray on user's system.
Parameters:
Name Type Attributes Description
options Object <optional>
Configuration options for the web socket connection.
Properties
Name Type Attributes Default Description
host string | Array.<string> <optional>
['localhost', 'localhost.qz.io'] Host running the QZ Tray software.
port Object <optional>
Config options for ports to cycle.
Properties
Name Type Attributes Default Description
secure Array.<number> <optional>
[8181, 8282, 8383, 8484] Array of secure (WSS) ports to try
insecure Array.<number> <optional>
[8182, 8283, 8384, 8485] Array of insecure (WS) ports to try
usingSecure boolean <optional>
true If the web socket should try to use secure ports for connecting.
keepAlive number <optional>
60 Seconds between keep-alive pings to keep connection open. Set to 0 to disable.
retries number <optional>
0 Number of times to reconnect before failing.
delay number <optional>
0 Seconds before firing a connection. Ignored if options.retries is 0.
Source:
Returns:
Type
Promise.<(null|Error)>

(static) disconnect() → {Promise.<(null|Error)>}

Stop any active connection with QZ Tray.
Source:
Returns:
Type
Promise.<(null|Error)>

(static) getConnectionInfo() → {Object.<{socket: String, host: String, port: Number}>}

Source:
Returns:
Details of active websocket connection
Type
Object.<{socket: String, host: String, port: Number}>

(static) getNetworkInfo(hostnameopt, portopt) → {Promise.<(Object.<{ipAddress: String, macAddress: String}>|Error)>}

Parameters:
Name Type Attributes Description
hostname string <optional>
Hostname to try to connect to when determining network interfaces, defaults to "google.com"
port number <optional>
Port to use with custom hostname, defaults to 443
Source:
Returns:
Connected system's network information.
Type
Promise.<(Object.<{ipAddress: String, macAddress: String}>|Error)>

(static) isActive() → {boolean}

Check connection status. Active connection is necessary for other calls to run.
Source:
See:
  • connect
Returns:
If there is an active connection with QZ Tray.
Type
boolean

(static) setClosedCallbacks(calls)

List of functions called for any connection closing event outside of an API call.

Also called when websocket#disconnect is called.

Parameters:
Name Type Description
calls function | Array.<function()> Single or array of Function({Event} event) calls.
Source:

(static) setErrorCallbacks(calls)

List of functions called for any connections errors outside of an API call.

Also called if websocket#connect fails to connect.

Parameters:
Name Type Description
calls function | Array.<function()> Single or array of Function({Event} event) calls.
Source: