Skip to content

Commit

Permalink
docs: added stage management section
Browse files Browse the repository at this point in the history
  • Loading branch information
saksham-gt committed Jun 26, 2024
1 parent 89a2c8d commit bd51c27
Show file tree
Hide file tree
Showing 4 changed files with 300 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/flutter-core/stage-management/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"position": 7,
"label": "Stage Management",
"collapsible": true,
"className": "pre-call-docs"
}
115 changes: 115 additions & 0 deletions docs/flutter-core/stage-management/host-controls.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
title: Stage Host Controls
description: Stage management APIs for Host in Dyte meetings.
sidebar_position: 2
tags:
- flutter-core
- stage
---

In a stage management-enabled meeting, a user with the `selfPermissions.host.canAcceptStageRequests` permission as `true` is
considered a host. The `dyteMobileClient.stage` object in Dyte's Flutter Core SDK provides stage management APIs that allow hosts to
manage stage access requests, invite participants to the stage, and remove participants from the stage.

### List of Stage Access Requests

You can retrieve the list of pending stage access requests by accessing the `dyteMobileClient.stage.accessRequests` property. This property
provides a list of `DyteJoinedMeetingParticipant` objects who have requested stage access.

:::note
If the local user is not a host, this property returns an empty list.
:::

### Grant stage access

A privileged user can grant access to stage for a set of users with `grantAccess` method.

| **Parameters** | **Type** |
| -------------- | ------------------------------ |
| peer | _DyteJoinedMeetingParticipant_ |

```dart
dyteClient.stage.grantAccess(peer);
```

To grant access to all stage requests at a time, you can user `grantAccessToAll()` method. This method takes no parameters.

```dart
dyteClient.stage.grantAccessToAll();
```

### Deny stage access

A privileged user can deny access to stage for a set of users with `denyAccess` method.

| **Parameters** | **Type** |
| -------------- | ------------------------------ |
| peer | _DyteJoinedMeetingParticipant_ |

```dart
dyteClient.stage.denyAccess(peer);
```

To deny all stage requests at a time, you can user `denyAccessToAll()` method. This method takes no parameters.

```dart
dyteClient.stage.denyAccessToAll();
```

### Kick participant from stage

A privileged user can kick a participant from stage with `kick` method.

| **Parameters** | **Type** |
| -------------- | ------------------------------ |
| peer | _DyteJoinedMeetingParticipant_ |

```dart
dyteClient.stage.kick(peer);
```

### Listening to Stage Access Requests

You can listen to incoming stage access requests or changes in the access requests list if you are a host. The SDK provides the
following callbacks to `DyteStageEventsListener`:

```dart
class StageEventListener extends DyteStageEventsListener {
@override
void onPresentRequestAdded(DyteJoinedMeetingParticipant participant) {
// Called when a participant requests to join the stage. Triggered only if the local user is a host.
}
@override
void onPresentRequestClosed(DyteJoinedMeetingParticipant participant) {
// Called when a participant with a pending stage access request leaves the meeting.
// Triggered only if the local user is a host.
}
@override
void onPresentRequestRejected(DyteJoinedMeetingParticipant participant) {
// Called when a participant's stage access request is denied by the host.
// Triggered only if the local user is a host.
}
@override
void onPresentRequestWithdrawn(DyteJoinedMeetingParticipant participant) {
// Called when a participant cancels their stage access request.
// Triggered only if the local user is a host.
}
@override
void onStageRequestsUpdated(List<DyteJoinedMeetingParticipant> accessRequests) {
// Called when the list of stage access requests is updated.
}
}
```

You need to attach the listener to meeting client as follows:

```dart
dyteClient.addStageEventsListener(StageEventsListener())
```

These APIs enable you to manage stage access requests and participants effectively in Dyte meetings. Next, we'll explore the
Stage APIs available to Viewer participants.
140 changes: 140 additions & 0 deletions docs/flutter-core/stage-management/introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
---
title: Introduction
description: Stage management in Dyte meetings.
sidebar_position: 1
tags:
- flutter-core
- stage
---

_Below documentation is relevant for Interactive Livestream(LHLS) and Webinar(WebRTC) use cases._

Instead of a traditional publish-subscribe model, where a user can publish their media and others can choose to subscribe, Dyte
comes with an optional managed configuration. In this managed configuration, a less privileged user can be configured with a
default behavior to not publish media. The user can then request permission to publish their media, which a privileged user can
choose to grant or deny.

### Accessing the Stage APIs

Dyte's stage management APIs allow users to perform actions such as joining and leaving the stage, managing stage requests and
permissions, and kicking participants from the stage. These APIs are accessible through the `dyteMobileClient.stage` object.

### Stage Status

