@FrostyJas o the unreal framework provides two classes: UOnlineSession and AGameSession. Both with seemingly similar functionality. The differences are:
UOnlineSession
Owned by Game Instance
Persists for lifetime of application
Exists on clients and servers
Very much so a shell of a class (only 6 virtual functions with ZERO default implementations)
AGameSession
Owned by GameModeBase
Only on server
Exists for lifetime of the gamemode / world
Tons of functionality with default implementations and ties to AGameMode
So I’m torn because on the one hand, I need to implement my session logic in a way that is persistent across Worlds, especially for continuous playlist sessions or map vote switches, leaning me toward OnlineSession. I don’t want to do some hacky solution with the GameSession where I make a temp copy of the important state data in order to transition levels.
On the other hand, GameSession has a ton of existing functionality and is already designed to hook deeply into the GameMode with player registering, match starting, stopping, etc.
Is there a right answer here?
edit: @FrostyJas thanks for responding, this was the origininal post but i didn’t know that i can carry the game session actor across seamless travels, so i think this is the correct option!
I see that you had some questions on game sessions. Were you able to resolve the issue? If not, toss me some info on what you’re running into and I’ll be happy to take a peek! Thanks!
I have an Online Subsystem based matchmaking plugin on the marketplace. UOnlineSession is where you want to implement everything that is tied to the global state. See UOnlineSessionClient. The AGameSession class is more to do with stuff related to a single session itself. Its more or less the manager of that session.
So AGameSession is only onwed by the server GameMode and the UOnlineSession is owned by the GameInstance so after further reading, it seems best to create, start, stop, and destroy the game session from the AGameSession (and AGameMode has special hooks directly to AGameSession).
For “global” client stuff like Login, handle that in the GameInstance, and then for other client activities like finding / joining sessions you should handle it in your MainMenuPlayerController.