I’m using a setup for my game where from my game instance I was reaching into my game sessions to start / join / find games.
Example
GetGameSession()->JoinASession(Player->GetPreferredUniqueNetId(), GameSessionName, SearchResult);
My question is why when I had my DestroySessionAndLeaveGame function with its delegates and handles inside of my game session class would it cause a crash when I clicked my Leave Game and Kick Player UI buttons.But when I moved the destruction code into my game instance class everything worked fine. From my limited understanding they should have both been using the same GameSessionName?
void UMyGameInstance::DestroySessionAndLeaveGame()
{
IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();
if (OnlineSub)
{
IOnlineSessionPtr Sessions = OnlineSub->GetSessionInterface();
if (Sessions.IsValid())
{
Sessions->AddOnDestroySessionCompleteDelegate_Handle(GetGameSession()->OnDestroySessionCompleteDelegate);
Sessions->DestroySession(GameSessionName);
}
}
}