How does an online subsystem obtains a world context?

I need to run GetPortFromNetDriver(Subsystem.GetInstanceName()). The instance name resolves to my custom online subsystem name.

Following the GetPortFromNetDriver method I see it uses:

UWorld* World = GetWorldForOnline(InstanceName);

Which in the end will try to find a world context using my online subsystem instance name as the world context handle:

FWorldContext* UEngine::GetWorldContextFromHandle(const FName WorldContextHandle)
{
	for (FWorldContext& WorldContext : WorldList)
	{
		if (WorldContext.ContextHandle == WorldContextHandle)
		{
			return &WorldContext;
		}
	}
	return nullptr;
}

Should there be a world context with a handle associated with my online subsystem?

If so, how does the flow works?

I’m very interested in this as well, for my case i’m trying to just get access to the Port the Null system assigns itself in the even multiple sever sessions on the same IP This is needed as admins may wish to run multiple dedicated servers on a single box and would be unfortunate to have to have separate folders just for an INI to be adjusted.

Sorry, just noticed this question so hopefully it’s still relevant. For net driver get port, GetPortFromNetDriver is perfect, otherwise, GetWorldForOnline. The parameter for both is from the FOnlineSubsystemImpl::GetInstanceName. i.e.

UWorld* World = GetWorldForOnline(Subsystem->GetInstanceName());