When I specify a criteria the FindSessions does not take into account a specific criteria.
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); // Must equal the game version
GUIDSessionSearchSettings->QuerySettings.Set(SETTING_SERVERINSTANCEGUID, Join_CurrentGUID, EOnlineComparisonOp::Equals); // The GUID to find
/* @todo this one does not work, do not know why.*/
// Check only game instance server
SessionSearchSettings->QuerySettings.Set(SETTING_GAMEINSTANCE, 1, EOnlineComparisonOp::Equals);
TSharedRef<FKOnlineGameSearchBase> SearchSettingsRef = SessionSearchSettings.ToSharedRef();
if (OnlineSessionInterface.IsValid())
{
OnlineSessionInterface->CancelFindSessions();
}
OnFindGUIDSessionCompleteDelegate.BindUObject(this, &AKBasePlayerController::OnFindSessionsComplete);
OnFindGUIDSessionCompleteDelegateHandle = OnlineSessionInterface->AddOnFindSessionsCompleteDelegate_Handle(OnFindGUIDSessionCompleteDelegate);
OnlineSessionInterface->FindSessions(0, SearchSettingsRef);
Only the SETTING_GAMEINSTANCE isn’t taken into account.
Also two results in the array. (I’ve posted another question regarding the number of results return even with MaxSearchResults set to 1)
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();
if (count > 0)
{
// Since the filter of game instance server does not work,
// check the results and pick the right game instance
for (int i = 0; i < count; ++i)
{
FOnlineSessionSearchResult Result = SessionSearchSettings->SearchResults[i];
if (Result.IsValid())
{
int32 bGameInstanceServer = 0x0000;
Result.Session.SessionSettings.Get(SETTING_GAMEINSTANCE, bGameInstanceServer);
if (bGameInstanceServer == 1)
{
The array contains two elements, one with SETTING_GAMEINSTANCE = 0 and one with SETTING_GAMEINSTANCE = 1
The other filters seem working but not this one.
Is this a bug or did I make a mistake ?
Regards,
D.