ShooterGame client session cast failure

Hey everyone.

I’ve been dissecting the shooter game example, and moving parts of it out into a new project to experiment with the online subsystem.

I found eXi’s tutorial, which helped a lot (thanks for this). But this tutorial uses a different approach, and I want to study shooter game specifically.

My primary confusion is surrounding the “ShooterGameSession” class. As far as I understand it, ShooterGame is using this class to handle joining/leaving/etc sessions, but it also acts as the session itself. Adding to the confusion is that it exists in different configurations depending on if it’s running on the client or server.

To simplify things in my code, I am not interested in a client hosted game. There will only be dedicated servers and dedicated clients.

So I’ve got a working testbed going:
Dedicated server, creates a session on startup. This works fine.
Client loads to a level with a basic menu. Pressing “search” calls GameInstance FindSessions

I was able to get this to work (enough to prove that there is in fact a session being created on the server) using eXi’s tutorial, but that moved so much code out of the ShooterGame session that I felt I was diverging too much.

So I am moving back to the shooter game approach. Here’s where I am stuck:

Inside of gameInstance there is a function GetGameSession(), which is supposed to return the current gameSession cast to the custom gameSession called “shooterGameSession” in shootergame.

But on the client, the cast is failing. I’m missing where the session gets setup for the client, and how this should be done…

For reference here are a few bits related to the server session creation (which is working):

AMyGameSession::AMyGameSession(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
	if (IsRunningDedicatedServer()) {
// how to init for a client?

void AMyGameSession::RegisterServer() {
	UE_LOG(LogTemp, Log, TEXT("[LEET] GAME SESSION RegisterServer"));
	UWorld* World = GetWorld();
	IOnlineSessionPtr SessionInt = Online::GetSessionInterface();

	FOnlineSessionSettings Settings;
	Settings.NumPublicConnections = 3;
	Settings.bShouldAdvertise = true;
	Settings.bAllowJoinInProgress = true;
	Settings.bIsLANMatch = true;
	Settings.bUsesPresence = true;
	Settings.bAllowJoinViaPresence = true;

	SessionInt->CreateSession(0, GameSessionName, Settings);

I found it.

Inside the gameMode there is this:

/** Returns game session class to use */
TSubclassOf<AGameSession> ALEETAPIDEMO4GameMode::GetGameSessionClass() const
	return AMyGameSession::StaticClass();