1
This commit is contained in:
@@ -69,7 +69,7 @@ func (t *TcpClient) handleConn(c net.Conn) {
|
|||||||
//5、修改数据库中打印机状态(没在连接池中说明是重新连接的)
|
//5、修改数据库中打印机状态(没在连接池中说明是重新连接的)
|
||||||
//6、监听心跳时间,超过1分多钟就clear掉
|
//6、监听心跳时间,超过1分多钟就clear掉
|
||||||
//globals.SugarLogger.Debugf("handleConn timeout channel...: %v", t.TimeoutMap[printNo])
|
//globals.SugarLogger.Debugf("handleConn timeout channel...: %v", t.TimeoutMap[printNo])
|
||||||
if t.Clients[printNo] == nil {
|
if t.getClients(printNo) == nil {
|
||||||
t.addConn(c, printNo, status)
|
t.addConn(c, printNo, status)
|
||||||
t.buildAllMap(printNo)
|
t.buildAllMap(printNo)
|
||||||
t.HandleTcpMessages(printNo)
|
t.HandleTcpMessages(printNo)
|
||||||
@@ -314,7 +314,7 @@ func (t *TcpClient) HandleCheckTcpHeart(key string) {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-t.TimeoutMap[key]:
|
case <-t.TimeoutMap[key]:
|
||||||
t.Clients[key].C.Close()
|
t.getClients(key).C.Close()
|
||||||
close(t.MsgMap[key])
|
close(t.MsgMap[key])
|
||||||
close(t.CallBackMap[key])
|
close(t.CallBackMap[key])
|
||||||
delete(t.Clients, key)
|
delete(t.Clients, key)
|
||||||
|
|||||||
@@ -219,6 +219,13 @@ func (t *TcpClient) getPrintStatusTime(key string) time.Time {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取连接对象
|
||||||
|
func (t *TcpClient) getClients(key string) *PrintInfo {
|
||||||
|
t.RLock()
|
||||||
|
defer t.RUnlock()
|
||||||
|
return t.Clients[key]
|
||||||
|
}
|
||||||
|
|
||||||
func (t *TcpClient) isExistMsg(key string) bool {
|
func (t *TcpClient) isExistMsg(key string) bool {
|
||||||
t.RLock()
|
t.RLock()
|
||||||
defer t.RUnlock()
|
defer t.RUnlock()
|
||||||
|
|||||||
Reference in New Issue
Block a user