Loading...
Searching...
No Matches
FAccelByteUtilities Class Reference

Static Public Member Functions

static bool IsRunningDevMode ()
static FString AccelByteStorageFile ()
static FString GetCacheFilenameTelemetry ()
static FString GetCacheFilenameGeneralPurpose ()
template<typename CharType = TCHAR, template< typename > class PrintPolicy = TPrettyJsonPrintPolicy, typename InStructType>
static bool TArrayUStructToJsonString (TArray< InStructType > const &InArray, FString &OutJsonString, int64 CheckFlags=0, int64 SkipFlags=0, int32 Indent=0)
static void RemoveEmptyStrings (TSharedPtr< FJsonObject > Json)
template<typename TEnum>
static FString GetUEnumValueAsString (TEnum Value)
 Convert an UEnum value into a String enum value.
template<typename TEnum>
static TEnum GetUEnumValueFromString (FString const &ValueString)
 Convert a String enum value into a UEnum value.
static FString GetPlatformString (EAccelBytePlatformType Platform)
 Retrieve Platform name from the specified PlatformType.
static FString GetAuthenticatorString (EAccelByteLoginAuthFactorType Authenticator)
static FString CreateQueryParams (TMap< FString, FString > Map, FString SuffixChar=TEXT("?"))
static FString CreateQueryParamValueUrlEncodedFromArray (TArray< FString > const &Array, FString const &Delimiter=TEXT(","))
static void RemoveEmptyFieldsFromJson (TSharedPtr< FJsonObject > const &JsonObjectPtr, uint8 const Flags=FieldRemovalFlagObjects|FieldRemovalFlagStrings|FieldRemovalFlagArrays|FieldRemovalFlagNested, TArray< FString > const &ExcludedFieldNames={})
 Remove fields which have empty values according to the given flags. Defaults to removing empty objects/arrays, blank strings, and looping recursively on object and array field values. Possible Removal flags are as follow:
template<typename ObjectType>
static bool UStructArrayToJsonObjectString (TArray< ObjectType > const &Objects, FString &OutString)
 Convert array of UStructs into JSON array string.
static FString GenerateSessionTeamId ()
 Generate a new team Id for player session.
static FString EncodeHMACBase64 (FString const &Message, FString const &Key)
 Encode HMAC the message using built in function from UnrealEngine and then Base64 the result.
static FString GetPlatformName ()
 Get current Platform name.
static FString XOR (FString const &Input, FString const &Key)
 Execute XOR operation between two string values.
static FString GetAuthTrustId ()
 Retrieve AuthTrustId that was cached in a filed.
static void SetAuthTrustId (FString const &AuthTrustId)
 Store AuthTrustId value to a file.
static FString GetAuthorizationCode ()
 Retrieve Authorization Code provided by AccelByte Launcher.
static bool IsUsingExchangeCode ()
 Retrieve an information if get authorization code is using exchange method provided by AccelByte Launcher.
static FString GetFlightId ()
 Get game client flight id.
static FString AccelByteStoredKeyDeviceId ()
 Get the key to DeviceID cache entry.
static bool GetValueFromCommandLineSwitch (const FString &Key, FString &Value)
 Parse command line to obtain an argument that:
