I am trying to wrap my brain around the Online Subsystem and I thought Shooter Game would be a decent example. However all I seem to be doing is getting utterly lost. I’ve look around at a few tutorials and my game scenario is that you can play single player or join a dedicated server to play online. Your machine will never be the host.
Similar to the Shooter Game I created a new GameInstance and GameSession class. From what I assume a build dedicated server will call RegisterServer when it comes online. Within that function it will create the GameSession. The thing I do not understand is the GameSession never seems to be created on the client, and yet the GameInstance performs operations such as Searching and Joining through the GameSession object. The GameSession even has functions for Hosting, Finding, and Joining Sessions. In another tutorial I have found those same functions are on the GameInstance, which makes more since because GameSession object would not be created in a non dedicated server build.
I’m pretty sure you need to create a GameSession on the dedicated server, I’m not sure why the GameInstance on the client needs/uses the GameSession when one would not be created… am I missing something?
Okay, this one was a late night rant really. I’m still not sure how this works or if this works in the Shooter Game but I’ve decided to just ignore it. Basically what I have done is have Session Creation, Startup, and Destruction be Handled by the Custom Session for my game. GameInstance Handles Finding and Joining Sessions.
So with age comes insight. I believe what is happening is the ShooterGame leverages a non-dedicated host setup so p2p I believe. So because Clients need to Create the Session, all the logic for creating and hosting is in the Session Object itself, which makes since. However for a Dedicated Server setup with No p2p but all dedication I suggest doing as I did and have my session object handle session creation as the dedicated server will call RegisterServer and start the process, and all your find and join logic in the GameInstance. I’ve also seen one person put it into an intermediate object that can be leveraged by both the P2P and Dedicated Server models.
The AGameSession exists only on the server and it is the GameMode that keeps a reference to it. GameInstance is generally where you Find and Join Sessions but if you are doing a P2P Game it is also where you can start a new session. If you are doing a Dedicated Server than Register Dedicated Server is where you want to do that, The Game Mode itself on a Dedicated Server will create the session and call Register.