I'm new with node.js and socket.io
I have two clients, and they have their ID 1 & 2. I need to send data via socket.io that contain: user_from, user_to, action
And the data is send from both sides.
How do i send this data from client 1 with socket.emit(), so I can set variable:data ?
How to read that data on server with socket.get ?
And send it again from server to client 2 ? (i found this code: io.sockets.volatile.emit( 'broadcast_msg' , msg ); but i want to send it only from specific user to specific user, not all users connected.)
Thank you for your help, I see a lot of examples, but not what I need.
UPDATE:
I don't understand this code:
// on server started we can load our client.html page
function handler(req, res) {
fs.readFile(__dirname + '/client.html', function(err, data) {
if(err) {
console.log(err);
res.writeHead(500);
return res.end('Error loading client.html');
}
res.writeHead(200);
res.end(data);
});
}
Why do I need to do this? I have ex: index.php?menu=30 or index.php?menu=30&action=12