This commit is contained in:
suyl
2021-08-03 14:52:08 +08:00
parent aeee9731cd
commit 9b8bc1c240

View File

@@ -191,6 +191,8 @@ func (t *TcpClient) doPrint(key string) (err error) {
if !t.isExistMsg(key) {
return err
}
defer close(t.MsgMap[key])
defer close(t.CallBackMap[key])
globals.SugarLogger.Debugf("doPrint printNo: %s", key)
go func() {
for {
@@ -201,7 +203,7 @@ func (t *TcpClient) doPrint(key string) (err error) {
default:
select {
case printMsg, ok := <-t.MsgMap[key]:
if !ok{
if !ok {
return
}
var (
@@ -254,14 +256,13 @@ func (t *TcpClient) doPrint(key string) (err error) {
}
}
}()
close(t.MsgMap[key])
close(t.CallBackMap[key])
return err
}
//检测心跳
func (t *TcpClient) HandleCheckTcpHeart(key string) {
globals.SugarLogger.Debugf("HandleCheckTcpHeart begin key: %s", key)
defer t.Clients[key].C.Close()
go func() {
for {
select {
@@ -297,5 +298,4 @@ func (t *TcpClient) HandleCheckTcpHeart(key string) {
//}
}
}()
t.Clients[key].C.Close()
}