Last Updated: 2/15/2022, 11:53:01 AM

# Setting Up Multiple Environments

# Overview

AccelByte enables you to use different environments, such as Prod, Cert, and Dev, with one single project, meaning that you only need to build your game once. By using our SDK, you will be able to switch environments even when your build is running. For example, you can run and test your build in the Cert environment and then publish your game to the Prod environment, all without having to rebuild your game for each separate environment.

# Prerequisites

You will need to fill in three new AccelByteSettings in DefaultEngine.ini in order to enable switching of environments:

  • For the Dev environment, fill in the configuration in [/Script/AccelByteUe4Sdk.AccelByteSettingsDev]

    [/Script/AccelByteUe4Sdk.AccelByteSettingsDev]
    ClientId=Game Client ID
    ClientSecret=Game Client Secret
    Namespace=Game Namespace
    PublisherNamespace=Publisher Namespace
    RedirectURI="http://127.0.0.1"
    BaseUrl="https://dev.accelbyte.io"
    IamServerUrl="https://dev.accelbyte.io/iam"
    PlatformServerUrl="https://dev.accelbyte.io/platform"
    LobbyServerUrl="wss://dev.accelbyte.io/lobby/"
    CloudStorageServerUrl="https://dev.accelbyte.io/binary-store"
    BasicServerUrl="https://dev.accelbyte.io/basic"
    GameProfileServerUrl="https://dev.accelbyte.io/soc-profile"
    StatisticServerUrl="https://dev.accelbyte.io/statistic"
    QosManagerServerUrl="https://dev.accelbyte.io/qosm"
    LeaderboardServerUrl="https://dev.accelbyte.io/leaderboard"
    CloudSaveServerUrl="https://dev.accelbyte.io/cloudsave"
    GameTelemetryServerUrl="https://dev.accelbyte.io/game-telemetry"
    AgreementServerUrl="https://dev.accelbyte.io/agreement"
    AchievementServerUrl="https://dev.accelbyte.io/achievement"
    SessionBrowserServerUrl="https://dev.accelbyte.io/sessionbrowser"
    UGCServerUrl="https://dev.accelbyte.io/ugc"
    ReportingServerUrl="https://dev.accelbyte.io/reporting"
    AppId=Your App Id
    
  • For the Cert environment, fill in the configuration in [/Script/AccelByteUe4Sdk.AccelByteSettingsCert]

    [/Script/AccelByteUe4Sdk.AccelByteSettingsCert]
    ClientId=Game Client ID
    ClientSecret=Game Client Secret
    Namespace=Game Namespace
    PublisherNamespace=Publisher Namespace
    RedirectURI="http://127.0.0.1"
    BaseUrl="https://cert.accelbyte.io"
    IamServerUrl="https://cert.accelbyte.io/iam"
    PlatformServerUrl="https://cert.accelbyte.io/platform"
    LobbyServerUrl="wss://cert.accelbyte.io/lobby/"
    CloudStorageServerUrl="https://cert.accelbyte.io/binary-store"
    BasicServerUrl="https://cert.accelbyte.io/basic"
    GameProfileServerUrl="https://cert.accelbyte.io/soc-profile"
    StatisticServerUrl="https://cert.accelbyte.io/statistic"
    QosManagerServerUrl="https://cert.accelbyte.io/qosm"
    LeaderboardServerUrl="https://cert.accelbyte.io/leaderboard"
    CloudSaveServerUrl="https://cert.accelbyte.io/cloudsave"
    GameTelemetryServerUrl="https://cert.accelbyte.io/game-telemetry"
    AgreementServerUrl="https://cert.accelbyte.io/agreement"
    AchievementServerUrl="https://cert.accelbyte.io/achievement"
    SessionBrowserServerUrl="https://cert.accelbyte.io/sessionbrowser"
    UGCServerUrl="https://cert.accelbyte.io/ugc"
    ReportingServerUrl="https://cert.accelbyte.io/reporting"
    AppId=Your App Id
    
  • For the Prod environment, fill in the configuration in [/Script/AccelByteUe4Sdk.AccelByteSettingsProd]

    [/Script/AccelByteUe4Sdk.AccelByteSettingsProd]
    ClientId=Game Client ID
    ClientSecret=Game Client Secret
    Namespace=Game Namespace
    PublisherNamespace=Publisher Namespace
    RedirectURI="http://127.0.0.1"
    BaseUrl="https://demo.accelbyte.io"
    IamServerUrl="https://demo.accelbyte.io/iam"
    PlatformServerUrl="https://demo.accelbyte.io/platform"
    LobbyServerUrl="wss://demo.accelbyte.io/lobby/"
    CloudStorageServerUrl="https://demo.accelbyte.io/binary-store"
    BasicServerUrl="https://demo.accelbyte.io/basic"
    GameProfileServerUrl="https://demo.accelbyte.io/soc-profile"
    StatisticServerUrl="https://demo.accelbyte.io/statistic"
    QosManagerServerUrl="https://demo.accelbyte.io/qosm"
    LeaderboardServerUrl="https://demo.accelbyte.io/leaderboard"
    CloudSaveServerUrl="https://demo.accelbyte.io/cloudsave"
    GameTelemetryServerUrl="https://demo.accelbyte.io/game-telemetry"
    AgreementServerUrl="https://demo.accelbyte.io/agreement"
    AchievementServerUrl="https://demo.accelbyte.io/achievement"
    SessionBrowserServerUrl="https://demo.accelbyte.io/sessionbrowser"
    UGCServerUrl="https://demo.accelbyte.io/ugc"
    ReportingServerUrl="https://dev.accelbyte.io/reporting"
    AppId=Your App Id
    

