1

I'm writing a an Android app that connect to a socket implement by Node.JS + socket.io. I'm using AndroidAsync (https://github.com/koush/AndroidAsync) for Android Client. I want to emit some events that only specified client can listen. But I can't find how to join in a room on Android client.

  1. Is there any solution for room joining on android?
  2. Is there any method that the Android client listen specified events (not all events) without using room?

2 Answers 2

0

When client connects on server side, you have handle of socket and it has ID socket.id. This ID is unique per socket so you can use it to identify sockets.

So on connection you can make your own arrays of sockets and push them there. Then you can iterate through them and emit any message.
It is not necessary to use built-in rooms for this, and you can make yours easily.

So Identifying sockets your own way - will allow you to manage them better and will give you ability to send messages to specific socket. As far as there is a way to reference it using ID or any other identification method.

0

Yes, use SocketIOClient.of to join a specific endpoint/channel. See:

https://github.com/koush/AndroidAsync/blob/master/AndroidAsync/src/com/koushikdutta/async/http/socketio/SocketIOClient.java#L173

You get a similar connect callback that is invoked when the endpoint is connected, providing a new socketioclient for that specific endpoint.

2
  • I havea problem.Such as: if you create SocketIO connection,You can easily SocketIO.emit("eventName",..).But You created a SocketIOClient,you can not emit("eventName",..) how can I do that like SocketIO with SocketIOClient? thanks
    – erginduran
    Aug 27, 2014 at 18:10
  • @koush : please take a look on this question : stackoverflow.com/questions/31422468/…
    – sam_k
    Jul 15, 2015 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.