badineen
(badineen)
July 14, 2017, 3:52am
1
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?
badineen
(badineen)
July 14, 2017, 4:16am
2
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");
badineen
(badineen)
July 14, 2017, 4:24am
3
The MYPROJECT.h file has
#include "UnrealNetwork.h"
#include "Online.h"
Is that the right place to put them?
badineen
(badineen)
July 14, 2017, 7:06am
4
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.
Vawx
(Vawx)
July 14, 2017, 4:12am
5
Have you added “OnlineSubsystem” to your MYPROJECT.Build.cs file?
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem" });
Vawx
(Vawx)
July 14, 2017, 4:21am
6
How about?:
#include "UnrealNetwork.h"
(alongside Online.h)
Vawx
(Vawx)
July 14, 2017, 4:26am
7
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.