Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is a question to broadcast twice and more? #221

Open
christisall opened this issue Mar 13, 2015 · 0 comments
Open

It is a question to broadcast twice and more? #221

christisall opened this issue Mar 13, 2015 · 0 comments

Comments

@christisall
Copy link
Contributor

server1:9091 server2:9092
client1 ---> server1
client2 ---> server2
client3 ---> server2

then client4 ---> server2, clinet1 will receive 3 broadcast messages.
if there are N connections to server2, the client which connect to server1 will receive N broadcast messages.

Maybe I misunderstood the useage of netty-socketio.

I want to implement that client1 can send custom message to client3 when I use Redisson.

Thank you very much!

    public static void main(String[] args) throws InterruptedException {

        Configuration config = new Configuration();
        config.setHostname("192.168.1.113");
        config.setPort(9091);
        config.setContext("/chat");

        Redisson redisson = Redisson.create();
        RedissonStoreFactory rsf = new RedissonStoreFactory(redisson);
        config.setStoreFactory(rsf);

        final SocketIOServer server = new SocketIOServer(config);

        server.addConnectListener(new ConnectListener() {

            @Override
            public void onConnect(SocketIOClient client) {
                server.getBroadcastOperations().sendEvent("online", “examples”);
            }
        });

                //..........

      }


//BroadcastOperations.java :  Line 52

    public BroadcastOperations(Iterable<SocketIOClient> clients, StoreFactory storeFactory) {
        super();
        this.clients = clients;
        for (SocketIOClient socketIOClient : clients) {
            Namespace namespace = (Namespace)socketIOClient.getNamespace();
            Set<String> rooms = namespace.getRooms(socketIOClient);

            List<String> roomsList = namespaceRooms.get(namespace.getName());
            //××××××××××××××××××××××××××××××××××××××××××××
            //why use List?  may it duplicate?
            //Set<String>  roomsList-----------It works!
            //××××××××××××××××××××××××××××××××××××××××××××

            if (roomsList == null) {
                roomsList = new ArrayList<String>();
                namespaceRooms.put(namespace.getName(), roomsList);
            }
            roomsList.addAll(rooms);
        }
        this.storeFactory = storeFactory;
    }

You have implement the Broadcast Dispatch event with room/namespace.
I can't find the dispatch message from person to person ?

May be you can help me, Thks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant