This commit is contained in:
邹宗楠
2026-05-11 10:03:21 +08:00
parent 040f0b7d8d
commit 35c8468789
3 changed files with 9 additions and 8 deletions

View File

@@ -386,11 +386,11 @@ func DoPrintMsg(appID int, msgID, printNo, content string, orderNo string) (err
Status: event.PrintMsgWait, Status: event.PrintMsgWait,
} }
t, ok := event.TcpClientList[printNo] t, ok := event.TcpClientList.Load(printNo)
if ok { if ok {
t.Lock() t.(*event.TcpClient).Lock()
defer t.Unlock() defer t.(*event.TcpClient).Unlock()
t.MsgMap[printNo] <- printMsg t.(*event.TcpClient).MsgMap[printNo] <- printMsg
printMsg.Status = event.PrintMsgAlreadyLoad printMsg.Status = event.PrintMsgAlreadyLoad
} /*else { } /*else {
t = event.NewTcpClient() t = event.NewTcpClient()

View File

@@ -88,11 +88,11 @@ func handleConn(c net.Conn) error {
callback = true callback = true
} }
if _, have := TcpClientList[printNo]; !have { if value, have := TcpClientList.Load(printNo); !have {
t = NewTcpClient() t = NewTcpClient()
TcpClientList[printNo] = t TcpClientList.Store(printNo, t)
} else { } else {
t = TcpClientList[printNo] t = value.(*TcpClient)
} }
if heartbeat { if heartbeat {
// 证明是心跳 // 证明是心跳

View File

@@ -17,7 +17,7 @@ import (
"unicode/utf8" "unicode/utf8"
) )
var TcpClientList = make(map[string]*TcpClient, 0) var TcpClientList = new(sync.Map)
const ( const (
heartText = "1e000f02000151" // 老版心跳 heartText = "1e000f02000151" // 老版心跳
@@ -843,6 +843,7 @@ func HandleCheckTcpHeart(t *TcpClient, key string) {
close(t.CallBackMap[key]) close(t.CallBackMap[key])
//t.delConn(key) //t.delConn(key)
t.clear(key) t.clear(key)
TcpClientList.Delete(key)
return return
} }
} }