* Joins a room. * * @example * io.on("connection", (socket) => { * // join a single room * socket.join("room1"); * * // join multiple rooms * socket.join(["room1", "room2"]); * }); * * @param {String|Array} rooms - room or array of rooms * @return a Promis
(rooms: Room | Array<Room>)
| 556 | * @return a Promise or nothing, depending on the adapter |
| 557 | */ |
| 558 | public join(rooms: Room | Array<Room>): Promise<void> | void { |
| 559 | getLogger("socket.io").debug(`[socket] join room ${rooms}`); |
| 560 | |
| 561 | return this.adapter.addAll( |
| 562 | this.id, |
| 563 | new Set(Array.isArray(rooms) ? rooms : [rooms]) |
| 564 | ); |
| 565 | } |
| 566 | |
| 567 | /** |
| 568 | * Leaves a room. |
no test coverage detected