aa
This commit is contained in:
@@ -193,20 +193,22 @@ func handleConn(c net.Conn) {
|
||||
printNo = string(printNoData)
|
||||
globals.SugarLogger.Debugf("handleConn printno :[%v]", printNo)
|
||||
status := printStatus2JxStatus(data[len(data)-8 : len(data)-6])
|
||||
tcpClient.s.Lock()
|
||||
if tcpClient.Clients[printNo] == nil {
|
||||
printInfo := &PrintInfo{
|
||||
C: c,
|
||||
Status: printStatus2JxStatus(data[len(data)-8 : len(data)-6]),
|
||||
StatusTime: time.Now(),
|
||||
}
|
||||
tcpClient.s.Lock()
|
||||
tcpClient.Clients[printNo] = printInfo
|
||||
tcpClient.s.Unlock()
|
||||
changePrinterStatus(printNo, status)
|
||||
if status > 0 {
|
||||
printFail()
|
||||
}
|
||||
} else {
|
||||
//改变打印机状态
|
||||
tcpClient.s.Lock()
|
||||
changePrinterStatus(printNo, status)
|
||||
if tcpClient.Clients[printNo] != nil {
|
||||
if tcpClient.Clients[printNo].Status != status {
|
||||
@@ -214,8 +216,8 @@ func handleConn(c net.Conn) {
|
||||
}
|
||||
tcpClient.Clients[printNo].StatusTime = time.Now()
|
||||
}
|
||||
tcpClient.s.Unlock()
|
||||
}
|
||||
tcpClient.s.Unlock()
|
||||
} else if strings.Contains(data, printText) {
|
||||
globals.SugarLogger.Debugf("handleConn print: %v", data)
|
||||
changePrintMsg(data)
|
||||
@@ -407,7 +409,9 @@ func HandleCheckTcpHeart() {
|
||||
tcpClient.s.Unlock()
|
||||
for _, v := range keys {
|
||||
changePrinterStatus(v, printerStatusOffline)
|
||||
delete(tcpClient.Clients, v)
|
||||
if tcpClient.Clients[v] != nil {
|
||||
delete(tcpClient.Clients, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user