Search
Duplicate

SDK Initialization

생성일
2024/03/14 05:07
태그
To use StovePCSDK, you need to execute the initialization function first. For initialization, input appropriate values to the StovePCConfig and StovePCCallback structures and call the StovePC_Init function. To use the StovePC_Init function, enter the following into the CHelloStoveDlg::OnBnClickedInit function.
void CHelloStoveDlg::OnBnClickedInit() { /*Add the 'Follow Through' code here.*/ //config StovePCConfig config; memset(&config, 0, sizeof(StovePCConfig)); config.env = "LIVE"; config.appKey = "YOUR_APP_KEY"; config.secretKey = "YOUR_SECRET_KEY"; config.gameId = L"YOUR_GAME_ID"; config.logLevel = StovePCLogLevel::STOVE_PC_LOG_LEVEL_DEBUG; config.logPath = L""; //callback StovePCCallback callback; memset(&callback, 0, sizeof(StovePCCallback)); callback.OnError = OnError; callback.OnInitComplete = OnInitComplete; callback.OnToken = OnToken; callback.OnUser = OnUser; //initialize StovePCResult result = StovePC_Init(config, callback); if (result != StovePCResult::STOVE_PC_NO_ERROR) { //StovePCSDK initialize fail _displayConfig(config); CString log; log.Format(L"[Error] StovePC_Init, Result %d", result); OnLog(log); } else { //StovePCSDK initialize success _displayConfig(config); OnLog(L"[Success] StovePC_Init"); //You have successfully called the StovePC_Init function. //Now, regularly call in the StovePC_RunCallback function from the timer. SetTimer(USER_TIMER, 500, NULL); } }
C++
복사
Precautions The PCSDK log path must be set as an absolute path. ex) C:\Program Files\{Your Game Folder}\Logs Do not add "\" at the end. PCSDK automatically adds the file name "StovePCSDK.log".
If "" is set as an empty string, PCSDK automatically creates a log in the path of the game executable file folder or the folder where the PCSDK DLL is located.
"YOUR_APP_KEY", "YOUR_SECRET_KEY", and "YOUR_GAME_ID" must be changed to data previously issued by STOVE Studio (opens new window). If you call the StovePC_Init function without logging into the stove launcher with the stove account applied for entry into STOVE Studio, error code 150 (sgup initialization failure) occurs.
We also included the following in the code above. If the StovePC_Init function returns value called from the CHelloStoveDlg::OnBnClickedInit function is successful (that is, when it return STOVE_PC_NO_ERROR), you need to put the StovePC_RunCallback function on the timer. We code the example to follow to call the StovePC_RunCallback function every 500ms through MFC's SetTimer function. When the callback CHelloStoveDlg::OnTimer function is executed periodically through SetTimer, add the StovePC_RunCallback function as shown in the code below.
void CHelloStoveDlg::OnTimer(UINT_PTR nIDEvent) { if (nIDEvent == USER_TIMER) { /*Add the 'Follow Through' code here.*/ StovePC_RunCallback(); } CDialogEx::OnTimer(nIDEvent); }
C++
복사
Comment out the OnInitComplete function, it calls back the function when the StovePC_Init function is ordinarily complete, and input the code below.
Also, if the StovePC_Init function is executed normally, the callback OnInitComplete function is called. In other words, when it calls the OnInitComplete function, it means that it executes the StovePC_Init function successfully. As shown in the code below, you can log the successful initialization of StovePCSDK.
void OnInitComplete() { /*Add the 'Follow Through' code here.*/ OnLog(L"[Success] InitComplete\n"); }
C++
복사
It calls the OnError function when the StovePC_Init function or any other function call from StovePCSDK fails. You can check by writing the code below to narrow the function error of StovePCSDK.
void OnError(const StovePCError error) { /*Add the 'Follow Through' code here.*/ OnLog(L"[Error]\n"); CString log; log.Format(L"StovePCError occurred\n -funcType: %d, result:%d, externalError: %d", error.functionType, error.result, error.externalError); OnLog(log); }
C++
복사