Socket.io 0.9和1.0广播给所有会员

在Socket.io 1.0和Socket.io 0.9中,以下哪种语法是正确的,可将消息广播到一个房间内所有连接的套接字?

以下都没有发送消息到我的客户端Web控制台,它有一个简单的日志语句,但至less有四个发送到其他客户端。

我怎么会正确地发出一个“joined_channel”消息回我连接的客户端,和房间里的所有其他客户端?

Client socket.on('joined_channel', function(data){ console.log('joined channel', data); }) Server // this is for 0.9 io.sockets.in(data.room).emit('joined_channel', data.room); // which version is this for? Any? socket.broadcast.to(data.room).emit('joined_channel', data.room); // is this to all connected users? io.sockets.emit('joined_channel', data.room); // To all connected users globally? io.emit('joined_channel', data.room); // how is socket different than io? socket.emit('joined_channel', data.room); // this is for 0.9 but does it work at all? io.sockets.to(data.room).emit('joined_channel', data.room); // this is as above but 1.0? io.to(data.room).emit('joined_channel', data.room); 

这是最新的socket.io。

这是从http://psitsmike.com/2011/10/node-js-and-socket-io-multiroom-chat-tutorial/

 //emit from server to everyone but the clients socket socket.broadcast.emit('joined_channel', data); //broadcast information to a certain room only (excluding the client) socket.broadcast.to( data.room ).emit('joined_channel'); //broadcast information globally to a certain room io.sockets.in( data.room ).emit('joined_channel');