client.on('msg', function(msg){
//io.sockets.in(msg.room).emit('msg', msg);
client.get('room', function(err, room) {
io.sockets.in(room).emit('msg',msg);
})
});
正在将消息发送到所有房间,而不仅仅是"房间",但我不了解原因。我正在使用
client.set("room",name,function(){ return true; });
我正在将值设置为 on('join'),我看不出在使用 in() 时它甚至是一个发送到所有房间的选项,如果它没有找到任何东西,它默认为不发送到任何房间,不发送到 ALL?
我的完整服务器.js代码
提前感谢伙计们。
io.sockets.on("connection",function(socket){
socket.on("load Ex",function(data){
io.sockets.in(parseInt(data.coneference)).emit('ex mesajlar', allData);
});
});
在客户端,您必须通过按钮单击或记录 Ready 事件触发load Ex
,然后创建侦听器客户端中的套接字。
socket.on("ex mesajlar",function(data) {
alert(data.msg);
});