netadapter

package
v0.0.0-...-6e9d532 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: ISC Imports: 11 Imported by: 0

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) ID

func (na *NetAdapter) ID() *id.ID

ID returns this netAdapter's ID in the network

func (*NetAdapter) P2PBroadcast

func (na *NetAdapter) P2PBroadcast(netConnections []*NetConnection, message appmessage.Message) error

P2PBroadcast sends the given `message` to every peer corresponding to each NetConnection in the given netConnections

func (*NetAdapter) P2PConnect

func (na *NetAdapter) P2PConnect(address string) error

P2PConnect tells the NetAdapter's underlying p2p server to initiate a connection to the given address

func (*NetAdapter) P2PConnectionCount

func (na *NetAdapter) P2PConnectionCount() int

P2PConnectionCount returns the count of the connected p2p connections

func (*NetAdapter) P2PConnections

func (na *NetAdapter) P2PConnections() []*NetConnection

P2PConnections returns a list of p2p connections currently connected and active

func (*NetAdapter) SetP2PRouterInitializer

func (na *NetAdapter) SetP2PRouterInitializer(routerInitializer RouterInitializer)

SetP2PRouterInitializer sets the p2pRouterInitializer function for the net adapter

func (*NetAdapter) SetRPCRouterInitializer

func (na *NetAdapter) SetRPCRouterInitializer(routerInitializer RouterInitializer)

SetRPCRouterInitializer sets the rpcRouterInitializer 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) 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) SetOnInvalidMessageHandler

func (c *NetConnection) SetOnInvalidMessageHandler(onInvalidMessageHandler server.OnInvalidMessageHandler)

SetOnInvalidMessageHandler sets the invalid message handler for 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