Skip to main content

Converting user IDs from online subsystem types

The online subsystem APIs defined in the engine by Epic Games use the FUniqueNetId type to refer to user IDs. This type has now been deprecated by Epic Games and is phased out in favour of UE::Online::FAccountId.

In order to call C++ APIs and systems documented in the rest of this section, you'll need to convert from FUniqueNetId to the relevant type.

info

The C++ APIs described in this section are only available in the Paid Edition, as the Free Edition does not ship with any C++ headers.

Updating your game module dependencies

Before you can use the user ID conversion functions, you need to update your game module's .Build.cs file to depend on the RedpointEOSCore module, like so:

PrivateDependencyModuleNames.AddRange(new string[]
{
"RedpointEOSCore",
});

Including the user ID header

To access the user ID conversion functions, include the relevant header and use the relevant namespace:

#include "RedpointEOSCore/Id/Id.h"

using namespace Redpoint::EOS::Core::Id;

Checking user ID validity

To check if a specific UE::Online::FAccountId meets a condition, use one of the following functions:

  • IsValidId: Is the user ID not the value from GetInvalidAccountId?
  • IsDedicatedServerId: Is the user ID the value from GetDedicatedServerAccountId?
  • IsProductUserId: Is the user ID a valid ID that points to a user (not a dedicated server)?

Serializing and deserializing user IDs to string values

To serialize UE::Online::FAccountId to string values, use either:

  • GetUserIdString: Returns the product user ID as a string, or an empty string if the provided user ID is not valid or if the provided user ID refers to a dedicated server.
  • GetUserIdDebugString: Returns the product user ID as a string, or a string value suitable for logging indicating whether the user ID is an invalid ID or refers to a dedicated server.

To deserialize a string value back into a UE::Online::FAccountId, use:

  • TryParseAccountId: Returns an TOptional<UE::Online::FAccountId>, which is set only if the string passed into this function could be converted back into a user ID.

Converting between user ID types

To convert between user ID types, use the following functions depending on the source and target type:

Function nameSource typeResult type
GetProductUserIdUE::Online::FAccountIdEOS_ProductUserId
GetAccountIdFUniqueNetIdUE::Online::FAccountId
GetAccountIdTSharedRef<const FUniqueNetId>UE::Online::FAccountId
GetAccountIdEOS_ProductUserIdUE::Online::FAccountId
GetDedicatedServerAccountIdNo input parameterUE::Online::FAccountId
GetInvalidAccountIdNo input parameterUE::Online::FAccountId
GetUniqueNetIdUE::Online::FAccountIdTSharedPtr<const FUniqueNetIdEOS>
GetUniqueNetIdRefUE::Online::FAccountIdTSharedRef<const FUniqueNetIdEOS>

Handling Epic Games account IDs

To convert Epic Games account IDs to string values and back, use one of the following functions:

Function nameSource typeResult type
GetEpicGamesAccountIdFStringEOS_EpicAccountId
GetEpicGamesUserIdStringEOS_EpicAccountIdFString

You should avoid directly using Epic Games account IDs where possible, and instead use the product user ID functions listed in earlier sections as this will keep your game portable to non-EGS stores and platforms.