# Tutorials

# Retrieve the Unreal OSS Online Environment

Retrieve the available Unreal OSS Online Environment to check the environment and avoid mismatching environment settings. This will ensure that the game is running in the correct environment.

IOnlineSubsystem* OSS = IOnlineSubsystem::Get(PS4_SUBSYSTEM);
EOnlineEnvironment::Type OSSEnvironment = OSS->GetOnlineEnvironment();

# Convert Unreal OSS Environment to AB Settings Environment

Convert the Unreal OSS Environment enumeration to the AB Setting Environment so you can switch between AB Environments based on what is set in the Unreal OSS Environment. For more information on these environments, see the example enumeration in the Unreal OSS and AB Settings environments below:

Convert the Unreal OSS Environment enumeration to the AB Setting Environment using the following function:

  ESettingsEnvironment ConvertOSSEnvtoABEnv (const EOnlineEnvironment::Type& Environment)
  {
  	switch (Environment)
  	{
  	case EOnlineEnvironment::Type::Development :
            return ESettingsEnvironment::Development;

  	case EOnlineEnvironment::Type::Certification:
            return ESettingsEnvironment::Certification;

  	case EOnlineEnvironment::Type::Production:
            return ESettingsEnvironment::Production;

  	case EOnlineEnvironment::Type::Unknown:
  	default:
            return ESettingsEnvironment::Default;
  	}
  }

# Call Switch Environment Function

In order to switch between environments, make sure to use AccelByteUe4SdkModule.h (opens new window) and call the IAccelByteUe4SdkModuleInterface::Get().SetEnvironment(ABEnvironment); function, as seen in the example below:

IOnlineSubsystem* OSS = IOnlineSubsystem::Get(PS4_SUBSYSTEM);
EOnlineEnvironment::Type OSSEnvironment = OSS->GetOnlineEnvironment();

ESettingsEnvironment ABEnvironment = ConvertOSSEnvtoABEnv(OSSEnvironment);

IAccelByteUe4SdkModuleInterface::Get().SetEnvironment(ABEnvironment);

After you call IAccelByteUe4SdkModuleInterface::Get().SetEnvironment(ABEnvironment;., the SDK will load the respective AccelByte Environment Settings that you have previously set. You will now be able to switch between AccelByte Environments.