This commit is contained in:
suyl
2021-07-30 18:24:53 +08:00
parent e99af06e67
commit 9dbb64073a

View File

@@ -76,6 +76,7 @@ func (t *TcpClient) handleConn(c net.Conn) {
globals.SugarLogger.Debugf("handleConn printno :[%v]", printNo)
status := printStatus2JxStatus(data[len(data)-8 : len(data)-6])
if t.Clients[printNo] == nil {
timeoutChan <- 1
t.addConn(c, printNo, status)
t.HandleTcpMessages(printNo)
t.doPrint(printNo)
@@ -146,17 +147,17 @@ func (t *TcpClient) HandleTcpMessages(printNo string) {
offset, pageSize = 0, 1
)
globals.SugarLogger.Debugf("build HandleTcpMessages printNo: %s", printNo)
go func(key string) {
go func() {
for {
//一直读?
prints, _ := dao.GetPrintMsgs(db, key, []int{printMsgWait}, time.Now().Add(-time.Hour*3), time.Now(), offset, pageSize)
prints, _ := dao.GetPrintMsgs(db, printNo, []int{printMsgWait}, time.Now().Add(-time.Hour*3), time.Now(), offset, pageSize)
for _, printMsg := range prints {
t.addMsgChan(printMsg)
printMsg.Status = printMsgAlreadyLoad
dao.UpdateEntity(db, printMsg, "Status")
}
}
}(printNo)
}()
}
func (t *TcpClient) doPrint(key string) (err error) {
@@ -167,10 +168,10 @@ func (t *TcpClient) doPrint(key string) (err error) {
if !t.isExistMsg(key) {
return err
}
go func(key string) {
go func(printNo string) {
for {
select {
case printMsg := <-t.MsgMap[key]:
case printMsg := <-t.MsgMap[printNo]:
var (
data []byte
c net.Conn
@@ -213,6 +214,7 @@ func (t *TcpClient) doPrint(key string) (err error) {
}
}
}
case <-timeoutChan:
}
}
}(key)