Skip to main content

Run Participants and Collaboration in Kotlin

Build waiting-room decisions, participant moderation, co-host assignment, messages, polls, breakouts, whiteboard, and recording with com.mediasfu:mediasfu-sdk:1.0.5.

Complete the Kotlin room lifecycle first. Use one current MediasfuGenericState, and show privileged controls only when that state says the current person has the required room authority.

Prefer the supplied room

Start with MediasfuGeneric. Its state already provides convenient functions for the most common host workflows:

fun moderateParticipant(
state: MediasfuGenericState,
participant: Participant,
) {
state.muteParticipant(participant)
state.removeParticipant(participant)
}

fun updatePanelist(
state: MediasfuGenericState,
participant: Participant,
makePanelist: Boolean,
) {
if (makePanelist) state.addPanelist(participant)
else state.removePanelist(participant)
}

Call one action per user decision; the combined snippet only shows the available functions. Never mute and remove someone from one button. Wait for current room state before showing an action as complete.

Waiting, requests, and co-hosts

Remove and ban are different actions

removeParticipant disconnects someone from the current room without setting the room's ban flag. For an authorized Ban action, Kotlin 1.0.5 provides confirmExit(ConfirmExitOptions(..., ban = true)). MediaSFU then rejects a later join that uses the same banned room identity.

Make usernames stable and unique for authenticated accounts. If people can choose a different name on every join, a username-based ban can be evaded. Label the ordinary action Remove from room and reserve Ban from room for the explicit ban = true flow.

import com.mediasfu.sdk.methods.exit_methods.ConfirmExitOptions
import com.mediasfu.sdk.methods.exit_methods.confirmExit
import com.mediasfu.sdk.socket.SocketManager

suspend fun banFromRoom(
roomSocket: SocketManager,
localRoomSocket: SocketManager?,
username: String,
roomName: String,
) {
confirmExit(
ConfirmExitOptions(
socket = roomSocket,
localSocket = localRoomSocket,
member = username,
roomName = roomName,
ban = true,
),
)
}

Pass the socket managers owned by the active room. Enable this action only for a role your application allows to ban participants, and confirm the result from room state before changing the UI.

Custom UIs can call the exact Kotlin functions after constructing their option objects from the current room state:

suspend fun decideWaiting(options: RespondToWaitingOptions) =
respondToWaiting(options)

suspend fun decideRequest(options: RespondToRequestsOptions) =
respondToRequests(options)

suspend fun updateCoHost(options: ModifyCoHostSettingsOptions) =
modifyCoHostSettings(options)

For RespondToWaitingOptions, type = true admits and type = false rejects. For requests, preserve the request's own type or icon and send the selected accept or reject action. Version 1.0.5 does not define separate request-to-speak and admission functions; label the action from the request your application actually received.

Co-host assignment changes a selected participant and their responsibilities. Panelist controls are separate. Do not present either as an arbitrary role editor or as a user-defined permission system; the package does not publish a general role-and-permission editor.

ActionObservable successRecovery
Admit or rejectThe waiting list changes and the affected person receives the result.Keep the entry pending until room state changes.
Approve or denyThe request leaves the current request list.Restore it after connection or authority failure.
Mute or removeEvery connected client receives the participant change.Do not hide a local card to simulate success.
Assign co-hostThe target receives the new controls and responsibilities.Keep the previous role if the room does not confirm it.

Messages and polls

sendMessage(SendMessageOptions) accepts receivers and group. Use group = true for a room/group message and show the intended recipients for an addressed message. Confirm delivery through current message state; the SDK function alone is not a privacy or delivery guarantee.

The supplied state has a complete poll flow:

state.createPoll(question, options, type = "singleChoice")
state.voteInPoll(pollId, optionIndex)
state.endPoll(pollId)

Disable repeat actions while pending. After reconnecting, reload the current messages and poll rather than replaying the last action.

Breakouts and whiteboard

Use DefaultBreakoutRoomsModal with BreakoutRoomsModalOptions. Its public workspace handles assignments and exposes start and stop actions. Confirm every participant has a destination before starting, show a destination only after the room confirms it, and reload assignments after a reconnect. Stop the breakout before navigating people back to the main room or clearing drafts.

Use ConfigureWhiteboardModal with ConfigureWhiteboardModalOptions for the shared board lifecycle. The supplied workspace owns start, update, and stop. Version 1.0.5 does not publish a standalone low-level drawing-action API, so keep custom drawing tools app-owned and test them with two devices. The supplied board is the supported annotation path; do not promise a separate screen-annotation command API.

Recording and product policy

Use confirmRecording, startRecording, and stopRecording with their matching Kotlin option objects. Starting checks the local recording confirmation and the selected local media before it requests recording.

That confirmation is not participant consent. Version 1.0.5 does not provide a storage destination, retention, access, export, or deletion policy API. Your app must show consent and your backend must enforce the recording lifecycle.

Cleanup and release checklist

On leave, removal, or host-ended meeting, close every workspace and clear app-owned selections, pending decisions, message drafts, poll drafts, breakout assignments, drawing tools, recording timers, listeners, and room authority. Keep participant leave, participant removal, and meeting-ended states distinct.

  • Test host, co-host, panelist, and participant authority separately.
  • Admit, reject, approve, deny, mute, remove, and assign co-host.
  • Send a room message and an addressed message to the intended recipients.
  • Create, vote, and end a poll without duplicate actions.
  • Start and stop breakouts with every participant assigned.
  • Start, use, and stop the whiteboard on two devices.
  • Start and stop recording with consent and retention behavior visible.
  • Reconnect during a pending action without replaying it.
  • Leave and confirm app-owned state, media, and listeners are cleared.

Run the package's Android compile and unit tests, then repeat the checklist on every Android and iOS device family you release.