static bool GetValueFromCommandLineSwitch (const FString &Key, int &Value)
static bool GetValueFromCommandLineSwitch (const FString &Key, bool &Value)
static bool GetAccelByteConfigFromCommandLineSwitch (const FString &Key, FString &Value)
static bool GetAccelByteConfigFromCommandLineSwitch (const FString &Key, int &Value)
static bool GetAccelByteConfigFromCommandLineSwitch (const FString &Key, bool &Value)
static bool LoadABConfigFallback (const FString &Section, const FString &Key, FString &Value, const FString &DefaultSection=TEXT(""))
static bool LoadABConfigFallback (const FString &Section, const FString &Key, bool &Value, const FString &DefaultSection=TEXT(""))
static bool LoadABConfigFallback (const FString &Section, const FString &Key, int &Value, const FString &DefaultSection=TEXT(""))
static FString ConvertItemSortByToString (EAccelByteItemListSortBy const &SortBy)
static FString ConvertChallengeSortByToString (EAccelByteModelsChallengeSortBy const &SortBy)
static bool ReplaceDecimalSeparator (FString &NumberStr, const TCHAR *From, const TCHAR *To)
static bool IsNumericString (const FString &String)
static bool IsLanguageUseCommaDecimalSeparator ()
static bool IsAccelByteIDValid (FString const &AccelByteId, EAccelByteIdHypensRule HypenRule=EAccelByteIdHypensRule::NO_RULE)
static void AppendModulesVersionToMap (TMap< FString, FString > &Headers)
static FString GetContentType (EAccelByteFileType const &FileType)
static const FString GenerateHashString (const FString &Message)
static bool IsValidEmail (const FString &Email)
static bool SplitArraysToNum (const TArray< FString > &InArray, const int32 Num, TArray< TArray< FString > > &OutArrays)
static FString ConvertAccelByteGeneralSortByToString (EAccelByteGeneralSortBy SortBy)
 Convert an AccelByte general sort enum into a string value.
static FString GetDevModeDeviceId (FString const &Default)
 Obtain DeviceID for development mode GAME CLIENT NON SHIPPING BUILD ONLY! Can be controlled using either command-line args or configuration file.
static FString GetPluginVersionAccelByteSDK ()
static FString GetPluginVersionOnlineSubsystemAccelByte ()

Static Public Attributes

static constexpr uint8 FieldRemovalFlagObjects = 1 << 0
static constexpr uint8 FieldRemovalFlagArrays = 1 << 1
static constexpr uint8 FieldRemovalFlagStrings = 1 << 2
static constexpr uint8 FieldRemovalFlagDates = 1 << 3
static constexpr uint8 FieldRemovalFlagNumbers = 1 << 4
static constexpr uint8 FieldRemovalFlagNull = 1 << 5
static constexpr uint8 FieldRemovalFlagNested = 1 << 6
static constexpr uint8 FieldRemovalFlagNumbersZeroValues = 1 << 7
static constexpr uint8 FieldRemovalFlagAll = 0xFF & ~FieldRemovalFlagNumbersZeroValues

Static Protected Member Functions

static FString RandomizeDeviceId (int64 Seed=FDateTime::UtcNow().ToUnixTimestamp())
 Create a randomized 30 digit alpha-numeric DeviceID.
static FString GetOrSetIfDeviceIdNotFound (FString const &Default="")
 Try to obtain DeviceID from a cached value if not found using the Default parameter and also store it into the cache.
static EAccelByteDevModeDeviceIdMethod GetCurrentDeviceIdOverrideMethod ()
 Get the development mode DeviceID override method from "DefaultEngine.ini" Section: [AccelByte.Dev] Key: DeviceIdOverrideMethod=(STRING).
static FString AccelByteStoredSectionIdentifiers ()
static FString AccelByteStored ()
static FString AccelByteStoredSectionIAM ()
static FString AccelByteStoredKeyAuthTrustId ()

Member Function Documentation

◆ ConvertAccelByteGeneralSortByToString()

FString FAccelByteUtilities::ConvertAccelByteGeneralSortByToString ( EAccelByteGeneralSortBy SortBy)
static

Convert an AccelByte general sort enum into a string value.

Parameters
SortByThe AccelByte enum value to be converted.
Returns
The string representation of the given enum value.

◆ EncodeHMACBase64()

FString FAccelByteUtilities::EncodeHMACBase64 ( FString const & Message,
FString const & Key )
static

Encode HMAC the message using built in function from UnrealEngine and then Base64 the result.

Parameters
MessageSpecified text.
KeyHMAC Buffer Key.
Returns
Encoded string result.

◆ GenerateSessionTeamId()

FString FAccelByteUtilities::GenerateSessionTeamId ( )
static

