【发布时间】:2013-03-15 19:27:29
【问题描述】:
我正在尝试将 coffeescript 与 socket.io 一起使用。
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无法正确编译。
我应该如何解决这个问题?
【问题讨论】:
-
什么是编译错误信息?
-
没有错误。但是coffeescript会将io.sockets.in("foobar")编译成io.sockets["in"]("foobar")。
-
@OrionChang 没关系。这两个符号在 JavaScript 中是等价的。
-
这实际上是一个咖啡功能
标签: node.js coffeescript socket.io