Meeting Object Explained·续2

// 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


**Accessing Participant Data:**

```swift
// 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

Participant Control Methods:

// 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 Properties:

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)

The meeting.participants contains maps of all remote participants in the meeting, organized by their state.

Note

meeting.participants only contains remote participants. It does not include the local participant. Local participant is available in meeting.self.

Participant Maps:

// 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

Accessing Participant Data:

// 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();

Participant Properties:

Each participant object has similar properties to 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 MediaStreamTrack

Meeting metadata

meeting.meta - Meeting Metadata

The meeting.meta contains information about the meeting room itself.

meeting.meta.meetingId; // Meeting identifier
meeting.meta.meetingTitle; // Meeting Title
meeting.meta.meetingStartedTimestamp; // Meeting start time

The meeting.meta contains information about the meeting room itself.

meeting.meta.meetingId; // Meeting identifier
meeting.meta.meetingTitle; // Meeting Title
meeting.meta.meetingStartedTimestamp; // Meeting start time

The meeting.meta contains information about the meeting room itself.

meeting.meta.meetingId; // Meeting identifier
meeting.meta.meetingTitle; // Meeting Title
meeting.meta.meetingStartedTimestamp; // Meeting start time

The meeting.meta contains information about the meeting room itself.

Properties:

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)

Methods:

// 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
)

The meeting.meta contains information about the meeting room itself.

Properties:

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)

Methods:

// 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
)

The meeting.meta contains information about the meeting room itself.

meeting.meta.meetingId; // Meeting identifier
meeting.meta.meetingTitle; // Meeting Title
meeting.meta.meetingStartedTimestamp; // Meeting start time

Chat

meeting.chat - Chat Messages

The meeting.chat manages text messages, images, and files shared in the meeting.

// 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(", ")}`);
});

The meeting.chat manages text messages, images, and files shared in the meeting.

// 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(", ")}`);
});

The meeting.chat manages text messages, images, and files shared in the meeting.

// 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(", ")}`);
});

The meeting.chat manages text messages, images, and files shared in the meeting.

// 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 -> {}
}

The meeting.chat manages text messages, images, and files shared in the meeting.

// 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
}

The meeting.chat manages text messages, images, and files shared in the meeting.

// 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(", ")}`);
});