Manage Participants in a Session·续3

Remove a participant

To remove a specific participant from the session:

  1. Check that the local participant has permission to remove participants.
   const canKickParticipant = meeting.self.permissions.kickParticipant === true;
   if (!canKickParticipant) {
    // Disable the control in your UI.
   }
   ```

2. Call `kick()` on the target participant.

If the local participant does not have the required permission, `kick()` throws a `ClientError` with code `1201`.

```ts
   try {
    await participant.kick();
   } catch (err: any) {
    if (err?.code === 1201) {
        // The local participant does not have permission to remove participants.
        return;
    }
    throw err;
   }
   ```

3. Handle the result by listening for updates.

After the call succeeds:
   - The kicked participant is removed from `meeting.participants.joined`.
   - The participant is removed from other participant maps they were in (for example, `meeting.participants.pinned`).
   - The SDK emits `participantLeft` on `meeting.participants.joined`.

```ts
   meeting.participants.joined.on("participantLeft", (participant) => {
    // Remove the participant tile from the UI.
   });
   ```

Other participants in the session also observe the participant leaving through `participantLeft`.
4. On the removed participant's side, the session disconnects and `meeting.self` emits `roomLeft` event with state set to `kicked`.

```ts
   meeting.self.on("roomLeft", ({ state }) => {
    if (state === "kicked") {
        // Show a message and navigate the user out of the meeting UI.
    }
   });
   ```

1. Check that the local participant has permission to remove participants.

```ts
   const canKickParticipant = meeting.self.permissions.kickParticipant === true;
   if (!canKickParticipant) {
    // Disable the control in your UI.
   }
   ```

2. Call `kick()` on the target participant.

If the local participant does not have the required permission, `kick()` throws a `ClientError` with code `1201`.

```ts
   try {
    await participant.kick();
   } catch (err: any) {
    if (err?.code === 1201) {
        // The local participant does not have permission to remove participants.
        return;
    }
    throw err;
   }
   ```

3. Handle the result by listening for updates.

After the call succeeds:
   - The kicked participant is removed from `meeting.participants.joined`.
   - The participant is removed from other participant maps they were in (for example, `meeting.participants.pinned`).
   - The SDK emits `participantLeft` on `meeting.participants.joined`.

```ts
   meeting.participants.joined.on("participantLeft", (participant) => {
    // Remove the participant tile from the UI.
   });
   ```

Other participants in the session also observe the participant leaving through `participantLeft`.
4. On the removed participant's side, the session disconnects and `meeting.self` emits `roomLeft` event with state set to `kicked`.

```ts
   meeting.self.on("roomLeft", ({ state }) => {
    if (state === "kicked") {
        // Show a message and navigate the user out of the meeting UI.
    }
   });
   ```

1. Check that the local participant has permission to remove participants.

```ts
   const canKickParticipant = meeting.self.permissions.kickParticipant === true;
   if (!canKickParticipant) {
    // Disable the control in your UI.
   }
   ```

2. Call `kick()` on the target participant.

If the local participant does not have the required permission, `kick()` throws a `ClientError` with code `1201`.

```ts
   try {
    await participant.kick();
   } catch (err: any) {
    if (err?.code === 1201) {
        // The local participant does not have permission to remove participants.
        return;
    }
    throw err;
   }
   ```

3. Handle the result by listening for updates.

After the call succeeds:
   - The kicked participant is removed from `meeting.participants.joined`.
   - The participant is removed from other participant maps they were in (for example, `meeting.participants.pinned`).
   - The SDK emits `participantLeft` on `meeting.participants.joined`.

```ts
   meeting.participants.joined.on("participantLeft", (participant) => {
    // Remove the participant tile from the UI.
   });
   ```

Other participants in the session also observe the participant leaving through `participantLeft`.
4. On the removed participant's side, the session disconnects and `meeting.self` emits `roomLeft` event with state set to `kicked`.

```ts
   meeting.self.on("roomLeft", ({ state }) => {
    if (state === "kicked") {
        // Show a message and navigate the user out of the meeting UI.
    }
   });
   ```

1. Check that the local participant has permission to remove participants.

```kotlin
val canKickParticipant = meeting.localUser.permissions.host.canKickParticipant
if (!canKickParticipant) {
    // Disable the control in your UI.
}
  1. Call kick() on the target participant. If the local participant does not have the required permission, kick() returns a HostError.
