Adding custom variables to online subsystem searches

So I have followed this wiki on how to interact with the online subsystem. However I can’t add any custom variables, for example it would be nice to have a user defined server name. So say I’m editing OnlineSubsystemNull to add these variables, I’ve got this far:

In OnlineSubsystemNullTypes.h

class FOnlineSessionInfoNull : public FOnlineSessionInfo
{
    ...
    FString ServerName;
    ...
};

In OnlineSessionInterfaceNull.cpp

bool FOnlineSessionNull::CreateSession(int32 HostingPlayerNum, FName SessionName, const FOnlineSessionSettings& NewSessionSettings)
{
    ...
    Session->ServerName = SessionName.ToString();
    ...
}

and finally in my FindSessions() function I cast the sessioninfo into the child class which should have the extra info-

TSharedPtr<FOnlineSessionInfoNull> Fosin = StaticCastSharedPtr<FOnlineSessionInfoNull>(SessionSearch->SearchResults[SearchIdx].Session.SessionInfo);
Whatever = Fosin->ServerName;

While everything builds correctly, the ServerName variable is always blank when I go to get it, uninitialized I suspect. It looks like everything is taken care of in the AppendSessionToPacket function and yet it doesn’t append my extra variables.

Any help?

To add to the mystery, using GEngine->AddOnScreenDebugMessage, I can see the servername intact as it goes into AppendSessionToPacket, but then it is blank in ReadSessionFromPacket

Ok so it appears the NboSerializerNull.h decides what variables in FOnlineSessionInfoNull get added to a packet. So I was successful just adding the servername to the packet in AppendSessionToPacket and reading it back out in ReadSessionFromPacket.

In OnlineSessionInterfaceNull.cpp

void FOnlineSessionNull::AppendSessionToPacket(FNboSerializeToBufferNull& Packet, FOnlineSession* Session)
{
	/** Owner of the session */
	Packet << *StaticCastSharedPtr<const FUniqueNetIdString>(Session->OwningUserId)
		<< Session->OwningUserName
		<< Session->NumOpenPrivateConnections
		<< Session->NumOpenPublicConnections;

	// Try to get the actual port the netdriver is using
	SetPortFromNetDriver(*LANSubsystem, Session->SessionInfo);
	TSharedPtr<FOnlineSessionInfoNull> FosinPtr = StaticCastSharedPtr<FOnlineSessionInfoNull>(Session->SessionInfo);
	// Write host info (host addr, session id, and key)
	Packet << *FosinPtr;
	Packet << FosinPtr->ServerName;

	// Now append per game settings
	AppendSessionSettingsToPacket(Packet, &Session->SessionSettings);
}

and

void FOnlineSessionLAN::ReadSessionFromPacket(FNboSerializeFromBufferNull& Packet, FOnlineSession* Session)
{
    ...
    Packet >> NullSessionInfo->ServerName
    ...
}