javascript – socket.io从两个房间加入客户端

我想加入两个房间的客户到一个新的房间.有没有办法实现这个目标?喜欢:

io.sockets.clients(room1 , room2).join(room 3);

解决方法:

var rooms = ['room1', 'room2', room3]; // list of rooms

socket.join('room1'); // assign the room on connection

var clients = io.sockets.clients(rooms[0]); // list of all clients in room1

for (client in clients)
    {
        clients[client].leave(rooms[0]); // leave room1
        clients[client].join(rooms[2]); // join room3
    }

对room2重复相同的操作.希望这可以帮助

上一篇:高效构建 Docker 镜像的最佳实践


下一篇:为Android开发Instance Messaging Client Server