val filters = mutableMapOf(
"members" to mutableMapOf("\$in" to listOf("tommaso")),
"starts_at" to mutableMapOf("\$lt" to threeHoursFromNow),
//"ended_at" to false,
)
val sort = listOf(SortField.Asc("starts_at"))
val result = client.queryCalls(filters=filters, sort=sort, limit=10, watch=true)
Querying Calls
For many video calling, livestream or audio rooms apps you’ll want to show:
- Upcoming calls
- Calls that are currently live
- Popular livestreams/ audio rooms with a link to the recording
The SDK makes it easy to query calls
Example Queries
Calls that are about to start
Calls that are ongoing / currently have participants
client.queryCalls(mapOf("ongoing" to true)).let { result ->
result
.onSuccess { calls: QueriedCalls -> Log.d(TAG, "Query success: $calls") }
.onError { error: Error -> Log.e(TAG, "Query failure: ${error.message}") }
}
Calls filters on a custom property
val filters = mutableMapOf(
"custom.color" to "red",
)
val sort = listOf(SortField.Asc("starts_at"))
val result = client.queryCalls(filters=filters, sort=sort, limit=10, watch=true)
Pagination
The query response is paginated and the maximum count of items is defined by the limit
parameter.
Use the prev
and next
parameters from the last response as parameters for requesting the next page.
// Request first page (prev and next are not set)
val resultPage1 = client.queryCalls(filters=emptyMap(), limit=10)
...
val resultPage1 = queryResult as Result.Success
// Request second page with prev and next parameters from previous response
val resultPage2 = client.queryCalls(
filters = emptyMap(),
limit = 10,
prev = resultPage1.value.prev,
next = resultPage1.value.next
)
Fields for Query Calls
You can filter on the following fields
Option | Description |
---|---|
type | The call type. Typically default, livestream etc |
id | The id for this call |
cid | The cid for this call. IE default:123 |
created_by_user_id | The user id who created the call |
created_at | When the call was created |
updated_at | When the call was updated |
starts_at | When the call starts at |
ended_at | When the call ended |
backstage | If the call is in backstage mode or not |
members | Check if you are a member of this call |
custom | You can query custom data using the “custom.myfield” syntax |
Sorting is supported on the fields below:
starts_at
created_at
updated_at
ended_at
type
id
cid
If you specify watch
the SDK will automatically keep the data about these calls updated.
This allows you to show a live preview of who’s in the call.
On this page: