Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadLengthPrefix ¶
ReadLengthPrefix reads the name from Reader with a length-byte-prefix.
Types ¶
type ID ¶
type ID string
ID is an identifier used to write protocol headers in streams.
const (
TestingID ID = "/p2p/_testing"
)
These are reserved protocol.IDs.
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux provides simple stream multixplexing. It helps you precisely when:
- You have many streams
- You have function handlers
It contains the handlers for each protocol accepted. It dispatches handlers for streams opened by remote peers.
func (*Mux) Handle ¶
Handle reads the next name off the Stream, and calls a handler function This is done in its own goroutine, to avoid blocking the caller.
func (*Mux) HandleSync ¶
HandleSync reads the next name off the Stream, and calls a handler function This is done synchronously. The handler function will return before HandleSync returns.
func (*Mux) RemoveHandler ¶
RemoveHandler removes the protocol handler on the Network's Muxer. This operation is threadsafe.
func (*Mux) SetDefaultHandler ¶
func (m *Mux) SetDefaultHandler(h inet.StreamHandler)
func (*Mux) SetHandler ¶
func (m *Mux) SetHandler(p ID, h inet.StreamHandler)
SetHandler sets the protocol handler on the Network's Muxer. This operation is threadsafe.