Everything is fine, but FindSession
is not able to find any session.
Log:-
[2022.09.10-16.23.40:081][962]LogTemp: Warning: Starting to find sessions!
[2022.09.10-16.23.41:005][146]LogOnlineSession: Warning: STEAM: Server response IP:37.10.126.113
[2022.09.10-16.23.41:022][149]LogOnlineSession: Warning: STEAM: Removed incompatible build: ServerBuildUniqueId = 0x00000000, GetBuildUniqueId() = 0x0129a2ee
[2022.09.10-16.23.41:162][177]LogOnlineSession: Warning: STEAM: Server response IP:85.215.176.226
[2022.09.10-16.23.41:162][177]LogOnlineSession: Warning: STEAM: Removed incompatible build: ServerBuildUniqueId = 0x00000000, GetBuildUniqueId() = 0x0129a2ee
[2022.09.10-16.23.41:202][185]LogOnlineSession: Warning: STEAM: Server response IP:20.151.66.71
[2022.09.10-16.23.41:202][185]LogOnlineSession: Warning: STEAM: Removed incompatible build: ServerBuildUniqueId = 0x00000000, GetBuildUniqueId() = 0x0129a2ee
[2022.09.10-16.23.41:242][193]LogOnlineSession: Warning: STEAM: Server response IP:20.151.66.71
[2022.09.10-16.23.41:242][193]LogOnlineSession: Warning: STEAM: Removed incompatible build: ServerBuildUniqueId = 0x00000000, GetBuildUniqueId() = 0x0129a2ee
[2022.09.10-16.23.41:262][197]LogOnlineSession: Warning: STEAM: Server response IP:34.78.226.104
[2022.09.10-16.23.41:262][197]LogOnlineSession: Warning: STEAM: Removed incompatible build: ServerBuildUniqueId = 0x00000000, GetBuildUniqueId() = 0x0129a2ee
[2022.09.10-16.23.41:462][237]LogOnlineSession: Warning: STEAM: Server response IP:8.142.106.102
[2022.09.10-16.23.41:463][237]LogOnlineSession: Warning: STEAM: Removed incompatible build: ServerBuildUniqueId = 0x00000000, GetBuildUniqueId() = 0x0129a2ee
[2022.09.10-16.23.41:464][237]LogOnline: Verbose: OSS: Async task 'FOnlineAsyncTaskSteamFindServers bWasSuccessful: 1 Results: 0' succeeded in 1.361377 seconds
[2022.09.10-16.23.41:464][237]LogTemp: Warning: Finished Find Sessions!
GameInstance.CPP -
// Fill out your copyright notice in the Description page of Project Settings.
#include "PuzzlePlatformsGameInstance.h"
#include "Engine/Engine.h"
#include "OnlineSessionSettings.h"
#include "OnlineSubsystem.h"
#include "UObject/ConstructorHelpers.h"
#include "Blueprint/UserWidget.h"
#include "MenuSystem/InGameMenu.h"
#include "MenuSystem/MainMenu.h"
#define OUT
const static FName SESSION_NAME = TEXT("My Session Game"); //Gloable Name For Creating Session
UPuzzlePlatformsGameInstance::UPuzzlePlatformsGameInstance(const FObjectInitializer & ObjectInitializer)
{
static ConstructorHelpers::FClassFinder<UUserWidget> BPMenuWidget(TEXT("/Game/MenuSystem/WBP_MainMenu")); //Getting the address of Blueprint Menu Widget
if(!BPMenuWidget.Succeeded()) return;
MainMenuClass = BPMenuWidget.Class;
static ConstructorHelpers::FClassFinder<UUserWidget> BPInGameMenuWidget(TEXT("/Game/MenuSystem/WBP_InGameMenu")); //Getting the address of Blueprint Menu Widget
if(!BPInGameMenuWidget.Succeeded()) return;
InGameMenuClass = BPInGameMenuWidget.Class;
}
void UPuzzlePlatformsGameInstance::Init()
{
IOnlineSubsystem* Subsystem = IOnlineSubsystem::Get();
if(Subsystem)
{
UE_LOG(LogTemp, Warning, TEXT("Subsystem Name:- %s"), *Subsystem->GetSubsystemName().ToString()); //Debug Line to check the name of SubSystem
SessionInterface = Subsystem->GetSessionInterface();
if(SessionInterface.IsValid())
{
SessionInterface->OnCreateSessionCompleteDelegates.AddUObject(this, &UPuzzlePlatformsGameInstance::OnCreateSessionComplete);
SessionInterface->OnDestroySessionCompleteDelegates.AddUObject(this, &UPuzzlePlatformsGameInstance::OnDestroySessionComplete);
SessionInterface->OnFindSessionsCompleteDelegates.AddUObject(this, &UPuzzlePlatformsGameInstance::OnFindSessionsComplete);
SessionInterface->OnJoinSessionCompleteDelegates.AddUObject(this, &UPuzzlePlatformsGameInstance::OnJoinSessionComplete);
}
}
}
void UPuzzlePlatformsGameInstance::CreateSession()
{
if(!SessionInterface.IsValid()) return;
//Session Settings
FOnlineSessionSettings SessionSetting;
SessionSetting.bShouldAdvertise = true; //Shoud be able to be found when using FindSession Function
SessionSetting.NumPublicConnections = 2; //Total no. of player in this session
SessionSetting.bIsLANMatch = false; //Is this session going to be visible only for Same lan connected Devices?
SessionSetting.bUsesPresence = true;
SessionSetting.bUseLobbiesIfAvailable = true;
SessionInterface->CreateSession(0, SESSION_NAME, SessionSetting);
}
void UPuzzlePlatformsGameInstance::OnCreateSessionComplete(FName SessionName, bool bSuccess)
{
if(!bSuccess)
{
return;
}
UWorld* World = GetWorld();
if(!World) return;
World->ServerTravel("/Game/Levels/PuzzlePlatformLevel?listen", ETravelType::TRAVEL_Absolute); //Travel to playeble level
if(MainMenuWidget)
{
MainMenuWidget->TearDownMenu(); //Tear Down the main menu
}
}
void UPuzzlePlatformsGameInstance::OnDestroySessionComplete(FName SessionName, bool bSuccess)
{
if(!bSuccess)
{
return;
}
CreateSession(); //After deleting old session
}
void UPuzzlePlatformsGameInstance::OnFindSessionsComplete(bool bSuccess)
{
if(!bSuccess) return;
UE_LOG(LogTemp, Warning, TEXT("Finished Find Sessions!"));
if(!SessionSearch || !MainMenuWidget) return;
TArray<FOnlineSessionSearchResult> SessionsList = SessionSearch->SearchResults; // all search results
TArray<FString> ServerNames;
for (FOnlineSessionSearchResult Session : SessionsList) //Convering founded session's ID to string
{
ServerNames.Add(Session.GetSessionIdStr());
}
MainMenuWidget->SetServerList(ServerNames); //Calling SetServerList Function form Menu Widget so that menu could update the list of current live servers
}
void UPuzzlePlatformsGameInstance::OnJoinSessionComplete(FName SessionName, EOnJoinSessionCompleteResult::Type ResultType)
{
if(ResultType != EOnJoinSessionCompleteResult::Success) return;
if(!SessionInterface) return;
FString ConnectInfo;
bool bCallWorked = SessionInterface->GetResolvedConnectString(SessionName, OUT ConnectInfo);
if(!bCallWorked) return;
UEngine* Engine = GetEngine();
if(Engine)
{
Engine->AddOnScreenDebugMessage(0, 2.f, FColor::Green, FString::Printf(TEXT("Joining! Address: %s"), *ConnectInfo));
}
APlayerController* Controller = GetFirstLocalPlayerController();
if(!Controller) return;
Controller->ClientTravel(ConnectInfo, ETravelType::TRAVEL_Absolute);
if(MainMenuWidget)
{
MainMenuWidget->TearDownMenu();
}
}
void UPuzzlePlatformsGameInstance::RefreshServerList() //Function to find session
{
if(!SessionInterface) return;
SessionSearch = MakeShareable(new FOnlineSessionSearch()); //Making shareable FOnlineSessionSearch pointer and assigning it to TSharedPtr SessionSearch
if(SessionSearch.IsValid()) //Making sure session search is not null otherwise we won't be able to convert it to Shared Refrence
{
UE_LOG(LogTemp, Warning, TEXT("Starting to find sessions!"));
SessionSearch->bIsLanQuery = false; //Telling to search only Lan Connected Servers
SessionSearch->MaxSearchResults = 100;
SessionSearch->QuerySettings.Set(SESSION_NAME, true, EOnlineComparisonOp::Equals);
SessionInterface->FindSessions(0, SessionSearch.ToSharedRef()); //Converting TShareedPtr to TSharedRef and Starting to find sessions
}
}
void UPuzzlePlatformsGameInstance::Host() //function for hosting
{
if(!SessionInterface.IsValid()) return;
//Checking if there is any session already created, If yes then first destroy it
auto ExistingSession = SessionInterface->GetNamedSession(SESSION_NAME);
if(ExistingSession)
{
SessionInterface->DestroySession(SESSION_NAME);
}
else
{
CreateSession();
}
}
void UPuzzlePlatformsGameInstance::Join(const uint32 Index) //function of joining
{
if(!SessionInterface || !SessionSearch) return;
SessionInterface->JoinSession(0, SESSION_NAME, SessionSearch->SearchResults[Index]);
}
void UPuzzlePlatformsGameInstance::LoadInGameMenu() //Display Pause Menu (This function will be called for level blueprint when pressed a specific button)
{
if(!InGameMenuClass) return;
InGameMenuWidget = CreateWidget<UInGameMenu>(this, InGameMenuClass); //Creating widget to display
if(!InGameMenuWidget) return;
InGameMenuWidget->SetMenuInterface(this);
InGameMenuWidget->Setup();
}
void UPuzzlePlatformsGameInstance::TravelMainMenuLevel() //Travel to main menu level
{
UWorld* World = GetWorld();
if(!World) return;
World->ServerTravel("/Game/Levels/MainMenuLevel?listen", ETravelType::TRAVEL_Absolute);
}
void UPuzzlePlatformsGameInstance::LoadMenu() //load Main Menu (This function will be called for level blueprint)
{
if(!MainMenuClass) return; //Bp class of user widget
MainMenuWidget = CreateWidget<UMainMenu>(this, MainMenuClass); //Creating widget to display
if(!MainMenuWidget) return;
MainMenuWidget->SetMenuInterface(this); //calling this function from MainMenuClass, setting GameInstance as IMenuInterface
MainMenuWidget->Setup();
}
NOTE:-
-
Steam is on while playing the game.
-
I tried playing the game with my friend using Packaged Project and Powershell both.
-
I also tried increasing MaxSearchResults to 50k
-
On my friend’s PC, Space War Project is not working. I tried many things, but was not able to run SpaceWar on his PC. I don’t think this should be the reason for not being able to play with my friend.
-
This log is showing on my computer as I host the lobby from my friend’s computer.
Verbose: STEAM: FOnlineAsyncEventSteamRichPresenceUpdate got new information about user 76561199072553947
-
When I host the lobby this warning shows in the hosting PC’s log
LogOnlineSession: Warning: Steam: No game present to join for session (GameSession)