WsProvider class

The WebSocket Provider allows sending requests using WebSocket to a WebSocket RPC server TCP port. Unlike the [HttpProvider], it does support subscriptions and allows listening to events such as new blocks or balance changes.

Inheritance

Constructors

WsProvider(Uri url, {bool autoConnect = true})
Creates a new websocket connection, connects automatically by default

Properties

channel ↔ WebSocketChannel?
WebSocket connection
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isOpen bool
no setter
queries Map<int, Completer<RpcResponse>>
Maps the query id to the completer that will resolve the query
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
subscriptions Map<String, StreamController<SubscriptionMessage>>
Maps the subscription id to the stream controller that will emit the subscription data
final
url Uri
The endpoint url
final

Methods

connect() Future
Open websocket channel
override
disconnect() Future
override
getOrCreateSubscriptionController(String subscription, [FutureOr<void> onCancel(String subscription)?]) StreamController<SubscriptionMessage>
getSubscriptionController(String subscriptionId) StreamController<SubscriptionMessage>?
isConnected() bool
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
ready() Future<bool>
Promise that resolves the first time we are connected and loaded
send(String method, List params) Future<RpcResponse>
Send arbitrary message to RPC node
override
subscribe(String method, List params, {FutureOr<void> onCancel(String subscription)?}) Future<SubscriptionResponse>
Send arbitrary message to RPC node
override
toString() String
A string representation of this object.
inherited

Operators

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