-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
socket.emit not working inside socket.on server side #3565
Comments
Little info. I tried to run socket.emit inside socket.on on the client side and it worked fine. Must be a server side bug. I also tried io.to(socket.id).emit on server side to no avail. |
If you are trying to emit to a specific client you can use something like this.
EDIT: I just saw that you have tried this as well. I'm not sure as to what your problem might be, because I am also using socket.io version 2.3.0 and this seems to work just fine for me. |
I decided to use the callback functionality to reply directly to the requestor. It makes the design a little easier as well. I couldn't get it to work when having an emit event(or similar) directly inside a .on event. |
You want to:
Current behaviour
*I cannot socket.emit from inside a socket.on callback on the server
Steps to reproduce (if the current behaviour is a bug)
Try to socket.emit inside of a socket.on from server side
Expected behaviour
The client to receive the message specific to their connection
Setup
Code
I cannot use io.emit or io.socket.emit because I only want the message to go to the requesting client. The issue has equals in front to help you find it.
The text was updated successfully, but these errors were encountered: