Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // supported protocol messages/feature sets SupportedFeatureSets = bitset.From([]uint64{sting.FeatureSet}) )
Functions ¶
Types ¶
type Events ¶
type Events struct { // Fired when a handshake was fully completed. HandshakeCompleted *events.Event // Holds event instances to attach to for received messages. // Use a message's ID to get the corresponding event. Received []*events.Event // Holds event instances to attach to for sent messages. // Use a message's ID to get the corresponding event. Sent []*events.Event // Fired for generic protocol errors. // It is suggested to close the underlying ReadWriteCloser of the Protocol instance // if any error occurs. Error *events.Event }
Events holds protocol related events.
type Protocol ¶
type Protocol struct { // The protocol features this instance supports. // This variable is only usable after protocol handshake. FeatureSet byte // Holds events for sent and received messages, handshake completion and generic errors. Events Events // contains filtered or unexported fields }
Protocol encapsulates the logic of parsing and sending protocol messages.
func New ¶
func New(conn io.ReadWriteCloser) *Protocol
New generates a new protocol instance which is ready to read a first message header.
func (*Protocol) Handshaked ¶
func (p *Protocol) Handshaked()
Handshaked has to be called when a handshake message was received (and finalized) and sent. If this function is called twice, it will trigger a HandshakeCompleted event.
func (*Protocol) Send ¶
Send sends the given message (including the message header) to the underlying writer. It fires the corresponding send event for the specific message type.
func (*Protocol) Start ¶
func (p *Protocol) Start()
Start kicks off the protocol by sending a handshake message and starting to read from the connection.
func (*Protocol) SupportedFeatureSets ¶
SupportedFeatureSets returns a slice of named supported feature sets.