WsConnection class

The single WebSocket a node holds to the hub.

All of a node's endpoints — its coordination stream plus every data stream — share one connection, so this owns the socket and demultiplexes on the way in.

Uses package:web_socket_channel, which presents one API over dart:io sockets on the VM and the browser's WebSocket on the web. That is what lets this file stay in the web-safe part of the package.

Constructors

WsConnection(Uri hubUri, {required HubCredentials credentials, int maxFrameBytes = WsLimits.defaultMaxFrameBytes})

Properties

closedBy → HubConnectionException?
Why the hub closed this connection, if it did and said so.
no setter
control → Stream<WsFrame>
Control frames from the hub, for callers that need them directly (query results, peer departures).
no setter
credentials → HubCredentials
The session name and shared secret this connection authenticates with.
final
epoch → int?
The session generation the hub admitted this connection into.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hubUri → Uri
final
inbound → Stream<WsInbound>
Relayed traffic for this node's endpoints.
no setter
isConnected → bool
no setter
maxFrameBytes → int
Largest frame this connection will send, in bytes.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
signals → Stream<WsSignal>
Signalling frames addressed to one of this connection's endpoints.
no setter

Methods

announce(PeerDescriptor descriptor, {bool publish = true}) → Future<int>
Registers (or re-registers) an endpoint and returns its hub slot.
close() → Future<void>
connect({Duration timeout = const Duration(seconds: 10), required String nodeUId}) → Future<void>
Opens the socket and completes the authentication handshake.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
publishMessage({required String streamName, required String fromEndpointId, required Object payload}) → void
publishSample(Uint8List frame) → void
query(DiscoveryQuery q, {bool continuous = false}) → int
Runs a query. Returns its id so it can be cancelled with unquery.
sendSignal({required String fromEndpointId, required String toEndpointId, required Object? payload}) → void
Sends an opaque payload to one named endpoint, through the hub.
slotFor(String endpointId) → int?
subscribe({required String streamName, required String subscriberEndpointId, required List<String> producerEndpointIds}) → void
toString() → String
A string representation of this object.
inherited
unquery(int qid) → void
unsubscribe({required String streamName, required String subscriberEndpointId, required List<String> producerEndpointIds}) → void
Tears down routes installed by subscribe.

Operators

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