Hey everyone, having a little trouble getting sessions to work. I’ve been using the ShooterGame as an example, and I feel like this is how it should be setup but I am obviously missing something here.
UNetworkingTestInstance.cpp:
bool UALGameInstance::HostSession(TSharedPtr<const FUniqueNetId> UserId, FName SessionName, bool bIsLAN, bool bIsPresence, int32 MaxNumPlayers)
{
IOnlineSubsystem* const Subsystem = IOnlineSubsystem::Get();
if (Subsystem)
{
IOnlineSubsystemPtr Session = Subsystem->GetSessionInterface();
if (Session.IsValid() && UserId.IsValid())
{
SessionSettings = MakeShareable(new FOnlineSessionSettings());
OnCreateSessionCompleteDelegateHandle = Session->AddOnCreateSessionCompleteDelegate_Handle(OnCreateSessionCompleteDelegate);
return Session->CreateSession(*UserId, SessionName, *SessionSettings);
}
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("No Subsystem found"));
}
return false;
}
I get an error at line 19 that “‘initializing’: cannot convert from ‘IOnlineSessionPtr’ to ‘TSharedPtr’”
Any idea what’s wrong?
This is what I have #included in NetworkingTest.h
#include "Core.h"
#include "Net/UnrealNetwork.h"
#include "Online.h"
This is my build file:
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "OnlineSubsystemUtils" });
PrivateDependencyModuleNames.Add("OnlineSubsystem");