leave
Leaves the room, disconnecting the local participant.
After leaving, the local participant receives RoomEventListener.onRoomLeft and remote participants receive RoomEventListener.onParticipantLeft. The camera and microphone are released before onRoomLeft fires.
Available once the room is connected and, unlike the other room actions, also while it is RoomState.RECONNECTING, so an app can always get out of a live session. Called while a join is still in progress, it cancels that join. After a failed join (RoomState.FAILED) it releases what the join opened and fires onRoomLeft as usual.
In any other state it throws, and nothing is reported on RoomEventListener.onError.
Events:
ParticipantEventListener.onStreamDisabled — emitted on all participants for each stream the local participant was publishing
RoomEventListener.onRoomStateChanged — emitted on the local participant with RoomState.DISCONNECTED
RoomEventListener.onRoomLeft — emitted on the local participant with LeaveReason.MANUAL_LEAVE_CALLED
RoomEventListener.onParticipantLeft — emitted on remote participants when the participant leaves
Code Example:
lifecycleScope.launch { room.leave() }See also
Throws
code 3035 (ERROR_ACTION_PERFORMED_BEFORE_ROOM_JOINED) if join was never called; code 3054 (ERROR_ALREADY_IN_REQUESTED_STATE) if it has already ended.