Server ServerSDK API Reference
Server sdk api.
API List
| API | Description |
|---|---|
| InitSdk | Init modules for PGOS service. Note: InitSdk/InitConfig/Destroy must be called on the main thread. |
| InitConfig | Init config for PGOS service. Note: InitSdk/InitConfig/Destroy must be called on the main thread. |
| GetConfig | Get configuration value of the specified key, except for "secret_key". |
| GetModule | Get specified PGOS service module object, it's an internal function. |
| GetSDKVersion | Get current PGOS SDK version. |
| InitSdkForkingProcess | Init for PGOS service. Used when fork() function will be called in game server. Note: InitSdkForkingProcess/InitConfig/Destroy must be called on the main thread. |
| Destroy | Shutdown PGOS service, should be called during process shutdown if possible. Note: InitSdk/InitConfig/Destroy must be called on the main thread. |
API Details
InitSdk
Init modules for PGOS service. Note: InitSdk/InitConfig/Destroy must be called on the main thread.
/**
* Init modules for PGOS service.
* Note: InitSdk/InitConfig/Destroy must be called on the main thread.
*
* @param params Request parameters for init sdk.
*/
void InitSdk(
const InitSdkParams& params);
Parameters:
| Param | Type | Description |
|---|---|---|
| params | const InitSdkParams& | Request parameters for init sdk. |
Return: void
InitConfig
Init config for PGOS service. Note: InitSdk/InitConfig/Destroy must be called on the main thread.
/**
* Init config for PGOS service.
* Note: InitSdk/InitConfig/Destroy must be called on the main thread.
*
* @param cfgs A configuration consisting of key/value pairs, such as "title_id", "secret_key", and others.
*/
void InitConfig(
const pgos::pmap<pgos::pstring, pgos::pstring>& cfgs);
Parameters:
| Param | Type | Description |
|---|---|---|
| cfgs | const std::map<std::string, std::string>& | A configuration consisting of key/value pairs, such as "title_id", "secret_key", and others. |
Return: void
GetConfig
Get configuration value of the specified key, except for "secret_key".
/**
* Get configuration value of the specified key, except for "secret_key".
*
* @param cfg_key The specified key, such as "title_id", "log_level", and others.
* @return The configuration value of the specified key.
*/
pgos::pstring GetConfig(
const pgos::pstring& cfg_key);
Parameters:
| Param | Type | Description |
|---|---|---|
| cfg_key | const std::string& | The specified key, such as "title_id", "log_level", and others. |
Return: pgos::pstring
The configuration value of the specified key.
GetModule
Get specified PGOS service module object, it's an internal function.
/**
* Get specified PGOS service module object, it's an internal function.
*
* @param mod_id server module id.
* @return service module object pointer.
*/
void* GetModule(
ModuleID mod_id);
Parameters:
| Param | Type | Description |
|---|---|---|
| mod_id | ModuleID | server module id. |
Return: void*
service module object pointer.
GetSDKVersion
Get current PGOS SDK version.
/**
* Get current PGOS SDK version.
*
* @return PGOS SDK version string.
*/
pgos::pstring GetSDKVersion();
Parameters:
(No parameters)
Return: pgos::pstring
PGOS SDK version string.
InitSdkForkingProcess
Init for PGOS service. Used when fork() function will be called in game server. Note: InitSdkForkingProcess/InitConfig/Destroy must be called on the main thread.
/**
* Init for PGOS service. Used when fork() function will be called in game server.
* Note: InitSdkForkingProcess/InitConfig/Destroy must be called on the main thread.
*
* @param params Request parameters for init sdk.
*/
void InitSdkForkingProcess(
const InitSdkParams& params);
Parameters:
| Param | Type | Description |
|---|---|---|
| params | const InitSdkParams& | Request parameters for init sdk. |
Return: void
Destroy
Shutdown PGOS service, should be called during process shutdown if possible. Note: InitSdk/InitConfig/Destroy must be called on the main thread.
/**
* Shutdown PGOS service, should be called during process shutdown if possible.
*
* Note: InitSdk/InitConfig/Destroy must be called on the main thread.
*/
void Destroy();
Parameters:
(No parameters)
Return: void