Reputation: 19
I am creating a chat application in Socket.io and node I am new in this I have a some query regarding chat app how can we maintain user's list and how can we send a message to specific person from user list?
Upvotes: 0
Views: 2179
Reputation: 1112
Like this (On the server-side) Cheatsheet:
// sending to individual socketid (private message)
socket.to(<socketid>).emit('hey', 'I just met you');
The <>
chatacters can be omitted, just make sure you replace socketid
with whatever the socket ID truly is. This will sent a message to ONLY the socket id specified. I know this works because I use it.
Upvotes: 1