val error = participant.kick()
if (error != null) {
    // Handle error - permission denied.
}
  1. Handle the result by listening for updates. After the call succeeds, the kicked participant is removed from meeting.participants.joined.
meeting.addParticipantsEventListener(object : RtkParticipantsEventListener {
    override fun onParticipantLeave(participant: RtkRemoteParticipant) {
        // Remove the participant tile from the UI.
    }
})
  1. Check that the local participant has permission to remove participants.
let canKickParticipant = meeting.localUser.permissions.host.canKickParticipant
if !canKickParticipant {
    // Disable the control in your UI.
}
  1. Call kick() on the target participant. If the local participant does not have the required permission, kick() returns a HostError.
if let error = participant.kick() {
    // Handle error - permission denied.
}
  1. Handle the result by listening for updates. After the call succeeds, the kicked participant is removed from meeting.participants.joined.
extension MeetingViewModel: RtkParticipantsEventListener {
    func onParticipantLeave(participant: RtkRemoteParticipant) {
        // Remove the participant tile from the UI.
    }
}

// Register the listener
meeting.addParticipantsEventListener(participantsEventListener: self)
  1. Check that the local participant has permission to remove participants.
const canKickParticipant = meeting.self.permissions.kickParticipant;
if (!canKickParticipant) {
    // Disable the control in your UI.
}
  1. Call kick() on the target participant.
participant
    .kick()
    .catch((err) => {
        // Handle error - permission denied or other issue.
        console.log(err);
    });
  1. Handle the result by listening for updates. After the call succeeds, the kicked participant is removed from meeting.participants.joined.
meeting.participants.joined.on('participantLeft', (participant) => {
    // Remove the participant tile from the UI.
});

Remove all participants

This removes everyone from the session, including the local participant. This ends the session for everyone.

For a complete end-a-session flow, refer to End a session.

To remove all participants from the session:

  1. Check that the local participant has permission to remove participants.
   const canKickParticipant = meeting.self.permissions.kickParticipant === true;
   if (!canKickParticipant) {
    // Disable the control in your UI.
   }
   ```

2. Call `kickAll()`.

If the local participant does not have the required permission, `kickAll()` throws a `ClientError` with code `1201`.

```ts
   try {
    await meeting.participants.kickAll();
   } catch (err: any) {
    if (err?.code === 1201) {
        // The local participant does not have permission to remove participants.
        return;
    }
    throw err;
   }
   ```

3. Handle the result by listening for updates.

After the call succeeds, all participants exit the session. On each client, `meeting.self` emits `roomLeft` with state set to `ended`.

```ts
   meeting.self.on("roomLeft", ({ state }) => {
    if (state === "ended") {
        // Show a message and navigate the user out of the meeting UI.
    }
   });
   ```

1. Check that the local participant has permission to remove participants.

```ts
   const canKickParticipant = meeting.self.permissions.kickParticipant === true;
   if (!canKickParticipant) {
    // Disable the control in your UI.
   }
   ```

2. Call `kickAll()`.

If the local participant does not have the required permission, `kickAll()` throws a `ClientError` with code `1201`.

```ts
   try {
    await meeting.participants.kickAll();
   } catch (err: any) {
    if (err?.code === 1201) {
        // The local participant does not have permission to remove participants.
        return;
    }
    throw err;
   }
   ```

3. Handle the result by listening for updates.

After the call succeeds, all participants exit the session. On each client, `meeting.self` emits `roomLeft` with state set to `ended`.

```ts
   meeting.self.on("roomLeft", ({ state }) => {
    if (state === "ended") {
        // Show a message and navigate the user out of the meeting UI.
    }
   });
   ```

1. Check that the local participant has permission to remove participants.

```ts
   const canKickParticipant = meeting.self.permissions.kickParticipant === true;
   if (!canKickParticipant) {
    // Disable the control in your UI.
   }
   ```

2. Call `kickAll()`.

If the local participant does not have the required permission, `kickAll()` throws a `ClientError` with code `1201`.

```ts
   try {
    await meeting.participants.kickAll();
   } catch (err: any) {
    if (err?.code === 1201) {
        // The local participant does not have permission to remove participants.
        return;
    }
    throw err;
   }
   ```

3. Handle the result by listening for updates.

After the call succeeds, all participants exit the session. On each client, `meeting.self` emits `roomLeft` with state set to `ended`.

```ts
   meeting.self.on("roomLeft", ({ state }) => {
    if (state === "ended") {
        // Show a message and navigate the user out of the meeting UI.
    }
   });
   ```

1. Check that the local participant has permission to remove participants.

```kotlin
val canKickParticipant = meeting.localUser.permissions.host.canKickParticipant
if (!canKickParticipant) {
    // Disable the control in your UI.
}
  1. Call kickAll() on the participants object. If the local participant does not have the required permission, kickAll() returns a HostError.
