p2p/protocol/multistream/client library

Package multistream implements client functionality for the multistream-select protocol. The protocol is defined at https://github.com/multiformats/multistream-select

Functions

decodeVarint(Uint8List bytes) → (int, int)
Decodes a varint to an integer
encodeVarint(int value) Uint8List
Encodes an integer as a varint
readDelimited(P2PStream stream) Future<Uint8List>
Reads a delimited message from the stream
readNextToken(P2PStream stream) Future<String>
Reads the next token from the stream
selectOneOf(List<ProtocolID> protos, P2PStream stream) Future<ProtocolID>
SelectOneOf will perform handshakes with the protocols on the given list until it finds one which is supported by the muxer.
selectProtoOrFail(ProtocolID proto, P2PStream stream) Future<void>
SelectProtoOrFail performs the initial multistream handshake to inform the muxer of the protocol that will be used to communicate on this stream. It returns an error if the muxer does not support the protocol.
writeDelimited(P2PStream stream, List<int> message) Future<void>
Writes a delimited message to the stream

Exceptions / Errors

NoProtocolsException
ErrNoProtocols is the error thrown when no protocols have been specified.
ProtocolNotSupportedException
ErrNotSupported is the error returned when the muxer doesn't support the protocols tried for the handshake.
UnrecognizedResponseException
ErrUnrecognizedResponse is the error returned when the muxer responds with an unexpected message.