我有问题,因为这个例子不起作用,我不知道为什么......
服务器
var app = require('http').createServer(handler);
var io = require('socket.io').listen(app);
var fs = require('fs');
var port = 3250;
app.listen(port);
io.sockets.on('connection', function(socket) {
socket.on('room', function(room) {
socket.join(room);
});
var room = abc123
io.sockets.in(room).emit('m', 'what is going on, party people?');
});
客户
var room = "abc123";
socket.on('connect', function() {
socket.emit('room', room);
});
socket.on('m', function(data) {
document.write(data);
});
我正在尝试使用此https://gist.github.com/crabasa/2896891并没有帮助:(
谢谢你的帮助!