This commit is contained in:
邹宗楠
2023-12-19 13:45:24 +08:00
parent 0f781849b4
commit a29a10152a

View File

@@ -73,7 +73,6 @@ func handleConn(c net.Conn, t *TcpClient) error {
if c == nil { if c == nil {
return errors.New("conn is nil") return errors.New("conn is nil")
} }
defer c.Close()
for { for {
buffer, n, err := ConnRead(c) buffer, n, err := ConnRead(c)
if err != nil { if err != nil {
@@ -482,7 +481,7 @@ func HandleCheckTcpHeart(t *TcpClient, key string) {
statusTime := t.getPrintStatusTime(key) statusTime := t.getPrintStatusTime(key)
if !utils.IsTimeZero(statusTime) { if !utils.IsTimeZero(statusTime) {
//1分钟内没心跳判断打印机掉线了 //1分钟内没心跳判断打印机掉线了
if time.Now().Sub(statusTime) > time.Second*70 { if time.Now().Sub(statusTime) > time.Second*60 {
globals.SugarLogger.Debugf("超过一分十秒没有心跳的打印机[%s]", key) globals.SugarLogger.Debugf("超过一分十秒没有心跳的打印机[%s]", key)
changePrinterStatus(key, printerStatusOffline) changePrinterStatus(key, printerStatusOffline)
delete(t.TimeoutMap, key) delete(t.TimeoutMap, key)
@@ -499,26 +498,4 @@ func HandleCheckTcpHeart(t *TcpClient, key string) {
} }
} }
Poll.AddJob(fn) Poll.AddJob(fn)
//go func() {
// for {
// if t.TimeoutMap[key] == true {
// statusTime := t.getPrintStatusTime(key)
// if !utils.IsTimeZero(statusTime) {
// //1分钟内没心跳判断打印机掉线了
// if time.Now().Sub(statusTime) > time.Second*70 {
// globals.SugarLogger.Debugf("超过一分十秒没有心跳的打印机[%s]", key)
// changePrinterStatus(key, printerStatusOffline)
// delete(t.TimeoutMap, key)
// globals.SugarLogger.Debugf("t := %s", utils.Format4Output(t.Clients[key].StatusTime, false))
// }
// }
// } else {
// t.getClients(key).C.Close()
// close(t.MsgMap[key])
// close(t.CallBackMap[key])
// t.delConn(key)
// return
// }
// }
//}()
} }