FindSessions QuerySettings.Set does not take into account the criteria

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.

Hi domzorg,

I apologize for the delayed response. I wanted to let you know that we are looking into this post and will get you more information soon.

Several questions here:

  • what platform are we talking about? Steam/Live/etc?
  • what is the difference between SessionSearchSettings and GUIDSessionSearchSettings? Looks like you have two search filters setup, but can only use one at a time
  • if you are going to call CancelFindSession, you need to wait for the delegate that Cancel has completed before you start another search. It may not always bite you, but you can’t guarantee the speed at which the Cancel call completes and calling FindSession in the same function can end in “already searching, ignore…”

It is for the NULL subsystem.
The GUIDSessionSearchSettings was a mistake. I’ve change it.
I will check if something changed if I wait for the cancel find to complete. But the SessionSearchSettings contains already the results. The CancelFind changes the result array ?

D.

Ah, now that I know its the NULL subsystem, I understand a little better.

Unfortunately the NULL interface is a very simple mocking interface when other platforms aren’t available. It uses a LAN beacon broadcast to listening servers which will respond when they get the request.

There is no filtering of the search criteria in this case, the servers just blindly respond. Code could be written to parse the request inside FOnlineSessionNull::OnValidQueryPacketReceived, but it was never written.

Typically LAN was more server browser-ish and on a much more limited scale of results so the server side filtering was left out of the implementation for time.

All major platforms (Steam/Live/PSN/etc) support server side filtering.

Thank you for your explanations.
It is very clear for me now.

D.