FetchJoinableSpaces (Unity)
- Declaration
public static void FetchJoinableSpaces(Action<List<CavrnusSpaceInfo>> onRecvCurrentJoinableSpaces)
- Description
Gets a list of all current spaces which can be joined.
Note that this list will not update as new spaces are added, removed, or modified. To maintain those changes in your menu, consider instead using BindJoinableSpaces.
- Sample
using CavrnusSdk.API;
using UnityEngine;
public class FetchJoinableSpaces : MonoBehaviour
{
void Start()
{
CavrnusFunctionLibrary.AwaitAuthentication(auth => FetchMySpaces());
}
private void FetchMySpaces()
{
CavrnusFunctionLibrary.FetchJoinableSpaces(spaces =>
{
//Attempt to join the space named "DEMO"
foreach (var space in spaces)
{
if (space.Name == "DEMO")
{
CavrnusFunctionLibrary.JoinSpace(space.Id, spaceConn => { }, err => { });
return;
}
}
Debug.LogError("No available space named \"DEMO\"");
});
}
}