mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-25 11:06:43 +08:00
test: push log add
This commit is contained in:
parent
f661245d9f
commit
35ceb7542a
@ -124,11 +124,13 @@ func (ws *WsServer) registerClient(client *Client) {
|
|||||||
)
|
)
|
||||||
cli, userOK, clientOK = ws.clients.Get(client.userID, client.platformID)
|
cli, userOK, clientOK = ws.clients.Get(client.userID, client.platformID)
|
||||||
if !userOK {
|
if !userOK {
|
||||||
|
log.ZDebug(client.ctx, "user not exist", "userID", client.userID, "platformID", client.platformID)
|
||||||
ws.clients.Set(client.userID, client)
|
ws.clients.Set(client.userID, client)
|
||||||
atomic.AddInt64(&ws.onlineUserNum, 1)
|
atomic.AddInt64(&ws.onlineUserNum, 1)
|
||||||
atomic.AddInt64(&ws.onlineUserConnNum, 1)
|
atomic.AddInt64(&ws.onlineUserConnNum, 1)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
log.ZDebug(client.ctx, "user exist", "userID", client.userID, "platformID", client.platformID)
|
||||||
if clientOK { //已经有同平台的连接存在
|
if clientOK { //已经有同平台的连接存在
|
||||||
ws.clients.Set(client.userID, client)
|
ws.clients.Set(client.userID, client)
|
||||||
ws.multiTerminalLoginChecker(cli)
|
ws.multiTerminalLoginChecker(cli)
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package msggateway
|
package msggateway
|
||||||
|
|
||||||
import "sync"
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
type UserMap struct {
|
type UserMap struct {
|
||||||
m sync.Map
|
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) {
|
func (u *UserMap) Set(key string, v *Client) {
|
||||||
allClients, existed := u.m.Load(key)
|
allClients, existed := u.m.Load(key)
|
||||||
if existed {
|
if existed {
|
||||||
|
log.ZDebug(context.Background(), "Set existed", "user_id", key, "client", v)
|
||||||
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 {
|
} else {
|
||||||
|
log.ZDebug(context.Background(), "Set not existed", "user_id", key, "client", v)
|
||||||
var clients []*Client
|
var clients []*Client
|
||||||
clients = append(clients, v)
|
clients = append(clients, v)
|
||||||
u.m.Store(key, clients)
|
u.m.Store(key, clients)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user