fix: platform client conn delete

This commit is contained in:
Gordon 2023-06-06 18:42:13 +08:00
parent b5e16aeb2c
commit f75fabd664
2 changed files with 3 additions and 3 deletions

View File

@ -161,7 +161,7 @@ func (ws *WsServer) multiTerminalLoginChecker(client []*Client) {
} }
func (ws *WsServer) unregisterClient(client *Client) { func (ws *WsServer) unregisterClient(client *Client) {
defer ws.clientPool.Put(client) defer ws.clientPool.Put(client)
isDeleteUser := ws.clients.delete(client.userID, client.platformID) isDeleteUser := ws.clients.delete(client.userID, client.ctx.GetRemoteAddr())
if isDeleteUser { if isDeleteUser {
atomic.AddInt64(&ws.onlineUserNum, -1) atomic.AddInt64(&ws.onlineUserNum, -1)
} }

View File

@ -51,13 +51,13 @@ func (u *UserMap) Set(key string, v *Client) {
u.m.Store(key, clients) u.m.Store(key, clients)
} }
} }
func (u *UserMap) delete(key string, platformID int) (isDeleteUser bool) { func (u *UserMap) delete(key string, connRemoteAddr string) (isDeleteUser bool) {
allClients, existed := u.m.Load(key) allClients, existed := u.m.Load(key)
if existed { if existed {
oldClients := allClients.([]*Client) oldClients := allClients.([]*Client)
var a []*Client var a []*Client
for _, client := range oldClients { for _, client := range oldClients {
if client.platformID != platformID { if client.ctx.GetRemoteAddr() != connRemoteAddr {
a = append(a, client) a = append(a, client)
} }
} }