mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
拆分不同类型到不同的文件
This commit is contained in:
52
protocol/model_connect.go
Normal file
52
protocol/model_connect.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package protocol
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var (
|
||||
MConnect = connect{}
|
||||
MHeart = heart{}
|
||||
MStockCount = stockCount{}
|
||||
MStockQuote = stockQuote{}
|
||||
MStockList = stockList{}
|
||||
MStockMinute = stockMinute{}
|
||||
MStockMinuteTrade = stockMinuteTrade{}
|
||||
)
|
||||
|
||||
type ConnectResp struct {
|
||||
Info string
|
||||
}
|
||||
|
||||
type connect struct{}
|
||||
|
||||
func (connect) Frame() *Frame {
|
||||
return &Frame{
|
||||
Control: Control01,
|
||||
Type: TypeConnect,
|
||||
Data: []byte{0x01},
|
||||
}
|
||||
}
|
||||
|
||||
func (connect) Decode(bs []byte) (*ConnectResp, error) {
|
||||
if len(bs) < 68 {
|
||||
return nil, errors.New("数据长度不足")
|
||||
}
|
||||
//前68字节暂时还不知道是什么
|
||||
return &ConnectResp{Info: string(UTF8ToGBK(bs[68:]))}, nil
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
type heart struct{}
|
||||
|
||||
func (this *heart) Frame() *Frame {
|
||||
return &Frame{
|
||||
Control: Control01,
|
||||
Type: TypeHeart,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user