Skip to main content

Handling AGS Online Feature in Mainmenu for Connection Errors

Last updated on February 27, 2025

When a player is unable to access an AGS online feature from the game's main menu, it is essential to display a clear and informative error message. This helps players understand that the online feature is currently unavailable due to a connection issue, rather than leaving them confused about why it isn’t working.

For example, if a player tries to access features like store, user entitlements or user wallet but encounters a network failure, the game should notify them with a meaningful message like "Unable to connect. Please check your internet connection and try again."

Below are some examples of AGS online features that might be affected in the main menu. Along with that, we'll also provide a sample code snippet to detect connection issues and handle them properly in your game.

Retrieve Store Display information

...
auto ABSubsystem = IOnlineSubsystem::Get(ACCELBYTE_SUBSYSTEM);
auto StoreInterface = ABSubsystem->GetStoreV2Interface();
FOnlineStoreV2AccelBytePtr ABStoreInterface = StaticCastSharedPtr<FOnlineStoreV2AccelByte>(StoreInterface);

FString StoreId;
FString ViewId;
FString Region;
constexpr EAccelBytePlatformMapping PlatformMapping = EAccelBytePlatformMapping::NONE;
ABStoreInterface->QueryStorefront("<UserId>", StoreId, ViewId, Region, PlatformMapping,
FOnQueryStorefrontComplete::CreateWeakLambda(this, [](bool bWasSuccessful, const TArray<FString>& ViewIds, const TArray<FString>& SectionIds, const TArray<FUniqueOfferId>& OfferIds, const TArray<FString>& ItemMappingIds, const FString& Error)
{
if (bWasSuccessful)
{
// Do something when the query store display is successful.
}
else
{
// Implement a solution to handle failed request.
}
}
));
...

Currently, if a retreiving in-game store fails, the AGS OSS does not provide details about whether the failure was caused by an HTTP timeout or another issue.

Query Player's Entitlements

...
auto ABSubsystem = IOnlineSubsystem::Get(ACCELBYTE_SUBSYSTEM);
auto EntitlementsInterface = ABSubsystem->GetEntitlementsInterface();
FOnlineEntitlementsAccelBytePtr ABEntitlementsInterface = StaticCastSharedPtr<FOnlineEntitlementsAccelByte>(EntitlementsInterface);

ABEntitlementsInterface->OnQueryEntitlementsCompleteDelegates.AddWeakLambda(this, [this](bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Namespace, const FString& ErrorMessage)
{
if (bWasSuccessful)
{
// Do something when the query user entitlements is successful.
}
else
{
// Implement a solution to handle failed request.
}
});
EntitlementsInterface->QueryEntitlements(UserId, TEXT(""), FPagedQuery());
...

Currently, if a retreiving user entitlements fails, the AGS OSS does not provide details about whether the failure was caused by an HTTP timeout or another issue.

Get Player's Wallet Data

...
auto ABSubsystem = IOnlineSubsystem::Get(ACCELBYTE_SUBSYSTEM);
auto WalletInterface = ABSubsystem->GetWalletInterface();

WalletInterface->OnGetWalletInfoCompletedDelegates..AddWeakLambda(this, [this](int32 LocalUserNum, bool bWasSuccessful, const FAccelByteModelsWalletInfo& Response, const FString& Error)
{
if (bWasSuccessful)
{
// Do something when the retrieving wallet data is successful.
}
else
{
// Implement a solution to handle failed request.
}
});
WalletInterface->GetWalletInfoByCurrencyCode(0, TEXT("<SampleCurrencyCode>"), true;
...

Currently, if a retreiving user entitlements fails, the AGS OSS does not provide details about whether the failure was caused by an HTTP timeout or another issue.