我昨天试了,
socket.broadcast.emit是发给除自己外的所有,
socket.emit只发给自己 ,
io.sockets.emit 发给全部
clients = io.sockets.clients()
clients.forEach(function(client){
if(client.name ==data.to){
client.emit('say’,data);
}
})
client.emit私聊发给对应的client
学自: http://cnodejs.org/topic/51d51cd8d44cbfa3047926ba