[英]node.js socket.io cannot send to specific client
我發現了一些對此的引用,但實際上並沒有什么幫助。 此外,根據一些研究,這是向特定客戶發送消息的正確方法。 我有:
io.sockets.socket(players[i].id).emit('deal_card', {
// etc
});
我在這一行得到了這個錯誤:
Missing error handler on 'socket'.TypeError: Object #<Namespace> has no method 'socket'
有任何想法嗎?
對於socket.io 1.0使用:
io.sockets.connected[players[i].id].emit('deal_card', {..});
適用於0.9:
io.sockets.sockets[players[i].id].emit('deal_card', {..});
(不是io.sockets.socket [players [i] .id] .emit('deal_card',{..});)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.