\<uses-permission android:name="com.oculus.permission.USE_COLOCATION_DISCOVERY_API"/\>
Success | The API call succeeded. |
AlreadyAdvertising | A Colocation Session already is advertising, a no-op occurs. |
AlreadyDiscovering | Colocation Sessions are already being discovered, a no-op occurs. |
Failure | The API call failed with no additional details. |
Unsupported | Colocation Session is not supported. |
OperationFailed | The API call operation failed. |
InvalidData | The result received does not represent the API call. |
NetworkFailed | The user is not connected to a network. |
NoDiscoveryMethodAvailable | The user does not have discovery methods such as bluetooth enabled. |
async void TryStartSession()
{
byte[] data = null; // your custom data here
var result = await OVRColocationSession.StartAdvertisementAsync(data);
if (!result.TryGetValue(out var sessionUuid))
{
Debug.LogError($"Unable to start colocation session! status={result.Status}");
return;
}
await ShareCurrentAnchorsWith(sessionUuid); // your impl.
}
void OnDiscoveredSession(OVRColocationSession.Data data)
{
if (!RegisterNewSession(data.AdvertisementUuid)) // your impl.
return;
Debug.Log($"Discovered new colocated session: {data.AdvertisementUuid}");
// e.g.:
LoadMetadata(data.Metadata); // your impl.
LoadSharedAnchorsFrom(data.AdvertisementUuid); // your impl.
}
async void StartDiscoveringSessions()
{
OVRColocationSession.ColocationSessionDiscovered -= OnDiscoveredSession; // prevents duplicate listeners
OVRColocationSession.ColocationSessionDiscovered += OnDiscoveredSession;
var result = await OVRColocationSession.StartDiscoveryAsync();
if (result.Success)
return;
Debug.LogError($"Unable to start discovering colocation sessions! status={result.Status}");
OVRColocationSession.ColocationSessionDiscovered -= OnDiscoveredSession;
}