This commit is contained in:
suyl
2021-07-29 18:11:20 +08:00
parent c8a1d09ba4
commit b18672e92d
2 changed files with 40 additions and 16 deletions

View File

@@ -99,9 +99,9 @@ var (
regexpQrr = regexp.MustCompile(byteSignQrRight + "(.*?)" + byteSignQrRightE)
regexpSound = regexp.MustCompile(byteSignSound + "(.*?)" + byteSignSoundE)
printMsgChan = make(chan *model.PrintMsg, 1024)
printMsgCallbackChan = make(chan string, 1024)
printMsgChanFail = make(chan *model.PrintMsg, 1024)
printMsgChan = make(chan *model.PrintMsg, 1024)
//printMsgCallbackMap = make(map[string]chan string, 1024)
printMsgChanFail = make(chan *model.PrintMsg, 1024)
)
type PrintInfo struct {
@@ -112,7 +112,8 @@ type PrintInfo struct {
//连接的客户端,吧每个客户端都放进来
type TcpClient struct {
Clients map[string]*PrintInfo
Clients map[string]*PrintInfo
CallBackMap map[string]chan string
*sync.RWMutex
}
@@ -142,6 +143,11 @@ func (t *TcpClient) addConn(c net.Conn, key string, status int) {
}
}
func (t *TcpClient) buildCallBackMap(key string) {
dataChan := make(chan string, 1024)
t.CallBackMap[key] = dataChan
}
func (t *TcpClient) getPrintStatus(key string) int {
t.RLock()
defer t.RUnlock()
@@ -185,7 +191,8 @@ func (t *TcpClient) setPrintStatus(key string, status int) {
func NewTcpClient() *TcpClient {
t := &TcpClient{
Clients: make(map[string]*PrintInfo),
Clients: make(map[string]*PrintInfo),
CallBackMap: make(map[string]chan string, 1024),
}
t.RWMutex = new(sync.RWMutex)
return t