Clients -
http :
WebSocketClient
Represents a WebSocket client endpoint.
Constructor
__init
(string url, WebSocketClientConfiguration? config)
- url string
- config WebSocketClientConfiguration? ()
Remote Methods
pushText | Push text to the connection. |
pushBinary | Push binary data to the connection. |
ping | Ping the connection. |
pong | Send pong message to the connection. |
close | Close the connection. |
ready | Called when the client is ready to receive messages. Can be called only once. |
Methods
Initializes the endpoint.
Sets a connection related attribute.
Gets connection related attribute if any.
Removes connection related attribute if any.
Gives the connection id associated with this connection.
Gives the subprotocol if any that is negotiated with the client.
Gives the secured status of the connection.
Gives the open or closed status of the connection.
Gives the HTTP response if any received for the client handshake request.
pushText
(string | json | xml | boolean | int | float | byte | byte data, boolean finalFrame)
returns WebSocketError?Push text to the connection.
Parameters
- data string | json | xml | boolean | int | float | byte | byte
-
Data to be sent, if byte[] it is converted to a UTF-8 string for sending
- finalFrame boolean (default true)
-
Set to
true
if this is a final frame of a (long) message
-
Return Type
(WebSocketError?) error
if an error occurs when sending
Push binary data to the connection.
Parameters
- data byte
-
Binary data to be sent
- finalFrame boolean (default true)
-
Set to
true
if this is a final frame of a (long) message
-
Return Type
(error) error
if an error occurs when sending
Ping the connection.
Parameters
- data byte
-
Binary data to be sent.
-
Return Type
(WebSocketError?) error
if an error occurs when sending
Send pong message to the connection.
Parameters
- data byte
-
Binary data to be sent
-
Return Type
(WebSocketError?) error
if an error occurs when sending
Close the connection.
Parameters
- statusCode int (default 1000)
-
Status code for closing the connection
- reason string (default ())
-
Reason for closing the connection
- timeoutInSeconds int (default 60)
-
Time to wait 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 < 0 (e.g., -1), then the connection waits until a close frame is received. If WebSocket frame is received from the remote endpoint, within waiting period the connection is terminated immediately.
-
Return Type
(WebSocketError?) error
if an error occurs when sending
Called when the client is ready to receive messages. Can be called only once.
-
Return Type
(WebSocketError?) error
if an error occurs when sending
Sets a connection related attribute.
Parameters
- key string
-
key that identifies the attribute
- value any
-
value of the attribute
Gets connection related attribute if any.
Parameters
- key string
-
the key to identify the attribute.
-
Return Type
(any) the attribute related to the given key or
nil
Removes connection related attribute if any.
Parameters
- key string
-
the key to identify the attribute.
-
Return Type
(any) the attribute related to the given key or
nil
Gives the connection id associated with this connection.
-
Return Type
(string) the unique id associated with the connection
Gives the subprotocol if any that is negotiated with the client.
-
Return Type
(string) The subprotocol if any negotiated with the client or
nil
Gives the secured status of the connection.
-
Return Type
(boolean) true
if the connection is secure.
Gives the open or closed status of the connection.
-
Return Type
(boolean) true
if the connection is open