fix: ws去除客户端读写互斥锁
This commit is contained in:
@@ -14,8 +14,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ws客户端读写互斥锁
|
|
||||||
mutex sync.Mutex
|
|
||||||
// ws客户端 [clientId: client]
|
// ws客户端 [clientId: client]
|
||||||
WsClients sync.Map
|
WsClients sync.Map
|
||||||
// ws用户对应的多个客户端id [uid:clientIds]
|
// ws用户对应的多个客户端id [uid:clientIds]
|
||||||
@@ -161,7 +159,6 @@ func (s *WSImpl) clientWrite(wsClient *model.WSClient) {
|
|||||||
|
|
||||||
// CloseClient 客户端关闭
|
// CloseClient 客户端关闭
|
||||||
func (s *WSImpl) CloseClient(clientID string) {
|
func (s *WSImpl) CloseClient(clientID string) {
|
||||||
mutex.Lock()
|
|
||||||
v, ok := WsClients.Load(clientID)
|
v, ok := WsClients.Load(clientID)
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
@@ -173,7 +170,6 @@ func (s *WSImpl) CloseClient(clientID string) {
|
|||||||
client.Conn.Close()
|
client.Conn.Close()
|
||||||
client.StopChan <- struct{}{}
|
client.StopChan <- struct{}{}
|
||||||
WsClients.Delete(clientID)
|
WsClients.Delete(clientID)
|
||||||
mutex.Unlock()
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// 客户端断线时自动踢出Uid绑定列表
|
// 客户端断线时自动踢出Uid绑定列表
|
||||||
|
|||||||
Reference in New Issue
Block a user