When I login as same user in different browser and then try to do socket.brodcast then the msg is displayed in the other browser as well of the same user.
How can I broadcast that msg to only other users.
One user different browser
Upload the project on github and send link.
Although it’s same as in videos . In the video also this thing is happening.
This is because you subscribe to the event “username” when you call s.join(u)
So whenever an emit is made to the “username”, all the sockets that subscribed to the “username” receive the message.
In order to avoid this, you can do something like this: instead of socket.join(username), do socket.join(username + socket.id), and while emitting you have to determine on which socket id you need to pass the message, and pass it to the event named username + socket.id
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.