StartSessionAdvertisementAsyncStopSessionAdvertisementAsync

StartSessionAdvertisementAsync and StopSessionAdvertisementAsync C++ API is accessed through the OculusXRColocation interface.TSharedPtr<FStartSessionAdvertisementRequest>.TSharedPtr<FStopSessionAdvertisementRequest>.FStartSessionAdvertisementRequest and FStopSessionAdvertisementRequest type are classes that wraps an underlying AsyncRequest type and the function call will configure and execute the AsyncRequest for you. Completion, both failure and success, will occur on the game thread. Either immediately as the request is executed or after some number of frames.| Delegate | Parameters |
|---|---|
FStartSessionAdvertisementRequest::FCompleteDelegate | FStartSessionAdvertisementRequest::FResultType Result |
FStopSessionAdvertisementRequest::FCompleteDelegate | FStopSessionAdvertisementRequest::FResultType Result |
| Name | Type | Description |
|---|---|---|
TResultType | EColocationResult | The result enum value. |
TValueType | FOculusXRColocationSession | Structure containing the session UUID and Metadata. |
You are not required to use a lambda as your delegate functor, that is only used to simplify this example.
void StartAdvertising(const TArray<uint8>& Metadata)
{
OculusXRColocation::FColocation::StartSessionAdvertisementAsync(
Metadata,
FStartSessionAdvertisementRequest::FCompleteDelegate::CreateLambda([](
const FStartSessionAdvertisementRequest::FResultType& Result)
{
if (Result.IsSuccess())
{
FOculusXRColocationSession session = Result.GetValue();
}
else
{
auto status = Result.GetStatus()
// Do something with the status code on error
}
})
);
}
void StopAdvertising()
{
OculusXRColocation::FColocation::StopSessionAdvertisementAsync(
FStopSessionAdvertisementRequest::FCompleteDelegate::CreateLambda([](
const FStopSessionAdvertisementRequest::FResultType& Result)
{
if (Result.IsSuccess())
{
// Stopped successfully
}
else
{
auto status = Result.GetStatus()
// Do something with the status code on error
}
})
);
}
DiscoverSessionsAsyncStopDiscoverSessions

DiscoverSessionsAsync and StopDiscoverSessions C++ API is accessed through the OculusXRColocation interface.OnSessionFound parameter which will be executed every time a Colocation Session is found. The return type of the API call is TSharedPtr<FDiscoverSessionsRequest>. The FDiscoverSessionsRequest type is a class that wraps an underlying AsyncRequest type and the function call will configure and execute the AsyncRequest for you. Completion, both failure and success, will occur on the game thread. Either immediately as the request is executed or after some number of frames.FDiscoverSessionsRequest. The return type of the API call is EColocationResult.| Delegate | Parameters |
|---|---|
FDiscoverSessionsRequest::FCompleteDelegate | FDiscoverSessionsRequest::FResultType Result |
FOculusXRColocationSessionFoundDelegate | const FOculusXRColocationSession& Session |
| Name | Type | Description |
|---|---|---|
TResultType | EColocationResult | The result enum value. |
TValueType | TArray<FOculusXRColocationSession> | Array of found colocation sessions. |
You are not required to use a lambda as your delegate functor, that is only used to simplify this example.
TSharedPtr<FDiscoverSessionsRequest> StartDiscovery()
{
auto request = OculusXRColocation::FColocation::DiscoverSessionsAsync(
FDiscoverSessionsRequest::FCompleteDelegate::CreateLambda([](
const FDiscoverSessionsRequest::FResultType& Result)
{
if (Result.IsSuccess())
{
TArray<FOculusXRColocationSession> sessions = Result.GetValue();
}
else
{
auto status = Result.GetStatus()
// Do something with the status code on error
}
}),
FOculusXRColocationSessionFoundDelegate::CreateLambda([](
const FOculusXRColocationSession& Session)
{
// Do something when a session is found
})
);
return request;
}
void StopDiscovery(TSharedPtr<FDiscoverSessionsRequest> Request)
{
auto result = OculusXRColocation::FColocation::StopDiscoverSessions(Request);
if(result != Success)
{
switch(result)
{
// ... Do whatever you want based on the error code
}
}
}