You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
505 B
Go
20 lines
505 B
Go
2 years ago
|
package packet
|
||
|
|
||
|
type (
|
||
|
// IPacket 数据帧
|
||
|
IPacket interface {
|
||
|
GetHeader() interface{} // 数据帧头部 Header
|
||
|
GetLen() uint32 // 数据帧长度 4bytes - 32bit 占位,根据实际情况进行转换
|
||
|
GetBody() []byte // 数据 Body
|
||
|
}
|
||
|
|
||
|
// Packer 数据帧 封包/解包
|
||
|
Packer interface {
|
||
|
// Pack 封包,将原始数据构造为二进制流数据帧
|
||
|
Pack(header interface{}, data []byte) ([]byte, error)
|
||
|
|
||
|
// Unpack 解包
|
||
|
Unpack(data []byte) ([]IPacket, error)
|
||
|
}
|
||
|
)
|