最佳答案
Socket.io 的自述文件包含以下示例:
var io = require('socket.io').listen(80);
io.sockets.on('connection', function (socket) {
socket.join('justin bieber fans');
socket.broadcast.to('justin bieber fans').emit('new fan');
io.sockets.in('rammstein fans').emit('new non-fan');
});
socket.broadcast.to()
和 io.sockets.in()
有什么区别?