NativePlatformService

NativePlatformService

#Overview

name: NativePlatformService

The value of this variable can be defined or overridden in .ini config files. 3 .ini config files referencing this setting variable.

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of NativePlatformService is to specify the native online subsystem service for the current platform. It is primarily used in the context of Unreal Engine’s online subsystem framework.

This setting variable is primarily relied upon by the OnlineSubsystem module and its related plugins, such as OnlineSubsystemEOS and OnlineSubsystemEOSPlus. These modules are responsible for managing online functionality in Unreal Engine games.

The value of this variable is set in the engine configuration file, specifically in the [OnlineSubsystem] section of the BaseEngine.ini file. It is typically read using GConfig->GetString() function calls.

NativePlatformService interacts with other online subsystem-related variables, such as DefaultPlatformService and ConfigDefinedPlatformServices. It is often used in conjunction with these to determine which online subsystem should be used in different scenarios.

Developers must be aware that this variable is crucial for determining the native online functionality for the platform. It affects how the game interacts with platform-specific online services, such as matchmaking, achievements, and user authentication.

Best practices when using this variable include:

  1. Ensure it is correctly set in the appropriate configuration file for each target platform.
  2. Be aware of its value when implementing cross-platform online functionality.
  3. Use it in conjunction with other online subsystem variables to create a robust and flexible online architecture.
  4. Test thoroughly on all target platforms to ensure the correct online subsystem is being used.
  5. Consider the implications of changing this value, as it can significantly affect the game’s online behavior.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/Android/BaseAndroidEngine.ini:3, section: [OnlineSubsystem]

Location: <Workspace>/Engine/Config/IOS/BaseIOSEngine.ini:74, section: [OnlineSubsystem]

Location: <Workspace>/Projects/Lyra/Config/Custom/SteamEOS/DefaultEngine.ini:3, section: [OnlineSubsystem]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystem/Source/Private/OnlineSubsystemModule.cpp:82

Scope (from outer to inner):

file
function     void FOnlineSubsystemModule::StartupModule

Source code excerpt:

	// Also load the console/platform specific OSS which might not necessarily be the default OSS instance
	FString InterfaceString;
	GConfig->GetString(TEXT("OnlineSubsystem"), TEXT("NativePlatformService"), InterfaceString, GEngineIni);
	NativePlatformService = FName(*InterfaceString);

	// Some default OSSes may rely on the native OSS for functionality. This config is to ensure the native is loaded first in cases where this is desired

	bool bLoadNativeOSSBeforeDefault = false;
	GConfig->GetBool(TEXT("OnlineSubsystem"), TEXT("bLoadNativeOSSBeforeDefault"), bLoadNativeOSSBeforeDefault, GEngineIni);

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystem/Source/Private/OnlineSubsystemModule.cpp:407

Scope (from outer to inner):

file
function     IOnlineSubsystem* FOnlineSubsystemModule::GetNativeSubsystem

Source code excerpt:

IOnlineSubsystem* FOnlineSubsystemModule::GetNativeSubsystem(bool bAutoLoad)
{
	if (!NativePlatformService.IsNone())
	{
		if (bAutoLoad || IOnlineSubsystem::IsLoaded(NativePlatformService))
		{
			return IOnlineSubsystem::Get(NativePlatformService);
		}
	}
	return nullptr;
}

IOnlineSubsystem* FOnlineSubsystemModule::GetSubsystemByConfig(const FString& ConfigString, bool bAutoLoad)

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystem/Source/Public/OnlineSubsystemModule.h:28

Scope (from outer to inner):

file
class        class FOnlineSubsystemModule : public IModuleInterface

Source code excerpt:

	 * Specified in Base<Platform>Engine.ini
	 *	[OnlineSubsystem]
	 *	NativePlatformService
	 */
	FName NativePlatformService;

	/**
	* Name of the online service associated with User Defined strings
	* Specified in Base<Platform>Engine.ini
	*	[OnlineSubsystem]
	*	ConfigDefinedPlatformServices
	*/
	TMap<FString, FName> ConfigDefinedSubsystems;

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemEOS/Source/OnlineSubsystemEOS/Private/OnlineSubsystemEOS.cpp:259

Scope (from outer to inner):

file
function     bool FOnlineSubsystemEOS::Init

Source code excerpt:

	GConfig->GetString(TEXT("OnlineSubsystem"), TEXT("DefaultPlatformService"), DefaultOSS, GEngineIni);
	FString PlatformOSS;
	GConfig->GetString(TEXT("OnlineSubsystem"), TEXT("NativePlatformService"), PlatformOSS, GEngineIni);
	bIsDefaultOSS = DefaultOSS == TEXT("EOS");
	bIsPlatformOSS = PlatformOSS == TEXT("EOS");
	bWasLaunchedByEGS = FParse::Param(FCommandLine::Get(), TEXT("EpicPortal"));

	bool bUnused;
	if (GConfig->GetBool(TEXT("/Script/OnlineSubsystemEOS.EOSSettings"), TEXT("bShouldEnforceBeingLaunchedByEGS"), bUnused, GEngineIni))

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemEOS/Source/OnlineSubsystemEOSPlus/Private/OnlineSubsystemEOSPlus.cpp:41

Scope (from outer to inner):

file
function     bool FOnlineSubsystemEOSPlus::Init

Source code excerpt:

	{
		// Load the native platform OSS name
		GConfig->GetString(TEXT("OnlineSubsystem"), TEXT("NativePlatformService"), BaseOSSName, GEngineIni);
	}
	if (BaseOSSName.IsEmpty())
	{
		UE_LOG_ONLINE(Error, TEXT("FOnlineSubsystemEOSPlus::Init() failed to find the native OSS!"));
		return false;
	}

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemEOS/Source/OnlineSubsystemEOSPlus/Private/OnlineSubsystemEOSPlusModule.cpp:77

Scope (from outer to inner):

file
function     void FOnlineSubsystemEOSPlusModule::LoadBaseOSS

Source code excerpt:

	{
		// Load the native platform OSS name
		GConfig->GetString(TEXT("OnlineSubsystem"), TEXT("NativePlatformService"), BaseOSSName, GEngineIni);
	}
	if (BaseOSSName.IsEmpty())
	{
		UE_LOG_ONLINE(Verbose, TEXT("EOSPlus failed to find the native OSS!"));
		return;
	}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/OnlineReplStructs.cpp:1053

Scope (from outer to inner):

file
function     void TestUniqueIdRepl

Source code excerpt:


	bool bPlatformSerializationSuccess = true;
	FString NativePlatformService;
	if (bSetupSuccess && 
		GConfig->GetString(TEXT("OnlineSubsystem"), TEXT("NativePlatformService"), NativePlatformService, GEngineIni) && 
		!NativePlatformService.IsEmpty())
	{
		FUniqueNetIdPtr PlatformUserId = UOnlineEngineInterface::Get()->GetUniquePlayerIdWrapper(InWorld, 0, FName(*NativePlatformService)).GetUniqueNetId();

		FUniqueNetIdRepl ValidPlatformIdIn(PlatformUserId);
		if (!ValidPlatformIdIn.IsValid() || PlatformUserId != ValidPlatformIdIn.GetUniqueNetId() || *PlatformUserId != *ValidPlatformIdIn)
		{
			UE_LOG(LogNet, Warning, TEXT("PlatformUserId input %s != PlatformUserId output %s"), PlatformUserId.IsValid() ? *PlatformUserId->ToString() : *InvalidUniqueNetIdStr, *ValidPlatformIdIn.ToString());
			bPlatformSerializationSuccess = false;