WebSocketTransport constructor
WebSocketTransport({})
Creates a transport that dials connectTo on start.
listenPort (native only; 0 = an ephemeral port, null = no listener)
additionally accepts inbound connections — the side a browser peer dials.
reconnectBaseDelay and reconnectMaxDelay bound the redial backoff.
maxInboundConnections, helloTimeout and maxFrameBytes bound what an
inbound connection may cost: a connection beyond the cap is closed, one
that has not introduced itself within helloTimeout is evicted, and one
that sends a message larger than maxFrameBytes is closed. Hygiene
against floods, not authentication: peers are authenticated by
Passnote's signed session handshake, not by the transport.
Implementation
WebSocketTransport({
this.connectTo = const [],
this.listenPort,
Duration reconnectBaseDelay = const Duration(seconds: 2),
Duration reconnectMaxDelay = const Duration(seconds: 60),
this.maxInboundConnections = 64,
this.helloTimeout = const Duration(seconds: 10),
this.maxFrameBytes = 4 << 20,
}) : _reconnectBaseDelay = reconnectBaseDelay,
_reconnectMaxDelay = reconnectMaxDelay {
if (listenPort != null && !backend.canServe) {
throw ArgumentError(
'listenPort is not supported in the browser; a web peer only dials '
'out. Configure connectTo: instead.',
);
}
}