packets

package
v0.0.0-...-e67ccf8 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMsgTooLong  = errors.New("message too long")
	ErrMsgTooShort = errors.New("message too short")
	ErrHeaderSize  = errors.New("header size can be: 1/2/4/8")
)

Functions

This section is empty.

Types

type IPacket

type IPacket interface {
	Packet(message []byte) (data []byte, err error)
	UnPacket(reader io.Reader) ([]byte, error)
}

func NewPacket

func NewPacket(opts ...Option) IPacket

type Option

type Option func(*Packet)

func WithBigEndian

func WithBigEndian(b bool) Option

func WithDecrypter

func WithDecrypter(decrypter func([]byte) ([]byte, error)) Option

func WithEncrypter

func WithEncrypter(encrypter func([]byte) ([]byte, error)) Option

func WithHeaderSize

func WithHeaderSize(header int) Option

func WithMaxMsgSize

func WithMaxMsgSize(size int) Option

func WithMinMsgSize

func WithMinMsgSize(size int) Option

type Packet

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

func (*Packet) Packet

func (p *Packet) Packet(message []byte) (data []byte, err error)

Packet 封包

func (*Packet) UnPacket

func (p *Packet) UnPacket(reader io.Reader) (b []byte, err error)

UnPacket 拆包

Jump to

Keyboard shortcuts

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