WebSocketConnection class
Manages a single WebSocket connection with state management and event handling.
Constructors
- WebSocketConnection.new(WebSocketConfig config)
- Creates a new WebSocketConnection.
Properties
- config → WebSocketConfig
-
The configuration for this connection.
final
- connectionDuration → Duration?
-
Returns the connection duration if connected.
no setter
-
eventStream
→ Stream<
WebSocketEvent> -
Returns the stream of connection events.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isActive → bool
-
Returns true if the connection is active.
no setter
- isClosed → bool
-
Returns true if the connection is closed.
no setter
- isConnected → bool
-
Returns true if the connection is connected.
no setter
-
messageStream
→ Stream<
WebSocketMessage> -
Returns the stream of incoming messages.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → WebSocketState
-
Returns the current connection state.
no setter
-
stateStream
→ Stream<
WebSocketState> -
Returns the stream of state changes.
no setter
-
statistics
→ Map<
String, dynamic> -
Returns connection statistics.
no setter
- timeSinceLastMessage → Duration?
-
Returns the time since the last message.
no setter
Methods
-
connect(
) → Future< void> - Connects to the WebSocket server.
-
disconnect(
) → Future< void> - Disconnects from the WebSocket server.
-
dispose(
) → Future< void> - Disposes of the connection and all resources.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
send(
WebSocketMessage message) → Future< bool> - Sends a message through the WebSocket connection.
-
sendBinary(
List< int> bytes) → Future<bool> - Sends a binary message.
-
sendJson(
Map< String, dynamic> json) → Future<bool> - Sends a JSON message.
-
sendPing(
) → Future< bool> - Sends a ping message.
-
sendPong(
) → Future< bool> - Sends a pong message.
-
sendText(
String text) → Future< bool> - Sends a text message.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited