Session Management
Session management covers moderator-level controls for recording, muting participants, locking the room, managing waiting users, removing participants, and ending or extending the session. All methods use the EnxRtc class; callbacks are assigned as properties before use.
EnableX lets moderators record the session either automatically from the moment it starts, or on demand during a live call. When recording is active, all participants are notified so your UI can display a recording indicator. Both recording modes use the same start and stop methods — the difference is in how recording is initiated.
Sessions can be recorded in two ways:
- Auto-recording — configured at room creation time with
"settings": { "auto_recording": true }. Recording begins as soon as the moderator joins. The moderator can still stop it at any time usingstopRecord(). - On-demand recording — the moderator calls
startRecord()during the session when they decide to begin capturing.
In both cases, two callbacks fire when recording becomes active: one private acknowledgement to the moderator, and one broadcast to all participants so every client can update its UI simultaneously.
Starting Recording
Call EnxRtc.startRecord() to begin recording. Register both callbacks before calling joinRoom() so you do not miss the initial state when auto-recording is configured.
EnxRtc.startRecord();
// Moderator receives private acknowledgement that recording has started
EnxRtc.onStartRecordingEvent = (Map<dynamic, dynamic> map) {
print('Recording started (moderator): $map');
};
// All participants are notified — show recording indicator to everyone
EnxRtc.onRoomRecordingOn = (Map<dynamic, dynamic> map) {
setState(() { isRecording = true; });
};
Stopping Recording
Call EnxRtc.stopRecord() to end an active recording. Only the moderator can stop recording, even when auto-recording is configured. Both the moderator and all participants receive callbacks when recording stops.
EnxRtc.stopRecord();
// Moderator receives private acknowledgement that recording has stopped
EnxRtc.onStopRecordingEvent = (Map<dynamic, dynamic> map) {
print('Recording stopped (moderator): $map');
};
// All participants are notified — remove recording indicator
EnxRtc.onRoomRecordingOff = (Map<dynamic, dynamic> map) {
setState(() { isRecording = false; });
};
Recording Callbacks
| Callback | Who receives it | When it fires |
|---|---|---|
onStartRecordingEvent |
Moderator only | Private acknowledgement — recording has started successfully. |
onRoomRecordingOn |
All participants | Broadcast — recording is now active. Show a recording badge in your UI. |
onStopRecordingEvent |
Moderator only | Private acknowledgement — recording has stopped successfully. |
onRoomRecordingOff |
All participants | Broadcast — recording has ended. Remove the recording badge. |
Live Recording is a distinct recording mode that transcodes and composites participant streams into a single video file during the session, rather than waiting until after it ends. This makes the output available within minutes of the session closing — significantly faster than standard recording, which transcodes post-session.
Live Recording uses a custom view URL to determine the composite layout — how streams are positioned, their sizes, and any branding elements. If you do not supply a URL, a default layout is used.
Starting Live Recording
Build a configuration map with a urlDetails key. Leave the inner map empty to use the default layout, or include your custom view URL to control the output appearance.
Map<String, dynamic> config = {
'urlDetails': {} // Empty for default layout; add { 'url': 'https://...' } for custom layout
};
await EnxRtc.startLiveRecording(config);
// Moderator receives acknowledgement that live recording has started
EnxRtc.onACKStartLiveRecording = (Map<dynamic, dynamic> map) {
print('Live recording started: $map');
};
// All participants are notified when live recording is active
EnxRtc.onLiveRecordingNotification = (Map<dynamic, dynamic> map) {
print('Live recording is now active: $map');
};
Stopping Live Recording
EnxRtc.stopLiveRecording();
"settings": { "live_recording": { "auto_recording": true, "url": "https://your-layout-url" } } in the room creation payload.
Hard muting lets a moderator enforce silence across the entire room or for a specific participant. Unlike a participant's own mute toggle, a hard mute cannot be reversed by the affected user — only the moderator can lift it. Use hard muting in webinars, panel sessions, or any scenario where guaranteed silence is required.
Hard muting is available at two levels:
- Room level — silences all participants simultaneously. Any participant who joins after the mute is applied is also muted automatically.
- Participant level — mutes the audio or video of a single named participant by their
clientId.
Room-Level Mute
// Mute all participants' audio in the room
EnxRtc.hardMute();
// Lift the room-wide audio mute
EnxRtc.hardUnMute();
| Callback | Fires when |
|---|---|
onHardMuted |
Room-level audio mute applied. All participants are notified — disable unmute controls in your UI. |
onHardUnMuted |
Room-level audio mute lifted. Participants can toggle their own audio again. |
Participant-Level Mute
Pass the target participant's clientId to mute or unmute their audio or video independently. The affected participant and all other participants receive separate callbacks so every client can update its UI.
// Mute a specific participant's audio
EnxRtc.hardMuteAudio(clientId);
// Lift audio mute for a specific participant
EnxRtc.hardUnMuteAudio(clientId);
// Mute a specific participant's video
EnxRtc.hardMuteVideo(clientId);
// Lift video mute for a specific participant
EnxRtc.hardUnMuteVideo(clientId);
| Callback | Fires when |
|---|---|
onParticipantAudioMuted |
A participant's audio was hard-muted by the moderator. |
onParticipantAudioUnMuted |
A participant's audio hard-mute was lifted by the moderator. |
onParticipantVideoMuted |
A participant's video was hard-muted by the moderator. |
onParticipantVideoUnMuted |
A participant's video hard-mute was lifted by the moderator. |
Locking the room prevents any new participants from joining the session. Participants who are already connected remain in the session and are unaffected. Unlock the room when you are ready to allow new joiners again. Only moderators can lock and unlock the room.
This is useful for securing a session once all expected attendees have joined — for example, preventing late entrants from disrupting a presentation or exam in progress.
// Lock the room — no new participants can join
EnxRtc.lockRoom();
// Unlock the room — new participants can join again
EnxRtc.unLockRoom();
| Callback | Fires when |
|---|---|
onRoomLocked |
Room has been locked. All connected participants are notified — update lock status in your UI. |
onRoomUnLocked |
Room has been unlocked. All connected participants are notified. |
When a room is created with knock mode enabled, participants cannot join directly. Instead they wait in a lobby until the moderator individually approves or denies their entry. This is useful for secure meetings, interviews, or any scenario where you need to vet each participant before admitting them.
The moderator receives an onUserAwaited callback for each waiting participant. The callback payload contains the participant's name and clientId, which you use to show an approve/deny UI and then act on the moderator's decision.
// Moderator is notified when a participant is waiting in the lobby
EnxRtc.onUserAwaited = (Map<dynamic, dynamic> map) {
String name = map['name'];
String clientId = map['clientId'];
print('User waiting: $name | ID: $clientId');
// Present approve/deny controls in your UI
};
// Approve a waiting participant — they join the room
EnxRtc.approveAwaitedUser(clientId);
// Deny a waiting participant — they are removed from the lobby
EnxRtc.denyAwaitedUser(clientId);
| Callback | Fires when |
|---|---|
onUserAwaited |
A participant is waiting in the lobby. Moderator only. Payload contains participant name and clientId. |
onAcknowledgeApproveAwaitedUser |
The moderator's approval was acknowledged — the waiting participant is now joining the room. |
onAcknowledgeDenyAwaitedUser |
The moderator's denial was acknowledged — the waiting participant has been removed from the lobby. |
EnxRtc.dropUser(clientId) forcefully removes a connected participant from the session. The removed participant's app receives a disconnect event so it can navigate away from the call screen gracefully. All other participants are also notified via onUserDisConnected so they can remove the participant's video tile from their layout. Only moderators can drop participants.
// Force-disconnect a participant by their clientId
EnxRtc.dropUser(clientId);
| Callback | Fires when |
|---|---|
onUserDisConnected |
The removed participant has been disconnected. Fires on all remaining participants — remove their video tile from your layout. |
Sessions have a maximum duration configured at room creation time. As the session approaches its limit, EnableX warns all participants in advance. EnxRtc.extendConferenceDuration(int minutes) adds time to the current session beyond its originally configured duration, giving participants more time without ending and restarting.
Call this method when you receive a remaining-duration warning to give participants the option to continue. The extension confirmation fires to all participants so every client can update its session timer.
// Add 30 minutes to the current session duration
EnxRtc.extendConferenceDuration(30);
| Callback | Fires when |
|---|---|
onConferenceDurationExtended |
Session duration was extended successfully. Fires on all participants — refresh the session timer in your UI. |
EnxRtc.destroy() terminates the session immediately for every connected participant. Unlike disconnect() — which disconnects only the caller — destroy() forces every participant offline at once. All participants receive onRoomDestroyed so each client can navigate away from the call screen. Only moderators can call destroy().
// End the session for all participants immediately — moderator only
EnxRtc.destroy();
| Callback | Fires when |
|---|---|
onRoomDestroyed |
Session has been destroyed. Fires on all participants — navigate away from the call screen immediately. |
destroy() is irreversible and instant. All participants lose their connection without warning. The session cannot be resumed after destroy() is called. Reserve it for deliberate, intentional session termination — not for the moderator's own exit.
EnxRtc.switchUserRole(clientId) promotes a participant to moderator or demotes a moderator to participant. This is a full role swap — the targeted participant immediately gains all moderator-level controls, and the calling moderator's role changes accordingly. Use this to hand off session control without ending or restarting the session.
All participants receive onUserRoleSwitched so their apps can update UI controls to reflect the new role assignment.
// Switch the role of a specific participant (promote or demote)
EnxRtc.switchUserRole(clientId);
| Callback | Fires when |
|---|---|
onUserRoleSwitched |
Role has been changed for the specified participant. Fires on all participants — update moderator controls in your UI accordingly. |
Pin and spotlight give moderators precise control over which participants appear in the Active Talker list, independent of speaking activity.
- Pin — keeps a participant persistently visible in the Active Talker list regardless of whether they are speaking. Pinned participants appear after active speakers. Use this to ensure a presenter, sign-language interpreter, or key participant is always on screen.
- Spotlight — pushes a participant to the top of the Active Talker list, above active speakers. Use spotlight when you want a specific participant's stream to have elevated layout priority during a presentation or demo.
// Pin one or more participants to keep them visible
EnxRtc.pinUsers([clientId1, clientId2]);
// Remove pinning from participants
EnxRtc.unpinUsers([clientId1, clientId2]);
// Add participants to the spotlight (top of Active Talker list)
EnxRtc.addSpotlightUsers([clientId1]);
// Remove participants from the spotlight
EnxRtc.removeSpotlightUsers([clientId1]);
| Callback | Fires when |
|---|---|
onPinnedUsers |
Pin has been applied. Update your Active Talker layout to keep pinned participants visible. |
onUnpinnedUsers |
Pin has been removed. The participant returns to normal Active Talker ordering. |
onSpotlightUsers |
Spotlight has been added. The spotlighted participant moves to the top of the Active Talker list. |
onUnspotlightUsers |
Spotlight has been removed. The participant returns to normal ordering. |
EnxRtc.switchRoomMode(String roomMode) changes the active room mode mid-session without ending or restarting it. This is useful for transitioning between collaborative discussion (Group mode) and structured presentation (Lecture mode) within a single session.
When switching from Group to Lecture mode, all participant streams are dropped and floor access control activates — only the moderator-approved participant can publish. When switching back from Lecture to Group mode, all participants are notified to publish their streams, but the SDK does not auto-publish; your app must call the appropriate publish method based on the user's intent.
// Switch the room to lecture mode
EnxRtc.switchRoomMode('lecture');
// Switch the room back to group mode
EnxRtc.switchRoomMode('group');
| Callback | Fires when |
|---|---|
onRoomModeSwitched |
Room mode has changed. Fires on all participants — adapt your UI for the new mode (for example, show or hide publish controls). |