Rooms functionality can be accessed through the
PlayResolverwhich includes all the methods needed to use rooms.
To manage Rooms we must first decide which region we are working with.
async Task<(IReadOnlyList<string>, bool)> FetchRegions()
PlayResolver.csallows us to fetch the regions available for our project. This task returns a list of regions (as strings) and a boolean that indicates if the operation was successful.
async Task<string> FetchLocalRegions()
PlayResolver.csreturns the local region string for a local running Rooms Server, or null if the operation is un-successful (if the Server isn't running for example).
Every other Rooms API will require a region string that indicates the relevant region for the operation so these strings should not be changed before using them for other operations.
RoomsConnectDialogpopulates a dropdown with the region strings returned by both of these methods directly for easy selection.
After we have the available regions we can start managing Rooms, for instance:
async Task<RoomData> CreateRoom(string region, RoomCreationOptions options = null)
PlayResolver.csallows us to create a Room in the region we send it.
RoomCreationOptionsis used to optionally specify:
- a Room name
- the maximum number of Clients allowed for the Room
- a list of tags for Room filtering and other uses
- a key-value collection for the Room
This task returns the
RoomDatafor the created Room assuming the operation was successful.
async Task<IReadOnlyList<RoomData>> FetchRooms(string region, string tags = null)
PlayResolver.csallows us to search for available Rooms in a region. We can also optionally specify tags for filtering the Rooms.
This task returns a list of
RoomDataobjects for the Rooms available for our specifications.
void JoinRoom(IClient client, RoomData room, bool isSimulator = false)
PlayResolver.csconnects the client that we pass to the method to the Room we pass to the method. This
RoomDataobject can be either the one we get back from
CreateRoomor one of the ones we got from
When joining a Room, the method is optionally supplied if the connecting Client is a Simulator, as well.
RoomsConnectDialogdemonstrates both of these cases in
CreateRoomwhen called with true for autoJoin and in