server

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: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNetwork = errors.New("network error")

ErrNetwork is an error related to the internals of the connection, and not an error that came from outside (e.g. from OnDisconnectedHandler).

Functions

This section is empty.

Types

type Connection

type Connection interface {
	fmt.Stringer
	Start(router *router.Router)
	Disconnect()
	IsConnected() bool
	IsOutbound() bool
	SetOnDisconnectedHandler(onDisconnectedHandler OnDisconnectedHandler)
	SetOnInvalidMessageHandler(onInvalidMessageHandler OnInvalidMessageHandler)
	Address() *net.TCPAddr
}

Connection represents a p2p server connection.

type OnConnectedHandler

type OnConnectedHandler func(connection Connection) error

OnConnectedHandler is a function that is to be called once a new Connection is successfully established.

type OnDisconnectedHandler

type OnDisconnectedHandler func()

OnDisconnectedHandler is a function that is to be called once a Connection has been disconnected.

type OnInvalidMessageHandler

type OnInvalidMessageHandler func(err error)

OnInvalidMessageHandler is a function that is to be called when an invalid message (cannot be parsed/doesn't have a route) was received from a connection.

type Server

type Server interface {
	Connect(address string) (Connection, error)
	Start() error
	Stop() error
	SetOnConnectedHandler(onConnectedHandler OnConnectedHandler)
}

Server represents a p2p server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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