1
This commit is contained in:
@@ -76,6 +76,7 @@ func (t *TcpClient) handleConn(c net.Conn) error {
|
||||
c.Write([]byte("ok"))
|
||||
return err
|
||||
}
|
||||
data = "1e001a020001513132303232303931353030313935390000008a"
|
||||
//证明是心跳
|
||||
if strings.Contains(data, heartText) || strings.Contains(data, heartTextNew) {
|
||||
printNoData, _ := hex.DecodeString(data[len(heartText) : len(data)-8])
|
||||
@@ -91,6 +92,7 @@ func (t *TcpClient) handleConn(c net.Conn) error {
|
||||
if t.getClients(printNo) == nil {
|
||||
t.addConn(c, printNo, status)
|
||||
t.buildAllMap(printNo)
|
||||
t.TimeoutMap[printNo] <- true
|
||||
t.HandleTcpMessages(printNo)
|
||||
t.doPrint(printNo)
|
||||
if status == printerStatusOnline {
|
||||
@@ -170,6 +172,7 @@ func (t *TcpClient) changePrintMsg(data string, orderNo int64, printNo string) (
|
||||
}
|
||||
|
||||
func (t *TcpClient) HandleTcpMessages(printNo string) {
|
||||
fmt.Println("============:", t.getTimeOut(printNo))
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
offset, pageSize = 0, 10
|
||||
@@ -318,6 +321,7 @@ func (t *TcpClient) HandleCheckTcpHeart(key string) {
|
||||
globals.SugarLogger.Debugf("HandleCheckTcpHeart begin key: %s", key)
|
||||
go func() {
|
||||
for {
|
||||
fmt.Println("============:", t.getTimeOut(key))
|
||||
select {
|
||||
case <-t.TimeoutMap[key]:
|
||||
t.getClients(key).C.Close()
|
||||
|
||||
Reference in New Issue
Block a user