netadapter

package
v0.6.4-rc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2020 License: ISC Imports: 14 Imported by: 10

Documentation

Index

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

func (*NetAdapter) Stop

func (na *NetAdapter) Stop() error

Stop safely closes 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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL