【发布时间】:2014-10-24 05:53:27
【问题描述】:
我知道这是一个非常受欢迎的问题,但我没有找到我的问题的答案。 非常相似的问题: socket.IO: how can i get the socketid when i emit to a specific client in socket.io 1.0
我想使用 socketId 向特定的客户端发出,但是我得到一个错误,见下文。
socket.join( gameId );
io.sockets.connected( opponent ).join( gameId );
socket.emit( 'ready', gameId, 'X', x, y );
io.sockets.connected( opponent ).emit( 'ready', gameId, 'O', x, y );
错误:
io.sockets.connected( opponent ).join( gameId );
^
TypeError: Property 'connected' of object #<Namespace> is not a function
请帮助我。
忘了说了,.join(gameId) 和io.to(socket.id) 不能用
【问题讨论】:
标签: node.js sockets socket.io socket.io-1.0