Game Engine

how to initialize GS2-SDK for Game Engine


Initialization of the SDK is done through a utility class called Profile. Profile is used to initialize both the always-connected session used for notifications and the HTTP session used for API calls, as well as to automatically handle miscellaneous processes such as session disconnection and access token expiration.


Argument NameDescription
clientIdCredential Information
clientSecretCredential Information
regionGS2 region to connect to
distributorNamespaceNameNamespace name of the GS2-Distributor performing the transaction processing

The basic reopener is Gs2BasicReopener. This class defines the general reconnection process assumed by GS2.

Although omitted in the example implementation below, you can specify distributorNamespaceName here to use any GS2-Distributor’s namespace for transaction processing. If you want GS2-Distributor to record the transaction logs it executes in GS2-Log, you must explicitly set the namespace in which the logs are exported here.

Gs2BasicReopener Request

Argument NameDescription
gatewaySettingNotification settings
versionSettingVersion check settings

Gs2BasicReopener requires two arguments to be set as needed.


This setting is for receiving push notifications from the server.

When automatically executing transactions (stamp sheets) on the server side or using the matchmaking function, setting this item will enable you to receive notifications when the process is complete. If you are developing a game that utilizes GS2, it may be an essential item to configure. Set the namespace of the GS2-Gateway to be used for notification processing.


This is a setting to automatically perform an app version check when the session is reconnected.

By performing a version check when reconnecting to a session, you can force players to perform a version check at regular intervals. Using GS2-Gateway’s session disconnection API, it is possible to force version check on all playing players and kick out players who are playing with older versions.

This feature also implements credential escalation after the version check. This is the handling process that GS2-Version has for assigning a new credential after passing a version check. The credentials embedded in the game will have only the minimum privileges necessary to perform the version check, and can be promoted to sufficient privileges to play the game after passing the version check.

Implementation Example

    var profile = new Profile(
        region: Region.ApNorthEast1,
        reopener: new Gs2BasicReopener(
    const auto Profile = MakeShared<Gs2::UE5::Util::FProfile>(
        MakeShareable<Gs2::UE5::Util::IReOpener>(new Gs2::UE5::Util::FGs2BasicReOpener(
                    TArray<Gs2::UE5::Version::Model::FEzTargetVersionPtr> Arr;
                    return Arr;
    const auto Profile = MakeShared<Gs2::UE5::Util::FProfile>(
        MakeShareable<Gs2::UE5::Util::IReOpener>(new Gs2::UE5::Util::FGs2BasicReOpener())

Initialization of SDK

Once the profile object is created, initialize GS2-SDK. By performing the initialization process, a GS2 client instance can be obtained.

Implementation Example

    var gs2 = await profile.InitializeAsync();
    var initializeFuture = profile.InitializeFuture();
    yield return initializeFuture;
    if (initializeFuture.Error != null) {
        throw initializeFuture.Error;
    var gs2 = initializeFuture.Result;
    const auto InitializeFuture = Profile->Initialize();
    if (InitializeFuture->GetTask().IsError())
        UE_LOG(GameLog, Error, TEXT("%s"), ToCStr(InitializeFuture->GetTask().Error()->String()));
        return InitializeFuture->GetTask().Error();
    const auto Gs2 = InitializeFuture->GetTask().Result();