/ SDKs / Unity
SDKs
Calls SDKs Unity v1
Calls SDKs Unity
Calls SDKs
Unity
Version 1

Retrieve a list of rooms

Copy link

You can retrieve a list of rooms by using the parameters in SbRoomListQuery as filters. The following table shows all supported filters for SbRoomListQuery to search for specific rooms you want to retrieve.

Property nameTypeDescription

Limit

int

Filters query results to include the specified the number of results to return per page. Acceptable values are 1 to 100, inclusive. (Default: 10)

RoomIds

List< String >

Filters query results to include the specified unique identifiers for the rooms.

RoomState

SbRoomState?

Filters query results to include room with the specified room state. Acceptable values are the following:
- Open: Indicates that users can enter the room to participate in a group call.
- Deleted: Indicates that users can't enter the room and the room can't be reopened.

CurrentParticipantCountRange

SbRange

Filters query results to include rooms with the specified range of numbers for current participants.

CreatedByUserIds

List< String >

Filters query results to include rooms that were created by specified user IDs.

CreatedAtRange

List< String >

Filters query results to include rooms that were created between the specified range of time.

You can specify the filters as the following.

TimeSpan aWeekAgo = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)) + TimeSpan.FromDays(-7);
var roomListQueryParams = new SbRoomListQueryParams()
{
   Limit = 50,
   RoomState = SbRoomState.Open,
   CurrentParticipantCountRange = SbRange.GreaterThanOrEqualTo(1),
   CreatedByUserIds = { "USER_ID1", "USER_ID2" },
   CreatedAtRange = SbRange.GreaterThanOrEqualTo((long)aWeekAgo.TotalMilliseconds)
};

To retrieve the list of rooms you specified using the filters, call the SbRoomListQuery.Next(SbRoomListQueryHandler) method.

var roomListQuery = SendbirdCall.CreateRoomListQuery(roomListQueryParams);
roomListQuery.Next((rooms, error) => { });

After retrieving the list of rooms, the user can select a room they wish to enter using the following code.

rooms[index].Enter(roomEnterParams, (error) =>
{
   // User has entered the room.
});

Note: The room data returned is updated only after a user has entered the room. To update the details about a room, call the SendbirdCall.FetchRoomById() method.