This commit is contained in:
suyl
2021-07-14 15:03:51 +08:00
parent 956600b68f
commit 74cd4f6727

View File

@@ -364,12 +364,17 @@ func HandleTcpMessages() {
func HandleCheckTcpHeart() { func HandleCheckTcpHeart() {
for { for {
tcpClient.s.Lock() tcpClient.s.Lock()
for _, v := range tcpClient.Clients { keys := []string{}
for k, v := range tcpClient.Clients {
if time.Now().Sub(v.StatusTime) > time.Minute+time.Second { if time.Now().Sub(v.StatusTime) > time.Minute+time.Second {
v.Status = printerStatusOffline v.Status = printerStatusOffline
keys = append(keys, k)
} }
} }
tcpClient.s.Unlock() tcpClient.s.Unlock()
for _, v := range keys {
delete(tcpClient.Clients, v)
}
} }
} }