net_packet

package
v0.0.0-...-bd0de05 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PACKET_ID_SIZE     = 4
	PACKET_LENGTH_SIZE = 2
	PACKET_LIMIT       = 8192
)

Variables

This section is empty.

Functions

func EncodeNetPacket

func EncodeNetPacket(id uint32, data []byte) []byte

编码

func WritePacket

func WritePacket(netPackets []*NetPacket) (bodyList [][]byte)

合并包(封装数据包)

Types

type NetPacket

type NetPacket struct {
	Id     uint32
	Length int
	Body   []byte
}

func DecodeNetPacket

func DecodeNetPacket(body []byte) (*NetPacket, error)

解码

func ReadPacket

func ReadPacket(netData []byte) (netPackets []*NetPacket, err error)

读取数据包

type NetPacketPool

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

func GetPool

func GetPool() *NetPacketPool

func (*NetPacketPool) Get

func (p *NetPacketPool) Get() *NetPacket

func (*NetPacketPool) Init

func (p *NetPacketPool) Init()

func (*NetPacketPool) Put

func (p *NetPacketPool) Put(netData *NetPacket)

Jump to

Keyboard shortcuts

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