codec

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VanillaMaximumUncompressedSize = 8 * 1024 * 1024   // 8MiB
	HardMaximumUncompressedSize    = 128 * 1024 * 1024 // 128MiB
	UncompressedCap                = VanillaMaximumUncompressedSize
)

Variables

This section is empty.

Functions

func NewDecryptReader

func NewDecryptReader(r io.Reader, secret []byte) (reader io.Reader, err error)

func NewEncryptWriter

func NewEncryptWriter(w io.Writer, secret []byte) (wr io.Writer, err error)

Types

type Decoder

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

Decoder is a synchronized packet decoder for the Minecraft Java edition.

func NewDecoder

func NewDecoder(r io.Reader, direction proto.Direction, log logr.Logger) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode() (ctx *proto.PacketContext, err error)

Decode reads the next packet from the underlying reader. It blocks other calls to Decode until return.

func (*Decoder) SetCompressionThreshold

func (d *Decoder) SetCompressionThreshold(threshold int)

func (*Decoder) SetProtocol

func (d *Decoder) SetProtocol(protocol proto.Protocol)

func (*Decoder) SetReader

func (d *Decoder) SetReader(rd io.Reader)

func (*Decoder) SetState

func (d *Decoder) SetState(state *state.Registry)

type Encoder

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

Encoder is a synchronized packet encoder.

func NewEncoder

func NewEncoder(w io.Writer, direction proto.Direction, log logr.Logger) *Encoder

func (*Encoder) Direction added in v0.35.0

func (e *Encoder) Direction() proto.Direction

Direction returns the encoder's direction.

func (*Encoder) SetCompression

func (e *Encoder) SetCompression(threshold, level int) (err error)

func (*Encoder) SetProtocol

func (e *Encoder) SetProtocol(protocol proto.Protocol)

func (*Encoder) SetState

func (e *Encoder) SetState(state *state.Registry)

func (*Encoder) SetWriter

func (e *Encoder) SetWriter(w io.Writer)

func (*Encoder) Sync

func (e *Encoder) Sync(fn func() error) error

Sync locks the encoder while running fn, making sure no write calls are run during this call.

func (*Encoder) Write

func (e *Encoder) Write(payload []byte) (n int, err error)

Write encodes payload and writes it to the underlying writer. The payload must not already be compressed nor encrypted and must start with the packet's id VarInt and then the packet's data.

func (*Encoder) WritePacket

func (e *Encoder) WritePacket(packet proto.Packet) (n int, err error)

Jump to

Keyboard shortcuts

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