This commit is contained in:
bense
2022-05-14 13:20:18 +08:00
parent 562d11daaf
commit 13073cd8e4
12 changed files with 129 additions and 77 deletions

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"encoding/binary"
"encoding/hex"
"fmt"
)
type GetHistoryMinuteTimeData struct {
@@ -77,7 +76,6 @@ func (obj *GetHistoryMinuteTimeData) Serialize() ([]byte, error) {
///20150520\t4.756000\t4.850000\t4.960000\t4.756000\t353161092\t1722953216.000000”
func (obj *GetHistoryMinuteTimeData) UnSerialize(header interface{}, data []byte) error {
obj.respHeader = header.(*RespHeader)
fmt.Println(hex.EncodeToString(data))
pos := 0
err := binary.Read(bytes.NewBuffer(data[pos:pos+2]), binary.LittleEndian, &obj.reply.Count)

View File

@@ -89,8 +89,6 @@ func (obj *GetIndexBars) Serialize() ([]byte, error) {
func (obj *GetIndexBars) UnSerialize(header interface{}, data []byte) error {
obj.respHeader = header.(*RespHeader)
fmt.Println(hex.EncodeToString(data))
pos := 0
err := binary.Read(bytes.NewBuffer(data[pos:pos+2]), binary.LittleEndian, &obj.reply.Count)
pos += 2

View File

@@ -6,7 +6,6 @@ import (
"bytes"
"encoding/binary"
"encoding/hex"
"fmt"
)
type GetMinuteTimeData struct {
@@ -79,7 +78,7 @@ func (obj *GetMinuteTimeData) Serialize() ([]byte, error) {
///20150520\t4.756000\t4.850000\t4.960000\t4.756000\t353161092\t1722953216.000000”
func (obj *GetMinuteTimeData) UnSerialize(header interface{}, data []byte) error {
obj.respHeader = header.(*RespHeader)
fmt.Println(hex.EncodeToString(data))
pos := 0
err := binary.Read(bytes.NewBuffer(data[pos:pos+2]), binary.LittleEndian, &obj.reply.Count)
// 跳过4个字节

View File

@@ -41,8 +41,8 @@ func (obj *GetSecurityCount) SetParams(req *GetSecurityCountRequest) {
}
func (obj *GetSecurityCount) Serialize() ([]byte, error) {
obj.reqHeader.PkgLen1 = 2 + uint16(len(obj.contentHex)) + 2
obj.reqHeader.PkgLen2 = 2 + uint16(len(obj.contentHex)) + 2
obj.reqHeader.PkgLen1 = 2 + 4 + 2
obj.reqHeader.PkgLen2 = 2 + 4 + 2
buf := new(bytes.Buffer)
err := binary.Write(buf, binary.LittleEndian, obj.reqHeader)

View File

@@ -3,7 +3,7 @@ package proto
import (
"bytes"
"encoding/binary"
"gotdx/utils"
"gotdx/util"
)
type GetSecurityList struct {
@@ -88,7 +88,7 @@ func (obj *GetSecurityList) UnSerialize(header interface{}, data []byte) error {
binary.Read(bytes.NewBuffer(data[pos:pos+8]), binary.LittleEndian, &name)
pos += 8
ele.Code = utils.Utf8ToGbk(name[:])
ele.Code = util.Utf8ToGbk(name[:])
pos += 4
binary.Read(bytes.NewBuffer(data[pos:pos+1]), binary.LittleEndian, &ele.DecimalPoint)

View File

@@ -5,7 +5,7 @@ import (
"encoding/binary"
"encoding/hex"
"fmt"
"gotdx/utils"
"gotdx/util"
)
type GetSecurityQuotes struct {
@@ -146,7 +146,7 @@ func (obj *GetSecurityQuotes) UnSerialize(header interface{}, data []byte) error
binary.Read(bytes.NewBuffer(data[pos:pos+6]), binary.LittleEndian, &code)
//enc := mahonia.NewDecoder("gbk")
//ele.Code = enc.ConvertString(string(code[:]))
ele.Code = utils.Utf8ToGbk(code[:])
ele.Code = util.Utf8ToGbk(code[:])
pos += 6
binary.Read(bytes.NewBuffer(data[pos:pos+2]), binary.LittleEndian, &ele.Active1)
pos += 2

View File

@@ -4,7 +4,7 @@ import (
"bytes"
"encoding/binary"
"encoding/hex"
"gotdx/utils"
"gotdx/util"
)
type Hello1 struct {
@@ -59,7 +59,7 @@ func (obj *Hello1) Serialize() ([]byte, error) {
func (obj *Hello1) UnSerialize(header interface{}, data []byte) error {
obj.respHeader = header.(*RespHeader)
serverInfo := utils.Utf8ToGbk(data[68:])
serverInfo := util.Utf8ToGbk(data[68:])
obj.reply.Info = serverInfo
return nil

View File

@@ -4,7 +4,7 @@ import (
"bytes"
"encoding/binary"
"encoding/hex"
"gotdx/utils"
"gotdx/util"
)
type Hello2 struct {
@@ -57,7 +57,7 @@ func (obj *Hello2) Serialize() ([]byte, error) {
func (obj *Hello2) UnSerialize(header interface{}, data []byte) error {
obj.respHeader = header.(*RespHeader)
serverInfo := utils.Utf8ToGbk(data[58:])
serverInfo := util.Utf8ToGbk(data[58:])
//fmt.Println(hex.EncodeToString(data))
obj.reply.Info = serverInfo
return nil