val error = meeting.participants.kickAll()
if (error != null) {
    // Handle error - permission denied.
}
  1. Handle the result by listening for updates. After the call succeeds, all participants exit the session.
meeting.addMeetingRoomEventListener(object : RtkMeetingRoomEventListener {
    override fun onMeetingEnded() {
        // Show a message and navigate the user out of the meeting UI.
    }
})
  1. Check that the local participant has permission to remove participants.
let canKickParticipant = meeting.localUser.permissions.host.canKickParticipant
if !canKickParticipant {
    // Disable the control in your UI.
}
  1. Call kickAll() on the participants object. If the local participant does not have the required permission, kickAll() returns a HostError.
if let error = meeting.participants.kickAll() {
    // Handle error - permission denied.
}
  1. Handle the result by listening for updates. After the call succeeds, all participants exit the session.
extension MeetingViewModel: RtkMeetingRoomEventListener {
    func onMeetingEnded() {
        // Show a message and navigate the user out of the meeting UI.
    }
}

// Register the listener
meeting.addMeetingRoomEventListener(meetingRoomEventListener: self)
  1. Check that the local participant has permission to remove participants.
const canKickParticipant = meeting.self.permissions.kickParticipant;
if (!canKickParticipant) {
    // Disable the control in your UI.
}
  1. Call kickAll() on the participants object.
meeting.participants
    .kickAll()
    .catch((err) => {
        // Handle error - permission denied or other issue.
        console.log(err);
    });
  1. Handle the result by listening for updates. After the call succeeds, all participants exit the session.
meeting.self.on('roomLeft', ({ state }) => {
    if (state === 'kicked') {
        // Show a message and navigate the user out of the meeting UI.
    }
});

Next steps

  • Review how presets control permissions in Preset.
  • Review error handling details in Error Codes.

Was this helpful?

YesNo

On this page

Manage Participants in a Session·续3 - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/realtime/realtimekit/humans/core/manage-participants-in-a-session/#page","headline":"Manage Participants in a Session","description":"Use RealtimeKit host controls to mute, pin, or remove participants in a live session.","url":"https://developers.cloudflare.com/realtime/realtimekit/humans/core/manage-participants-in-a-session/","inLanguage":"en","image":"https://developers.cloudflare.com/realtime/realtimekit/humans/core/manage-participants-in-a-session/og.png?v=e51984af50731733","dateModified":"2026-10-19","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Acquire and manage participant audio and video tracks in RealtimeKit using different approaches. title: Media Acquisition Approaches image: https://developers.cloudflare.com/realtime/realtimekit/humans/core/media-acquisition-approaches/og.png?v=c72929bbd84baa03


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/realtime/llms.txt
Use this file to discover all available pages before exploring further.