拆分不同类型到不同的文件

This commit is contained in:
钱纯净
2024-10-28 22:59:29 +08:00
parent 6ec87de116
commit 9eac8cbc1a
8 changed files with 196 additions and 201 deletions

View File

@@ -0,0 +1,25 @@
package protocol
import "errors"
type StockCountResp struct {
Count uint16
}
type stockCount struct{}
// Frame 0c0200000001080008004e04000075c73301
func (this *stockCount) Frame(exchange Exchange) *Frame {
return &Frame{
Control: Control01,
Type: TypeStockCount,
Data: []byte{exchange.Uint8(), 0x0, 0x75, 0xc7, 0x33, 0x01}, //后面的4字节不知道啥意思
}
}
func (this *stockCount) Decode(bs []byte) (*StockCountResp, error) {
if len(bs) < 2 {
return nil, errors.New("数据长度不足")
}
return &StockCountResp{Count: Uint16(bs)}, nil
}