Socket.IO 1.0.x:通过 id 获取套接字 [英] Socket.IO 1.0.x: Get socket by id
本文介绍了Socket.IO 1.0.x:通过 id 获取套接字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在0.9.x版本中,我们可以像这样通过ID获取socket:
In the 0.9.x version, we can get socket by ID like this:
io.sockets.socket(socketId)
但是在 1.0.x 中我们不能.1.0.x如何通过id查找socket?
But in 1.0.x we can't. How to find a socket by id in 1.0.x?
推荐答案
对于 socket.io 1.0 使用:
For socket.io 1.0 use:
io.sockets.connected[socketId]
对于 0.9,它的 io.sockets.sockets[socketId] 而不是 io.sockets.socket[socketId]
For 0.9 its io.sockets.sockets[socketId] and not io.sockets.socket[socketId]
这篇关于Socket.IO 1.0.x:通过 id 获取套接字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文