简体   繁体   中英

How do I add a socket.io socket to a room via their socketid?

I'm running a function with this line I pilfered from the internet somewhere:

io.sockets[socketID].join(roomName);

It isn't working properly. Is there any way I can accomplish adding a socket to a room without having reference to the socket object? Or is there any way to get a reference to the socket object from an ID?

Thanks!

在socket.io 1+中,您将使用服务器上的套接字ID,如下所示:

io.sockets.connected[socketID].join(roomName);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM