net

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NetBufferSize = 2048
View Source
var NetChannelSize = 10
View Source
var NetDataShards = 10
View Source
var NetParityShards = 3

Functions

func RegisterMessage

func RegisterMessage(m Message)

Types

type Event

type Event interface {
}

type EventClosed

type EventClosed struct {
}

type EventConnect

type EventConnect struct {
	ID   uint32
	Peer *Peer
}

type EventDisconnect

type EventDisconnect struct {
	ID   uint32
	Peer *Peer
}

type EventHosting

type EventHosting struct {
}

type EventJoined

type EventJoined struct {
}

type EventJoining

type EventJoining struct {
}

type EventMessage

type EventMessage struct {
	ID      uint32
	Peer    *Peer
	Message Message
}

type Message

type Message interface {
	Ident() uint8
	ToBytes() []byte
	FromBytes(b []byte) (Message, int)
}

func MessageFromBytes

func MessageFromBytes(b []byte) (Message, int)

type MessageClose

type MessageClose struct {
}

func (MessageClose) FromBytes

func (m MessageClose) FromBytes(b []byte) (Message, int)

func (MessageClose) Ident

func (m MessageClose) Ident() uint8

func (MessageClose) ToBytes

func (m MessageClose) ToBytes() []byte

type MessageID

type MessageID struct {
	ID uint32
}

func (MessageID) FromBytes

func (m MessageID) FromBytes(b []byte) (Message, int)

func (MessageID) Ident

func (m MessageID) Ident() uint8

func (MessageID) ToBytes

func (m MessageID) ToBytes() (b []byte)

func (MessageID) Type

func (m MessageID) Type() string

type MessageRaw

type MessageRaw struct {
	Data []byte
}

func (MessageRaw) FromBytes

func (m MessageRaw) FromBytes(b []byte) (Message, int)

func (MessageRaw) Ident

func (m MessageRaw) Ident() uint8

func (MessageRaw) ToBytes

func (m MessageRaw) ToBytes() (b []byte)

type Packet

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

type Peer

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

func NewPeer

func NewPeer(addr *net.UDPAddr, conn *net.UDPConn) *Peer

func (*Peer) Close

func (p *Peer) Close() error

Close closes the peer connection. (it actually does nothing!)

func (*Peer) ID

func (p *Peer) ID() uint32

func (*Peer) LocalAddr

func (p *Peer) LocalAddr() net.Addr

LocalAddr returns the connection's local address.

func (*Peer) ReadFrom

func (p *Peer) ReadFrom(b []byte) (n int, addr net.Addr, err error)

ReadFrom is used to read from the peer's virtual packet buffer.

func (*Peer) Send

func (p *Peer) Send(msg Message) error

Send sends a Payload to the given peer.

func (*Peer) SetDeadline

func (p *Peer) SetDeadline(t time.Time) error

SetDeadline does nothing.

func (*Peer) SetReadDeadline

func (p *Peer) SetReadDeadline(t time.Time) error

SetReadDeadline does nothing.

func (*Peer) SetWriteDeadline

func (p *Peer) SetWriteDeadline(t time.Time) error

SetWriteDeadline does nothing.

func (*Peer) WriteTo

func (p *Peer) WriteTo(b []byte, addr net.Addr) (n int, err error)

WriteTo writes the bytes to the given address.

type PeerPacket

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

type ServerClient

type ServerClient struct {

	//
	Matchmaker string

	UseMatchmaker bool
	Hosting       bool
	Running       bool

	EventChan chan Event
	// contains filtered or unexported fields
}

func (*ServerClient) Close

func (s *ServerClient) Close()

func (*ServerClient) ConnectTo

func (s *ServerClient) ConnectTo(address string) error

func (*ServerClient) ID

func (s *ServerClient) ID() uint32

func (*ServerClient) Init

func (s *ServerClient) Init()

func (*ServerClient) LogicLoop

func (s *ServerClient) LogicLoop()

LogicLoop is the main logic loop that handles raw packets and otherwise.

func (*ServerClient) Open

func (s *ServerClient) Open(address string) error

func (*ServerClient) Peers

func (s *ServerClient) Peers() []*Peer

func (*ServerClient) ReadLoop

func (s *ServerClient) ReadLoop()

ReadLoop runs the network read loop, handling new connections as necessary.

Jump to

Keyboard shortcuts

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