Client: Client
Represents a WebSocket synchronous client endpoint.
Constructor
Initializes the synchronous client when called.
init (string url, *ClientConfiguration config)
- url string
URL of the target service
- config *ClientConfiguration
The configurations to be used when initializing the client
Remote Methods
writeTextMessage | Writes text messages to the connection. |
writeBinaryMessage | Writes binary data to the connection. |
ping | Pings the connection. |
pong | Sends a pong message to the connection. |
close | Closes the connection. |
readTextMessage | Reads text messages in a synchronous manner |
readBinaryMessage | Reads binary data in a synchronous manner |
Methods
initEndpoint | |
setAttribute | Sets a connection-related attribute. |
getAttribute | Gets connection-related attributes if any. |
removeAttribute | Removes connection related attribute if any. |
getConnectionId | Gives the connection id associated with this connection. |
getNegotiatedSubProtocol | Gives the subprotocol if any that is negotiated with the client. |
isSecure | Gives the secured status of the connection. |
isOpen | Gives the open or closed status of the connection. |
getHttpResponse | Gives the HTTP response if any received for the client handshake request. |
writeTextMessage
Writes text messages to the connection. If an error occurs while sending the text message to the connection, that message will be lost.
Parameters
- data string
Data to be sent.
writeBinaryMessage
function writeBinaryMessage(byte[ ] data) returns Error?
Writes binary data to the connection. If an error occurs while sending the binary message to the connection, that message will be lost.
Parameters
- data byte[ ]
Binary data to be sent
ping
function ping(byte[ ] data) returns Error?
Pings the connection. If an error occurs while sending the ping frame to the server, that frame will be lost.
Parameters
- data byte[ ]
Binary data to be sent
pong
function pong(byte[ ] data) returns Error?
Sends a pong message to the connection. If an error occurs while sending the pong frame to the connection, that the frame will be lost.
Parameters
- data byte[ ]
Binary data to be sent
close
Closes the connection.
Parameters
- statusCode int? (default 1000)
Status code for closing the connection
- reason string? (default ())
Reason for closing the connection
- timeout decimal (default 60)
Time to wait (in seconds) for the close frame to be received from the remote endpoint before closing the connection. If the timeout exceeds, then the connection is terminated even though a close frame is not received from the remote endpoint. If the value is < 0 (e.g., -1), then the connection waits until a close frame is received. If the WebSocket frame is received from the remote endpoint within the waiting period, the connection is terminated immediately.