1 Star 0 Fork 40

peng2289/go808

forked from coco/go808 
Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
t808_0x8603.go 814 Bytes
Copy Edit Raw Blame History
Your Name authored 2020-04-07 18:27 +08:00 . 添加详细注释
package protocol
// 删除矩形区域
type T808_0x8603 struct {
// 区域ID列表
IDs []uint32
}
func (entity *T808_0x8603) MsgID() MsgID {
return MsgT808_0x8603
}
func (entity *T808_0x8603) Encode() ([]byte, error) {
writer := NewWriter()
// 写入ID总数
writer.WriteByte(byte(len(entity.IDs)))
// 写入ID列表
for _, id := range entity.IDs {
writer.WriteUint32(id)
}
return writer.Bytes(), nil
}
func (entity *T808_0x8603) Decode(data []byte) (int, error) {
if len(data) < 1 {
return 0, ErrInvalidBody
}
count := int(data[0])
reader := NewReader(data[1:])
entity.IDs = make([]uint32, 0, count)
for i := 0; i < count; i++ {
id, err := reader.ReadUint32()
if err != nil {
return 0, err
}
entity.IDs = append(entity.IDs, id)
}
return len(data) - reader.Len() - 1, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/oco/go808.git
git@gitee.com:oco/go808.git
oco
go808
go808
32b1471f79b9

Search