mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-04 03:13:15 +08:00
online cache
This commit is contained in:
parent
1bfaf3e2d9
commit
dcd874979e
@ -118,11 +118,11 @@ func (u *userMap) DeleteClients(userID string, clients []*Client) (isDeleteUser
|
||||
tmp := result.Clients
|
||||
result.Clients = result.Clients[:0]
|
||||
for _, client := range tmp {
|
||||
if _, ok := deleteAddr[client.ctx.GetRemoteAddr()]; ok {
|
||||
continue
|
||||
if _, delCli := deleteAddr[client.ctx.GetRemoteAddr()]; delCli {
|
||||
offline = append(offline, int32(client.PlatformID))
|
||||
} else {
|
||||
result.Clients = append(result.Clients, client)
|
||||
}
|
||||
offline = append(offline, int32(client.PlatformID))
|
||||
result.Clients = append(result.Clients, client)
|
||||
}
|
||||
defer u.push(userID, result, offline)
|
||||
if len(result.Clients) > 0 {
|
||||
|
||||
@ -51,11 +51,8 @@ func NewOnlineCache(user rpcclient.UserRpcClient, group *GroupLocalCache, rdb re
|
||||
log.ZError(ctx, "OnlineCache redis subscribe parseUserOnlineStatus", err, "payload", message.Payload, "channel", message.Channel)
|
||||
continue
|
||||
}
|
||||
log.ZDebug(ctx, "OnlineCache setUserOnline", "userID", userID, "platformIDs", platformIDs, "payload", message.Payload)
|
||||
x.setUserOnline(userID, platformIDs)
|
||||
//if err := x.setUserOnline(ctx, userID, platformIDs); err != nil {
|
||||
// log.ZError(ctx, "redis subscribe setUserOnline", err, "payload", message.Payload, "channel", message.Channel)
|
||||
//}
|
||||
storageCache := x.setUserOnline(userID, platformIDs)
|
||||
log.ZDebug(ctx, "OnlineCache setUserOnline", "userID", userID, "platformIDs", platformIDs, "payload", message.Payload, "storageCache", storageCache)
|
||||
}
|
||||
}()
|
||||
return x
|
||||
@ -115,10 +112,10 @@ func (o *OnlineCache) GetGroupOnline(ctx context.Context, groupID string) ([]str
|
||||
onlineUserIDs = append(onlineUserIDs, userID)
|
||||
}
|
||||
}
|
||||
log.ZDebug(ctx, "OnlineCache GetGroupOnline", "groupID", groupID, "onlineUserIDs", onlineUserIDs)
|
||||
log.ZDebug(ctx, "OnlineCache GetGroupOnline", "groupID", groupID, "onlineUserIDs", onlineUserIDs, "allUserID", userIDs)
|
||||
return onlineUserIDs, nil
|
||||
}
|
||||
|
||||
func (o *OnlineCache) setUserOnline(userID string, platformIDs []int32) {
|
||||
o.local.SetHas(o.getUserOnlineKey(userID), platformIDs)
|
||||
func (o *OnlineCache) setUserOnline(userID string, platformIDs []int32) bool {
|
||||
return o.local.SetHas(o.getUserOnlineKey(userID), platformIDs)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user