RoomStore handles all room-related operations in AtomicXCore, offering a comprehensive set of APIs for managing the entire lifecycle of conference rooms—from creation to dissolution. Using RoomStore, you can efficiently build a robust room management system with features like retrieving and updating room details.onRoomEnded event.Core Concept | Type | Core Responsibilities & Description |
data class | Data model representing room information, including all details and state management. Key features: Room info management (ID, name, creator). Real-time status tracking (member count, room status, creation time). Permission control (device and message management) . | |
data class | Maintains the user's room-related state. Key property: currentRoom represents the room state for the current user. | |
abstract class | Represents real-time events related to room activity. | |
abstract class | The main class for managing the entire room lifecycle. Supports room management operations and real-time event subscriptions via RoomListener. |
CreateRoomOptions to set the room name and other attributes.createAndJoinRoom API to perform the operation.webinar_ to distinguish them from standard meeting rooms.import android.util.Logimport io.trtc.tuikit.atomicxcore.api.CompletionHandlerimport io.trtc.tuikit.atomicxcore.api.room.CreateRoomOptionsimport io.trtc.tuikit.atomicxcore.api.room.RoomStoreimport io.trtc.tuikit.atomicxcore.api.room.RoomTypeprivate val roomID = "webinar_123456"private val roomType = RoomType.WEBINARfun createAndJoinRoom() {// 1. Configure room creation parameters// CreateRoomOptions defines basic room attributes and member management settingsval options = CreateRoomOptions(roomName = "Team Meeting Room", // Room display name// 2. Set initial room permission controlsisAllCameraDisabled = false, // Disable all members' camerasisAllMessageDisabled = false, // Mute all membersisAllMicrophoneDisabled = false, // Mute all membersisAllScreenShareDisabled = false // Disable screen sharing for all members)// 3. Call RoomStore to create and join the room// This method automatically handles room creation (if it doesn't exist) and joining logicRoomStore.shared().createAndJoinRoom(roomID, roomType, options, object : CompletionHandler {override fun onSuccess() {Log.d("Room", "Room created and joined successfully")}override fun onFailure(code: Int, desc: String) {Log.e("Room", "Failed to create and join room [Error code: $code]: $desc")}})}
Parameter Name | Type | Required | Description |
roomID | String | Yes | Unique room identifier. Length: 0–48 bytes. Use only numbers, English letters (case-sensitive), underscores (_), and hyphens (-). Avoid spaces and Chinese characters. |
roomType | RoomType | Yes | Room type: STANDARD: Standard room.WEBINAR: Large webinar room.For webinar scenarios, use WEBINAR. |
options | CreateRoomOptions | Yes | Room creation configuration. See CreateRoomOptions struct for details. |
completion | CompletionHandler | No | Completion callback. Returns the result of create and join operation. If failed, returns error code and message. |
Parameter Name | Type | Required | Description |
roomName | String | No | Room name (optional, defaults to empty). Length: 0–60 bytes. Supports Chinese, English, numbers, and special characters. |
password | String | No | Room password. Empty string means no password. Length: 0–32 bytes. For easy mobile input, use 4–8 digits. If set, users must enter the password to join. Do not store sensitive info in plain text. Passwords are not supported for webinar rooms; leave empty. |
isAllMicrophoneDisabled | Boolean | No | Disable microphones for all members (except host/administrators): true: Disabled. false: Enabled (default). |
isAllCameraDisabled | Boolean | No | Disable cameras for all members (except host/administrators): true: Disabled. false: Enabled (default). |
isAllScreenShareDisabled | Boolean | No | Disable screen sharing for all members (only host/administrators can share): true: Disabled. false: Enabled (default). |
isAllMessageDisabled | Boolean | No | Mute all members (disable chat): true: Disabled. false: Enabled (default). |
joinRoom API.import android.util.Logimport io.trtc.tuikit.atomicxcore.api.CompletionHandlerimport io.trtc.tuikit.atomicxcore.api.room.RoomStoreimport io.trtc.tuikit.atomicxcore.api.room.RoomTypeprivate val roomID = "webinar_123456"private val roomType = RoomType.WEBINARfun joinRoom() {// 1. Prepare parameters for joining the room// joinRoom is used to join a known and ongoing room// 2. Call RoomStore to join the roomRoomStore.shared().joinRoom(roomID, roomType, completion = object : CompletionHandler {override fun onSuccess() {Log.d("Room", "Joined room successfully")}override fun onFailure(code: Int, desc: String) {Log.e("Room", "Failed to join room [Error code: $code]: $desc")}})}
RoomParticipantState. For details, see Member Management.Parameter Name | Type | Required | Description |
roomID | String | Yes | Unique room identifier. Length: 0–48 bytes. Use only numbers, English letters (case-sensitive), underscores (_), and hyphens (-). Avoid spaces and Chinese characters. |
roomType | RoomType | Yes | Room type: STANDARD: Standard room.WEBINAR: Large webinar room.For webinar scenarios, use WEBINAR. |
password | String | No | Room password. Empty string means no password. Length: 0–32 bytes. Use 4–8 digits for easy input. If set, users must enter the password to join. Do not store sensitive info in plain text. Passwords are not supported for webinar rooms; leave empty. |
completion | CompletionHandler | No | Completion callback. Returns the result of join operation. If failed, returns error code and message. |
leaveRoom API.import android.util.Logimport io.trtc.tuikit.atomicxcore.api.room.RoomStoreimport io.trtc.tuikit.atomicxcore.api.CompletionHandlerfun leaveRoom() {// 1. Business logic description// leaveRoom is used for regular members or hosts to voluntarily exit the room// Unlike endRoom, when the host calls leaveRoom, only they leave; the room remains active// 2. Call RoomStore to leave the room// This operation stops audio/video streams and notifies the server to remove the current user from the roomRoomStore.shared().leaveRoom(object : CompletionHandler {override fun onSuccess() {Log.d("Room", "Left room successfully")}override fun onFailure(code: Int, desc: String) {Log.e("Room", "Failed to leave room [Error code: $code]: $desc")}})}
endRoom API. After the room ends, all members receive a room ended event.import android.util.Logimport io.trtc.tuikit.atomicxcore.api.CompletionHandlerimport io.trtc.tuikit.atomicxcore.api.room.RoomStorefun endRoom() {// 1. Business logic description// endRoom is used to permanently dissolve the current room// Note: This operation is typically restricted to the host (Owner); after dissolution, all members are forcibly removed// 2. Call RoomStore to dissolve the room// This method sends a dissolution command to the server and notifies all online members that the room has endedRoomStore.shared().endRoom(object : CompletionHandler {override fun onSuccess() {Log.d("Room", "Room dissolved successfully")}override fun onFailure(code: Int, desc: String) {Log.e("Room", "Failed to dissolve room [Error code: $code]: $desc")}})}
updateRoomInfo API. All room members will receive a room state change notification after the update.import android.util.Logimport io.trtc.tuikit.atomicxcore.api.room.RoomStoreimport io.trtc.tuikit.atomicxcore.api.room.UpdateRoomOptionsimport io.trtc.tuikit.atomicxcore.api.CompletionHandlerprivate val roomID = "webinar_123456"fun updateRoomInfo() {// 1. Configure room update parameters// UpdateRoomOptions is used to define which room attributes to updateval options = UpdateRoomOptions(roomName = "New Webinar Name" // Update room display name)// 2. Set modification flags// modifyFlagList specifies which fields to update, supports combining multiple flagsval modifyFlagList = listOf(UpdateRoomOptions.ModifyFlag.ROOM_NAME)// 3. Call RoomStore to update room information// This method submits the update request to the server and synchronizes it to all room membersRoomStore.shared().updateRoomInfo(roomID, options, modifyFlagList, object : CompletionHandler {override fun onSuccess() {Log.d("Room", "Room information updated successfully")}override fun onFailure(code: Int, desc: String) {Log.e("Room", "Failed to update room information [Error code: $code]: $desc")}})}
Parameter Name | Type | Required | Description |
roomID | String | Yes | Unique room identifier. Length: 0–48 bytes. Use only numbers, English letters (case-sensitive), underscores (_), and hyphens (-). Avoid spaces and Chinese characters. |
options | UpdateRoomOptions | Yes | Room property update configuration. See UpdateRoomOptions struct for details. |
modifyFlagList | List | Yes | Specifies which properties to update. Webinar rooms currently support updating the room name. See ModifyFlag documentation for usage. |
completion | CompletionHandler | No | Completion callback. Returns the result of the update operation. If failed, returns error code and message. |
Parameter Name | Type | Required | Description |
roomName | String | No | Room name (optional, defaults to empty). Length: 0–60 bytes. Supports Chinese, English, numbers, and special characters. |
password | String | No | Room password. Empty string means no password. Length: 0–32 bytes. Use 4–8 digits for easy input. If set, users must enter the password to join. Do not store sensitive info in plain text. Passwords are not supported for webinar rooms; leave empty. |
Parameter Name | Type | Required | Description |
ROOM_NAME | enum | No | Flag for updating the room name. When modifying roomName, also set the roomName flag in ModifyFlag. |
PASSWORD | enum | No | Flag for updating the room password. When modifying password, also set the password flag in ModifyFlag.Passwords are not supported for webinar rooms. |
getRoomInfo API to retrieve detailed room information.import android.util.Logimport io.trtc.tuikit.atomicxcore.api.room.RoomStoreimport io.trtc.tuikit.atomicxcore.api.room.RoomInfoimport io.trtc.tuikit.atomicxcore.api.room.GetRoomInfoCompletionHandlerprivate val roomID = "webinar_123456"fun getRoomInfo() {// 1. Business logic description// getRoomInfo is used to retrieve detailed information for a specified room// You can get the room name, creator, permission settings, and other complete information// 2. Call RoomStore to get room information// This operation fetches the latest room status and configuration from the serverRoomStore.shared().getRoomInfo(roomID, object : GetRoomInfoCompletionHandler {override fun onSuccess(roomInfo: RoomInfo) {Log.d("Room", "Room information retrieved successfully, roomInfo: $roomInfo")}override fun onFailure(code: Int, desc: String) {Log.e("Room", "Failed to retrieve room information [Error code: $code]: $desc")}})}
import android.content.Contextimport android.util.AttributeSetimport android.util.Logimport android.widget.FrameLayoutimport io.trtc.tuikit.atomicxcore.api.room.RoomInfoimport io.trtc.tuikit.atomicxcore.api.room.RoomListenerimport io.trtc.tuikit.atomicxcore.api.room.RoomStoreclass RoomMainView @JvmOverloads constructor(context: Context,attrs: AttributeSet? = null,defStyleAttr: Int = 0) : FrameLayout(context, attrs, defStyleAttr) {// Room event listenerprivate val roomListener = object : RoomListener() {override fun onRoomEnded(roomInfo: RoomInfo) {Log.d("Room", "The current room has ended")// Recommended action: Close the current page and return to the previous screen}}override fun onAttachedToWindow() {super.onAttachedToWindow()// Add room event listenerRoomStore.shared().addRoomListener(roomListener)}override fun onDetachedFromWindow() {super.onDetachedFromWindow()// Remove listener to prevent memory leaksRoomStore.shared().removeRoomListener(roomListener)}}
import android.util.Logimport io.trtc.tuikit.atomicxcore.api.room.RoomStoreimport kotlinx.coroutines.CoroutineScopeimport kotlinx.coroutines.Dispatchersimport kotlinx.coroutines.launch// Subscribe to changes in the current room informationprivate fun subscribeCurrentRoomState() {CoroutineScope(Dispatchers.Main).launch {RoomStore.shared().state.currentRoom.collect { roomInfo ->Log.d("Room", "Room information updated, new room info: $roomInfo")}}}
Store/Component | Description | API Documentation |
RoomStore | Room lifecycle management: create and join / join / leave / end room / update, get room information / listen to passive room events (such as room dissolution, room info updates, etc.). |
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan