LanTransport class

A LAN Transport that discovers same-app peers over mDNS / DNS-SD and exchanges frames over WebSocket connections.

Discovery advertises a service of type _passnote-<appId>._tcp carrying a node TXT entry (this instance's NodeId) and the port of its WebSocket server. Peers browse the same type, then dial each other's WebSocket. To avoid two connections between the same pair, only the node with the lexicographically smaller id dials; the larger id accepts the inbound connection.

The WebSocket layer is covered by the default unit run; mDNS discovery is socket-bound and covered by the tagged loopback integration test.

Constructors

LanTransport({Duration discoveryInterval = const Duration(seconds: 5), Duration reconnectBaseDelay = const Duration(seconds: 2), Duration reconnectMaxDelay = const Duration(seconds: 60), int maxInboundConnections = 64, Duration helloTimeout = const Duration(seconds: 10), int maxFrameBytes = 4 << 20})
Creates a transport.

Properties

events → Stream<PeerEvent>
Stream of peer connection and disconnection events.
no setter
hashCode → int
The hash code for this object.
no setterinherited
helloTimeout → Duration
How long an inbound connection may stay open without naming itself.
final
inbound → Stream<InboundFrame>
Stream of frames received from remote peers.
no setter
maxFrameBytes → int
Largest message accepted on a connection, in bytes.
final
maxInboundConnections → int
Most inbound connections open at once.
final
port → int?
The local port the WebSocket server is bound to, or null before start. Diagnostics and tests; peers learn it over mDNS.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
send(PeerId to, Frame frame) → Future<void>
Sends frame to the peer identified by to.
start({required NodeId self, required String appId}) → Future<void>
Starts the transport, advertising self under appId.
stop() → Future<void>
Stops the transport, closing all active connections.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited