I don’t know if it is a bug, but when I specify MaxSearchResults = 1; in the SearchSettings and FindSessions, it returns more than one element in the SearchResults array.
Is this member var used in FindSessions to limit the number of results ?
IOnlineSessionPtr OnlineSessionInterface = OnlineSubsystem->GetSessionInterface();
SessionSearchSettings = MakeShareable(new FKOnlineGameSearchBase(false));
SessionSearchSettings->MaxSearchResults = 1;
FString GameVer = FString::Printf(TEXT("%i"), FNetworkVersion::GetLocalNetworkVersion());
SessionSearchSettings->QuerySettings.Set(SETTING_SERVERVERSION, GameVer, EOnlineComparisonOp::Equals); SessionSearchSettings->QuerySettings.Set(SETTING_SERVERINSTANCEGUID, JoinCurrentGUID, EOnlineComparisonOp::Equals); // The GUID to find
TSharedRef<FKOnlineGameSearchBase> SearchSettingsRef = SessionSearchSettings.ToSharedRef();
if (OnlineSessionInterface.IsValid())
{
OnlineSessionInterface->CancelFindSessions();
}
OnFindGUIDSessionCompleteDelegate.BindUObject(this, &AKBasePlayerController::OnFindSessionsComplete);
OnFindGUIDSessionCompleteDelegateHandle = OnlineSessionInterface->AddOnFindSessionsCompleteDelegate_Handle(OnFindGUIDSessionCompleteDelegate);
OnlineSessionInterface->FindSessions(0, SearchSettingsRef);
In the OnFindSessionsComplete the array has 2 elements.
void AKBasePlayerController::OnFindSessionsComplete(bool bWasSuccessful)
{
if (bWasSuccessful)
{
// Clear the delegate
IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get();
if (OnlineSubsystem && SessionSearchSettings.IsValid())
{
IOnlineSessionPtr OnlineSessionInterface = OnlineSubsystem->GetSessionInterface();
OnlineSessionInterface->ClearOnFindSessionsCompleteDelegate_Handle(OnFindGUIDSessionCompleteDelegateHandle);
int32 count = SessionSearchSettings->SearchResults.Num();
UE_LOG(LogDebug, Log, TEXT("AKBasePlayerController::OnFindSesssionComplete - SessionSearchSettings->SearchResults.Num=%i"), SessionSearchSettings->SearchResults.Num());
count = 2
Regards,
D.