msg

package
v0.0.0-...-2692626 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const GProtoHeadLength uint32 = 8

GProtoHeadLength 包头长度

Variables

This section is empty.

Functions

This section is empty.

Types

type Header struct {
	MessageID uint32 //消息号
	ResultID  uint32 //结果id
}

Header 协议包头

func (*Header) Marshal

func (p *Header) Marshal() []byte

func (*Header) String

func (p *Header) String() string

func (*Header) Unmarshal

func (p *Header) Unmarshal(data []byte)

type Packet

type Packet struct {
	Header  Header
	Message proto.Message // Marshal 时候使用
}

Packet 协议包

func NewPacket

func NewPacket(messageID uint32, resultID uint32, message proto.Message) *Packet

func (*Packet) Marshal

func (p *Packet) Marshal() ([]byte, error)

Marshal 序列化 数据包

func (*Packet) Unmarshal

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

Unmarshal 反序列化 data:完整包数据 包头+包体

Jump to

Keyboard shortcuts

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