aa
This commit is contained in:
@@ -120,7 +120,7 @@ type TcpClient struct {
|
||||
Clients map[string]*PrintInfo //放tcp连接的,printNo 为key
|
||||
MsgMap map[string]chan *model.PrintMsg //放打印信息的,printNo为key
|
||||
CallBackMap map[string]chan string //放打印信息回调信息的,printNo为key
|
||||
TimeoutChan chan bool //退出channel
|
||||
TimeoutMap map[string]chan bool //退出channel
|
||||
*sync.RWMutex
|
||||
}
|
||||
|
||||
@@ -149,9 +149,6 @@ func (t *TcpClient) addConn(c net.Conn, key string, status int) {
|
||||
Status: status,
|
||||
StatusTime: time.Now(),
|
||||
}
|
||||
if t.TimeoutChan == nil {
|
||||
t.TimeoutChan = make(chan bool)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TcpClient) buildMsgMap(key string) {
|
||||
@@ -168,6 +165,13 @@ func (t *TcpClient) buildCallBackMap(key string) {
|
||||
t.CallBackMap[key] = dataChan
|
||||
}
|
||||
|
||||
func (t *TcpClient) buildTimeoutMap(key string) {
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
dataChan := make(chan bool)
|
||||
t.TimeoutMap[key] = dataChan
|
||||
}
|
||||
|
||||
func (t *TcpClient) getPrintStatus(key string) int {
|
||||
t.RLock()
|
||||
defer t.RUnlock()
|
||||
@@ -283,7 +287,7 @@ func NewTcpClient() *TcpClient {
|
||||
Clients: make(map[string]*PrintInfo),
|
||||
CallBackMap: make(map[string]chan string),
|
||||
MsgMap: make(map[string]chan *model.PrintMsg),
|
||||
TimeoutChan: make(chan bool),
|
||||
TimeoutMap: make(map[string]chan bool),
|
||||
}
|
||||
t.RWMutex = new(sync.RWMutex)
|
||||
return t
|
||||
|
||||
Reference in New Issue
Block a user