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