RouterL2 class
Enhanced router with more high-level API for building rich client applications.
This class extends the functionality of RouterL1 by providing a
higher-level API for managing peer connections and monitoring peer status.
It is designed to simplify the development of client applications that
require real-time communication and peer discovery.
- Inheritance
-
- Object
- RouterBase
- RouterL0
- RouterL1
- RouterL2
- Implementers
Constructors
Properties
- crypto → Crypto
-
The cryptography instance used for encryption and signing.
finalinherited
- deltaT ↔ int
-
Defines the required clock synchronization accuracy between nodes, in
milliseconds.
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isNotRunning → bool
-
no setterinherited
- isRunning → bool
-
no setterinherited
- keepalivePeriod → Duration
-
The keepalive period, specifying the interval for sending keepalive
messages to peers.
finalinherited
-
lastSeenStream
→ Stream<
PeerStatus> -
A stream of peer status updates.
no setter
- logger ↔ void Function(String)?
-
The logger used for logging events.
getter/setter pairinherited
- maxForwardsLimit ↔ int
-
Defines the maximum number of times a message can be forwarded.
getter/setter pairinherited
- maxStoredHeaders ↔ int
-
The maximum number of stored headers for routes.
getter/setter pairinherited
-
messageStream
→ Stream<
Message> -
Returns a stream of incoming messages.
no setterinherited
- messageTTL ↔ Duration
-
The message time-to-live, specifying how long messages are considered
valid.
getter/setter pairinherited
- peerAddressTTL ↔ Duration
-
The peer address time-to-live, specifying how long peer addresses are
considered valid. Defaults to twice the keepalive period.
getter/setter pairinherited
- peerOnlineTimeout ↔ Duration
-
The timeout period for considering a peer offline.
getter/setter pair
- retryPeriod ↔ Duration
-
The retry period for sending messages.
getter/setter pairinherited
-
routes
→ Map<
PeerId, Route> -
The routes maintained by the router, stored as a map of PeerId to
Route.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
selfAddresses
→ Iterable<
FullAddress> -
Returns an iterable of the self addresses of this router.
no setterinherited
- selfId → PeerId
-
no setterinherited
-
transports
→ List<
TransportBase> -
The transports used for network communication.
finalinherited
- useForwardersLimit ↔ int
-
Defines the maximum number of forwarders to use for message delivery.
getter/setter pairinherited
Methods
-
addPeerAddress(
{required PeerId peerId, required FullAddress address, required AddressProperties properties, bool? canForward}) → void - Adds an address for a peer to the routing table.
-
getPeerStatus(
PeerId peerId) → bool - Returns the status of a peer.
-
init(
[Uint8List? seed]) → Future< Uint8List> -
Initializes the router.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onMessage(
Packet packet) → Future< Packet> -
Handles incoming packets.
override
-
pingPeer(
PeerId peerId) → Future< bool> - Pings a peer to check if it is online.
-
removePeerAddress(
PeerId peerId) → void - Removes the peer address from the routing table.
-
resolvePeerId(
PeerId peerId) → Iterable< FullAddress> -
Resolves a Peer ID to a set of network addresses.
inherited
-
sendDatagram(
{required Iterable< FullAddress> addresses, required Uint8List datagram}) → void -
Sends a datagram to the specified addresses.
inherited
-
sendDatagramConfirmable(
{required int messageId, required Uint8List datagram, required Iterable< FullAddress> addresses, Duration? ackTimeout}) → Future<void> -
Sends a confirmable datagram and waits for an acknowledgement.
inherited
-
sendMessage(
{required PeerId dstPeerId, bool isConfirmable = false, int? messageId, Uint8List? payload, Duration? ackTimeout, Iterable< FullAddress> ? useAddresses}) → Future<PacketHeader> -
Sends a message to the specified destination peer.
inherited
-
start(
) → Future< void> -
Starts the router.
inherited
-
stop(
) → void -
Stops the router.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited