From 7a2c11d92e394fe7138dd3a6537f11d377797e7a Mon Sep 17 00:00:00 2001 From: by <123456@qq.com> Date: Fri, 16 Aug 2024 09:10:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A8=83=E5=A8=83=E6=9C=BA=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machine/action/action_server.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/machine/action/action_server.go b/machine/action/action_server.go index 373f439..68ad3b6 100644 --- a/machine/action/action_server.go +++ b/machine/action/action_server.go @@ -3,6 +3,7 @@ package action import ( "bytes" "fmt" + "math" "mongo.games.com/game/machine/machinedoll" "mongo.games.com/game/protocol/machine" "mongo.games.com/goserver/core/logger" @@ -169,7 +170,7 @@ func SMDollMachineGrabHandler(session *netlib.Session, packetId int, data interf // 监听抓取结果返回 func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid, id int32) { - num := 1 + num := int64(1) for { // 读取数据 fmt.Println("监听抓取结果返回!") @@ -179,12 +180,6 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid fmt.Println("Failed to read response from client:", err) return } - if n != 0 && num == 1 { - num += 1 - fmt.Println("清除脏数据!!!!!!!!!!!!!buf = ", buf[:n]) - continue - } - num++ // 将读取到的数据按照 221 进行分割 parts := bytes.Split(buf[:n], []byte{221}) fmt.Println("获取到的返回值:", parts) @@ -195,7 +190,7 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid if len(part) > 0 { part = part[:len(part)-1] // 去除最后一个字节,该字节为分隔符 fmt.Println("比较返回结果 part = ", part) - if bytes.Contains(part, instruction) { + if bytes.Contains(part, instruction) && num != 1 { fmt.Printf("Part %d: %s\n", i+1, part) //回应数据 _, err = conn.Write([]byte{0xAA, 0x04, 0x01, 0x50, 0x09, 0x5c, 0xdd}) @@ -213,7 +208,7 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid conn.SetDeadline(time.Time{}) return } - if bytes.Contains(part, instruction1) { + if bytes.Contains(part, instruction1) && num != 1 { fmt.Printf("Part %d: %s\n", i+1, part) //回应数据 _, err = conn.Write([]byte{0xAA, 0x04, 0x01, 0x50, 0x09, 0x5c, 0xdd}) @@ -257,6 +252,10 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid } } } + num++ + if num >= math.MaxInt64 { + num = 2 + } } }