In meetings where stage management is enabled, a user's stage status can change within the values represented by the `DyteStageStatus`
enum. These status values include:

- `onStage`: Indicates that the user is currently on the stage and is allowed to publish media.
- `offStage`: Indicates that the user is a viewer and is not on the stage. They can see and listen to those on stage.
- `requestedToJoinStage`: Indicates that the user has a pending request to join the stage. This status is assigned to the user
until the host accepts or rejects their request.
- `acceptedToJoinStage`: Indicates that the host has accepted the user's request to join the stage.
- `rejectedToJoinStage`: Indicates that the host has rejected the user's request to join the stage. The user can request again
to join from this status.

The `dyteMobileClient.stage.status` property provides the current stage status of the local user.

### Viewers

You can retrieve a list of off-stage participants (viewers) in a stage-enabled meeting by accessing the `meeting.stage.viewers`
property. This property provides a list of `DyteJoinedMeetingParticipant` objects whose stage status is not `onStage`.

### Joining the Stage

To interact with peers and publish media, users can join the stage. This action is only possible if the user's preset allows them
to publish media or if their request to join the stage has been accepted by a host (i.e., their stage status is `acceptedToJoinStage`).

```dart
dyteClient.stage.join();
```

### Leaving the Stage

When users want to stop interacting with peers, they can leave the stage. This action stops their media from being published,
and their audio and video are no longer received by others in the room.

```dart
dyteClient.stage.leave();
```

### List of Stage Events

The `DyteStageEventListener` interface provides callback methods for various stage events. Implement these callbacks to handle
stage-related events in your application:

```dart
class StageEventListener extends DyteStageEventsListener {
@override
void onAddedToStage() {
// Called when the local user successfully joins the stage.
}
@override
void onParticipantRemovedFromStage(
DyteJoinedMeetingParticipant participant) {
// Called when a participant is removed from the stage by the host.
}
@override
void onPresentRequestAdded(DyteJoinedMeetingParticipant participant) {
// Called when a participant requests to join the stage. Triggered only if the local user is a host.
}
@override
void onPresentRequestClosed(DyteJoinedMeetingParticipant participant) {
// Called when a participant with a pending stage access request leaves the meeting.
// Triggered only if the local user is a host.
}
@override
void onPresentRequestReceived() {
// Called when the local user's stage access request is accepted by the host,
// or when the local user, who is a viewer, is invited to the stage by the host.
}
@override
void onPresentRequestRejected(DyteJoinedMeetingParticipant participant) {
// Called when a participant's stage access request is denied by the host.
// Triggered only if the local user is a host.
}
@override
void onPresentRequestWithdrawn(DyteJoinedMeetingParticipant participant) {
// Called when a participant cancels their stage access request.
// Triggered only if the local user is a host.
}
@override
void onRemovedFromStage() {
// Called when the local user is removed from the stage.
}
@override
void onStageRequestsUpdated(List<DyteJoinedMeetingParticipant> accessRequests) {
// Called when the list of stage access requests is updated.
}
@override
void onStageStatusUpdated(DyteStageStatus stageStatus) {
// Called when the local user's stage status is updated.
}
@override
void onParticipantStartedPresenting(DyteJoinedMeetingParticipant participant) {
// Called when a participant joins the stage.
}
@override
void onParticipantStoppedPresenting(DyteJoinedMeetingParticipant participant) {
// Called when a participant leaves the stage.
}
}
```

You need to attach the listener to meeting client as follows:

```dart
dyteClient.addStageEventsListener(StageEventsListener())
```

Next, we'll explore the Stage Management APIs for hosts, allowing them to manage stage requests, participants in Dyte meetings.
39 changes: 39 additions & 0 deletions docs/flutter-core/stage-management/viewer-participants.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: Stage Access for Viewers
description: Stage APIs for Viewers in Dyte meetings.
sidebar_position: 3
tags:
- flutter-core
- stage
---

Viewer participants in a stage-enabled meeting are users whose preset permission for media production is set as `canRequest`.
The `dyteMobileClient.stage` object provides APIs for viewer participants to request stage access and withdraw their join stage request.

### Request access

This method is used to create a new stage request which can be approved by the host.

```dart
dyteClient.stage.requestAccess();
```

When a host accepts the user's stage access request or allows the user directly to the stage, the SDK triggers the
`onPresentRequestReceived` callback in `DyteStageEventListener`. You can listen to this event:

```dart
class StageEventListener with DyteStageEventsListener {
@override
void onPresentRequestReceived() {
// Host accepted the join stage request or invited user directly to stage
}
}
```

### Withdraw join request

To cancel or withdraw a pending stage access request, you can call the `withdrawJoinRequest()` method:

```dart
dyteClient.stage.withdrawJoinRequest();
```

0 comments on commit bd51c27

Please sign in to comment.