pack

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWrongMagicNumber  = errors.New("vex: wrong magic number")
	ErrReadSizeMismatch  = errors.New("vex: read size != expected size")
	ErrWriteSizeMismatch = errors.New("vex: write size != expected size")
)
View Source
var (
	Endian = binary.BigEndian
)

Functions

func Send

func Send(client vex.Client, packetType PacketType, requestPacket []byte) (responsePacket []byte, err error)

Send sends a packet to server and gets a packet responded from server.

Types

type PacketHandler

type PacketHandler func(ctx context.Context, packetType PacketType, requestPacket []byte) (responsePacket []byte, err error)

PacketHandler is a handler for handling packets. You will receive a byte slice of request and should return a byte slice or error if necessary.

type PacketType

type PacketType = byte

PacketType is the type of packet.

type Router

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

func NewRouter

func NewRouter() *Router

NewRouter creates a router for registering some packet handlers.

func (*Router) Handle

func (r *Router) Handle(ctx *vex.Context)

Handle handles context of vex, and you can pass it to a server.

func (*Router) Register

func (r *Router) Register(packetType PacketType, handler PacketHandler)

Register registers a packet handler to router.

Jump to

Keyboard shortcuts

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