#include <OnlineUserCacheAccelByte.h>
Public Member Functions | |
| bool | QueryUsersByAccelByteIds (int32 LocalUserNum, const TArray< FString > &AccelByteIds, const FOnQueryUsersComplete &Delegate, bool bIsImportant=false) |
| bool | QueryUsersByPlatformIds (int32 LocalUserNum, const FString &PlatformType, const TArray< FString > &PlatformIds, const FOnQueryUsersComplete &Delegate, bool bIsImportant=false) |
| bool | QueryUsersByAccelByteIds (const FUniqueNetId &UserId, const TArray< FString > &AccelByteIds, const FOnQueryUsersComplete &Delegate, bool bIsImportant=false) |
| bool | QueryUsersByPlatformIds (const FUniqueNetId &UserId, const FString &PlatformType, const TArray< FString > &PlatformIds, const FOnQueryUsersComplete &Delegate, bool bIsImportant=false) |
| TSharedPtr< const FAccelByteUserInfo, ESPMode::ThreadSafe > | GetUser (const FUniqueNetId &UserId) |
| TSharedPtr< const FAccelByteUserInfo, ESPMode::ThreadSafe > | GetUser (const FAccelByteUniqueIdComposite &UserId) |
| bool | IsStalenessCheckEnabled () const |
| double | GetTimeUntilStaleSeconds () const |
| void | SetStalenessCheckEnabled (bool bInEnableStalenessChecking) |
| void | SetTimeUntilStaleSeconds (double InTimeUntilStaleSeconds) |
| bool | SetUserDataAsStale (const FUniqueNetId &UserUniqueId) |
| bool | SetUserDataAsStale (const FString &InAccelByteId) |
| bool | IsUserDataStale (const FUniqueNetId &UserUniqueId) |
| bool | IsUserDataStale (const FString &InAccelByteId) |
| void | Init () |
| void | AddUsersToCache (const TArray< FAccelByteUserInfoRef > &UsersQueried) |
| void | AddPublicCodeToCache (const FUniqueNetId &UserId, const FString &PublicCode) |
| void | AddPublicCodeToCache (const FAccelByteUniqueIdComposite &UserId, const FString &PublicCode) |
| void | AddLinkedPlatformInfoToCache (const FUniqueNetId &UserId, const TArray< FAccelByteLinkedUserInfo > &LinkedPlatformInfo) |
| void | AddLinkedPlatformInfoToCache (const FAccelByteUniqueIdComposite &UserId, const TArray< FAccelByteLinkedUserInfo > &LinkedPlatformInfo) |
| int32 | Purge () |
| bool | IsUserCached (const FAccelByteUniqueIdComposite &Id) |
| void | GetQueryAndCacheArrays (const TArray< FString > &AccelByteIds, TArray< FString > &UsersToQuery, TArray< FAccelByteUserInfoRef > &UsersInCache) |
Static Public Member Functions | |
| static bool | GetFromSubsystem (const IOnlineSubsystem *Subsystem, TSharedPtr< FOnlineUserCacheAccelByte, ESPMode::ThreadSafe > &OutInterfaceInstance) |
| static bool | GetFromWorld (const UWorld *World, TSharedPtr< FOnlineUserCacheAccelByte, ESPMode::ThreadSafe > &OutInterfaceInstance) |
Public Attributes | |
| PACKAGE_SCOPE | : FOnlineUserCacheAccelByte(FOnlineSubsystemAccelByte* InSubsystem) |
Manages users that are queried from the AccelByte backend, making bulk calls to retrieve user data, as well as getting extra necessary information for those users, such as platform IDs relevant to the current native platform.
As an explanation of how this works under the hood, the cache is made of shared FAccelByteUserInfo instances that are put into two maps. One map is for mapping the AccelByte ID to the user's information, and one is for mapping platform information to the user's information. This way either can be queried seamlessly to get the same user data. The only time you won't be able to query a user by their platform IDs is if they are not on the same platform as you, in which you can only query by AccelByte ID.
User data will be kept cached based on how long it has been since they have been accessed. You can configure how long users will stay in cache with the UserCachePurgeTimeoutSeconds variable in the OnlineSubsystemAccelByte settings in DefaultEngine.ini. Users will also not be purged if they were marked as important when queried.
| void FOnlineUserCacheAccelByte::AddLinkedPlatformInfoToCache | ( | const FAccelByteUniqueIdComposite & | UserId, |
| const TArray< FAccelByteLinkedUserInfo > & | LinkedPlatformInfo ) |
Adds linked platform information to the user cache for a given composite user ID. Creates a new cache entry if the user does not already exist in the cache.
| void FOnlineUserCacheAccelByte::AddLinkedPlatformInfoToCache | ( | const FUniqueNetId & | UserId, |
| const TArray< FAccelByteLinkedUserInfo > & | LinkedPlatformInfo ) |
Adds linked platform information to the user cache for a given user ID. Creates a new cache entry if the user does not already exist in the cache.
| void FOnlineUserCacheAccelByte::AddPublicCodeToCache | ( | const FAccelByteUniqueIdComposite & | UserId, |
| const FString & | PublicCode ) |
Add PublicCode to a user cache, create new if not exist
| void FOnlineUserCacheAccelByte::AddPublicCodeToCache | ( | const FUniqueNetId & | UserId, |
| const FString & | PublicCode ) |
Add PublicCode to a user cache, create new if not exist
| void FOnlineUserCacheAccelByte::AddUsersToCache | ( | const TArray< FAccelByteUserInfoRef > & | UsersQueried | ) |
Add an array of freshly queried users to the user cache
|
static |
Convenience method to get an instance of this interface from the subsystem passed in.
| Subsystem | Subsystem instance that we wish to get this interface from |
| OutInterfaceInstance | Instance of the interface that we got from the subsystem, or nullptr if not found |
|
static |
Convenience method to get an instance of this interface from the subsystem associated with the world passed in.
| World | World instance that we wish to get the interface from |
| OutInterfaceInstance | Instance of the interface that we got from the subsystem, or nullptr if not found |
| void FOnlineUserCacheAccelByte::GetQueryAndCacheArrays | ( | const TArray< FString > & | AccelByteIds, |
| TArray< FString > & | UsersToQuery, | ||
| TArray< FAccelByteUserInfoRef > & | UsersInCache ) |
Method used by user queries to get an array of users that we still need to query, as well as shared instances to users that we have already queried and can retrieve from the cache
| double FOnlineUserCacheAccelByte::GetTimeUntilStaleSeconds | ( | ) | const |
Returns the length of time in seconds that it takes for a user's cached data to become stale.
| TSharedPtr< const FAccelByteUserInfo, ESPMode::ThreadSafe > FOnlineUserCacheAccelByte::GetUser | ( | const FAccelByteUniqueIdComposite & | UserId | ) |
Attempt to get a user from the cache by a composite ID structure.
| TSharedPtr< const FAccelByteUserInfo, ESPMode::ThreadSafe > FOnlineUserCacheAccelByte::GetUser | ( | const FUniqueNetId & | UserId | ) |
Attempt to get a user from the cache by an AccelByte unique ID. This ID comes from either an FAccelByteUserInfo::Id field, or from the result of a query users call.
| void FOnlineUserCacheAccelByte::Init | ( | ) |
Initialize the user cache. This will load configuration values from the engine INI for the cache. Called from the subsystem initialization method.
| bool FOnlineUserCacheAccelByte::IsStalenessCheckEnabled | ( | ) | const |
Checks if staleness checks for cached user data is enabled.
| bool FOnlineUserCacheAccelByte::IsUserCached | ( | const FAccelByteUniqueIdComposite & | Id | ) |
Check whether a user exists already in the cache so that we don't requery them.
| bool FOnlineUserCacheAccelByte::IsUserDataStale | ( | const FString & | InAccelByteId | ) |
Check whether user's cached data has become stale.
| InAccelByteId | String representation of the user ID that you wish to check the staleness |
| bool FOnlineUserCacheAccelByte::IsUserDataStale | ( | const FUniqueNetId & | UserUniqueId | ) |
Check whether user's cached data has become stale.
| UserUniqueId | Unique ID of the user that we wish to check the staleness, must be an AccelByte unique ID |
| int32 FOnlineUserCacheAccelByte::Purge | ( | ) |
Searches through the user caches for a user that hasn't been accessed in longer than the maximum time set for this cache. If a user is found that exceeds this max time, and they are not marked as important, they will be removed from the cache entirely.
Will return the number of users purged from the cache.
Do not call this method directly, it will be called from the owning OnlineSubsystem's ticker!
| bool FOnlineUserCacheAccelByte::QueryUsersByAccelByteIds | ( | const FUniqueNetId & | UserId, |
| const TArray< FString > & | AccelByteIds, | ||
| const FOnQueryUsersComplete & | Delegate, | ||
| bool | bIsImportant = false ) |
Queries all of the IDs listed in the array on the AccelByte backend for user information, including platform IDs. If platform IDs are found and match the current platform that we are on, extra queries will be made through the platform OSSes.
Caches any results that we get from the backend, as well as will not query from the backend again if a duplicate is found.
| UserId | FUniqueNetId of the user that is attempting to query for users |
| AccelByteIds | Array of strings that represent an ID for a single user |
| Delegate | Delegate fired when the query is complete |
| bIsImportant | Whether or not we want to mark these users as important so that they stay in the cache, defaults to false. This should only be used for users that we want to persist for the length of the game session, such as friends. |
| bool FOnlineUserCacheAccelByte::QueryUsersByAccelByteIds | ( | int32 | LocalUserNum, |
| const TArray< FString > & | AccelByteIds, | ||
| const FOnQueryUsersComplete & | Delegate, | ||
| bool | bIsImportant = false ) |
Queries all of the IDs listed in the array on the AccelByte backend for user information, including platform IDs. If platform IDs are found and match the current platform that we are on, extra queries will be made through the platform OSSes.
Caches any results that we get from the backend, as well as will not query from the backend again if a duplicate is found.
| LocalUserNum | Index of the user that is attempting to query for other users |
| AccelByteIds | Array of strings that represent an ID for a single user |
| Delegate | Delegate fired when the query is complete |
| bIsImportant | Whether or not we want to mark these users as important so that they stay in the cache, defaults to false. This should only be used for users that we want to persist for the length of the game session, such as friends. |
| bool FOnlineUserCacheAccelByte::QueryUsersByPlatformIds | ( | const FUniqueNetId & | UserId, |
| const FString & | PlatformType, | ||
| const TArray< FString > & | PlatformIds, | ||
| const FOnQueryUsersComplete & | Delegate, | ||
| bool | bIsImportant = false ) |
Tries to query all platform IDs listed for the particular platform specified on the AccelByte backend to find AccelByte user matches. If a matches are found, a subsequent query and cache will be performed to get information from the AccelByte backend on those users.
| UserId | FUniqueNetId of the user that is attempting to query for users |
| PlatformType | String representing the type of platform that these IDs belong to |
| PlatformIds | Array of strings that represent an ID for a single user |
| Delegate | Delegate fired when the query is complete |
| bIsImportant | Whether or not we want to mark these users as important so that they stay in the cache, defaults to false. This should only be used for users that we want to persist for the length of the game session, such as friends. |
| bool FOnlineUserCacheAccelByte::QueryUsersByPlatformIds | ( | int32 | LocalUserNum, |
| const FString & | PlatformType, | ||
| const TArray< FString > & | PlatformIds, | ||
| const FOnQueryUsersComplete & | Delegate, | ||
| bool | bIsImportant = false ) |
Tries to query all platform IDs listed for the particular platform specified on the AccelByte backend to find AccelByte user matches. If a matches are found, a subsequent query and cache will be performed to get information from the AccelByte backend on those users.
| LocalUserNum | Index of the user that is attempting to query for other users |
| PlatformType | String representing the type of platform that these IDs belong to |
| PlatformIds | Array of strings that represent an ID for a single user |
| Delegate | Delegate fired when the query is complete |
| bIsImportant | Whether or not we want to mark these users as important so that they stay in the cache, defaults to false. This should only be used for users that we want to persist for the length of the game session, such as friends. |
| void FOnlineUserCacheAccelByte::SetStalenessCheckEnabled | ( | bool | bInEnableStalenessChecking | ) |
Enable or disable staleness checks in the user cache. Intended for runtime testing of cache. Prefer using ini or command line to enable or disable staleness checks.
| void FOnlineUserCacheAccelByte::SetTimeUntilStaleSeconds | ( | double | InTimeUntilStaleSeconds | ) |
Set the amount of time in seconds that it takes for a user's cached data to become stale. Intended for runtime testing of cache. Prefer using ini or command line to control staleness time.
| bool FOnlineUserCacheAccelByte::SetUserDataAsStale | ( | const FString & | InAccelByteId | ) |
Attempts to mark the referenced user's cached data as stale. If found, the force stale flag on the user's data will be updated, and the next request to get user data will request new data for this user, regardless of whether the stale datetime has been reached. This flag will be reset after the request is processed.
| InAccelByteId | String representation of the user ID that you wish to mark stale |
| bool FOnlineUserCacheAccelByte::SetUserDataAsStale | ( | const FUniqueNetId & | UserUniqueId | ) |
Attempts to mark the referenced user's cached data as stale. If found, the force stale flag on the user's data will be updated, and the next request to get user data will request new data for this user, regardless of whether the stale datetime has been reached. This flag will be reset after the request is processed.
| UserUniqueId | Unique ID of the user that we wish to set as stale, must be an AccelByte unique ID |