mrniko / netty-socketio

Socket.IO server implemented on Java. Realtime java framework
Apache License 2.0
6.76k stars 1.65k forks source link

集群环境中如何获取到,一个room下所有的clinet数(Redission) #797

Open shuimujibao opened 3 years ago

shuimujibao commented 3 years ago
public Iterable<SocketIOClient> getRoomClients(String room) {
       //该值为集群中,当前room下client的总数
        Set<UUID> sessionIds = roomClients.get(room);

        if (sessionIds == null) {
            return Collections.emptyList();
        }
        //此时过滤掉了,当前room中不在当前服务器的client
        List<SocketIOClient> result = new ArrayList<SocketIOClient>();
        for (UUID sessionId : sessionIds) {
            SocketIOClient client = allClients.get(sessionId);
            if(client != null) {
                result.add(client);
            }
        }
       //所以我获取到的当前room下client数,只是当前服务器的,并非整个集群下的
        return result;
    }
gaojunjun2016 commented 3 years ago

SocketIo 相关资讯可参考 https://www.gaojunjun.com/topic/2

bshugo9527 commented 1 month ago

我也想知道集群环境下怎么获取在线人数

shuimujibao commented 1 month ago

以提供方法了发自我的手机-------- 原始邮件 --------发件人: bshugo9527 @.>日期: 2024年7月27日周六 20:34收件人: mrniko/netty-socketio @.>抄送: 孙晓宇 @.>, Author @.>主 题: Re: [mrniko/netty-socketio] 集群环境中如何获取到,一个room下所有的clinet数(Redission) (#797) 我也想知道集群环境下怎么获取在线人数

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>