Generate a new team Id for player session.

Returns
String of team id with UUID format.

◆ GetAuthorizationCode()

FString FAccelByteUtilities::GetAuthorizationCode ( )
static

Retrieve Authorization Code provided by AccelByte Launcher.

Returns
Authorization code either from command line argument or environment variable.

◆ GetAuthTrustId()

FString FAccelByteUtilities::GetAuthTrustId ( )
static

Retrieve AuthTrustId that was cached in a filed.

Returns
AuthTrustId string.

◆ GetCurrentDeviceIdOverrideMethod()

EAccelByteDevModeDeviceIdMethod FAccelByteUtilities::GetCurrentDeviceIdOverrideMethod ( )
staticprotected

Get the development mode DeviceID override method from "DefaultEngine.ini" Section: [AccelByte.Dev] Key: DeviceIdOverrideMethod=(STRING).

Returns
DeviceID override method.

◆ GetDevModeDeviceId()

FString FAccelByteUtilities::GetDevModeDeviceId ( FString const & Default)
static

Obtain DeviceID for development mode GAME CLIENT NON SHIPPING BUILD ONLY! Can be controlled using either command-line args or configuration file.

IF you want to FORCEFULLY override the device ID: Please use Command-line args. Example: "PackagedGameClient.exe -deviceid YOUR_DEVICE_ID ......"

ELSE use the "DefaultEngine.ini" file to control the device ID. First of all, select the override method using this field in configuration: ===>Section: [AccelByte.Dev] Key: DeviceIdOverrideMethod=(STRING) Value: Supported string as enumerator = {COMMANDLINE, PICK_RANDOM, RANDOMIZE, PERSISTENT} Example [AccelByte.Dev] DeviceIdOverrideMethod=RANDOMIZE IF this field is wrong or left empty: The override behavior will be done by the following method order [COMMANDLINE, PICK_RANDOM, RANDOMIZE, PERSISTENT]

Then specify the key/value for the list of PICK_RANDOM override method ===>Section: [AccelByte.Dev] Key: [_] DeviceId=(STRING[]) Example [AccelByte.Dev] +DeviceId=aaasdfsadfasd +DeviceId=sdahssdghsgfd +DeviceId=safvcgdsfgsgf +DeviceId=gsdgdsfgfafsf

COMPILED EXAMPLE from DefaultEngine.ini [AccelByte.Dev] DeviceIdOverrideMethod=[COMMANDLINE, or PICK_RANDOM, or RANDOMIZE, or PERSISTENT] +DeviceId=aaasdfsadfasd +DeviceId=sdahssdghsgfd +DeviceId=safvcgdsfgsgf +DeviceId=gsdgdsfgfafsf

To deny all override and pretend to be shipping build: ===>Section: [AccelByte.Dev]

Key: DiscardOverride=(BOOL) Example [AccelByte.Dev] DiscardOverride=true

Parameters
DefaultThe default value if there is no override found
Returns
String of DeviceID.

◆ GetFlightId()

FString FAccelByteUtilities::GetFlightId ( )
static

Get game client flight id.

Returns
Flight id of game client.

◆ GetOrSetIfDeviceIdNotFound()

FString FAccelByteUtilities::GetOrSetIfDeviceIdNotFound ( FString const & Default = "")
staticprotected

Try to obtain DeviceID from a cached value if not found using the Default parameter and also store it into the cache.

Parameters
Default

◆ GetPlatformName()

FString FAccelByteUtilities::GetPlatformName ( )
static

Get current Platform name.

Returns
Current Platform name.

◆ GetPlatformString()

FString FAccelByteUtilities::GetPlatformString ( EAccelBytePlatformType Platform)
static

Retrieve Platform name from the specified PlatformType.

Parameters
PlatformPlatform type enumeration.

◆ GetUEnumValueAsString()

template<typename TEnum>
FString FAccelByteUtilities::GetUEnumValueAsString ( TEnum Value)
inlinestatic

