connection

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDelimiter = 0x00

Variables

This section is empty.

Functions

func Address

func Address(host string, port uint16) string

func AppendDelimeter

func AppendDelimeter(raw []byte) []byte

func GetIdFromAddr

func GetIdFromAddr(addr *net.Addr) int

func GetIdFromConn

func GetIdFromConn(conn *net.Conn) int

func GetTcpAddress

func GetTcpAddress(host string,
	port uint16) (addr *net.TCPAddr, err error)

func GetUdpAddress

func GetUdpAddress(host string,
	port uint16) (addr *net.UDPAddr, err error)

func GetUnixAddress

func GetUnixAddress(host string,
	port uint16) (addr *net.UnixAddr, err error)

func TruncateDelimeter

func TruncateDelimeter(raw []byte) []byte

Types

type Event

type Event struct {
	Id int
	EventType
}

type EventType

type EventType int
const (
	DISCONNECTED EventType = 0
	CONNECTED    EventType = 1
	ERROR        EventType = -1
)

type EventsToChannel

type EventsToChannel struct {
	// contains filtered or unexported fields
}

func NewEventsToChannel

func NewEventsToChannel(messageChannel chan<- Message,
	eventChannel chan<- Event) *EventsToChannel

func (*EventsToChannel) Connected

func (e2c *EventsToChannel) Connected(id int)

func (*EventsToChannel) Disconnected

func (e2c *EventsToChannel) Disconnected(id int)

func (*EventsToChannel) Received

func (e2c *EventsToChannel) Received(id int, message []byte)

type Handler

type Handler interface {
	Connected(id int)
	Received(id int, message []byte)
	Disconnected(id int)
}

type Message

type Message struct {
	Id      int
	Content []byte
}

type Protocol

type Protocol string
const (
	Tcp  Protocol = "tcp"
	Udp  Protocol = "udp"
	Tls  Protocol = "tls"
	Unix Protocol = "unix"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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