PeerSession class
A coordination session, independent of any transport.
This is the user-facing surface: initialize, join, create and drive data streams, exchange user messages, leave. It owns the CoordinationController and the data-stream registry, and delegates everything wire-related to the ITransport it is given.
Construct one with PeerSession.create to have the transport built from
the config, or pass a transport explicitly. A transport package may
subclass this to narrow return types to its own stream classes — see
LSLCoordinationSession.
All coordination events are emitted through a single events stream. Use the ControllerEventStreamExtensions for convenient filtering:
session.events.phaseChanges.listen((e) => print('Phase: ${e.phase}'));
session.events.streamCreate.listen((e) => print('Create: ${e.streamName}'));
session.events.nodeJoined.listen((e) => print('Joined: ${e.node.id}'));
- Inheritance
-
- Object
- CoordinationSession
- PeerSession
- Mixed-in types
Constructors
-
PeerSession(CoordinationConfig config, {required ITransport<
ITransportConfig> transport, NodeConfig? thisNodeConfig}) - Creates a session over an explicitly supplied transport.
- PeerSession.create(CoordinationConfig config, {NodeConfig? thisNodeConfig})
-
Creates a session, building the transport from
CoordinationConfig.transportConfig.
factory
Properties
- config ↔ CoordinationSessionConfig
-
Configuration for the coordination session.
latefinalinherited
-
connectedNodes
→ List<
Node> -
no setter
-
connectedParticipantNodes
→ List<
Node> -
no setter
-
coordinationClockSyncs
→ Stream<
ClockSyncSample> -
See CoordinationController.coordinationClockSyncs.
no setter
- coordinationConfig → CoordinationConfig
-
Overall configration for Coordination, Session, Streams, Topology,
Transport.
This is a CoordinationConfig object.
finalinherited
-
coordinationOutletConsumers
→ Stream<
bool> -
See CoordinationController.coordinationOutletConsumers.
no setter
- coordinationSendFailures → int
-
See CoordinationController.coordinationSendFailures.
no setter
- coordinatorUId → String?
-
no setter
- created → bool
-
Indicates whether the ILifecycle implementation has been created.
no setterinherited
- currentPhase → CoordinationPhase
-
no setter
- description → String
-
Returns a description of the identity.
no setteroverride
- disposed → bool
-
Indicates whether the ILifecycle implementation has been disposed.
no setterinherited
-
events
→ Stream<
ControllerEvent> -
Single event stream for all coordination events.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
Unique identifier for the session.
no setteroverride
- initialized → bool
-
Indicates whether the required initialization has been completed.
no setterinherited
- isAcceptingNodes → bool
-
no setter
- isCoordinator → bool
-
no setter
- joined → bool
-
Indicates whether the IJoinable is currently joined.
no setterinherited
- name → String
-
Human-readable name for the session.
no setteroverride
- paused → bool
-
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shadowUId ↔ String?
-
getter/setter pairinherited
- thisNode → Node
-
The node representing this instance in the coordination session.
no setterinherited
-
transport
→ ITransport<
ITransportConfig> -
Transport used for coordination.
no setteroverride
- uId → String
-
Returns a unique identifier that is guaranteed to be globally unique.
no setterinherited
Methods
-
create(
) → Future< void> -
Creates.
override
-
createDataStream(
DataStreamConfig config) → Future< DataStream< DataStreamConfig, IMessage< >IMessageType> > - Create a data stream with automatic setup.
-
destroyStream(
String streamName) → Future< void> - Destroy a stream completely (remove from registry and dispose all resources)
-
dispose(
) → Future< void> -
Disposes the ILifecycle implementation, releasing any resources.
override
-
flushStream(
String streamName) → Future< void> - Flush a stream to clear pending messages - coordinator broadcasts to all nodes
-
getConsumersForStream(
String streamName) → Future< Set< Node> > -
getDataStream(
String name) → Future< DataStream< DataStreamConfig, IMessage< >IMessageType> > -
The stream registered under
name, waiting for an in-flight create. -
getProducersForStream(
String streamName) → Future< Set< Node> > -
initialize(
) → Future< void> -
Initializes the lifecycle, preparing it for use.
override
-
join(
[Duration? timeout]) → Future< void> -
Join
override
-
leave(
) → Future< void> -
Leaves
override
-
manageResource<
R extends IResource> (R resource) → Future< void> -
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
noteNodeActivity(
String nodeUId) → void - See CoordinationController.noteNodeActivity.
-
pause(
) → Future< void> -
not yet implementd
override
-
pauseAcceptingNodes(
) → Future< void> -
pauseStream(
String streamName) → Future< void> - Pause a stream (stop polling but keep resources alive) - coordinator broadcasts to all nodes
-
releaseResource<
R extends IResource> (String resourceUID) → Future< R> -
override
-
resume(
) → Future< void> -
not yet implementd
override
-
resumeAcceptingNodes(
) → Future< void> -
resumeStream(
String streamName, {bool flushBeforeResume = true}) → Future< void> - Resume a stream with optional flushing - coordinator broadcasts to all nodes
-
sendUserMessage(
String messageType, String description, [Map< String, dynamic> ? payload, String? parentMessageId]) → Future<void> -
sinceLastHeard(
String nodeUId) → Duration? - See CoordinationController.sinceLastHeard.
-
startStream(
String streamName, {DateTime? startAt}) → Future< void> -
Starts
streamNameon every node. -
stopStream(
String streamName) → Future< void> - Stop a stream (pause polling, keep stream in registry for potential resumption)
-
toString(
) → String -
A string representation of this object.
inherited
-
updateConfig(
Map< String, dynamic> config) → Future<void> -
updateThisNode(
Node node) → void -
inherited
-
waitForMinNodes(
int minNodes, {Duration? timeout}) → Future< void> -
waitForUserMessage(
String messageType, {Duration? timeout}) → Future< UserMessageEvent> -
Wait for a user message of the given
messageType(the first positional argument passed to sendUserMessage on the sending node).
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited