var callType = StreamCallType.Default; // Call type affects default permissions
var callId = "my-call-id";
// Passing create: true will create the call if it doesn't exist
var streamCall = await _client.JoinCallAsync(callType, callId, create: true, ring: false, notify: false);Joining & Creating Calls
Joining a call
Most commonly, you will want to either join another call or create a new call and join it immediately.
You can easily achieve this with the _client.JoinCallAsync method and setting the create argument to true if you're creating a new call or false if you're joining another call.
The last two arguments control whether the call's members are alerted when you join:
| Argument | Description |
|---|---|
ring | When true, the call members are rung — they receive an incoming-call notification and can answer with AcceptAsync or decline with RejectAsync. Only meaningful when you are creating the call; use false when joining a call that is already running. |
notify | When true, the call members receive a regular (non-ringing) push notification that the call has started. Use this for "a call is happening" alerts that shouldn't make the device ring. |
ring: true sends an incoming-call notification to every member of the call. Pass false unless you have an incoming-call flow that handles AcceptAsync / RejectAsync.
The call type controls which features are enabled, and sets up permissions. You can read more about the call types here
For the call id there are a few things to note:
- You can reuse the same call multiple times.
- If you have a unique id for the call we recommend passing that as the id.
Creating a call
If you wish to only create a call object, that you'll join later, you can use the _client.GetOrCreateCallAsync method.
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);Get a call
To get a call by id and the call type you can use the _client.GetCallAsync method. This method will return the call object if it exists or return null if the call was not found.
var callType = StreamCallType.Default; // Call type affects default permissions
var callId = "my-call-id";
// Try to get call - will return null if the call doesn't exist
var streamCall = await _client.GetCallAsync(callType, callId);Querying Members
You can query the members of the call. This is helpful if you have thousands of members in a call and want to paginate.
var filters = new List<IFieldFilterRule>
{
CallMemberFilter.Role.EqualsTo("admin")
};
var result = await streamCall.QueryMembersAsync(filters, CallMemberSort.OrderByDescending(CallMemberSortField.LastActive), limit: 25);
// queried members, depending on how many members satisfy the filter this can be only a subset or a single "page" of results
var members = result.Members;
// In order to get the next "page" of results, use this token as a "next" argument in the QueryMembersAsync method
var next = result.Next;
// In order to get the previous "page" of results, use this token as a "prev" argument in the QueryMembersAsync method
var prev = result.Prev;You can filter the member list with CallMemberFilter on these fields.
Note that you can also query on custom data for the member or the user.
| Filter field | Description |
|---|---|
CallMemberFilter.Id | The user's id |
CallMemberFilter.Role | The member's role |
CallMemberFilter.CreatedAt | When the member was created |
CallMemberFilter.UpdatedAt | When the member was last updated |
CallMemberFilter.Custom() | The custom data on the member |
Sorting is done with CallMemberSort and one of the CallMemberSortField values:
| Sort field | Description |
|---|---|
CallMemberSortField.Name | The member's name |
CallMemberSortField.Role | The member's role |
CallMemberSortField.Banned | Whether the member is banned |
CallMemberSortField.ShadowBanned | Whether the member is shadow banned |
CallMemberSortField.CreatedAt | When the member was created |
CallMemberSortField.UpdatedAt | When the member was last updated |
CallMemberSortField.LastActive | When the member was last active |
CallMemberSortField.Teams | The teams the member belongs to |
CallMemberSortField.CustomField() | Sort by your own custom field on the member |