1 Answers to this question

Ans:  You can try the below code to send a message to a particular client with socket.io.

io.to(socket.id).emit("event", data);

Whenever the user joins into the server, the socket details will be generated including the ID. The UD is responsible for sending a message to a particular person or people.

The primary step is to store all the socket.ids in an array.

var person={};

person[name] =  socket.id;

The name will be the receiver name.

If you want to unleash your potential in this competitive field, please visit the Web Development Training page for more information, where you can find the       and       as well.

For more updates on the latest courses stay tuned to HKR Trainings.

WhatsApp
To Top