Class: Client

Client(ws)

Represents a web socket client. Maintains SerialPort objects that the client subscribes to.

Constructor

new Client(ws)

create a web socket client

Parameters:
Name Type Description
ws ws

Web socket object

Properties:
Name Type Description
serialPorts Array.<SerialPort>

list of subscribed SerialPort objects

serialPortsList Array.<string>

list of string names of subscribed SerialPort objects. Used for checking whether duplicate serial port is requested to open.

Source:

Methods

close()

close client connection. Set serialPorts and serialPortsList array to null.

Source:

echo()

echo received message back to web client

Source:

list()

list all available serial ports and send it to the client

Source:

openSerial(port)

add opened SerialPort object and its name

Parameters:
Name Type Description
port SerialPort

SerialPort object opened by client

Source:

sendit(toSend)

send data via websocket to the client

Parameters:
Name Type Description
toSend Object

JSON object received to be sent. Contains message method and data.

Source:

write(msg)

write received data to subscribed serial ports.

Parameters:
Name Type Description
msg String

received string data from client

Source:

Events

message

Parameters:
Name Type Description
inmessage Object

Type of message emitted from Client. Defined message types are: echo, list, openserial, write, close and error. Undefined message types are treated as error messages

Source: