WebSocket Client Class Pattern
The WebSocket Client Class Pattern establishes a connection to an endpoint hosting a WebSocket server.
import WebSocketClient from "embedded:network/ws/client";Constructor
Section titled “Constructor”WebSocketClient(options)
Section titled “WebSocketClient(options)”Creates a new WebSocketClient object instance.
WebSocketClient(options)Parameters
Section titled “Parameters”options
socket- ATCPclass constructor options object.
host- The remote hostname to connect to.
port(optional) - The remote port number to connect to.
protocol(optional) - The WebSocket sub-protocol as a string.
Instance Methods
Section titled “Instance Methods”read()
Section titled “read()”Returns the current message.
write(data, options)
Section titled “write(data, options)”Sends a message.
close()
Section titled “close()”Initiates a clean close of the WebSocket connection.