Hii,
You can try the code below:
io.to(socket.id).emit("event", data);
whenever a user joined to the server, socket details will be generated including ID. This is the ID really helps to send a message to particular people.
First we need to store all the socket.ids in array,
var people={};
people[name] = socket.id;
here name is the receiver name.
Example:
people["ccccc"]=2387423cjhgfwerwer23;
So, now we can get that socket.id with the receiver name whenever we are sending message for this we need to know the receivername.
Hope this work!!
Thank You!!