This commit is contained in:
suyl
2021-08-03 11:04:58 +08:00
parent 9bbcfbe1dc
commit 55400e0b9e
2 changed files with 11 additions and 8 deletions

View File

@@ -107,8 +107,6 @@ var (
regexpQrl = regexp.MustCompile(byteSignQrLeft + "(.*?)" + byteSignQrLeftE)
regexpQrr = regexp.MustCompile(byteSignQrRight + "(.*?)" + byteSignQrRightE)
regexpSound = regexp.MustCompile(byteSignSound + "(.*?)" + byteSignSoundE)
timeoutChan = make(chan bool)
)
type PrintInfo struct {
@@ -122,6 +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
*sync.RWMutex
}
@@ -150,6 +149,9 @@ 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) {
@@ -281,6 +283,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),
}
t.RWMutex = new(sync.RWMutex)
return t