zpack

package
v0.0.0-...-42b4611 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package zpack 封包拆包的实现

Index

Constants

This section is empty.

Variables

View Source
var DataPackInstance ziface.IDataPack

Functions

func NewDataPack

func NewDataPack() ziface.IDataPack

NewDataPack 拆包封包,单例赋值

Types

type DataPack

type DataPack struct {
}

func (*DataPack) GetHeadLen

func (dp *DataPack) GetHeadLen() uint32

GetHeadLen 获取包的头长度

func (*DataPack) Pack

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

Pack 封包

func (*DataPack) Unpack

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

Unpack 拆包

type Message

type Message struct {
	ID      uint32 // 消息的ID
	DataLen uint32 // 消息的长度
	Data    []byte // 消息内容
}

Message 是抽象类IMessage的实现,用于定义在Request中的消息的具体结构 是封包和拆包中,一个包的内容

func (*Message) GetData

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

GetData 获取消息内容

func (*Message) GetDataLen

func (m *Message) GetDataLen() uint32

GetDataLen 获取消息长度

func (*Message) GetMSgID

func (m *Message) GetMSgID() uint32

GetMSgID 获取消息ID

func (*Message) SetData

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

SetData 设置消息内容

func (*Message) SetDataLen

func (m *Message) SetDataLen(dataLen uint32)

SetDataLen 设置消息长度

func (*Message) SetMsgID

func (m *Message) SetMsgID(msgID uint32)

SetMsgID 设置消息ID

Jump to

Keyboard shortcuts

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