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

Need ability to arbitrarily emit with callback to a socket client. #1656

Closed
monteslu opened this issue Jun 30, 2014 · 6 comments
Closed

Need ability to arbitrarily emit with callback to a socket client. #1656

monteslu opened this issue Jun 30, 2014 · 6 comments

Comments

@monteslu
Copy link

0.9.x of Socket.io allowed you to get a socket by id and emit to it with a callback such as:

io.sockets.socket(someSocketId).emit('someTopic', data, callback); 

With 1.0.x we can only broadcast to the channel/id of a socket.

@mneil
Copy link

mneil commented Jul 1, 2014

I believe you can do this

io.sockets.connected[someSocketId].emit('someTopic', data, callback);

However, I found an issue with callbacks on the client side after 1.0.2

@monteslu
Copy link
Author

monteslu commented Jul 1, 2014

@mneil awesome!
Not sure if this works across a cluster, but works for a single instance.

@rauchg
Copy link
Contributor

rauchg commented Jul 1, 2014

Yup, that's the main reason we did away with the previous public API. That will work on single-node only.

@evanlucas
Copy link

Will this work in a cluster if using the redis adapter?

@monteslu
Copy link
Author

@evanlucas it still wont. You'll need to handle your own acknowledgments by manually tracking some type of acknowledgment ID tied to a cached callback function. Also, need to make sure you timeout those callbacks and clean up memory in case you never get a response :)

@darrachequesne
Copy link
Member

That issue was closed automatically. Please check if your issue is fixed with the latest release, and reopen if needed (with a fiddle reproducing the issue if possible).

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

5 participants