onRoomJoined

open fun onRoomJoined(switchRoomId: String? = null)

Called when the local participant has successfully joined the room.

This is the event to wait for after Room.join: from here the room is fully connected, Room.localParticipant has its final id, and you can enable media, subscribe to PubSub topics and call the other room actions.

It fires again on the same Room after a reconnect that needed a fresh join, and after a room switch, so treat it as "the session is live now" rather than a one-time setup hook.

Code Example:

override fun onRoomJoined(switchRoomId: String?) {
Log.d("Room", "Joined room: ${room.id}")
scope.launch {
room.pubSub.subscribe("CHAT", object : PubSubMessageListener {
override fun onMessageReceived(message: PubSubMessage) {
Log.d("PubSub", "Received: ${message.message}")
}
})
}
}

Parameters

switchRoomId

the room ID switched into. null on a first join and on a rejoin after reconnecting.

See also