-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ccec02f
commit e1b948b
Showing
6 changed files
with
151 additions
and
7 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
Packages/StreamVideo/DocsCodeSamples/03-guides/CallParticipantsPinning.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using StreamVideo.Core; | ||
|
||
namespace DocsCodeSamples._03_guides | ||
{ | ||
/// <summary> | ||
/// Code examples for guides/pinning-participants/ page | ||
/// </summary> | ||
internal class CallParticipantsPinning | ||
{ | ||
public async Task PinLocally() | ||
{ | ||
var callType = StreamCallType.Default; // Call type affects default permissions | ||
var callId = "my-call-id"; | ||
|
||
// Get call or create if it doesn't exist | ||
var streamCall = await _client.GetOrCreateCallAsync(callType, callId); | ||
|
||
var participant = streamCall.Participants.First(); | ||
|
||
streamCall.PinLocally(participant); | ||
} | ||
|
||
public async Task UnpinLocally() | ||
{ | ||
var callType = StreamCallType.Default; // Call type affects default permissions | ||
var callId = "my-call-id"; | ||
|
||
// Get call or create if it doesn't exist | ||
var streamCall = await _client.GetOrCreateCallAsync(callType, callId); | ||
|
||
var participant = streamCall.Participants.First(); | ||
|
||
streamCall.UnpinLocally(participant); | ||
} | ||
|
||
public async Task GetPinnedParticipants() | ||
{ | ||
var callType = StreamCallType.Default; // Call type affects default permissions | ||
var callId = "my-call-id"; | ||
|
||
// Get call or create if it doesn't exist | ||
var streamCall = await _client.GetOrCreateCallAsync(callType, callId); | ||
|
||
var participant = streamCall.Participants.First(); | ||
|
||
streamCall.PinLocally(participant); | ||
|
||
foreach (var pinnedParticipant in streamCall.PinnedParticipants) | ||
{ | ||
// Iterate through pinned participants | ||
} | ||
} | ||
|
||
public async Task CheckIfParticipantIsPinned() | ||
{ | ||
var callType = StreamCallType.Default; // Call type affects default permissions | ||
var callId = "my-call-id"; | ||
|
||
// Get call or create if it doesn't exist | ||
var streamCall = await _client.GetOrCreateCallAsync(callType, callId); | ||
|
||
var participant = streamCall.Participants.First(); | ||
|
||
streamCall.PinLocally(participant); | ||
|
||
var isPinned = streamCall.IsPinnedLocally(participant); | ||
var isPinnedLocally = streamCall.IsPinnedLocally(participant); | ||
var isPinnedRemotely = streamCall.IsPinnedRemotely(participant); | ||
} | ||
|
||
private IStreamVideoClient _client; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Packages/StreamVideo/DocsCodeSamples/03-guides/CallParticipantsPinning.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
docusaurus/docs/Unity/03-guides/09-pinning-call-participants.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: Pinning participants | ||
description: How to pin participants | ||
--- | ||
|
||
The StreamVideo SDK has support for pinning users, both locally for the current user, and remotely for everyone in the call. | ||
Every user can pin as many participants on the call as they want, and those users will be shown first in the list of participants for that user. Pinning someone for everyone in the call requires the `pinForEveryone` capability. | ||
By default, the pinned users appear first in the `streamCall.SortedParticipants` array. The ones which are pinned remotely appear before the local ones. If there are several remotely pinned users, they are sorted by the pinning date (the most recent pins appear first). | ||
|
||
### Local pins | ||
In order to pin a user locally: | ||
|
||
```csharp | ||
streamCall.PinLocally(participant); | ||
``` | ||
|
||
To unpin the user: | ||
```csharp | ||
streamCall.UnpinLocally(participant); | ||
``` | ||
|
||
In both examples, the `participant` is an object of type `IStreamVideoCallParticipant`. | ||
|
||
To get all pinned participants: | ||
```csharp | ||
foreach (var pinnedParticipant in streamCall.PinnedParticipants) | ||
{ | ||
// Iterate through pinned participants | ||
} | ||
``` | ||
|
||
You can check if the participant is pinned either locally or remotely by: | ||
```csharp | ||
var isPinned = streamCall.IsPinnedLocally(participant); | ||
``` | ||
|
||
Or to distinguish whether the participant is pinned locally or remotely you can more specific versions: | ||
```csharp | ||
var isPinnedLocally = streamCall.IsPinnedLocally(participant); | ||
var isPinnedRemotely = streamCall.IsPinnedRemotely(participant); | ||
``` |