Documentation ¶
Index ¶
- type NetAdapter
- func (na *NetAdapter) Broadcast(netConnections []*NetConnection, message appmessage.Message) error
- func (na *NetAdapter) Connect(address string) error
- func (na *NetAdapter) ConnectionCount() int
- func (na *NetAdapter) Connections() []*NetConnection
- func (na *NetAdapter) GetBestLocalAddress() (*appmessage.NetAddress, error)
- func (na *NetAdapter) ID() *id.ID
- func (na *NetAdapter) SetRouterInitializer(routerInitializer RouterInitializer)
- func (na *NetAdapter) Start() error
- func (na *NetAdapter) Stop() error
- type NetConnection
- func (c *NetConnection) Address() string
- func (c *NetConnection) DequeueInvalidMessage() (isOpen bool, err error)
- func (c *NetConnection) Disconnect()
- func (c *NetConnection) ID() *id.ID
- func (c *NetConnection) IsOutbound() bool
- func (c *NetConnection) NetAddress() *appmessage.NetAddress
- func (c *NetConnection) SetID(peerID *id.ID)
- func (c *NetConnection) String() string
- type RouterInitializer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NetAdapter ¶
type NetAdapter struct {
// contains filtered or unexported fields
}
NetAdapter is an abstraction layer over networking. This type expects a RouteInitializer function. This function weaves together the various "routes" (messages and message handlers) without exposing anything related to networking internals.
func NewNetAdapter ¶
func NewNetAdapter(cfg *config.Config) (*NetAdapter, error)
NewNetAdapter creates and starts a new NetAdapter on the given listeningPort
func (*NetAdapter) Broadcast ¶
func (na *NetAdapter) Broadcast(netConnections []*NetConnection, message appmessage.Message) error
Broadcast sends the given `message` to every peer corresponding to each NetConnection in the given netConnections
func (*NetAdapter) Connect ¶
func (na *NetAdapter) Connect(address string) error
Connect tells the NetAdapter's underlying server to initiate a connection to the given address
func (*NetAdapter) ConnectionCount ¶
func (na *NetAdapter) ConnectionCount() int
ConnectionCount returns the count of the connected connections
func (*NetAdapter) Connections ¶
func (na *NetAdapter) Connections() []*NetConnection
Connections returns a list of connections currently connected and active
func (*NetAdapter) GetBestLocalAddress ¶
func (na *NetAdapter) GetBestLocalAddress() (*appmessage.NetAddress, error)
GetBestLocalAddress returns the most appropriate local address to use for the given remote address.
func (*NetAdapter) ID ¶
func (na *NetAdapter) ID() *id.ID
ID returns this netAdapter's ID in the network
func (*NetAdapter) SetRouterInitializer ¶
func (na *NetAdapter) SetRouterInitializer(routerInitializer RouterInitializer)
SetRouterInitializer sets the routerInitializer function for the net adapter
func (*NetAdapter) Start ¶
func (na *NetAdapter) Start() error
Start begins the operation of the NetAdapter
type NetConnection ¶
type NetConnection struct {
// contains filtered or unexported fields
}
NetConnection is a wrapper to a server connection for use by services external to NetAdapter
func (*NetConnection) Address ¶
func (c *NetConnection) Address() string
Address returns the address associated with this connection
func (*NetConnection) DequeueInvalidMessage ¶
func (c *NetConnection) DequeueInvalidMessage() (isOpen bool, err error)
DequeueInvalidMessage dequeues the next invalid message
func (*NetConnection) Disconnect ¶
func (c *NetConnection) Disconnect()
Disconnect disconnects the given connection
func (*NetConnection) ID ¶
func (c *NetConnection) ID() *id.ID
ID returns the ID associated with this connection
func (*NetConnection) IsOutbound ¶
func (c *NetConnection) IsOutbound() bool
IsOutbound returns whether the connection is outbound
func (*NetConnection) NetAddress ¶
func (c *NetConnection) NetAddress() *appmessage.NetAddress
NetAddress returns the NetAddress associated with this connection
func (*NetConnection) SetID ¶
func (c *NetConnection) SetID(peerID *id.ID)
SetID sets the ID associated with this connection
func (*NetConnection) String ¶
func (c *NetConnection) String() string
type RouterInitializer ¶
type RouterInitializer func(*routerpkg.Router, *NetConnection)
RouterInitializer is a function that initializes a new router to be used with a new connection