We call the interface imported from the inherited UObject to the Plugin through Super.

FStoveResult UMyStoveSDKObject::StoveSDKInit(const FStoveConfig& fConfig)
{
    FStoveResult fResult = Super::StoveSDKInit(fConfig);
}

<aside> 💡 For the Plugin environment configuration, refer to the Configuring the project environment, categories 1 to 3, in PC SDK Unreal Walkthrough

</aside>

1. Config, Callback Settings

Suppose you wish to initialize the PC SDK. In that case, you must fill the FStoveConfig values and call the UStoveSDKObject::StoveSDKInit function of the inherited Actor.

Refer to the code below and fill in the field values of the FStoveConfig structures.

FStoveConfig fConfig{"LIVE",
                    "YOUR_APP_KEY",
                    "YOUR_SECRET_KEY",
                    "YOUR_GAME_ID",
                    StovePCLogLevel::STOVE_PC_LOG_LEVEL_DEBUG,
                    ""};

For the description of the FStoveConfig structure, refer to the StoveSDKStruct.h file in the Plugins\\StoveSDKPlugin\\Source\\StoveSDKPlugin\\Public folder.

To call the API of the PC SDK in the game project and check the result, you need to use the callback function. The callback function used in the game project is as follows.

    //StovePCSDK Callback
public:
    void OnError(FStoveError Error) final;
    void OnInitComplete() final;
    void OnToken(FStoveToken Token) final;
    void OnUser(FStoveUser User) final;
    void OnOwnership(int Size, FStoveOwnership* Ownerships) final;

The OnErrorOnInitComplete and OnOwnership callback functions must work together. You can integrate the rest of the callback functions only when necessary. For example, suppose you only use the Ownership function. In that case, you can implement it by defining it in the game project, as shown below.

/*As for when only using the Ownership function,
apart from the essential callbacks OnError, OnInitcomplte,
connect only the OnOwnership callback additionally.*/
void UMyStoveSDKObject::OnInitComplete()
{
    // Process detail after successful initialization
}

void UMyStoveSDKObject::OnError(FStoveError Error)
{
    // Process detail of the error
}

void UMyStoveSDKObject::OnOwnership(int Size, FStoveOwnership* Ownerships)
{
    // Process detail after the viewing ownership
}

2. SDK Initialization

Before using the API of PC SDK, enter the initialization code as shown below in the UMyStoveSDKObject::StoveSDKInit function of MyStoveSDKObject.cpp for initialization.

FStoveResult UMyStoveSDKObject::StoveSDKInit(const FStoveConfig& Config)
{
    FStoveResult ErrorResult = Super::StoveSDKInit(Config);
    if (ErrorResult.Result == StovePCResult::STOVE_PC_NO_ERROR)
    {
        /*StovePCSDK init Success*/

    }
}

The UMyStoveSDKObject::StoveSDKInit function immediately returns the FStovePCResult enum type value after checking only the validity of config and callback.

In case of success, it returns a value of STOVE_PC_NO_ERROR. In case of failure, it returns the corresponding error code, and you need to quit the game. For the entire list of error codes, refer to the StovePCDefine.h file.