1
This commit is contained in:
@@ -79,6 +79,7 @@ func (t *TcpClient) handleConn(c net.Conn) error {
|
||||
if strings.Contains(data, heartText) || strings.Contains(data, heartTextNew) {
|
||||
printNoData, _ := hex.DecodeString(data[len(heartText) : len(data)-8])
|
||||
printNo = string(printNoData)
|
||||
globals.SugarLogger.Debugf("TimeoutMap 1:%s", utils.Format4Output(t.TimeoutMap[printNo], false))
|
||||
status := printStatus2JxStatus(data[len(data)-8 : len(data)-6])
|
||||
//如果没在连接池里
|
||||
//1、加到连接池中,不同的打印机no开不同的goroutine
|
||||
@@ -91,6 +92,7 @@ func (t *TcpClient) handleConn(c net.Conn) error {
|
||||
t.addConn(c, printNo, status)
|
||||
t.buildAllMap(printNo)
|
||||
t.HandleTcpMessages(printNo)
|
||||
globals.SugarLogger.Debugf("TimeoutMap 3:%s", utils.Format4Output(t.TimeoutMap[printNo], false))
|
||||
t.doPrint(printNo)
|
||||
if status == printerStatusOnline {
|
||||
//t.printFail()
|
||||
@@ -315,7 +317,7 @@ func (t *TcpClient) doPrint(key string) (err error) {
|
||||
|
||||
//检测心跳
|
||||
func (t *TcpClient) HandleCheckTcpHeart(key string) {
|
||||
globals.SugarLogger.Debugf("HandleCheckTcpHeart begin key: %s", key)
|
||||
globals.SugarLogger.Debugf("HandleCheckTcpHeart begin key: %v", <-t.TimeoutMap[key])
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
@@ -324,6 +326,7 @@ func (t *TcpClient) HandleCheckTcpHeart(key string) {
|
||||
close(t.MsgMap[key])
|
||||
close(t.CallBackMap[key])
|
||||
t.delConn(key)
|
||||
close(t.TimeoutMap[key])
|
||||
//delete(t.Clients, key)
|
||||
return
|
||||
default:
|
||||
@@ -332,8 +335,8 @@ func (t *TcpClient) HandleCheckTcpHeart(key string) {
|
||||
//1分钟内没心跳判断打印机掉线了
|
||||
if time.Now().Sub(statusTime) > time.Minute+time.Second*10 {
|
||||
changePrinterStatus(key, printerStatusOffline)
|
||||
//t.clear(key)
|
||||
close(t.TimeoutMap[key])
|
||||
t.clear(key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user