RelaySessionHost class
Relay session host: the server half of the relay protocol, with no transport of its own.
A relay rebroadcasts opaque CRDT change blobs to the other clients of a room and persists them in a RelayStore, without ever interpreting CRDT data: merging is entirely a client concern. One host serves many rooms, keyed by document id.
Feed it connections with SessionHostServer.acceptConnection. For a host
that owns its own dart:io socket, use WebSocketRelayServer instead.
- Inheritance
-
- Object
- CRDTSocketServer
- SessionHostServer<
RelayClientSession> - RelaySessionHost
- Implementers
Constructors
-
RelaySessionHost({RelayStore? store, RelayCompactionCoordinator? compaction, Compressor? compressor, MessageCodec<
Message> ? messageCodec, int? maxBufferSize, List<ServerSyncPlugin> ? plugins}) - Relay session host: the server half of the relay protocol, with no transport of its own.
Properties
- compaction → RelayCompactionCoordinator
-
The compaction coordinator, shared across this host's sessions.
no setter
- compressor → Compressor
-
Compressor handed to every session this host creates.
finalinherited
- debugLabel → String
-
Name of the concrete host, used in diagnostics.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- isRunning → bool
-
Whether this host accepts sessions and does its background work.
no setterinherited
- maxBufferSize → int?
-
Maximum outbound buffer size per client session (bytes).
finalinherited
-
messageCodec
→ MessageCodec<
Message> ? -
Message codec handed to every session this host creates.
finalinherited
- ownsTransport → bool
-
Whether this host owns the transport it serves on.
no setterinherited
-
plugins
→ List<
ServerSyncPlugin> -
The server plugins
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
serverEvents
→ Stream<
ServerEvent> -
Server events stream
no setterinherited
-
sessions
→ Map<
String, RelayClientSession> -
Active sessions, by id.
no setterinherited
- startedMessage → String
-
Message of the ServerEventType.started event.
no setteroverride
- state → SessionHostState
-
Where this host is in its lifecycle.
no setterinherited
- stoppedMessage → String
-
Message of the ServerEventType.stopped event.
no setteroverride
- store → RelayStore
-
The room persistence used by this host.
no setter
Methods
-
acceptConnection(
TransportConnection connection, {String? sessionId}) → RelayClientSession? -
Register
connectionas a new session and return it.inherited -
addServerEvent(
ServerEvent event) → void -
Emit a ServerEvent on serverEvents.
inherited
-
broadcastMessage(
Message message, {List< String> ? excludeClientIds}) → Future<void> -
Broadcast a message to all subscribed clients
inherited
-
closeAllSessions(
) → Future< void> -
Gracefully close every session.
inherited
-
createSession(
{required String id, required TransportConnection connection}) → RelayClientSession -
Create the session for a newly accepted
connection.override -
dispose(
) → Future< void> -
Dispose the server
inherited
-
handleSessionClosed(
String sessionId) → void -
Drop a session whose event stream ended.
inherited
-
handleSessionError(
String sessionId, dynamic error) → void -
Report an error on a session's event stream.
inherited
-
handleSessionEvent(
SessionEvent event) → FutureOr< void> -
Handle a SessionEvent from one of this host's sessions.
override
-
handleSessionEventDisconnected(
SessionEventGeneric event) → void -
Report a disconnect and drop the session.
inherited
-
handleSessionEventError(
SessionEventGeneric event) → void -
Report a session-level error.
inherited
-
handleSessionEventPingReceived(
SessionEventGeneric event) → FutureOr< void> -
Report a ping from a client.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onDispose(
) → Future< void> -
Release what this host holds beyond its sessions and plugins.
inherited
-
onRunning(
) → void -
Runs each time this host becomes isRunning: on start, or on the
first acceptConnection of a host that does not own its transport.
inherited
-
onStart(
) → Future< void> -
Bring up the transport this host owns. Only called when ownsTransport.
inherited
-
onStarted(
) → Future< void> -
Start serving requests. Only called when ownsTransport.
inherited
-
onStop(
) → Future< void> -
Tear down the transport this host owns. Only called when ownsTransport.
inherited
-
sendMessageToClient(
String clientId, Message message) → Future< void> -
Send a message to a specific client
inherited
-
sessionById(
String id) → RelayClientSession? -
The session with
id, if this host still holds it.inherited -
start(
) → Future< bool> -
Start the server
inherited
-
startFailureMessage(
Object error) → String -
Message of the ServerEventType.error event reported when start fails.
override
-
stop(
) → Future< void> -
Stop the server
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited