packet

package
v0.0.0-...-58652bc Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMagicNumber uint8 = 110

Variables

This section is empty.

Functions

func Encode

func Encode(pkt *Packet) ([]byte, error)

Encode parse a packet to []byte.

func GenUniqSeq

func GenUniqSeq() uint32

GenUniqSeq generate a new unique sequence id

Types

type Packet

type Packet struct {
	Header  header
	Payload []byte // NUL-padded string
}

Packet is the holder of structured message.

func Decode

func Decode(r io.Reader) (*Packet, error)

Decode reads a packet from reader.

func NewPacket

func NewPacket() *Packet

func NewRequestPacket

func NewRequestPacket(payload []byte) *Packet

func Parse

func Parse(message []byte) (*Packet, error)

func (*Packet) ID

func (pkt *Packet) ID() uint64

ID return the ID from packet.

type PacketType

type PacketType uint8
const (
	PacketTypeRequest PacketType = iota
	PacketTypeResponse
	PacketTypeNotice
)

Jump to

Keyboard shortcuts

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