ProtocolSwitch class abstract

Switch is the component responsible for "dispatching" incoming stream requests to their corresponding stream handlers. It is both a Negotiator and a Router.

Implemented types
Implementers

Constructors

ProtocolSwitch.new()

Properties

hashCode int
The hash code for this object.
no setterinherited
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.
inherited
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.
inherited
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.
inherited
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.
inherited
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.
inherited
removeHandler(ProtocolID protocol) → void
RemoveHandler removes the registered handler (if any) for the given protocol ID string.
inherited
toString() String
A string representation of this object.
inherited

Operators

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