Introduction - Participants
The participants
property on RealtimeKitClient
provides access to remote participants in your RealtimeKit meeting. This whole module helps you manage participant data and listen to participant state changes.
It is of type RtkParticipants
and can be accessed as follows:
// Access the participants object
final participants = meeting.participants;
This object only contains data for remote participants and doesn't include your local user. For local user properties and controls, use the meeting.localUser
property instead.
Participant Lists
RealtimeKit organizes remote participants into different lists based on their current state in the meeting.
List | Description | Use Case |
---|---|---|
joined | All remote participants currently in the meeting | Displaying participant lists, user counts |
active | Participants whose media is subscribed and should be displayed on the screen | Building video grids, active speaker views |
waitlisted | Participants waiting for approval to join the meeting | Implementing waiting room interfaces |
screenShares | Participants currently sharing their screen | Displaying active screen shares |
Each remote participant is represented as an RtkRemoteParticipant
object, containing their properties and available actions.
// Example: Access all remote participants in the meeting
final joinedParticipants = meeting.participants.joined;
// Example: Access active participants for a video grid
final activeParticipants = meeting.participants.active;
Additional Properties
totalCount
: Total number of participants present in the meeting, including the local user.pinned
: Currently pinned participant, ornull
if no participant is pinned.
// Get the total participant count
final totalParticipants = meeting.participants.totalCount;
print("Meeting has $totalParticipants participants");
// Check and use pinned participant
final pinnedParticipant = meeting.participants.pinned;
if (pinnedParticipant != null) {
print("${pinnedParticipant!.name} is pinned");
}
Event Handling
The participants module provides RtkParticipantsEventListener
interface to notify you about changes to participants. For detailed information on available events, see the Events documentation.
// Example: Listening to Participants events
// Implement RtkParticipantEventsListener interface
class ParticipantsEventListener extends RtkParticipantEventsListener {
...
void onParticipantJoin(RtkRemoteParticipant participant) {
// your code here to handle new participant
}
...
}
// Add ParticipantsEventListener listener to meeting
final participantsEventListener = ParticipantsEventListener()
meeting.addParticipantsEventListener(participantsEventListener);
Broadcasting Messages
RealtimeKit allows you to broadcast custom messages to all participants in the meeting. This enables real-time interactions like emoji reactions, custom notifications.
The broadcast system uses two parameters:
type
: String identifier for categorizing messages. This helps receivers filter and process messages based on their typepayload
: JSON-serializable map (Map<String, dynamic>
) containing your custom data
Send a custom message to all participants using broadcastMessage
:
// Broadcast a greeting to everyone in the meeting
final payload = {
'message': 'Hello everyone!',
};
meeting.participants.broadcastMessage('custom_type', payload);
To receive these broadcast messages, implement the onNewBroadcastMessage
callback in your Participants event listener. See the Events documentation for details on handling broadcast messages.