I'm trying to create a basic chat application. I'm using socket.io and I'm having a hard time figuring out how should I handle user to user communication.
I read here few of the answers: How to send a message to a particular client with socket.io
but I'm still confused, let's say I have 3 users, A, B and C. I want A to speak to B, and I want C to speak to B. Of course, A should not see B and C messages to each other, and vice versa.
This socket rooms idea seems great, but it seems to me like anyone can join the "room" and see each others messages.
I'm pretty confused, and not sure how I should approach this. I read another answer, which is each user will have a socket, so I can use the socket to send message. So something like this:
A user ID -> socket number 1
B user ID -> socket number 2
C user ID -> socket number 3
So when A sends message to be, it will send it from A's socket to B's socket.
But I'm not sure I got that right.