Convert an UEnum value into a String enum value.

Parameters
ValueUEnum value.
Returns
String value of specified UEnum.

◆ GetUEnumValueFromString()

template<typename TEnum>
TEnum FAccelByteUtilities::GetUEnumValueFromString ( FString const & ValueString)
inlinestatic

Convert a String enum value into a UEnum value.

Parameters
ValueStringString enum value.
Returns
UEnum value of specified String enum.

◆ GetValueFromCommandLineSwitch()

bool FAccelByteUtilities::GetValueFromCommandLineSwitch ( const FString & Key,
FString & Value )
static

Parse command line to obtain an argument that:

  • intialized by dash (-)
  • contain a value that following equal sign (=) Assuming the switch is case insesitive Example: -serverip=127.0.0.1 key or switch is the serverip value is 127.0.0.1
Parameters
KeyThe key of switch argument.
ValueThe operation result will be returned through this parameter.
Returns
True if value from the second parameter is returned and
False if no value/args can be found

◆ IsUsingExchangeCode()

bool FAccelByteUtilities::IsUsingExchangeCode ( )
static

Retrieve an information if get authorization code is using exchange method provided by AccelByte Launcher.

Returns
Whether the current exchange method using exchange code or authorization code from command line argument.

◆ RandomizeDeviceId()

FString FAccelByteUtilities::RandomizeDeviceId ( int64 Seed = FDateTime::UtcNow().ToUnixTimestamp())
staticprotected

Create a randomized 30 digit alpha-numeric DeviceID.

Returns
Random string of DeviceID.

◆ RemoveEmptyFieldsFromJson()

void FAccelByteUtilities::RemoveEmptyFieldsFromJson ( TSharedPtr< FJsonObject > const & JsonObjectPtr,
uint8 const Flags = FieldRemovalFlagObjects | FieldRemovalFlagStrings | FieldRemovalFlagArrays | FieldRemovalFlagNested,
TArray< FString > const & ExcludedFieldNames = {} )
static

Remove fields which have empty values according to the given flags. Defaults to removing empty objects/arrays, blank strings, and looping recursively on object and array field values. Possible Removal flags are as follow:

  • FieldRemovalFlagObjects: for empty JSON object value
  • FieldRemovalFlagArrays: for empty JSON array value
  • FieldRemovalFlagStrings: for empty string value
  • FieldRemovalFlagDates: for empty date value
  • FieldRemovalFlagNumbers: for empty number value
  • FieldRemovalFlagNull: for null value
  • FieldRemovalFlagNested: for empty nested value
Parameters
JsonObjectPtrJSON object which will be modified.
FlagsRemoval flags for the empty value using bit flag.
ExcludedFieldNamesSpecified field names that will be excluded in the omission process.

◆ SetAuthTrustId()

void FAccelByteUtilities::SetAuthTrustId ( FString const & AuthTrustId)
static

Store AuthTrustId value to a file.

Parameters
AuthTrustIdAuthTrustId.

◆ SplitArraysToNum()

bool FAccelByteUtilities::SplitArraysToNum ( const TArray< FString > & InArray,
const int32 Num,
TArray< TArray< FString > > & OutArrays )
static

Split an array into multiple arrays with a maximum element number.

Parameters
InArrayArray to split.
NumNumber of maximum elements per array.
OutArraysResult with array split with maximum element number.

◆ UStructArrayToJsonObjectString()

template<typename ObjectType>
bool FAccelByteUtilities::UStructArrayToJsonObjectString ( TArray< ObjectType > const & Objects,
FString & OutString )
inlinestatic

Convert array of UStructs into JSON array string.

Parameters
ObjectsList of UStruct objects.
OutStringOutput string.

◆ XOR()

FString FAccelByteUtilities::XOR ( FString const & Input,
FString const & Key )
static

Execute XOR operation between two string values.

Parameters
InputSpecified input string.
KeySpecified key string.
Returns
String result from XOR operation.