net

package
v0.0.0-...-ad164ee Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnouncePacket

type AnnouncePacket struct {
	Packet
	Identity
	ConnectedNodes map[string]interface{}
}

AnnouncePacket contains information about the current node to send to other nodes

type Identity

type Identity struct {
	NodeName string
	Addr     string
}

Identity contains information to identify a struct

type Interface

type Interface struct {
	ErrChan     chan<- error
	MessageChan <-chan interface{}
	// contains filtered or unexported fields
}

Interface maintains connectivity with the mesh network, and provides functions for sending and receiving on the network. TODO: function for sending to addr, send to node name receive from node, receive from all

func NewInterface

func NewInterface(nodeName string, dataReceive udp.NetReader, announceSend udp.NetWriter, announceReceive udp.NetReader, settings InterfaceSettings) (*Interface, error)

NewInterface creates a net interface. addr must be of form ip:port. returns error if udp address resolution fails.

func (*Interface) Close

func (n *Interface) Close()

Close stops the announce daemon and closes all open connections and channels

func (*Interface) StartAnnounce

func (n *Interface) StartAnnounce()

StartAnnounce starts announcing the node to the network

type InterfaceSettings

type InterfaceSettings struct {
	AnnounceInterval time.Duration
}

InterfaceSettings contains settings for the net interface

type NodeInfo

type NodeInfo struct {
	NodeName string
	Addr     string
	Latency  latency
	// contains filtered or unexported fields
}

NodeInfo contains information about a discovered network node

type Packet

type Packet struct {
	SequenceNum uint16
}

Packet is the basic packet struct

Jump to

Keyboard shortcuts

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