跳到主要内容

Client ClientSDK API Reference

Client sdk api.

API List

APIDescription
InitSdkInit modules for PGOS service. Note: InitSdk/InitConfig/Tick/Destroy must be called on the main thread.
InitConfigInit config for PGOS service Note: InitSdk/InitConfig/Tick/Destroy must be called on the main thread.
GetConfigGet configuration value of the specified key, except for "secret_key".
TickTick for PGOS service which may dispatch PGOS events. Note: InitSdk/InitConfig/Tick/Destroy must be called on the main thread. NOte: In the PGOS Unreal Plugin, developers don't need to care about this interface and should not call it.
GetModuleGet specified PGOS service module object, it's an internal function.
OnAppEnterForegroundShould be called when the application enters the foreground. (for Android&iOS)
OnAppEnterBackgroundShould be called when the application enters the background. (for Android&iOS).
GetSDKVersionGet current PGOS SDK version.
DestroyShutdown PGOS service, should be called during process shutdown if possible. Note: InitSdk/InitConfig/Tick/Destroy must be called on the main thread.

API Details

InitSdk

Init modules for PGOS service. Note: InitSdk/InitConfig/Tick/Destroy must be called on the main thread.

/**
* Init modules for PGOS service.
* Note: InitSdk/InitConfig/Tick/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/Tick/Destroy must be called on the main thread.

/**
* Init config for PGOS service
* Note: InitSdk/InitConfig/Tick/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.

Tick

Tick for PGOS service which may dispatch PGOS events. Note: InitSdk/InitConfig/Tick/Destroy must be called on the main thread. NOte: In the PGOS Unreal Plugin, developers don't need to care about this interface and should not call it.

Deprecated.

/**
* Tick for PGOS service which may dispatch PGOS events.
* Note: InitSdk/InitConfig/Tick/Destroy must be called on the main thread.
* NOte: In the PGOS Unreal Plugin, developers don't need to care about this interface and should not call it.
* [DEPRECATED!!!] Tick was declared deprecated.
*/
void Tick();

Parameters:

(No parameters)

Return: void

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 Specified PGOS service module object, such as ClientFakeAccount, ClientBattle, and others.
* @return service module object pointer.
*/
void* GetModule(
ModuleID mod_id);

Parameters:

ParamTypeDescription
mod_idModuleIDSpecified PGOS service module object, such as ClientFakeAccount, ClientBattle, and others.

Return: void*

service module object pointer.

OnAppEnterForeground

Should be called when the application enters the foreground. (for Android&iOS)

/**
* Should be called when the application enters the foreground. (for Android&iOS)
*/
void OnAppEnterForeground();

Parameters:

(No parameters)

Return: void

OnAppEnterBackground

Should be called when the application enters the background. (for Android&iOS).

/**
* Should be called when the application enters the background. (for Android&iOS).
*/
void OnAppEnterBackground();

Parameters:

(No parameters)

Return: void

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.

Destroy

Shutdown PGOS service, should be called during process shutdown if possible. Note: InitSdk/InitConfig/Tick/Destroy must be called on the main thread.

/**
* Shutdown PGOS service, should be called during process shutdown if possible.
* Note: InitSdk/InitConfig/Tick/Destroy must be called on the main thread.
*/
void Destroy();

Parameters:

(No parameters)

Return: void