WebSocketClient class final Client

WebSocket client. With concurrency protection and reconnecting. Supports both web and io platforms.

Implemented types

Constructors

WebSocketClient([WebSocketOptions? options])
WebSocket client. With concurrency protection and reconnecting. Supports both web and io platforms.
WebSocketClient.connect(String url, [WebSocketOptions? options])
WebSocket client. With concurrency protection and reconnecting. Supports both web and io platforms.
factory
WebSocketClient.fromClient(IWebSocketClient client, [WebSocketOptions? options])
Creates a WebSocketClient from an existing IWebSocketClient. This is useful for testing or if you want to use a custom implementation with reconnecting and concurrency protection. WebSocket client. With concurrency protection and reconnecting. Supports both web and io platforms.

Properties

hashCode int
The hash code for this object.
no setterinherited
isClosed bool
Whether the WebSocket connection is closed.
no setteroverride
metrics WebSocketMetrics
Get the metrics for this client.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state WebSocketClientState
The current state of the WebSocket connection.
no setteroverride
stateChanges WebSocketStatesStream
Stream of state changes for the WebSocket connection.
no setteroverride
stream WebSocketMessagesStream
Stream of message events handled by this WebSocket. The stream provides messages as they are received from the network.
no setteroverride

Methods

add(Object data) Future<void>
Sends data on the WebSocket connection. The data in data must be either a String, or a List
override
close([int? code = 1000, String? reason = 'NORMAL_CLOSURE']) FutureOr<void>
Permanently stops the WebSocket connection and frees all resources. After calling this method the WebSocket client is no longer usable.
override
connect(String url) Future<void>
Connects to the WebSocket server. url - the URL that was used to establish the connection.
override
disconnect([int? code = 1000, String? reason = 'NORMAL_CLOSURE']) Future<void>
Closes the WebSocket connection. Set the optional code and reason arguments to send close information to the remote peer. If they are omitted, the peer will see No Status Rcvd (1005) code with no reason, indicates that no status code was provided even though one was expected. https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited