Documentation ¶
Index ¶
- type Connection
- func (c *Connection) Close()
- func (c *Connection) Do(messageType protocols.ProtocolMessageType, data interface{}) error
- func (c *Connection) Handshake() error
- func (c *Connection) ReadOne(timeout time.Duration) (*protocols.Message, error)
- func (c *Connection) ReadSync(handler PeerResponseHandlerFunc) error
- func (c *Connection) RequestPeers() error
- type ConnectionOptionFunc
- type PeerResponseHandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection represents a connection with a peer and enables communication
func NewConnection ¶
func NewConnection(ip *net.IP, options ...ConnectionOptionFunc) (*Connection, error)
NewConnection creates a new connection object with the specified peer
func (*Connection) Do ¶
func (c *Connection) Do(messageType protocols.ProtocolMessageType, data interface{}) error
Do send a request over the websocket
func (*Connection) Handshake ¶
func (c *Connection) Handshake() error
Handshake performs the RPC handshake. This should be called before any other method
func (*Connection) ReadSync ¶
func (c *Connection) ReadSync(handler PeerResponseHandlerFunc) error
ReadSync Reads for async responses over the connection in a synchronous fashion, blocking anything else
func (*Connection) RequestPeers ¶
func (c *Connection) RequestPeers() error
RequestPeers asks the current peer to respond with their current peer list
type ConnectionOptionFunc ¶
type ConnectionOptionFunc func(connection *Connection) error
ConnectionOptionFunc can be used to customize a new Connection
func WithHandshakeTimeout ¶
func WithHandshakeTimeout(timeout time.Duration) ConnectionOptionFunc
WithHandshakeTimeout sets the handshake timeout
type PeerResponseHandlerFunc ¶
PeerResponseHandlerFunc is a function that will be called when a response is returned from a peer