Answer the question
In order to leave comments, you need to log in
Socket.io: how to detect a specific user's client?
I am writing a chat, but there is a problem: how to determine the client of a particular user?
For example, user A sends a message to user B, while the socket with the message should only be delivered to user B and no one else. How to do it?
Answer the question
In order to leave comments, you need to log in
This is called "authorization".
If without registration, then do this: before accessing the chat, the user simply enters his nickname and sends it to the server, a new client corresponding to this socket is added to the server in memory in the array, and from the server’s point of view, each client connection has its own socket and there are no problems, the server can only receive a message from a specific socket and send it too.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question