1'
This commit is contained in:
@@ -168,10 +168,7 @@ func (t *TcpClient) HandleTcpMessages(printNo string) {
|
||||
|
||||
go func() {
|
||||
for {
|
||||
//if time.Now().Second()%2 != 0 {
|
||||
// continue
|
||||
//}
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
select {
|
||||
case <-t.TimeoutMap[printNo]:
|
||||
globals.SugarLogger.Debugf("HandleTcpMessages timeout")
|
||||
@@ -205,6 +202,7 @@ func (t *TcpClient) doPrint(key string) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
|
||||
if !t.isExistMsg(key) {
|
||||
return err
|
||||
}
|
||||
@@ -226,8 +224,6 @@ func (t *TcpClient) doPrint(key string) (err error) {
|
||||
c net.Conn
|
||||
)
|
||||
if printMsg != nil {
|
||||
time.Sleep(2 * time.Second)
|
||||
globals.SugarLogger.Debugf("printMsg ... %s", utils.Format4Output(printMsg, false))
|
||||
if err = checkPrintMsg(db, printMsg); err == nil {
|
||||
status := t.getPrintStatus(printMsg.PrintNo)
|
||||
switch status {
|
||||
@@ -265,7 +261,7 @@ func (t *TcpClient) doPrint(key string) (err error) {
|
||||
close(t.TimeoutMap[key])
|
||||
} else {
|
||||
//等待回调
|
||||
dataStr := <-t.CallBackMap[printMsg.PrintNo]
|
||||
dataStr := t.GetCallbackChan(printMsg.PrintNo)
|
||||
if dataStr != "" {
|
||||
a, b := getCallbackMsgInfo(dataStr)
|
||||
t.changePrintMsg(dataStr, a, b)
|
||||
|
||||
@@ -293,6 +293,15 @@ func (t *TcpClient) addCallbackChan(key, data string) {
|
||||
t.CallBackMap[key] <- data
|
||||
}
|
||||
|
||||
func (t *TcpClient) GetCallbackChan(key string) string {
|
||||
t.RLock()
|
||||
defer t.RUnlock()
|
||||
if t.CallBackMap[key] == nil {
|
||||
return ""
|
||||
}
|
||||
return <-t.CallBackMap[key]
|
||||
}
|
||||
|
||||
func (t *TcpClient) clear(key string) {
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user