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

Can't use BroadcastOperations to transfer binary data to All clients? #23

Open
whg333 opened this issue Apr 18, 2016 · 0 comments
Open

Comments

@whg333
Copy link

whg333 commented Apr 18, 2016

first of all, I am not good at English, please let me konw if you don't know what i say.

I modifed the example of BinaryEventLauncher as below, just to Let All connected client can see the picture if some one upload picture:

    server.addEventListener("msg", byte[].class, new DataListener<byte[]>() {
        @Override
        public void onData(SocketIOClient client, byte[] data, AckRequest ackRequest) {
            server.getBroadcastOperations().sendEvent("msg", data);
            //client.sendEvent("msg", data);
        }
    });

but It doesn't work, not all connected client can see the upload picture, maybe something wrong?

I have to use the for loop to make sure it work as i want:

    server.addEventListener("msg", byte[].class, new DataListener<byte[]>() {
        @Override
        public void onData(SocketIOClient client, byte[] data, AckRequest ackRequest) {
            for(SocketIOClient socketIOClient:server.getAllClients()){
                socketIOClient.sendEvent("msg", data);
            }
            //server.getBroadcastOperations().sendEvent("msg", data);
            //client.sendEvent("msg", data);
        }
    });

please tell me why? do i have to use the for loop instead of BroadcastOperations?

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

No branches or pull requests

1 participant