From c88f32cea3ea5b5cc673a513832fc7e3276be4bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 30 Dec 2022 09:34:46 +0800 Subject: [PATCH] 1 --- business/jxstore/event/event_tcp.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/business/jxstore/event/event_tcp.go b/business/jxstore/event/event_tcp.go index ca7e062b0..eba061080 100644 --- a/business/jxstore/event/event_tcp.go +++ b/business/jxstore/event/event_tcp.go @@ -2,6 +2,7 @@ package event import ( "encoding/hex" + "encoding/json" "fmt" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/model" @@ -55,11 +56,16 @@ func (t *TcpClient) handleConn(c net.Conn) { //看是心跳还是打印回调 data := hex.EncodeToString(buffer[:n]) - globals.SugarLogger.Debugf("====================data %s", data) - globals.SugarLogger.Debugf("====================data %s", string(buffer[:n])) - if strings.Contains(string(buffer[0:n]), "print_no") { - _, err := c.Write([]byte("ok")) - globals.SugarLogger.Debugf("errr %v", err) + if strings.Contains(string(buffer[0:n]), "print_no") { // 清理缓存 + param := struct { + PrintNo string `json:"print_no"` + }{} + if err := json.Unmarshal(buffer[0:n], ¶m); err != nil { + c.Write([]byte("err Unmarshal")) + return + } + t.buildMsgMap(param.PrintNo) + c.Write([]byte("ok")) return } //证明是心跳