Issue: Steam OSS Find Session Result is always empty. (0)
Please find the image attached for visual of Debug values.
Details:
Engine: Unreal 5.2
Project Type: C++
Online Subsystem: Steam
Steam App ID: Default 480 ( Space War )
Objective:
Be able to join steam session using online multiplayer in Unreal 5.2 C++
Current Status:
Able to creating session but when trying to connect a session, SessionSearch->SearchResults.Num() is always coming in as 0.
Things i tried already:
After reading a few forums , these lines needed to be there to be able to join, i tried and they are already there in my testing build.
sessionSettings->bUsesPresence = true;
sessionSettings->bUseLobbiesIfAvailable = true;
How am i testing:
I am using 2 different laptops , 2 different steam accounts, BUT same network.
not sure if this is helpful, but just letting the most detail out of me.
Creating Game Session Code
//Called When pressing the 1 key
if (!OnlineSessionInterface.IsValid())
{
return;
}
auto existingSessions = OnlineSessionInterface->GetNamedSession(NAME_GameSession);
if (existingSessions != nullptr)
{
OnlineSessionInterface->DestroySession(NAME_GameSession);
}
OnlineSessionInterface->AddOnCreateSessionCompleteDelegate_Handle(CreateSessionCompleteDelegate);
TSharedPtr<FOnlineSessionSettings> sessionSettings = MakeShareable(new FOnlineSessionSettings());
sessionSettings->bIsLANMatch = false;
sessionSettings->NumPublicConnections = 4;
sessionSettings->bAllowJoinInProgress = true;
sessionSettings->bAllowJoinViaPresence = true;
sessionSettings->bShouldAdvertise = true;
sessionSettings->bUsesPresence = true;
sessionSettings->bUseLobbiesIfAvailable = true;
const ULocalPlayer* localPlayer = GetWorld()->GetFirstLocalPlayerFromController();
OnlineSessionInterface->CreateSession(*localPlayer->GetPreferredUniqueNetId(), NAME_GameSession, *sessionSettings);
Joining Game Session / Checking the joining session
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, FString::Printf(TEXT("Searching For Sessions")));
//Find Game Sessions
if (!OnlineSessionInterface.IsValid())
{
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, FString::Printf(TEXT("Game Session Interface Invalid")));
}
return;
}
OnlineSessionInterface->AddOnFindSessionsCompleteDelegate_Handle(FindSessionsCompleteDelegate);
SessionSearch = MakeShareable(new FOnlineSessionSearch());
SessionSearch->MaxSearchResults = 1000000;
SessionSearch->bIsLanQuery = false;
const ULocalPlayer* localPlayer = GetWorld()->GetFirstLocalPlayerFromController();
OnlineSessionInterface->FindSessions(*localPlayer->GetPreferredUniqueNetId(), SessionSearch.ToSharedRef());
Code Reference: Unreal Engine 5 C++ Multiplayer Shooter | Udemy