Documentation
¶
Overview ¶
Package codec 提供 GAP 消息包的编解码能力。
这个包位于 GAP 协议的线格式层,负责把 gap.MsgPacket 编码为字节流, 并在接收侧把字节流还原为对应的消息包对象。
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrDecode 是 GAP 消息包解码错误的根错误。 ErrDecode = errors.New("gap-decode") )
View Source
var ( // ErrEncode 是 GAP 消息包编码错误的根错误。 ErrEncode = errors.New("gap-encode") )
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder struct {
MsgCreator gap.IMsgCreator // 用于构造消息体的消息构建器。
}
Decoder 根据消息头中的类型 ID 构造并解码消息体。
func NewDecoder ¶ added in v0.3.35
func NewDecoder(msgCreator gap.IMsgCreator) *Decoder
NewDecoder 创建使用指定消息构建器的解码器;构建器不得为 nil。
Click to show internal directories.
Click to hide internal directories.