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获得套接字,如下所示:
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查找套接字?
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屋!
查看全文