跳到主要内容

Server ServerSDK API Reference

Server sdk api.

API List

APIDescription
InitSdkInit modules for PGOS service. Note: InitSdk/InitConfig/Destroy must be called on the main thread.
InitConfigInit config for PGOS service. Note: InitSdk/InitConfig/Destroy must be called on the main thread.
GetConfigGet configuration value of the specified key, except for "secret_key".
GetModuleGet specified PGOS service module object, it's an internal function.
GetSDKVersionGet current PGOS SDK version.
InitSdkForkingProcessInit for PGOS service. Used when fork() function will be called in game server. Note: InitSdkForkingProcess/InitConfig/Destroy must be called on the main thread.
DestroyShutdown 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:

ParamTypeDescription
paramsconst 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:

ParamTypeDescription
cfgsconst 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:

ParamTypeDescription
cfg_keyconst 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:

ParamTypeDescription
mod_idModuleIDserver 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:

ParamTypeDescription
paramsconst 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