会议对象是与 RealtimeKit 会话进行交互的核心接口。它提供了对参与者、本地用户控制、聊天、投票、插件等的访问。此对象在您初始化 SDK 时返回。
本指南涵盖了会议对象上的核心命名空间以及最常用的属性、方法和事件。各命名空间参考已链接以获取更多详细信息。
会议对象包含多个属性,这些属性组织了会议的不同方面:
meeting.self 表示会议中的本地用户(你)。它提供用于控制自己的音频、视频和屏幕共享的属性和方法。
关键属性:
// Participant identifiers
meeting.self.id; // Peer ID (unique per session)
meeting.self.userId; // Participant ID (persistent across sessions)
meeting.self.name; // Participant display name
// Media state
meeting.self.audioEnabled; // Boolean: Is audio enabled?
meeting.self.videoEnabled; // Boolean: Is video enabled?
meeting.self.screenShareEnabled; // Boolean: Is screen share active?
// Media tracks
meeting.self.audioTrack; // Audio MediaStreamTrack, if audio is enabled
meeting.self.videoTrack; // Video MediaStreamTrack, if video is enabled
meeting.self.screenShareTracks; // Structure: { audio: MediaStreamTrack, video: MediaStreamTrack }, if screen share is enabled
// Room state
meeting.self.roomJoined; // Boolean: Has joined the meeting?
meeting.self.roomState; // Current room state常用方法:
// Media controls
await meeting.self.enableAudio(); // Emits a `audioUpdate` event on `meeting.self` when successful.
await meeting.self.disableAudio(); // Emits a `audioUpdate` event on `meeting.self` when successful.
await meeting.self.enableVideo(); // Emits a `videoUpdate` event on `meeting.self` when successful.
await meeting.self.disableVideo(); // Emits a `videoUpdate` event on `meeting.self` when successful.
await meeting.self.enableScreenShare(); // Emits a `screenShareUpdate` event on `meeting.self` when successful.
await meeting.self.disableScreenShare(); // Emits a `screenShareUpdate` event on `meeting.self` when successful.
// Update Name
await meeting.self.setName("New Name"); // setName works only works before joining the meeting
// List Devices
await meeting.self.getAllDevices(); // Returns all available devices
await meeting.self.getAudioDevices(); // Returns all available audio devices
await meeting.self.getVideoDevices(); // Returns all available video devices
await meeting.self.getSpeakerDevices(); // Returns all available speaker devices
await meeting.self.getCurrentDevices(); // {audio: MediaDevice, video: MediaDevice, speaker: MediaDevice} Returns the current device configuration
// Change a device
await meeting.self.setDevice((await meeting.self.getAllDevices())[0]);meeting.self 表示会议中的本地用户(你)。它提供用于控制自己的音频、视频和屏幕共享的属性和方法。
关键属性:
// Participant identifiers
meeting.self.id; // Peer ID (unique per session)
meeting.self.userId; // Participant ID (persistent across sessions)
meeting.self.name; // Participant display name
// Media state
meeting.self.audioEnabled; // Boolean: Is audio enabled?
meeting.self.videoEnabled; // Boolean: Is video enabled?
meeting.self.screenShareEnabled; // Boolean: Is screen share active?
// Media tracks
meeting.self.audioTrack; // Audio MediaStreamTrack, if audio is enabled
meeting.self.videoTrack; // Video MediaStreamTrack, if video is enabled
meeting.self.screenShareTracks; // Structure: { audio: MediaStreamTrack, video: MediaStreamTrack }, if screen share is enabled
// Room state
meeting.self.roomJoined; // Boolean: Has joined the meeting?
meeting.self.roomState; // Current room state常用方法:
// Media controls
await meeting.self.enableAudio(); // Emits a `audioUpdate` event on `meeting.self` when successful.
await meeting.self.disableAudio(); // Emits a `audioUpdate` event on `meeting.self` when successful.
await meeting.self.enableVideo(); // Emits a `videoUpdate` event on `meeting.self` when successful.
await meeting.self.disableVideo(); // Emits a `videoUpdate` event on `meeting.self` when successful.
await meeting.self.enableScreenShare(); // Emits a `screenShareUpdate` event on `meeting.self` when successful.
await meeting.self.disableScreenShare(); // Emits a `screenShareUpdate` event on `meeting.self` when successful.
// Update Name
await meeting.self.setName("New Name"); // setName works only works before joining the meeting
// List Devices
await meeting.self.getAllDevices(); // Returns all available devices
await meeting.self.getAudioDevices(); // Returns all available audio devices
await meeting.self.getVideoDevices(); // Returns all available video devices
await meeting.self.getSpeakerDevices(); // Returns all available speaker devices
await meeting.self.getCurrentDevices(); // {audio: MediaDevice, video: MediaDevice, speaker: MediaDevice} Returns the current device configuration
// Change a device
await meeting.self.setDevice((await meeting.self.getAllDevices())[0]);meeting.self 表示会议中的本地用户(你)。它提供用于控制自己的音频、视频和屏幕共享的属性和方法。
关键属性:
// Participant identifiers
meeting.self.id; // Peer ID (unique per session)
meeting.self.userId; // Participant ID (persistent across sessions)
meeting.self.name; // Participant display name
// Media state
meeting.self.audioEnabled; // Boolean: Is audio enabled?
meeting.self.videoEnabled; // Boolean: Is video enabled?
meeting.self.screenShareEnabled; // Boolean: Is screen share active?
// Media tracks
meeting.self.audioTrack; // Audio MediaStreamTrack, if audio is enabled
meeting.self.videoTrack; // Video MediaStreamTrack, if video is enabled
meeting.self.screenShareTracks; // Structure: { audio: MediaStreamTrack, video: MediaStreamTrack }, if screen share is enabled
// Room state
meeting.self.roomJoined; // Boolean: Has joined the meeting?
meeting.self.roomState; // Current room state常用方法:
// Media controls
await meeting.self.enableAudio(); // Emits a `audioUpdate` event on `meeting.self` when successful.
await meeting.self.disableAudio(); // Emits a `audioUpdate` event on `meeting.self` when successful.
await meeting.self.enableVideo(); // Emits a `videoUpdate` event on `meeting.self` when successful.
await meeting.self.disableVideo(); // Emits a `videoUpdate` event on `meeting.self` when successful.
await meeting.self.enableScreenShare(); // Emits a `screenShareUpdate` event on `meeting.self` when successful.
await meeting.self.disableScreenShare(); // Emits a `screenShareUpdate` event on `meeting.self` when successful.
// Update Name
await meeting.self.setName("New Name"); // setName works only works before joining the meeting
// List Devices
await meeting.self.getAllDevices(); // Returns all available devices
await meeting.self.getAudioDevices(); // Returns all available audio devices
await meeting.self.getVideoDevices(); // Returns all available video devices
await meeting.self.getSpeakerDevices(); // Returns all available speaker devices
await meeting.self.getCurrentDevices(); // {audio: MediaDevice, video: MediaDevice, speaker: MediaDevice} Returns the current device configuration
// Change a device
await meeting.self.setDevice((await meeting.self.getAllDevices())[0]);meeting.localUser 表示会议中的本地用户(您)。它提供了控制您自己的音频、视频和屏幕共享的属性和方法。
关键属性:
// Participant identifiers
meeting.localUser.id // ID of the local user participant
meeting.localUser.userId // Persistent user ID across sessions
meeting.localUser.name // Name of the local user
meeting.localUser.picture // URL to the picture of the local user (optional)
meeting.localUser.customParticipantId // User provided participant ID (optional)
meeting.localUser.permissions // Permissions related to various capabilities within a meeting context for the local user
// Media state
meeting.localUser.audioEnabled // Boolean: Is audio currently enabled for the local user
meeting.localUser.videoEnabled // Boolean: Is video currently enabled for the local user
meeting.localUser.screenShareEnabled // Boolean: Is screenshare currently enabled for the local user
meeting.localUser.isCameraPermissionGranted // Boolean: Does local user have access to device Camera permission
meeting.localUser.isMicrophonePermissionGranted // Boolean: Does local user have access to device Microphone permission
// Participant metadata
meeting.localUser.isHost // Boolean: Is the local user the host
meeting.localUser.isPinned // Boolean: Is the local user pinned
meeting.localUser.flags // Participant flags (recorder, hiddenParticipant, webinarHiddenParticipant)
// Preset Info
meeting.localUser.presetName // String value representing name of preset for local user
meeting.localUser.presetInfo // Typed object representing the preset information for local user
meeting.localUser.designToken // Design token for UI customization
// Stage and room state
meeting.localUser.stageStatus // Stage status of the local user
meeting.localUser.roomJoined // Boolean: Has local user joined the room
meeting.localUser.waitListStatus // Waitlist status of the local user (NONE, WAITING, ACCEPTED, or REJECTED)常用方法:
// Get local user video view
meeting.localUser.getSelfPreview() // Returns a VideoView that can be added to any ViewGroup in Android
// Update Name
meeting.localUser.setDisplayName("New Name") // Name change is visible only if it occurs before joinRoom() and after init()
// Mute/Unmute Audio
meeting.localUser.disableAudio { error: AudioError? -> }
meeting.localUser.enableAudio { error: AudioError? -> }
// Enable/Disable Video
meeting.localUser.disableVideo { error: VideoError? -> }
meeting.localUser.enableVideo { error: VideoError? -> }
// Enable/Disable Screenshare
meeting.localUser.canEnableScreenShare() // Check if screenshare can be enabled
val error: ScreenShareError? = meeting.localUser.enableScreenShare() // Returns error if fails, null if successful
meeting.localUser.disableScreenShare()
// Device management
val audioDevices = meeting.localUser.getAudioDevices() // Get all available audio devices
val videoDevices = meeting.localUser.getVideoDevices() // Get all available video devices
meeting.localUser.setAudioDevice(audioDevices[0]) // Switch audio device
meeting.localUser.setVideoDevice(videoDevices[0]) // Switch video device
val selectedAudio = meeting.localUser.getSelectedAudioDevice() // Get currently selected audio device
val selectedVideo = meeting.localUser.getSelectedVideoDevice() // Get currently selected video device
meeting.localUser.switchCamera() // Switch between front and back camera
// Stage permissions
meeting.localUser.canJoinStage() // Check if local user can join stage
meeting.localUser.canRequestToJoinStage() // Check if local user can request to join stage
// Host controls
meeting.localUser.canDoParticipantHostControls() // Check if local user can perform host controls
// Setup screen
meeting.localUser.shouldShowSetupScreen() // Check if setup screen should be shown
meeting.localUser.shouldJoinMediaRoom() // Check if local user should join media roommeeting.localUser 表示会议中的本地用户(您)。它提供了控制您自己的音频、视频和屏幕共享的属性和方法。
关键属性:
// Participant identifiers
meeting.localUser.id // ID of the local user participant
meeting.localUser.userId // Persistent user ID across sessions
meeting.localUser.name // Name of the local user
meeting.localUser.picture // URL to the picture of the local user (optional)
meeting.localUser.customParticipantId // User provided participant ID (optional)
meeting.localUser.permissions // Permissions related to various capabilities within a meeting context for the local user
// Media state
meeting.localUser.audioEnabled // Boolean: Is audio currently enabled for the local user
meeting.localUser.videoEnabled // Boolean: Is video currently enabled for the local user
meeting.localUser.screenShareEnabled // Boolean: Is screenshare currently enabled for the local user
meeting.localUser.isCameraPermissionGranted // Boolean: Does local user have access to device Camera permission
meeting.localUser.isMicrophonePermissionGranted // Boolean: Does local user have access to device Microphone permission
// Participant metadata
meeting.localUser.isHost // Boolean: Is the local user the host
meeting.localUser.isPinned // Boolean: Is the local user pinned
meeting.localUser.flags // Participant flags (recorder, hiddenParticipant, webinarHiddenParticipant)
// Preset Info
meeting.localUser.presetName // String value representing name of preset for local user
meeting.localUser.presetInfo // Typed object representing the preset information for local user
meeting.localUser.designToken // Design token for UI customization
// Stage and room state
meeting.localUser.stageStatus // Stage status of the local user
meeting.localUser.roomJoined // Boolean: Has local user joined the room
meeting.localUser.waitListStatus // Waitlist status of the local user (.none, .waiting, .accepted, or .rejected)常用方法:
// Get local user video view
meeting.localUser.getSelfPreview() // Returns a VideoView (UIView) for iOS
// Update Name
meeting.localUser.setDisplayName("New Name") // Name change is visible only if it occurs before joinRoom() and after init()
// Mute/Unmute Audio
meeting.localUser.disableAudio { error in }
meeting.localUser.enableAudio { error in }
// Enable/Disable Video
meeting.localUser.disableVideo { error in }
meeting.localUser.enableVideo { error in }
// Enable/Disable Screenshare
meeting.localUser.canEnableScreenShare() // Check if screenshare can be enabled
let error: ScreenShareError? = meeting.localUser.enableScreenShare() // Returns error if fails, nil if successful
meeting.localUser.disableScreenShare()
// Device management
let audioDevices = meeting.localUser.getAudioDevices() // Get all available audio devices
let videoDevices = meeting.localUser.getVideoDevices() // Get all available video devices
meeting.localUser.setAudioDevice(audioDevices[0]) // Switch audio device
meeting.localUser.setVideoDevice(videoDevices[0]) // Switch video device
let selectedAudio = meeting.localUser.getSelectedAudioDevice() // Get currently selected audio device
let selectedVideo = meeting.localUser.getSelectedVideoDevice() // Get currently selected video device
meeting.localUser.switchCamera() // Switch between front and back camera
// Stage permissions
meeting.localUser.canJoinStage() // Check if local user can join stage
meeting.localUser.canRequestToJoinStage() // Check if local user can request to join stage
// Host controls
meeting.localUser.canDoParticipantHostControls() // Check if local user can perform host controls
// Setup screen
meeting.localUser.shouldShowSetupScreen() // Check if setup screen should be shown
meeting.localUser.shouldJoinMediaRoom() // Check if local user should join media roommeeting.self 表示会议中的本地用户(你)。它提供用于控制自己的音频、视频和屏幕共享的属性和方法。
关键属性:
// Participant identifiers
meeting.self.id; // Peer ID (unique per session)
meeting.self.userId; // Participant ID (persistent across sessions)
meeting.self.name; // Participant display name
// Media state
meeting.self.audioEnabled; // Boolean: Is audio enabled?
meeting.self.videoEnabled; // Boolean: Is video enabled?
meeting.self.screenShareEnabled; // Boolean: Is screen share active?
// Media tracks
meeting.self.audioTrack; // Audio MediaStreamTrack, if audio is enabled
meeting.self.videoTrack; // Video MediaStreamTrack, if video is enabled
meeting.self.screenShareTracks; // Structure: { audio: MediaStreamTrack, video: MediaStreamTrack }, if screen share is enabled
// Room state
meeting.self.roomJoined; // Boolean: Has joined the meeting?
meeting.self.roomState; // Current room state常用方法:
// Media controls
await meeting.self.enableAudio(); // Emits a `audioUpdate` event on `meeting.self` when successful.
await meeting.self.disableAudio(); // Emits a `audioUpdate` event on `meeting.self` when successful.
await meeting.self.enableVideo(); // Emits a `videoUpdate` event on `meeting.self` when successful.
await meeting.self.disableVideo(); // Emits a `videoUpdate` event on `meeting.self` when successful.
await meeting.self.enableScreenShare(); // Emits a `screenShareUpdate` event on `meeting.self` when successful.
await meeting.self.disableScreenShare(); // Emits a `screenShareUpdate` event on `meeting.self` when successful.
// Update Name
await meeting.self.setName("New Name"); // setName works only works before joining the meeting
// List Devices
await meeting.self.getAllDevices(); // Returns all available devices
await meeting.self.getAudioDevices(); // Returns all available audio devices
await meeting.self.getVideoDevices(); // Returns all available video devices
await meeting.self.getSpeakerDevices(); // Returns all available speaker devices
await meeting.self.getCurrentDevices(); // {audio: MediaDevice, video: MediaDevice, speaker: MediaDevice} Returns the current device configuration
// Change a device
await meeting.self.setDevice((await meeting.self.getAllDevices())[0]);meeting.participants 包含会议中所有远程参与者的映射,并按其状态组织。
参与者映射:
// All participants who have joined
meeting.participants.joined; // Map of joined participants
meeting.participants.joined.toArray(); // Array of joined participants
// Participants with active media
meeting.participants.active; // Map of participants with active audio/video
meeting.participants.active.toArray(); // Array of participants with active audio/video
// Participants in waiting room
meeting.participants.waitlisted; // Map of waitlisted participants
meeting.participants.waitlisted.toArray(); // Array of waitlisted participants
// Pinned participants
meeting.participants.pinned; // Map of pinned participants
meeting.participants.pinned.toArray(); // Array of pinned participants访问参与者数据:
// Get all joined participants as an array
const joinedParticipants = meeting.participants.joined.toArray();
// Access first participant's IDs
const firstParticipant = joinedParticipants[0];
console.log("First Participant Peer ID:", firstParticipant?.id); // Peer ID (unique per session)
console.log("First Participant User ID:", firstParticipant?.userId); // Participant ID (persistent)
console.log("First Participant Name:", firstParticipant?.name); // Display name
console.log("First Participant Audio Enabled:", firstParticipant?.audioEnabled); // Audio state
console.log("First Participant Video Enabled:", firstParticipant?.videoEnabled); // Video state
console.log(
"First Participant Screen Share Enabled:",
firstParticipant?.screenShareEnabled,
); // Screen share state
console.log("First Participant Audio Track:", firstParticipant?.audioTrack); // Audio MediaStreamTrack
console.log("First Participant Video Track:", firstParticipant?.videoTrack); // Video MediaStreamTrack
console.log(
"First Participant Screen Share Track:",
firstParticipant?.screenShareTracks,
); // Screen share MediaStreamTrack
// Access participant by peer ID
const participant = meeting.participants.joined.get("peer-id");
// Get count of joined participants
const count = meeting.participants.joined.size();参与者属性:
每个参与者对象都具有与 meeting.self 类似的属性:
participant.id; // Peer ID
participant.userId; // Participant ID
participant.name; // Display name
participant.audioEnabled; // Audio state
participant.videoEnabled; // Video state
participant.screenShareEnabled; // Screen share state
participant.audioTrack; // Audio MediaStreamTrack
participant.videoTrack; // Video MediaStreamTrack
participant.screenShareTrack; // Screen share MediaStreamTrackmeeting.participants 包含会议中所有远程参与者的映射,按其状态组织。
参与者映射:
// All participants who have joined
meeting.participants.joined; // Map of joined participants
meeting.participants.joined.toArray(); // Array of joined participants
// Participants with active media
meeting.participants.active; // Map of participants with active audio/video
meeting.participants.active.toArray(); // Array of participants with active audio/video
// Participants in waiting room
meeting.participants.waitlisted; // Map of waitlisted participants
meeting.participants.waitlisted.toArray(); // Array of waitlisted participants
// Pinned participants
meeting.participants.pinned; // Map of pinned participants
meeting.participants.pinned.toArray(); // Array of pinned participants访问参与者数据:
// Get all joined participants as an array
const joinedParticipants = meeting.participants.joined.toArray();
// Access first participant's IDs
const firstParticipant = joinedParticipants[0];
console.log("First Participant Peer ID:", firstParticipant?.id); // Peer ID (unique per session)
console.log("First Participant User ID:", firstParticipant?.userId); // Participant ID (persistent)
console.log("First Participant Name:", firstParticipant?.name); // Display name
console.log("First Participant Audio Enabled:", firstParticipant?.audioEnabled); // Audio state
console.log("First Participant Video Enabled:", firstParticipant?.videoEnabled); // Video state
console.log(
"First Participant Screen Share Enabled:",
firstParticipant?.screenShareEnabled,
); // Screen share state
console.log("First Participant Audio Track:", firstParticipant?.audioTrack); // Audio MediaStreamTrack
console.log("First Participant Video Track:", firstParticipant?.videoTrack); // Video MediaStreamTrack
console.log(
"First Participant Screen Share Track:",
firstParticipant?.screenShareTracks,
); // Screen share MediaStreamTrack
// Access participant by peer ID
const participant = meeting.participants.joined.get("peer-id");
// Get count of joined participants
const count = meeting.participants.joined.size();参与者属性:
每个参与者对象都具有与 meeting.self 类似的属性:
participant.id; // Peer ID
participant.userId; // Participant ID
participant.name; // Display name
participant.audioEnabled; // Audio state
participant.videoEnabled; // Video state
participant.screenShareEnabled; // Screen share state
participant.audioTrack; // Audio MediaStreamTrack
participant.videoTrack; // Video MediaStreamTrack
participant.screenShareTrack; // Screen share MediaStreamTrackmeeting.participants 包含会议中所有远程参与者的映射,按其状态组织。
参与者映射:
// All participants who have joined
meeting.participants.joined; // Map of joined participants
meeting.participants.joined.toArray(); // Array of joined participants
// Participants with active media
meeting.participants.active; // Map of participants with active audio/video
meeting.participants.active.toArray(); // Array of participants with active audio/video
// Participants in waiting room
meeting.participants.waitlisted; // Map of waitlisted participants
meeting.participants.waitlisted.toArray(); // Array of waitlisted participants
// Pinned participants
meeting.participants.pinned; // Map of pinned participants
meeting.participants.pinned.toArray(); // Array of pinned participants访问参与者数据:
// Get all joined participants as an array
const joinedParticipants = meeting.participants.joined.toArray();
// Access first participant's IDs
const firstParticipant = joinedParticipants[0];
console.log("First Participant Peer ID:", firstParticipant?.id); // Peer ID (unique per session)
console.log("First Participant User ID:", firstParticipant?.userId); // Participant ID (persistent)
console.log("First Participant Name:", firstParticipant?.name); // Display name
console.log("First Participant Audio Enabled:", firstParticipant?.audioEnabled); // Audio state
console.log("First Participant Video Enabled:", firstParticipant?.videoEnabled); // Video state
console.log(
"First Participant Screen Share Enabled:",
firstParticipant?.screenShareEnabled,
); // Screen share state
console.log("First Participant Audio Track:", firstParticipant?.audioTrack); // Audio MediaStreamTrack
console.log("First Participant Video Track:", firstParticipant?.videoTrack); // Video MediaStreamTrack
console.log(
"First Participant Screen Share Track:",
firstParticipant?.screenShareTracks,
); // Screen share MediaStreamTrack
// Access participant by peer ID
const participant = meeting.participants.joined.get("peer-id");
// Get count of joined participants
const count = meeting.participants.joined.size();参与者属性:
每个参与者对象都具有与 meeting.self 类似的属性:
participant.id; // Peer ID
participant.userId; // Participant ID
participant.name; // Display name
participant.audioEnabled; // Audio state
participant.videoEnabled; // Video state
participant.screenShareEnabled; // Screen share state
participant.audioTrack; // Audio MediaStreamTrack
participant.videoTrack; // Video MediaStreamTrack
participant.screenShareTrack; // Screen share MediaStreamTrackmeeting.participants 包含会议中所有远程参与者的列表,按其状态组织。
参与者列表:
// All participants who have joined
val joined: List<RtkRemoteParticipant> = meeting.participants.joined
// Participants with active media
val active: List<RtkRemoteParticipant> = meeting.participants.active
// Participants in waiting room
val waitlisted: List<RtkRemoteParticipant> = meeting.participants.waitlisted
// Pinned participant
val pinned: RtkRemoteParticipant? = meeting.participants.pinned
// Participants sharing screen
val screenShares: List<RtkRemoteParticipant> = meeting.participants.screenShares
// Active speaker
val activeSpeaker: RtkRemoteParticipant? = meeting.participants.activeSpeaker
// Total count of participants (including local user if joined)
val totalCount: Int = meeting.participants.totalCount访问参与者数据:
// Get all joined participants
val joinedParticipants = meeting.participants.joined
// Access first participant
val firstParticipant = joinedParticipants.firstOrNull()
firstParticipant?.id // Participant ID (aka peerId)
firstParticipant?.userId // User ID
firstParticipant?.name // Display name
firstParticipant?.picture // Participant picture (if any)
firstParticipant?.customParticipantId // Custom participant ID
firstParticipant?.audioEnabled // Audio state
firstParticipant?.videoEnabled // Video state
firstParticipant?.screenShareEnabled // Screen share state
firstParticipant?.isPinned // Pin state
firstParticipant?.isHost // Host state
firstParticipant?.presetName // Preset name
firstParticipant?.stageStatus // Stage status
firstParticipant?.flags // Participant flags (recorder, hiddenParticipant, webinarHiddenParticipant)
// Get participant video view
firstParticipant?.getVideoView() // Returns a View that renders video stream
firstParticipant?.getScreenShareVideoView() // Returns a View that renders screenshare stream
// Access pagination
val maxNumberOnScreen = meeting.participants.maxNumberOnScreen // Max participants per page
val currentPageNumber = meeting.participants.currentPageNumber // Current page number
val pageCount = meeting.participants.pageCount // Total number of pages
val canGoNextPage = meeting.participants.canGoNextPage // Can navigate to next page
val canGoPreviousPage = meeting.participants.canGoPreviousPage // Can navigate to previous page
meeting.participants.setPage(1) // Switch to specific page参与者控制方法:
// Individual participant controls (host only)
firstParticipant?.disableAudio { error -> } // Disable participant's audio
firstParticipant?.disableVideo { error -> } // Disable participant's video
firstParticipant?.kick { error -> } // Remove participant from meeting
// Pin/Unpin participants
val error: HostError? = firstParticipant?.pin() // Pin participant
val error: HostError? = firstParticipant?.unpin() // Unpin participant
// Waiting room management
meeting.participants.acceptWaitingRoomRequest(participantId) // Accept from waiting room
meeting.participants.rejectWaitingRoomRequest(participantId) // Reject from waiting room
meeting.participants.acceptAllWaitingRoomRequests() // Accept all waiting participants
// Bulk operations (host only)
val error: HostError? = meeting.participants.disableAllAudio() // Disable all participants' audio
val error: HostError? = meeting.participants.disableAllVideo() // Disable all participants' video
val error: HostError? = meeting.participants.kickAll() // Remove all participants
// Broadcast custom message
meeting.participants.broadcastMessage("custom-event", mapOf("key" to "value"))
// Cache management
meeting.participants.enableCache() // Enable participant caching
meeting.participants.disableCache() // Disable participant caching参与者属性:
participant.id // Participant ID (aka peerId, unique per session)
participant.userId // User ID (persistent across sessions)
participant.name // Display name
participant.picture // Participant picture URL
participant.customParticipantId // Custom participant ID
participant.audioEnabled // Audio state
participant.videoEnabled // Video state
participant.screenShareEnabled // Screen share state
participant.isPinned // Pin state
participant.isHost // Host state
participant.presetName // Preset name
participant.stageStatus // Stage status
participant.flags // Participant flags (recorder, hiddenParticipant, webinarHiddenParticipant)meeting.participants 包含会议中所有远程参与者的列表,按其状态组织。
参与者列表:
// All participants who have joined
let joined: [RtkRemoteParticipant] = meeting.participants.joined
// Participants with active media
let active: [RtkRemoteParticipant] = meeting.participants.active
// Participants in waiting room
let waitlisted: [RtkRemoteParticipant] = meeting.participants.waitlisted
// Pinned participant
let pinned: RtkRemoteParticipant? = meeting.participants.pinned
// Participants sharing screen
let screenShares: [RtkRemoteParticipant] = meeting.participants.screenShares
// Active speaker
let activeSpeaker: RtkRemoteParticipant? = meeting.participants.activeSpeaker
// Total count of participants (including local user if joined)
let totalCount: Int = meeting.participants.totalCount访问参与者数据:
// Get all joined participants
let joinedParticipants = meeting.participants.joined
// Access first participant
let firstParticipant = joinedParticipants.first
firstParticipant?.id // Participant ID (aka peerId)
firstParticipant?.userId // User ID
firstParticipant?.name // Display name
firstParticipant?.picture // Participant picture (if any)
firstParticipant?.customParticipantId // Custom participant ID
firstParticipant?.audioEnabled // Audio state
firstParticipant?.videoEnabled // Video state
firstParticipant?.screenShareEnabled // Screen share state
firstParticipant?.isPinned // Pin state
firstParticipant?.isHost // Host state
firstParticipant?.presetName // Preset name
firstParticipant?.stageStatus // Stage status
firstParticipant?.flags // Participant flags (recorder, hiddenParticipant, webinarHiddenParticipant)
// Get participant video view
firstParticipant?.getVideoView() // Returns a UIView that renders video stream
firstParticipant?.getScreenShareVideoView() // Returns a UIView that renders screenshare stream
// Access pagination
let maxNumberOnScreen = meeting.participants.maxNumberOnScreen // Max participants per page
let currentPageNumber = meeting.participants.currentPageNumber // Current page number
let pageCount = meeting.participants.pageCount // Total number of pages
let canGoNextPage = meeting.participants.canGoNextPage // Can navigate to next page
let canGoPreviousPage = meeting.participants.canGoPreviousPage // Can navigate to previous page
meeting.participants.setPage(1) // Switch to specific page参与者控制方法:
// Individual participant controls (host only)
firstParticipant?.disableAudio { error in } // Disable participant's audio
firstParticipant?.disableVideo { error in } // Disable participant's video
firstParticipant?.kick { error in } // Remove participant from meeting
// Pin/Unpin participants
let error: HostError? = firstParticipant?.pin() // Pin participant
let error: HostError? = firstParticipant?.unpin() // Unpin participant
// Waiting room management
meeting.participants.acceptWaitingRoomRequest(participantId) // Accept from waiting room
meeting.participants.rejectWaitingRoomRequest(participantId) // Reject from waiting room
meeting.participants.acceptAllWaitingRoomRequests() // Accept all waiting participants
// Bulk operations (host only)
let error: HostError? = meeting.participants.disableAllAudio() // Disable all participants' audio
let error: HostError? = meeting.participants.disableAllVideo() // Disable all participants' video
let error: HostError? = meeting.participants.kickAll() // Remove all participants
// Broadcast custom message
meeting.participants.broadcastMessage("custom-event", ["key": "value"])
// Cache management
meeting.participants.enableCache() // Enable participant caching
meeting.participants.disableCache() // Disable participant caching参与者属性:
participant.id // Participant ID (aka peerId, unique per session)
participant.userId // User ID (persistent across sessions)
participant.name // Display name
participant.picture // Participant picture URL
participant.customParticipantId // Custom participant ID
participant.audioEnabled // Audio state
participant.videoEnabled // Video state
participant.screenShareEnabled // Screen share state
participant.isPinned // Pin state
participant.isHost // Host state
participant.presetName // Preset name
participant.stageStatus // Stage status
participant.flags // Participant flags (recorder, hiddenParticipant, webinarHiddenParticipant)meeting.participants 包含会议中所有远程参与者的映射,并按其状态组织。
参与者映射:
// All participants who have joined
meeting.participants.joined; // Map of joined participants
meeting.participants.joined.toArray(); // Array of joined participants
// Participants with active media
meeting.participants.active; // Map of participants with active audio/video
meeting.participants.active.toArray(); // Array of participants with active audio/video
// Participants in waiting room
meeting.participants.waitlisted; // Map of waitlisted participants
meeting.participants.waitlisted.toArray(); // Array of waitlisted participants
// Pinned participants
meeting.participants.pinned; // Map of pinned participants
meeting.participants.pinned.toArray(); // Array of pinned participants访问参与者数据:
// Get all joined participants as an array
const joinedParticipants = meeting.participants.joined.toArray();
// Access first participant's IDs
const firstParticipant = joinedParticipants[0];
console.log("First Participant Peer ID:", firstParticipant?.id); // Peer ID (unique per session)
console.log("First Participant User ID:", firstParticipant?.userId); // Participant ID (persistent)
console.log("First Participant Name:", firstParticipant?.name); // Display name
console.log("First Participant Audio Enabled:", firstParticipant?.audioEnabled); // Audio state
console.log("First Participant Video Enabled:", firstParticipant?.videoEnabled); // Video state
console.log(
"First Participant Screen Share Enabled:",
firstParticipant?.screenShareEnabled,
); // Screen share state
console.log("First Participant Audio Track:", firstParticipant?.audioTrack); // Audio MediaStreamTrack
console.log("First Participant Video Track:", firstParticipant?.videoTrack); // Video MediaStreamTrack
console.log(
"First Participant Screen Share Track:",
firstParticipant?.screenShareTracks,
); // Screen share MediaStreamTrack
// Access participant by peer ID
const participant = meeting.participants.joined.get("peer-id");
// Get count of joined participants
const count = meeting.participants.joined.size();参与者属性:
每个参与者对象都具有与 meeting.self 类似的属性:
participant.id; // Peer ID
participant.userId; // Participant ID
participant.name; // Display name
participant.audioEnabled; // Audio state
participant.videoEnabled; // Video state
participant.screenShareEnabled; // Screen share state
participant.audioTrack; // Audio MediaStreamTrack
participant.videoTrack; // Video MediaStreamTrack
participant.screenShareTrack; // Screen share MediaStreamTrackmeeting.meta 包含会议室本身的信息。
meeting.meta.meetingId; // Meeting identifier
meeting.meta.meetingTitle; // Meeting Title
meeting.meta.meetingStartedTimestamp; // Meeting start timemeeting.meta 包含会议室本身的信息。
meeting.meta.meetingId; // Meeting identifier
meeting.meta.meetingTitle; // Meeting Title
meeting.meta.meetingStartedTimestamp; // Meeting start timemeeting.meta 包含会议室本身的信息。
meeting.meta.meetingId; // Meeting identifier
meeting.meta.meetingTitle; // Meeting Title
meeting.meta.meetingStartedTimestamp; // Meeting start timemeeting.meta 包含有关会议室本身的信息。
属性:
meeting.meta.meetingId // Meeting identifier
meeting.meta.meetingTitle // Meeting title
meeting.meta.meetingStartedTimestamp // Meeting start time
meeting.meta.meetingType // Meeting type (GROUP_CALL, WEBINAR, or LIVESTREAM)
meeting.meta.meetingConfig // Meeting configuration containing audio and video settings
meeting.meta.meetingState // State of the meeting (RtkMeetingState)
meeting.meta.authToken // User's authentication token for the meeting
meeting.meta.selfActiveTab // Currently active tab for the local participant (ActiveTab?)
meeting.meta.mediaConnectionState // Current state of the media connection (MediaConnectionState)
meeting.meta.socketConnectionState // Current state of the socket connection (SocketConnectionState)方法:
// Sync active tab (for plugins or screen share)
meeting.meta.syncTab(
id = "plugin-id-or-screenshare-id", // Identifier for unique plugin/screen share
tabType = ActiveTabType.PLUGIN // or ActiveTabType.SCREENSHARE
)meeting.meta 包含有关会议室本身的信息。
属性:
meeting.meta.meetingId // Meeting identifier
meeting.meta.meetingTitle // Meeting title
meeting.meta.meetingStartedTimestamp // Meeting start time
meeting.meta.meetingType // Meeting type (.groupCall, .webinar, or .livestream)
meeting.meta.meetingConfig // Meeting configuration containing audio and video settings
meeting.meta.meetingState // State of the meeting (RtkMeetingState)
meeting.meta.authToken // User's authentication token for the meeting
meeting.meta.selfActiveTab // Currently active tab for the local participant (ActiveTab?)
meeting.meta.mediaConnectionState // Current state of the media connection (MediaConnectionState)
meeting.meta.socketConnectionState // Current state of the socket connection (SocketConnectionState)方法:
// Sync active tab (for plugins or screen share)
meeting.meta.syncTab(
id: "plugin-id-or-screenshare-id", // Identifier for unique plugin/screen share
tabType: .plugin // or .screenshare
)meeting.meta 包含会议室本身的信息。
meeting.meta.meetingId; // Meeting identifier
meeting.meta.meetingTitle; // Meeting Title
meeting.meta.meetingStartedTimestamp; // Meeting start timemeeting.chat 管理会议中共享的文本消息、图像和文件。
// Get all chat messages
const messages = meeting.chat.messages;
// Send a text message
await meeting.chat.sendTextMessage("Hello everyone!");
// Send an image
await meeting.chat.sendImageMessage(imageFile);
// Listen to chat messages
console.log("First message:", meeting.chat.messages[0]);
meeting.chat.on("chatUpdate", ({ message, messages }) => {
console.log(`Received message ${message}`);
console.log(`All messages in chat: ${messages.join(", ")}`);
});meeting.chat 管理会议中共享的文本消息、图像和文件。
// Get all chat messages
const messages = meeting.chat.messages;
// Send a text message
await meeting.chat.sendTextMessage("Hello everyone!");
// Send an image
await meeting.chat.sendImageMessage(imageFile);
// Listen to chat messages
console.log("First message:", meeting.chat.messages[0]);
meeting.chat.on("chatUpdate", ({ message, messages }) => {
console.log(`Received message ${message}`);
console.log(`All messages in chat: ${messages.join(", ")}`);
});meeting.chat 管理会议中共享的文本消息、图像和文件。
// Get all chat messages
const messages = meeting.chat.messages;
// Send a text message
await meeting.chat.sendTextMessage("Hello everyone!");
// Send an image
await meeting.chat.sendImageMessage(imageFile);
// Listen to chat messages
console.log("First message:", meeting.chat.messages[0]);
meeting.chat.on("chatUpdate", ({ message, messages }) => {
console.log(`Received message ${message}`);
console.log(`All messages in chat: ${messages.join(", ")}`);
});meeting.chat 管理在会议中共享的文本消息、图片和文件。
// Get all chat messages
val messages = meeting.chat.messages
// Send a text message
val message = "Hello everyone!"
meeting.chat.sendTextMessage(message) // Returns ChatTextError if fails, null if successful
// Send an image
meeting.chat.sendImageMessage(imageUri) { err ->
// Handle ChatFileError if any
}
// Send a file
meeting.chat.sendFileMessage(fileUri) { err ->
// Handle ChatFileError if any
}
// Listen to chat messages
meeting.addChatEventListener(object : RtkChatEventListener {
override fun onChatUpdates(messages: List<ChatMessage>) {
// Called whenever there is a change in chat messages
}
override fun onNewChatMessage(message: ChatMessage) {
// Called when a new chat message is shared
}
override fun onMessageRateLimitReset() {
// Called when rate limit for sending messages is reset
}
})
// Handle errors
when (err) {
is ChatFileError.FileFormatNotAllowed -> {} // File format not allowed
is ChatFileError.PermissionDenied -> {} // No permission to send file
is ChatFileError.RateLimitBreached -> {} // Rate limit breached
is ChatFileError.ReadFailed -> {} // File could not be read
is ChatFileError.UploadFailed -> {} // File could not be uploaded
else -> {}
}meeting.chat 管理在会议中共享的文本消息、图片和文件。
// Get all chat messages
let messages = meeting.chat.messages
// Send a text message
let message = "Hello everyone!"
meeting.chat.sendTextMessage(message) // Returns ChatTextError if fails, nil if successful
// Send an image
meeting.chat.sendImageMessage(imageUri) { err in
// Handle ChatFileError if any
}
// Send a file
meeting.chat.sendFileMessage(fileUri) { err in
// Handle ChatFileError if any
}
// Listen to chat messages
extension MeetingViewModel: RtkChatEventListener {
func onChatUpdates(messages: [ChatMessage]) {
// Called whenever there is a change in chat messages
}
func onNewChatMessage(message: ChatMessage) {
// Called when a new chat message is shared
}
func onMessageRateLimitReset() {
// Called when rate limit for sending messages is reset
}
}
// Add listener
meeting.addChatEventListener(self)
// Handle errors
switch err {
case .fileFormatNotAllowed:
// File format not allowed
case .permissionDenied:
// No permission to send file
case .rateLimitBreached:
// Rate limit breached
case .readFailed:
// File could not be read
case .uploadFailed:
// File could not be uploaded
default:
break
}meeting.chat 管理会议中共享的文本消息、图像和文件。
// Get all chat messages
const messages = meeting.chat.messages;
// Send a text message
await meeting.chat.sendTextMessage("Hello everyone!");
// Send an image
await meeting.chat.sendImageMessage(imageFile);
// Listen to chat messages
console.log("First message:", meeting.chat.messages[0]);
meeting.chat.on("chatUpdate", ({ message, messages }) => {
console.log(`Received message ${message}`);
console.log(`All messages in chat: ${messages.join(", ")}`);
});meeting.polls 管理会议中的投票。
// Get all polls
const polls = meeting.polls.items;
// Create a poll
await meeting.polls.create(
"What time works best?", //question
["9 AM", "2 PM", "5 PM"], // options
false, // anonymous
false, // hideVotes
);
// Vote on a poll
await meeting.polls.vote(pollId, optionIndex); // Retrieve pollId from meeting.polls.itemsmeeting.polls 管理会议中的投票。
// Get all polls
const polls = meeting.polls.items;
// Create a poll
await meeting.polls.create(
"What time works best?", //question
["9 AM", "2 PM", "5 PM"], // options
false, // anonymous
false, // hideVotes
);
// Vote on a poll
await meeting.polls.vote(pollId, optionIndex); // Retrieve pollId from meeting.polls.itemsmeeting.polls 管理会议中的投票。
// Get all polls
const polls = meeting.polls.items;
// Create a poll
await meeting.polls.create(
"What time works best?", //question
["9 AM", "2 PM", "5 PM"], // options
false, // anonymous
false, // hideVotes
);
// Vote on a poll
await meeting.polls.vote(pollId, optionIndex); // Retrieve pollId from meeting.polls.itemsmeeting.polls 管理会议中的投票。
// Get all polls
val polls = meeting.polls.items
// Create a poll
val pollsCreateError: PollsError? = meeting.polls.create(
question = "What time works best?",
options = listOf("9 AM", "2 PM", "5 PM"),
anonymous = false,
hideVotes = false
)
// Vote on a poll
val poll: Poll = meeting.polls.items.first()
val selectedPollOption: PollOption = poll.options.first()
val pollsError: PollsError? = meeting.polls.vote(poll.id, selectedPollOption)
// Listen to poll updates
meeting.addPollsEventListener(object : RtkPollsEventListener {
override fun onNewPoll(poll: Poll) {
// Called when a new poll is created
}
override fun onPollUpdate(poll: Poll) {
// Called when a poll is updated (votes, details changed)
}
override fun onPollUpdates(pollItems: List<Poll>) {
// Called when there are updates to the list of polls
}
})meeting.polls 管理会议中的投票。
// Get all polls
let polls = meeting.polls.items
// Create a poll
let pollsCreateError: PollsError? = meeting.polls.create(
question: "What time works best?",
options: ["9 AM", "2 PM", "5 PM"],
anonymous: false,
hideVotes: false
)
// Vote on a poll
let poll: Poll = meeting.polls.items.first
let selectedPollOption: PollOption = poll.options.first
let pollsError: PollsError? = meeting.polls.vote(poll.id, selectedPollOption)
// Listen to poll updates
extension MeetingViewModel: RtkPollsEventListener {
func onNewPoll(poll: Poll) {
// Called when a new poll is created
}
func onPollUpdate(poll: Poll) {
// Called when a poll is updated (votes, details changed)
}
func onPollUpdates(pollItems: [Poll]) {
// Called when there are updates to the list of polls
}
}
// Add listener
meeting.addPollsEventListener(self)meeting.polls 管理会议中的投票。
// Get all polls
const polls = meeting.polls.items;
// Create a poll
await meeting.polls.create(
"What time works best?", //question
["9 AM", "2 PM", "5 PM"], // options
false, // anonymous
false, // hideVotes
);
// Vote on a poll
await meeting.polls.vote(pollId, optionIndex); // Retrieve pollId from meeting.polls.itemsmeeting.plugins 属性管理会议插件(协作应用)。激活状态位于 Plugin 对象上。
// Get all available plugins
const allPlugins = meeting.plugins.all.toArray();
// Get active plugins
const activePlugins = meeting.plugins.active.toArray();
// Activate a plugin for all participants
await meeting.plugins.all.get(pluginId).activate();
// Deactivate a plugin for all participants
await meeting.plugins.all.get(pluginId).deactivate();meeting.plugins 属性管理会议插件(协作应用)。激活状态位于 Plugin 对象上。
// Get all available plugins
const allPlugins = meeting.plugins.all.toArray();
// Get active plugins
const activePlugins = meeting.plugins.active.toArray();
// Activate a plugin for all participants
await meeting.plugins.all.get(pluginId).activate();
// Deactivate a plugin for all participants
await meeting.plugins.all.get(pluginId).deactivate();meeting.plugins 属性管理会议插件(协作应用)。激活状态位于 Plugin 对象上。
// Get all available plugins
const allPlugins = meeting.plugins.all.toArray();
// Get active plugins
const activePlugins = meeting.plugins.active.toArray();
// Activate a plugin for all participants
await meeting.plugins.all.get(pluginId).activate();
// Deactivate a plugin for all participants
await meeting.plugins.all.get(pluginId).deactivate();meeting.plugins 属性管理会议插件(协作应用)。要在应用和插件之间交换消息,请参阅与插件交换消息。
// Get all available plugins
val plugins = meeting.plugins.all
// Get active plugins
val activePlugins = meeting.plugins.active
// Activate a plugin
meeting.plugins.all.first().activate()
// Deactivate a plugin
meeting.plugins.active.first().deactivate()
// Get plugin view
val pluginView = meeting.plugins.active.first().getPluginView() // Returns a WebView
// Send data to a plugin
val pluginId = ""
val plugin = meeting.plugins.active.firstOrNull { it.id == pluginId }
plugin?.sendData(
eventName = "my-custom-event",
data = "Hello world"
)
// Upload file to a plugin
plugin?.uploadFile(
RtkPluginFile(
resultCode = <activity-resultCode>,
data = Intent() // Intent with the file data
)
)
// Listen to plugin events
val pluginsEventListener = object : RtkPluginsEventListener {
override fun onPluginActivated(plugin: RtkPlugin) {
// Called when a plugin is activated
}
override fun onPluginDeactivated(plugin: RtkPlugin) {
// Called when a plugin is deactivated
}
override fun onPluginMessage(plugin: RtkPlugin, eventName: String, data: Any?) {
// Called when a plugin sends a message
}
override fun onPluginFileRequest(plugin: RtkPlugin) {
// Called when a plugin requests a file
}
}
meeting.addPluginsEventListener(pluginsEventListener)meeting.plugins 属性管理会议插件(协作应用)。要在应用和插件之间交换消息,请参阅与插件交换消息。
// Get all available plugins
let plugins = meeting.plugins.all
// Get active plugins
let activePlugins = meeting.plugins.active
// Activate a plugin
meeting.plugins.all.first?.activate()
// Deactivate a plugin
meeting.plugins.active.first?.deactivate()
// Get plugin view
let pluginView = meeting.plugins.active.first?.getPluginView() // Returns a WKWebView
// Send data to a plugin
let pluginId = ""
let plugin = meeting.plugins.active.first { $0.id == pluginId }
plugin?.sendData(
eventName: "my-custom-event",
data: "Hello world"
)
// Listen to plugin events
extension MeetingViewModel: RtkPluginsEventListener {
func onPluginActivated(plugin: RtkPlugin) {
// Called when a plugin is activated
}
func onPluginDeactivated(plugin: RtkPlugin) {
// Called when a plugin is deactivated
}
func onPluginMessage(plugin: RtkPlugin, eventName: String, data: Any?) {
// Called when a plugin sends a message
}
func onPluginFileRequest(plugin: RtkPlugin) {
// Called when a plugin requests a file
}
}
// Add listener
meeting.addPluginsEventListener(pluginsEventListener: self)meeting.plugins 属性管理会议插件(协作应用)。
// Get all available plugins
const plugins = meeting.plugins.all;
// Activate a plugin
await meeting.plugins.activate(pluginId);
// Deactivate a plugin
await meeting.plugins.deactivate();meeting.ai 提供了对 AI 驱动功能(如实时字幕)的访问。
// Access live transcriptions
meeting.ai.transcripts; // Shows only when transcription is enabled in Presetmeeting.ai 提供了对 AI 驱动功能(如实时字幕)的访问。
// Access live transcriptions
meeting.ai.transcripts; // Shows only when transcription is enabled in Presetmeeting.ai 提供了对 AI 驱动功能(如实时字幕)的访问。
// Access live transcriptions
meeting.ai.transcripts; // Shows only when transcription is enabled in Presetmeeting.ai 提供了对 AI 驱动功能(如实时字幕)的访问。
// Access live transcriptions
meeting.ai.transcripts; // Shows only when transcription is enabled in Presetmeeting.ai 在此移动平台上不受支持。
meeting.ai 在此移动平台上不受支持。
加入或离开会议室:
// Join the meeting room
await meeting.join(); // Emits a `roomJoined` event on `meeting.self` when successful
// Leave the meeting room
await meeting.leave();// Join the meeting room
await meeting.join(); // Emits a `roomJoined` event on `meeting.self` when successful
// Leave the meeting room
await meeting.leave();// Join the meeting room
await meeting.join(); // Emits a `roomJoined` event on `meeting.self` when successful
// Leave the meeting room
await meeting.leave();// Join the meeting room
meeting.joinRoom(
onSuccess = {
// Room Joined
},
onFailure = { err ->
// Handle error
}
)
// Leave the meeting room
meeting.leave(
onSuccess = {
// Room Left
},
onFailure = { err ->
// Handle error
}
)// Join the meeting room
meeting.joinRoom(
onSuccess: {
// Room Joined
},
onFailure: { err in
// Handle error
}
)
// Leave the meeting room
meeting.leave(
onSuccess: {
// Room Left
},
onFailure: { err in
// Handle error
}
)// Join the meeting room
await meeting.join(); // Emits a `roomJoined` event on `meeting.self` when successful
// Leave the meeting room
await meeting.leave();RealtimeKit 对参与者使用两种类型的标识符:
-
会话 ID (
id):每个会议连接的唯一标识符。每次参与者加入新会话时都会更改。在 Web 平台上,这被称为“Peer ID”,存储在meeting.self.id或participant.id中。在移动平台上,这被称为“参与者 ID”,存储在meeting.localUser.id或participant.id中。 -
用户 ID (
userId):参与者跨多个会话的持久标识符。当用户重新连接时保持不变。这存储在meeting.self.userId(Web) 或meeting.localUser.userId(Mobile) 中,对于远程参与者则存储在participant.userId中。
何时使用:
- 当您需要跨不同会话或重新连接跟踪同一用户时(例如,保存用户首选项或权限),请使用
userId。 - 当处理当前会话的连接时(例如,管理活动视频流或实时参与者状态),请使用
id。
-
监听事件而不是轮询:当状态发生变化时,会议对象会触发事件。订阅这些事件,而不是持续检查属性值。
-
使用参与者集合:在 Web 平台上,使用
toArray()将参与者映射转换为数组。在移动平台上,参与者集合已经是列表,您可以直接对其进行循环遍历。 -
检查连接状态:在访问需要活动会话的属性或调用方法之前,务必检查
roomJoined(在移动端为meeting.localUser.roomJoined)。 -
优雅地处理错误:许多方法都接受错误回调。请始终实现适当的错误处理,以提供良好的用户体验。
现在您已经了解了会议对象的结构,可以使用它来构建自定义会议体验。UI Kit 组件在内部使用相同的会议对象来提供开箱即用的界面。在下一指南中,我们将向您展示如何将 UI Kit 组件与直接会议对象访问相结合,以创建您自己的自定义 UI。