N
N
No Name2016-12-26 17:40:21
JavaScript
No Name, 2016-12-26 17:40:21

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

2 answer(s)
R
Rou1997, 2016-12-26
@Rou1997

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.

M
Mikhail Osher, 2016-12-26
@miraage

<facepalm>
    Read The Following Manual
</facepalm>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question