0
我正在尝试使用coffeescript与socket.io。可以在CoffeeScript中使用保留关键字“in”吗?
io = socketio.listen(server);
// handle incoming connections from clients
io.sockets.on('connection', function(socket) {
// once a client has connected, we expect to get a ping from them saying what room they want to join
socket.on('room', function(room) {
socket.join(room);
});
});
// now, it's easy to send a message to just the clients in a given room
room = "abc123";
io.sockets.in(room).emit('message', 'what is going on, party people?');
// this message will NOT go to the client defined above
io.sockets.in('foobar').emit('message', 'anyone in this room yet?');
io.sockets.in不能正确编译。
我应该如何解决这个问题?
什么是编译错误消息? – 2013-03-15 09:26:32
没有错误。但是coffeescript会将** io.sockets.in(“foobar”)**编译为** io.sockets [“in”](“foobar”)**。 – 2013-03-15 09:29:44
@OrionChang很好。这两个符号在JavaScript中是等效的。 – freakish 2013-03-15 09:40:51