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 |
struct | 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) . | |
struct | Maintains the user's room-related state. Key property: currentRoom represents the room state for the current user. | |
enum | Represents real-time events for room activity. | |
class | Core class for room lifecycle management. Provides APIs for room operations and supports real-time event subscriptions via roomEventPublisher. |
CreateRoomOptions with the room name and other properties.createAndJoinRoom API to create and enter the room.webinar_ to distinguish them from standard meeting rooms.import Foundationimport AtomicXCoreprivate let roomID = "webinar_123456"private let roomType = .webinarfunc createAndJoinRoom() {// 1. Configure room creation parameters// CreateRoomOptions defines the room's basic properties and member management settingsvar options = CreateRoomOptions()options.roomName = "Team webinar" // Room display nameoptions.password = "" // Room password (optional)// 2. Set global room permissionsoptions.isAllCameraDisabled = false // Disable all members' camerasoptions.isAllMessageDisabled = false // Mute all membersoptions.isAllMicrophoneDisabled = false // Mute all microphonesoptions.isAllScreenShareDisabled = false // Disable screen sharing for all members// 3. Create and join room// Automatically handles room creation (if needed) and joining logicRoomStore.shared.createAndJoinRoom(roomID: roomID, roomType: roomType, options: options) { result inswitch result {case .success():print("Successfully created and joined the room")case .failure(let error):print("Failed to create and join the room [Error code: \\(error.code)]: \\(error.message)")}}}
Parameter | 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.Use webinar for webinar scenarios. |
options | CreateRoomOptions | Yes | Room creation configuration. See CreateRoomOptions struct for details. |
completion | CompletionClosure | No | Callback for room creation/join result. Returns error code and message if unsuccessful. |
Parameter | 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 | Bool | No | Disable microphones for all members (except host/administrators): true: Disabled. false: Enabled (default). |
isAllCameraDisabled | Bool | No | Disable cameras for all members (except host/administrators): true: Disabled. false: Enabled (default). |
isAllScreenShareDisabled | Bool | No | Disable screen sharing for all members (only host/administrators can share): true: Disabled. false: Enabled (default). |
isAllMessageDisabled | Bool | No | Mute all members (disable chat): true: Disabled. false: Enabled (default). |
joinRoom API.import Foundationimport AtomicXCoreprivate let roomID = "webinar_123456"private let roomType = .webinarfunc joinRoom() {// 1. Prepare join parameters// joinRoom is used to enter an existing roomlet roomPassword = "" // Room password, empty or nil if not set// 2. Call joinRoom API// This checks room existence, user ban status, and password correctnessRoomStore.shared.joinRoom(roomID: roomID, roomType: roomType, password: roomPassword) { result inswitch result {case .success():print("Successfully joined the room")case .failure(let error):print("Failed to join the room [Error code: \\(error.code)]: \\(error.message)")}}}
RoomParticipantState. For details, see Member Management.Parameter | 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.Use webinar for webinar scenarios. |
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 | CompletionClosure | No | Callback for join result. Returns error code and message if unsuccessful. |
leaveRoom API.import Foundationimport AtomicXCorefunc leaveRoom() {// 1. Description// leaveRoom is for members or host to voluntarily exit the room// Unlike endRoom, when the host leaves, only they exit; the room persists// 2. Call leaveRoom API// Stops audio/video streams and removes the user from the room server-sideRoomStore.shared.leaveRoom { result inswitch result {case .success():print("Successfully left the room")case .failure(let error):print("Failed to leave the room [Error code: \\(error.code)]: \\(error.message)")}}}
endRoom API. All members will receive a room ended event.import Foundationimport AtomicXCorefunc endRoom() {// 1. Description// endRoom permanently dissolves the current room// Typically called only by the host. All members are removed after dissolution// 2. Call endRoom API// Sends the dissolve command to the server and notifies all participantsRoomStore.shared.endRoom { result inswitch result {case .success():print("Room ended successfully")case .failure(let error):print("Failed to end room [Error code: \\(error.code)]: \\(error.message)")}}}
updateRoomInfo API. After the update, all members receive a state change notification.import Foundationimport AtomicXCoreprivate let roomID = "webinar_123456"func updateRoomInfo() {// 1. Configure update parameters// UpdateRoomOptions defines which room properties to updatevar options = UpdateRoomOptions()options.roomName = "webinar room" // New room display name// 2. Set modify flags// ModifyFlag specifies fields to updatevar modifyFlag: UpdateRoomOptions.ModifyFlag = []modifyFlag.insert(.roomName) // Mark roomName for update// 3. Call updateRoomInfo API// Sends update request to the server and syncs changes to all membersRoomStore.shared.updateRoomInfo(roomID: roomID, options: options, modifyFlag: modifyFlag) { result inswitch result {case .success():print("Room information updated successfully")case .failure(let error):print("Failed to update room information [Error code: \\(error.code)]: \\(error.message)")}}}
Parameter | 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. |
modifyFlag | UpdateRoomOptions.ModifyFlag | Yes | Specifies which properties to update. Webinar rooms currently support updating the room name. See ModifyFlag documentation for usage. |
completion | CompletionClosure | No | Callback for update result. Returns error code and message if unsuccessful. |
Parameter | 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 | Type | Required | Description |
roomName | UInt | No | Flag for updating the room name. When modifying roomName, also set the roomName flag in ModifyFlag. |
password | UInt | 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.import Foundationimport AtomicXCoreprivate let roomID = "webinar_123456"func getRoomInfo() {// 1. Description// getRoomInfo fetches detailed info for a specified room// Includes room name, creator, participant count, permissions, etc.// 2. Call getRoomInfo API// Fetches the latest room state/configuration from the serverRoomStore.shared.getRoomInfo(roomID: roomID) { result inswitch result {case .success(let roomInfo):print("Successfully retrieved room info, roomInfo: \\(roomInfo)")case .failure(let error):print("Failed to retrieve room info [Error code: \\(error.code)]: \\(error.message)")}}}
import Foundationimport AtomicXCoreimport Combineprivate var cancellableSet = Set<AnyCancellable>()/// Set up room event listenerprivate func subscribeRoomEvent() {RoomStore.shared.roomEventPublisher.receive(on: DispatchQueue.main) // UI updates on main thread.sink { event inswitch event {case .onRoomEnded(let roomInfo):print("The current room has ended")default: break}}.store(in: &cancellableSet)}
import Foundationimport AtomicXCoreimport Combineprivate var cancellableSet = Set<AnyCancellable>()private func subscribeRoomState() {/// Set up current room state listenerRoomStore.shared.state.subscribe(StatePublisherSelector(keyPath: \\.currentRoom)).receive(on: DispatchQueue.main) // UI updates on main thread.sink { roomInfo inif let newRoomInfo = roomInfo {print("Room info updated. New room info: \\(newRoomInfo)")}}.store(in: &cancellableSet)}
Store/Component | Feature Description | API Documentation |
RoomStore | Complete room lifecycle management: create & join, join, leave, end room, update and get room info, listen for room events (such as dissolution, info updates, etc.) |
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan