zpack

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Factory

func Factory() *pack_factory

Factory Generates different packaging and unpackaging methods, singleton

(生成不同封包解包的方式,单例)

func NewDataPack

func NewDataPack() ziface.IDataPack

NewDataPack initializes a packing and unpacking instance (封包拆包实例初始化方法)

func NewDataPackLtv

func NewDataPackLtv() ziface.IDataPack

NewDataPackLtv initializes a packing and unpacking instance (封包拆包实例初始化方法)

Types

type DataPack

type DataPack struct{}

func (*DataPack) GetHeadLen

func (dp *DataPack) GetHeadLen() uint32

GetHeadLen returns the length of the message header (获取包头长度方法)

func (*DataPack) Pack

func (dp *DataPack) Pack(msg ziface.IMessage) ([]byte, error)

Pack packs the message (compresses the data) (封包方法,压缩数据)

func (*DataPack) Unpack

func (dp *DataPack) Unpack(binaryData []byte) (ziface.IMessage, error)

Unpack unpacks the message (decompresses the data) (拆包方法,解压数据)

type DataPackLtv

type DataPackLtv struct{}

DataPackLtv LTV little-endian data packing and unpacking used by Zinx in its early days, compatible with previous applications (Zinx早期使用的LTV 小端方式,兼容之前的应用)

func (*DataPackLtv) GetHeadLen

func (dp *DataPackLtv) GetHeadLen() uint32

GetHeadLen returns the length of the message header (获取包头长度方法)

func (*DataPackLtv) Pack

func (dp *DataPackLtv) Pack(msg ziface.IMessage) ([]byte, error)

Pack packs the message (compresses the data) (封包方法,压缩数据)

func (*DataPackLtv) Unpack

func (dp *DataPackLtv) Unpack(binaryData []byte) (ziface.IMessage, error)

Unpack unpacks the message (decompresses the data) (拆包方法,解压数据)

type Message

type Message struct {
	DataLen uint32 // Length of the message
	ID      uint32 // ID of the message
	Data    []byte // Content of the message
	// contains filtered or unexported fields
}

Message structure for messages

func NewMessage

func NewMessage(len uint32, data []byte) *Message

func NewMessageByMsgId

func NewMessageByMsgId(id uint32, len uint32, data []byte) *Message

func NewMsgPackage

func NewMsgPackage(ID uint32, data []byte) *Message

func (*Message) GetData

func (msg *Message) GetData() []byte

func (*Message) GetDataLen

func (msg *Message) GetDataLen() uint32

func (*Message) GetMsgID

func (msg *Message) GetMsgID() uint32

func (*Message) GetRawData

func (msg *Message) GetRawData() []byte

func (*Message) Init

func (msg *Message) Init(ID uint32, data []byte)

func (*Message) SetData

func (msg *Message) SetData(data []byte)

func (*Message) SetDataLen

func (msg *Message) SetDataLen(len uint32)

func (*Message) SetMsgID

func (msg *Message) SetMsgID(msgID uint32)

Jump to

Keyboard shortcuts

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