WebSocketResultHandler<T> class

A reconnecting, Result-flavored wrapper around a WebSocketChannel.

Each frame from the server is parsed by MessageParser and emitted on stream as Result<T>. Connection / parsing errors surface on the same stream as Error<T> events, so consumers don't need an onError handler.

Constructors

WebSocketResultHandler({required WebSocketChannelFactory channelFactory, required MessageParser<T> parser, ReconnectConfig reconnect = const ReconnectConfig()})
Creates a handler that opens its channel via channelFactory.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stream Stream<Result<T>>
Stream of parsed messages and failures.
no setter

Methods

close() Future<void>
Closes the channel and stops reconnect attempts. Safe to call multiple times.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
send(dynamic data) Result<void>
Sends data to the server. Returns Success when the data was handed to the underlying sink, or an Error if the channel is not connected.
toString() String
A string representation of this object.
inherited

Operators

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