MultistreamMuxer class
MultistreamMuxer is a muxer for multistream. Depending on the stream protocol tag it will select the right handler and hand the stream off to it.
- Implemented types
Constructors
- MultistreamMuxer.new({MultistreamConfig? config})
- Creates a new MultistreamMuxer with optional configuration
Properties
- config → MultistreamConfig
-
Configuration for multistream operations
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxRetries → int
-
Maximum number of retry attempts for transient failures (from config)
no setter
- readTimeout → Duration
-
Timeout for read operations (from config)
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addHandler(
ProtocolID protocol, HandlerFunc handler) → void -
AddHandler registers the given handler to be invoked for
an exact literal match of the given protocol ID string.
override
-
addHandlerWithFunc(
ProtocolID protocol, bool match(ProtocolID), HandlerFunc handler) → Future< void> -
AddHandlerWithFunc registers the given handler to be invoked
when the provided match function returns true.
override
-
handle(
P2PStream stream) → Future< void> -
Handle calls Negotiate to determine which protocol handler to use for an
inbound stream, then invokes the protocol handler function, passing it
the protocol ID and the stream. Returns an error if negotiation fails.
override
-
negotiate(
P2PStream stream) → Future< (ProtocolID, HandlerFunc)> -
Negotiate will return the registered protocol handler to use for a given
inbound stream, returning after the protocol has been determined and the
Negotiator has finished using the stream for negotiation. Returns an
error if negotiation fails.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
protocols(
) → Future< List< ProtocolID> > -
Protocols returns a list of all registered protocol ID strings.
Note that the Router may be able to handle protocol IDs not
included in this list if handlers were added with match functions
using AddHandlerWithFunc.
override
-
removeHandler(
ProtocolID protocol) → void -
RemoveHandler removes the registered handler (if any) for the
given protocol ID string.
override
-
selectOneOf(
P2PStream stream, List< ProtocolID> protocolsToSelect) → Future<ProtocolID?> - Selects one of the given protocols with the remote peer.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited