In referrer to node.js routing data with socket.io
On client:
// send data on some event
socket.emit('send', { u: user_id, a: action, v: value });
I have user_id and i could add user_id sender
On server:
socket.on('send', function (data) {
socket.broadcast.emit('request', { request: data });
});
Now the data is sent to all users listening to port, but I would like to only 2 by 2 users can get data.
So, users 1 & 2 are having there "channel", and users 3 & 4 theirs.
You need the id of the socket (socket.id) you want to send the request. Probably you will need an array with the user_id and its socketID (you can save it when the user enters). Then, when you know the socket id, you can send a message only to this socket.
io.sockets.socket(socketID).emit('request', { request: data });