为什么io.sockets.in无法正常工作?

时间:2018-08-04 19:29:13

标签: node.js socket.io

客户端脚本

var socket = io.connect();
var room = "abc123";

socket.on('connect', function() {

socket.emit('room', room);
});

socket.on('message', function(data) {
 console.log('Incoming message:', data);
});

服务器端脚本

io = socketio.listen(server);

io.sockets.on('connection', function(socket) {
 socket.on('room', function(room) {
    socket.join(room);
});
});
room = "abc123";
io.sockets.in(room).emit('message', 'what is going on, party 
people?');

我正在尝试将邮件发送到abc123,但是io.sockets.in无法正常工作

0 个答案:

没有答案