mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-05 21:02:11 +08:00
fix: fix get functions bug
This commit is contained in:
parent
e554f33b7d
commit
3053d4a5ce
@ -16,9 +16,10 @@ package msggateway
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/openimsdk/tools/utils/datautil"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/openimsdk/tools/utils/datautil"
|
||||||
|
|
||||||
"github.com/openimsdk/tools/log"
|
"github.com/openimsdk/tools/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -55,6 +56,7 @@ func (u *UserMap) Get(key string, platformID int) ([]*Client, bool, bool) {
|
|||||||
return nil, userExisted, false
|
return nil, userExisted, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set adds a client to the map.
|
||||||
func (u *UserMap) Set(key string, v *Client) {
|
func (u *UserMap) Set(key string, v *Client) {
|
||||||
allClients, existed := u.m.Load(key)
|
allClients, existed := u.m.Load(key)
|
||||||
if existed {
|
if existed {
|
||||||
@ -62,13 +64,12 @@ func (u *UserMap) Set(key string, v *Client) {
|
|||||||
oldClients := allClients.([]*Client)
|
oldClients := allClients.([]*Client)
|
||||||
oldClients = append(oldClients, v)
|
oldClients = append(oldClients, v)
|
||||||
u.m.Store(key, oldClients)
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
func (u *UserMap) delete(key string, connRemoteAddr string) (isDeleteUser bool) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user