fix: fix get functions bug

pull/2100/head
Xinwei Xiong (cubxxw) 2 years ago
parent e554f33b7d
commit 3053d4a5ce

@ -16,9 +16,10 @@ package msggateway
import (
"context"
"github.com/openimsdk/tools/utils/datautil"
"sync"
"github.com/openimsdk/tools/utils/datautil"
"github.com/openimsdk/tools/log"
)
@ -55,6 +56,7 @@ func (u *UserMap) Get(key string, platformID int) ([]*Client, bool, bool) {
return nil, userExisted, false
}
// Set adds a client to the map.
func (u *UserMap) Set(key string, v *Client) {
allClients, existed := u.m.Load(key)
if existed {
@ -62,14 +64,13 @@ func (u *UserMap) Set(key string, v *Client) {
oldClients := allClients.([]*Client)
oldClients = append(oldClients, v)
u.m.Store(key, oldClients)
}
} else {
log.ZDebug(context.Background(), "Set not existed", "user_id", key, "client_user_id", v.UserID)
var clients []*Client
clients = append(clients, v)
u.m.Store(key, clients)
}
}
func (u *UserMap) delete(key string, connRemoteAddr string) (isDeleteUser bool) {
// Attempt to load the clients associated with the key.

Loading…
Cancel
Save