GUAIDTokenResultObservers [Player Network SDK Only]
Registers the callback of the Auth module, the game needs to process the callback function. For more information on the callback data structure, see the following data structure GUAIDTokenResult.
note
It is strongly recommended to perform registration in the startup function of the game application.[Player Network SDK Only].
Data Structures
GUAIDTokenResult: inherits from GUABaseResult.
Parameter | Type | Description |
---|---|---|
IdToken | string | Player Network SDK unique OpenID Default: 64-bit unsigned integer string, also supports 32-bit. |
Function Definition
- Unity
- Unreal Engine
// IDTokenEvents callback event, to process QueryIDToken callback
event OnResultHandler<GUAIDTokenResult> IDTokenEvents;
// OnIDTokenResultNotify callback event, to process QueryIDToken callback
class GUA_EXTERN GUAAccountObserver
{
public:
virtual ~GUAAccountObserver() {};
virtual void OnIDTokenResultNotify(const GUAIDTokenResult &id_result) {};
};
Code Sample
- Unity
- Unreal Engine
// Add callbacks
UnionAdapterAPI.GetAccountService().IDTokenEvents += OnIDTokenEvent;
// Remove callbacks
UnionAdapterAPI.GetAccountService().IDTokenEvents -= OnIDTokenEvent;
// IDTokenEvents callback
public void OnIDTokenEvent(GUAIDTokenResult idtokenret)
{
Debug.Log("OnIDTokenEvent in Auth");
}
// 1. Define an observer class that inherits from GUA_NAMESPACE::GUAAccountObserver at the engine level.
// 2. Implement a callback interface with the same method name such as OnIDTokenResultNotify
class FGUAAccountObserver : public GUA_NAMESPACE::GUAAccountObserver {
public:
static FGUAAccountObserver Instance;
void OnIDTokenResultNotify(const GUA_NAMESPACE::GUAIDTokenResult &id_result)
{
}
};
FGUAAccountObserver FGUAAccountObserver::Instance;
//Configure the callback
GUA_NAMESPACE::GUAAccountService::SetAccountObserver(&FGUAAccountObserver::Instance);