packet

package
v0.0.0-...-9debb76 Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterInbound

func RegisterInbound(state protocol.State, id uint, supplier func() Inbound)

RegisterInbound registers a supplier function that creates an Inbound packet for a specific protocol.State and id.

Types

type Inbound

type Inbound interface {
	UnmarshalPacket(r protocol.Reader) error
}

Inbound represents a packet sent from the client.

type Outbound

type Outbound interface {
	PacketID() uint
	MarshalPacket(w protocol.Writer) error
}

Outbound represents a packet sent from the server.

type Reader

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

Reader is used to read packets.

func NewReader

func NewReader(r io.Reader, cfg ReaderConfig) *Reader

NewReader constructs a new Reader that reads from the provided io.Reader.

func (*Reader) ReadPacket

func (r *Reader) ReadPacket(state protocol.State) (pk Inbound, err error)

ReadPacket reads a single packet. It returns nil for unknown packets.

type ReaderConfig

type ReaderConfig struct {
	// MaxSize is the maximum size in Bytes per packet. Larger packets will be rejected.
	MaxSize int
}

ReaderConfig is used to configure settings for a Reader.

type Writer

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

Writer is used to write packets.

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter constructs a new Writer.

func (*Writer) Flush

func (w *Writer) Flush() error

Writes the internal buffer to the io.Writer that was used to construct this Writer.

func (*Writer) WritePacket

func (w *Writer) WritePacket(pk Outbound) error

WritePacket adds a single packet to the internal buffer, which will be written the next time that Flush is called.

Directories

Path Synopsis
inbound
outbound

Jump to

Keyboard shortcuts

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