SessionHostServer<S extends ClientSession> constructor
- Compressor? compressor,
- MessageCodec<
Message> ? messageCodec, - int? maxBufferSize,
- List<
ServerSyncPlugin> ? plugins,
A CRDTSocketServer that owns sessions, not a socket.
Everything a server does once a peer is connected — keeping the session map, broadcasting, reporting ServerEvents, tearing sessions down — lives here, and none of it mentions a transport. A concrete host supplies the sessions (createSession) and the handling of its own protocol's session events (handleSessionEvent).
Connections arrive through acceptConnection, which is the seam every
transport shares: dart:io hosts call it after upgrading an HttpRequest,
and an embedder (another runtime, a test) calls it with whatever
TransportConnection it already holds.
Plugins are per host
A ServerSyncPlugin binds to the host it is given to, once. Handing the
same plugin instance to two hosts throws a LateInitializationError far
from the line that caused it — build a fresh plugin per host.
Implementation
SessionHostServer({
Compressor? compressor,
this.messageCodec,
this.maxBufferSize,
super.plugins,
}) : compressor = compressor ?? NoCompression.instance,
_serverEventController = StreamController<ServerEvent>.broadcast();