MuxServerLoom

constructor(source: ConnectionSource, scope: CoroutineScope, selfId: PeerId, authorizer: RoomAuthorizer, dispatcher: CoroutineContext = requireNotNull(scope.coroutineContext[ContinuationInterceptor]) { "MuxServerLoom scope must have a ContinuationInterceptor (dispatcher)" }, random: Random = Random.Default, handshakeTimeout: Duration = 10.seconds)

Parameters

source

accept source for incoming client connections.

scope

parent scope for the loom. The owned pump scope (accept loop + per-connection read loops + tracking coroutines) is a child of it, so cancelling scope — or calling close — stops every pump.

selfId

this server's own PeerId.

authorizer

required authorization policy for per-room membership. Invoked on the first inbound frame per (connection, room) pair; a false return structurally excludes the connection from that room. Use RoomAuthorizer.AllowAll for open-access servers. Required (no default) per the "optional ≠ tuning" rule — absent it the gate would be silently disabled.

dispatcher

coroutine context for mesh-seam link loops. Defaults to the interceptor from scope so virtual-time tests share the test dispatcher automatically.

random

seeded Random for mesh-seam nonce generation.

handshakeTimeout

ceiling on a single accepted connection's handshake+admit; a connection that connects but never completes its MeshHello handshake is abandoned and closed after this, so it can never wedge the accept loop. Each accepted connection is admitted concurrently in its own child coroutine (all shared state is lock-guarded), so a slow handshake never starves later connections either.