1
This commit is contained in:
@@ -69,7 +69,7 @@ func (t *TcpClient) handleConn(c net.Conn) {
|
||||
//5、修改数据库中打印机状态(没在连接池中说明是重新连接的)
|
||||
//6、监听心跳时间,超过1分多钟就clear掉
|
||||
//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.buildAllMap(printNo)
|
||||
t.HandleTcpMessages(printNo)
|
||||
@@ -314,7 +314,7 @@ func (t *TcpClient) HandleCheckTcpHeart(key string) {
|
||||
for {
|
||||
select {
|
||||
case <-t.TimeoutMap[key]:
|
||||
t.Clients[key].C.Close()
|
||||
t.getClients(key).C.Close()
|
||||
close(t.MsgMap[key])
|
||||
close(t.CallBackMap[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 {
|
||||
t.RLock()
|
||||
defer t.RUnlock()
|
||||
|
||||
Reference in New Issue
Block a user