How to destroy a session when the listen server host closes the game?

Say you’re in a game that’s hosted on a listen server and the host decides to quit the game, you automatically get booted to the main menu, but the “local” session is never destroyed. Which means you won’t be able to start a server again without restarting the whole game. When you disconnect from the game from my in-game menu, the session is successfully destroyed using a using a function I wrote. Basically, I’m just looking for a good place to call my destroy session function for when you’re disconnected by the server. I’m using the steam subsystem btw.

Maybe overriding ClientReturnToMainMenu for my player controller class would be a good start?

The GameInstance HandleNetworkError virtual function/event gets called if you’re on the client and the host disconnects.

2 Likes

Can you show us how you destroy local session in your function?

There are a number of places that I have found that would be a good place to call destroy session, but each of them that I have found have a rare case where they will not destroy the session when it needs to be destroyed. The best place I have found currently as a ‘catch all’ fix is the time when the player opts to join session, or host session.
If you call destroy session just prior to join/host session, on a success or fail condition you will know you are in the clear to get another session.

2 Likes

This node is also used for leaving sessions. Clients also need to call this node when they leave a game.