LordZardeck
LordZardeck

Reputation: 8283

send data to specific socket

How can in send data to a specific connected socket in Node.js? I want to write a server that accepts incoming sockets, assigns them an id, and then when messages are sent from the other client, it is directed to that one. I guess you could say similar to a private message.

Also, is there a way to emit data EXCLUDING one socket?

Upvotes: 2

Views: 2224

Answers (1)

alessioalex
alessioalex

Reputation: 63653

There are similar questions on stackoverflow, here's an example:

Sending a message to a client via its socket.id

Quick version:

io.sockets.socket(id).emit('hello');

Upvotes: 1

Related Questions