增加关闭socket function

This commit is contained in:
duanhf2012
2020-03-31 14:39:30 +08:00
parent f410afbd58
commit 5ae1e683c9
2 changed files with 55 additions and 25 deletions

View File

@@ -152,4 +152,21 @@ func (slf *TcpService) SendMsg(clientid uint64,msg interface{}) error{
return err
}
return client.tcpConn.WriteMsg(bytes)
}
}
func (slf *TcpService) Close(clientid uint64) {
//
slf.mapClientLocker.Lock()
defer slf.mapClientLocker.Unlock()
client,ok := slf.mapClient[clientid]
if ok == false{
return
}
if client.tcpConn!=nil {
client.tcpConn.Close()
}
return
}