switchTo

suspend fun switchTo(roomId: String, token: String? = null)

Moves this participant into another room without tearing the session down — a breakout room, say. Faster than leave plus a fresh join, and the same Room object keeps working.

RoomEventListener.onRoomJoined fires again for the new room, this time with switchRoomId set to roomId. The new room is always entered in Mode.SEND_AND_RECV, whatever mode this one was in.

Parameters

roomId

the room to move to.

token

a token valid for that room, or null to reuse this room's.

Throws

code 3073 (ERROR_INVALID_PARAMETER) if roomId is blank, or 4076 (SWITCH_ROOM_FAILED) when the server refuses the switch, for example because roomId has no live session. Nothing reaches RoomEventListener.onError, and this participant stays in the current room, still connected.