join
Joins the room and starts publishing the microphone and camera requested in VideoSDK.createRoom.
Before calling it, register your RoomEventListener with addEventListener and get CAMERA / RECORD_AUDIO granted with VideoSDK.checkPermissions. A listener added afterwards can miss the join, and a missing permission leaves that device off for the whole session.
The local participant is in the room once RoomEventListener.onRoomJoined fires, not when this call returns — the event can arrive first. From then on localParticipant has its final id and the other room actions are accepted. The same Room can be joined again after leave.
Events:
RoomEventListener.onRoomStateChanged — emitted with RoomState.CONNECTING as the join starts
RoomEventListener.onRoomJoined — emitted on the local participant when the room is joined
RoomEventListener.onRoomStateChanged — emitted with RoomState.CONNECTED right after
onRoomJoined, or with RoomState.FAILED if the join failsRoomEventListener.onParticipantJoined — emitted on remote participants for the new joiner
ParticipantEventListener.onStreamEnabled — emitted on the local participant for each stream enabled on join
Code Example:
room.addEventListener(object : RoomEventListener() {
override fun onRoomJoined(switchRoomId: String?) { showCallScreen() }
override fun onError(error: VideoSDKError) { showError(error.message) }
})
lifecycleScope.launch {
try {
room.join()
} catch (e: VideoSDKException) {
showError(e.message)
}
}See also
Throws
code 3055 (ERROR_OPERATION_IN_PROGRESS) if a join is already running, code 3054 (ERROR_ALREADY_IN_REQUESTED_STATE) if this room is already joined, or the server's refusal otherwise — a bad or expired token included.