x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: UE 4.18
Tags:
more ▼

asked Oct 30 '17 at 12:35 PM in C++ Programming

avatar image

Mipmap Games
6 1 2

avatar image Mipmap Games Oct 31 '17 at 07:11 AM

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

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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
     ...
 }

more ▼

answered Nov 01 '17 at 05:14 AM

avatar image

Mipmap Games
6 1 2

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question