discovery

package
v0.0.0-...-8e0772f Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IDRequestPacket uint16 = iota
	IDResponsePacket
	IDMessagePacket
)

Variables

This section is empty.

Functions

func Marshal

func Marshal(pk Packet, senderID uint64) []byte

Types

type Header struct {
	PacketID uint16
	SenderID uint64
}

func (*Header) Read

func (h *Header) Read(r io.Reader) error

func (*Header) Write

func (h *Header) Write(w io.Writer)

type ListenConfig

type ListenConfig struct {
	NetworkID        uint64
	BroadcastAddress net.Addr
	Log              *slog.Logger
}

func (ListenConfig) Listen

func (conf ListenConfig) Listen(network string, addr string) (*Listener, error)

type Listener

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

func (*Listener) Close

func (l *Listener) Close() (err error)

func (*Listener) Credentials

func (l *Listener) Credentials() (*nethernet.Credentials, error)

func (*Listener) PongData

func (l *Listener) PongData(b []byte)

func (*Listener) ReadSignal

func (l *Listener) ReadSignal(cancel <-chan struct{}) (*nethernet.Signal, error)

func (*Listener) ServerData

func (l *Listener) ServerData(d *ServerData)

func (*Listener) WriteSignal

func (l *Listener) WriteSignal(signal *nethernet.Signal) error

type MessagePacket

type MessagePacket struct {
	RecipientID uint64
	Data        string
}

func (*MessagePacket) ID

func (*MessagePacket) ID() uint16

func (*MessagePacket) Read

func (pk *MessagePacket) Read(r io.Reader) error

func (*MessagePacket) Write

func (pk *MessagePacket) Write(w io.Writer)

type Packet

type Packet interface {
	ID() uint16

	Read(r io.Reader) error
	Write(w io.Writer)
}

func Unmarshal

func Unmarshal(b []byte) (Packet, uint64, error)

type RequestPacket

type RequestPacket struct{}

func (*RequestPacket) ID

func (*RequestPacket) ID() uint16

func (*RequestPacket) Read

func (*RequestPacket) Read(io.Reader) error

func (*RequestPacket) Write

func (*RequestPacket) Write(io.Writer)

type ResponsePacket

type ResponsePacket struct {
	ApplicationData []byte
}

func (*ResponsePacket) ID

func (*ResponsePacket) ID() uint16

func (*ResponsePacket) Read

func (pk *ResponsePacket) Read(r io.Reader) error

func (*ResponsePacket) Write

func (pk *ResponsePacket) Write(w io.Writer)

type ServerData

type ServerData struct {
	Version        uint8
	ServerName     string
	LevelName      string
	GameType       int32
	PlayerCount    int32
	MaxPlayerCount int32
	IsEditorWorld  bool
	TransportLayer int32
}

func (*ServerData) MarshalBinary

func (d *ServerData) MarshalBinary() ([]byte, error)

func (*ServerData) UnmarshalBinary

func (d *ServerData) UnmarshalBinary(data []byte) error

Jump to

Keyboard shortcuts

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