SocketClient class

Wraps a standard web socket instance to marshal and un-marshal the server / client payloads into dart object representation.

This class also deals with reconnection, handles timeout and keep alive messages.

It is meant to be instantiated once, and you can let this class handle all the heavy- lifting of socket state management. Once you're done with the socket connection, make sure you call the dispose method to release all allocated resources.


SocketClient(String url, {Iterable<String> protocols: const ['graphql-ws'], SocketClientConfig config: const SocketClientConfig(), @visibleForTesting Uint8List randomBytesForUuid})


config SocketClientConfig
connectionState → Stream<SocketConnectionState>
These streams will emit done events when the current socket is done. A stream that emits the last value of the connection state upon subscription.
protocols → Iterable<String>
randomBytesForUuid ↔ Uint8List
read / write
socket WebSocket
@visibleForTesting, read-only
url → String
hashCode → int
The hash code for this object.
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited


dispose() → Future<void>
Closes the underlying socket if connected, and stops reconnection attempts. After calling this method, this SocketClient instance must be considered unusable. Instead, create a new instance of this class. [...]
onConnectionLost([dynamic e]) → void
subscribe(SubscriptionRequest payload, bool waitForConnection) → Stream<SubscriptionData>
Sends a query, mutation or subscription request to the server, and returns a stream of the response. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
toString() → String
Returns a string representation of this object.


operator ==(dynamic other) → bool
The equality operator.