In Editor Networking, 2 OnlineSubsystems!

I am trying to get an in editor workflow working to aid simpler network debugging.
I have written in c++ session creation and loading into a lobby. Not using seamless travel.
Using “UGameplayStatics::OpenLevel(GetWorld(), “Lobby”, true, options);”
During the lobby initialization before any actors or gamemodes get BeginPlay, RegisterPlayers is called
“bool FOnlineSessionNull::RegisterPlayers(FName SessionName, const TArray< TSharedRef >& Players, bool bWasInvited)”

When launching in standalone with one window/one player everything works perfectly. This is the order of events…

  1. Load Map (the projects start up map)
  2. Creation Session: (IOnlineSubsystem::Get used and gets an Instance called “DefaultInstance”)
  3. Call OpenLevel lobby
  4. FOnlineSessionNull:RegisterPlayers gets called and this instance is called “DefaultInstance”
  5. All is well.

When launching from the in selected viewport window again with just one player.

  1. Load Map (the projects start up map)
  2. Creation Session: (IOnlineSubsystem::Get used and gets an Instance called “DefaultInstance”)
  3. Call OpenLevel lobby
  4. FOnlineSessionNull:RegisterPlayers gets called and this instance is called “Context1”
  5. In this instance Conext1 there is no session in its session array is its borked.
  6. I cached a pointer to the other onlinesubsystem called DefaultInstance and it still has the session there. But because the
    engine code has found “the” other instance it cannot find any sessions to register players with.

What is the correct way around this issue which I have observed working in a pure blueprint implimentation!

Looks like getting the onlinesubsystem eventually resolves to getting it by the name from a worldcontext handle which it then uses to get the onlinesubsystem.

Long story short: Do not use this IOnlineSubsystem::Get as this will only work for standalone games. If you want it to work in the editor use this Online::GetSubsystem(GetWorld()). There is a lot of code on the internet generally that uses the first method. I think this was why I was reluctant to go against that. But the correct thing to do is include OnlineSubsystemUtils.h which extends the Online functionality to include the GetSubsystem with a world parameter.