WebSocketClient class

High-level WebSocket client that uses adapters for implementation

Constructors

WebSocketClient.new(WebSocketAdapter _adapter)

Properties

config WebSocketConfig
Configuration used for this client
no setter
connectionStats Map<String, dynamic>
Gets current connection statistics
no setter
currentState WebSocketState
Current connection state
no setter
errorStream Stream
Stream of connection errors
no setter
hashCode int
The hash code for this object.
no setterinherited
isClosed bool
Checks if the connection is closed
no setter
isConnected bool
Checks if the connection is currently active
no setter
isConnecting bool
Checks if the connection is in a connecting state
no setter
logStream Stream<String>
Stream of log messages (if logging is enabled)
no setter
messageStream Stream<WebSocketMessage>
Stream of incoming messages
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stateStream Stream<WebSocketState>
Stream of connection state changes
no setter
statsStream Stream<Map<String, dynamic>>
Stream of connection and heartbeat statistics
no setter

Methods

connect() Future<void>
Establishes a WebSocket connection with automatic reconnection support
disconnect([int? code, String? reason]) Future<void>
Closes the WebSocket connection
dispose() Future<void>
Disposes of the client and cleans up resources
forceReconnect() Future<void>
Forces a reconnection (useful for testing connection resilience)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
send(dynamic data) Future<void>
Sends raw data through the WebSocket
sendBinary(List<int> bytes) Future<void>
Sends binary data
sendJson(Map<String, dynamic> json) Future<void>
Sends a JSON message
sendMessage(WebSocketMessage message) Future<void>
Sends a message through the WebSocket
sendText(String text) Future<void>
Sends a text message
toString() String
A string representation of this object.
inherited

Operators

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