bind static method
Binds the relay on port (0 = an ephemeral port).
maxClients bounds open connections (not just registered ones — a
socket costs a file descriptor whether or not it ever says hello); a
connection beyond it is closed with relayFullCode. A connection that
has not sent its hello within helloTimeout is evicted, so silent
sockets cannot hold the cap hostage. maxFrameBytes bounds one
envelope; a larger one closes its sender with 1009 message too big.
All of it is hygiene against accidents and floods, not authentication
(see the class docs).
Implementation
static Future<WebSocketRelay> bind({
required int port,
int maxClients = 256,
int maxFrameBytes = 4 << 20,
Duration helloTimeout = const Duration(seconds: 10),
}) async =>
WebSocketRelay._(
await HttpServer.bind(InternetAddress.anyIPv4, port),
maxClients,
maxFrameBytes,
helloTimeout,
);