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"

Issues trying to include online session types in GameSession.cpp

I've been trying to change the following function in GameSession.cpp

 void AGameSession::RegisterServer()
 {
 }

to

 void AGameSession::RegisterServer()
 {
     UWorld* World = GetWorld();
     IOnlineSessionPtr SessionInt = Online::GetSessionInterface(World);

     FOnlineSessionSettings Settings;
     Settings.NumPublicConnections = 42;
     Settings.bShouldAdvertise = true;
     Settings.bAllowJoinInProgress = true;
     Settings.bIsLANMatch = false;
     Settings.bUsesPresence = true;
     Settings.bAllowJoinViaPresence = true;
 
     SessionInt->CreateSession(0, GameSessionName, Settings);
     return;
 }

However, I get 28 errors related to undeclared identifiers, such as:

 'IOnlineSessionPtr': undeclared identifier
 'SessionInt': undeclared identifier
 'FOnlineSessionSettings': undeclared identifier
 ...

I assume this is because I need to #include some headers to access online types and functions. However, #including "Online.h" and "OnlineSubsystemUtils.h" came up with errors claiming that they could not be found, and #including their absolute filepaths ended up giving 99 errors.

Any advice?

PS. both the header files are in the /Plugins folder and not the /Runtime folder. Is that important?

Product Version: UE 4.15
Tags:
more ▼

asked Jul 14 '17 at 03:52 AM in C++ Programming

avatar image

badineen
21 1 2

avatar image Vawx Jul 14 '17 at 04:12 AM

Have you added "OnlineSubsystem" to your MYPROJECT.Build.cs file?

         PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem" });
avatar image badineen Jul 14 '17 at 04:16 AM

Yes, OnlineSubsystem is in there:

 PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "AdvancedSessions", "VRExpansionPlugin", "OnlineSubsystem", "OnlineSubsystemSteam", "OnlineSubsystemUtils" });
 PrivateDependencyModuleNames.AddRange(new string[] {  });
 DynamicallyLoadedModuleNames.Add("OnlineSubsystemNull");

avatar image Vawx Jul 14 '17 at 04:21 AM

How about?:

 #include "UnrealNetwork.h"

(alongside Online.h)

avatar image badineen Jul 14 '17 at 04:24 AM

The MYPROJECT.h file has

 #include "UnrealNetwork.h"
 #include "Online.h"

Is that the right place to put them?

avatar image Vawx Jul 14 '17 at 04:26 AM

For 4.15, that is probably fine as long as you are including your MYPROJECT.h file in your GameSession.cpp file.

This is the only reference I have used for game sessions and I haven't used in months:

https://wiki.unrealengine.com/How_To_Use_Sessions_In_C%2B%2B

I do know that when I used it, it was fine. Probably somewhere around 4.13 - 4.14.

avatar image badineen Jul 14 '17 at 07:06 AM

Error might be because I am trying to access a plugin's file from inside the engine source code. I assume that is the issue.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
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