Skip to content

Latest commit

 

History

History
14 lines (11 loc) · 289 Bytes

socket_rooms.md

File metadata and controls

14 lines (11 loc) · 289 Bytes

socket.rooms

  • (Object)

标识此socket所在房间的字符串哈希,按房间名称索引。

io.on('connection',(socket)=>{
    socket.join('room 237',()=>{
        let rooms= Object.keys(socket.rooms)
        console.log(rooms); // [ <socket.id>,"room 237" ]
    })
})