1 Star 0 Fork 40

peng2289/go808

forked from coco/go808 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
t808_0x0102.go 666 Bytes
一键复制 编辑 原始数据 按行查看 历史
Your Name 提交于 2020-04-07 18:27 +08:00 . 添加详细注释
package protocol
// 终端鉴权
type T808_0x0102 struct {
// 鉴权码
AuthKey string
}
func (entity *T808_0x0102) MsgID() MsgID {
return MsgT808_0x0102
}
func (entity *T808_0x0102) Encode() ([]byte, error) {
writer := NewWriter()
if len(entity.AuthKey) > 0 {
if err := writer.WritString(entity.AuthKey); err != nil {
return nil, err
}
}
return writer.Bytes(), nil
}
func (entity *T808_0x0102) Decode(data []byte) (int, error) {
if len(data) == 0 {
return 0, ErrInvalidBody
}
reader := NewReader(data)
authKey, err := reader.ReadString()
if err != nil {
return 0, err
}
entity.AuthKey = authKey
return len(data) - reader.Len(), nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/oco/go808.git
git@gitee.com:oco/go808.git
oco
go808
go808
32b1471f79b9

搜索帮助