|
|
|
@ -1,6 +1,10 @@
|
|
|
|
|
package msggateway
|
|
|
|
|
|
|
|
|
|
import "sync"
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
|
|
|
|
"sync"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type UserMap struct {
|
|
|
|
|
m sync.Map
|
|
|
|
@ -36,10 +40,12 @@ func (u *UserMap) Get(key string, platformID int) ([]*Client, bool, bool) {
|
|
|
|
|
func (u *UserMap) Set(key string, v *Client) {
|
|
|
|
|
allClients, existed := u.m.Load(key)
|
|
|
|
|
if existed {
|
|
|
|
|
log.ZDebug(context.Background(), "Set existed", "user_id", key, "client", v)
|
|
|
|
|
oldClients := allClients.([]*Client)
|
|
|
|
|
oldClients = append(oldClients, v)
|
|
|
|
|
u.m.Store(key, oldClients)
|
|
|
|
|
} else {
|
|
|
|
|
log.ZDebug(context.Background(), "Set not existed", "user_id", key, "client", v)
|
|
|
|
|
var clients []*Client
|
|
|
|
|
clients = append(clients, v)
|
|
|
|
|
u.m.Store(key, clients)
|
|
|
|
|