NoticeResultObserver
[MSDK & Player Network SDK] Register the callback of the notice module, the game needs to process the callback function. For more information on the callback data structure, see GUANoticeResult.
note
It is strongly recommended to perform registration in the startup function of the game application.
Function Definition
- Unity
- Unreal Engine
The list of methods used to process the callback events.
Callback Event | Common | [Player Network SDK Only] | [MSDK Only] |
---|---|---|---|
NoticeResultEvents | LoadNoticeData | - | - |
event OnResultHandler<GUANoticeRet> NoticeResultEvents;
The list of methods used to process the callback events.
Callback Event | Common | [Player Network SDK Only] | [MSDK Only] |
---|---|---|---|
OnLoadNoticeData | LoadNoticeData | - | - |
class GUA_EXTERN GUANoticeObserver
{
public:
virtual ~GUANoticeObserver() {};
virtual void OnLoadNoticeData(const GUANoticeResult ¬ice_result) {};
};
Code Sample
- Unity
- Unreal Engine
// Add callbacks
UnionAdapterAPI.GetNoticeService().NoticeResultEvents += OnNoticeResultEvent;
// Remove callbacks
UnionAdapterAPI.GetNoticeService().NoticeResultEvents -= OnNoticeResultEvent;
// NoticeResultEvents callback
private void OnNoticeResultEvent(GUANoticeRet noticeRet)
{
Debug.Log("OnNoticeResultEvent");
string methodTag = "";
if (noticeRet.MethodId == (int)GUAMethodID.GUA_NOTICE_REQUEST_DATA)
{
methodTag = "RequestNoticeData";
}
Debug.Log(methodTag + noticeRet.ToString());
NoticeSample noticeWindow = m_sample as NoticeSample;
if (noticeWindow != null)
{
noticeWindow.SetNoticeResult(noticeRet);
}
}
// 1. Define an observer class that inherits from GUA_NAMESPACE::GUANoticeObserver at the engine level.
// 2. Implement a callback interface with the same method name such as OnLoadNoticeData
class FGUANoticeObserver : public GUA_NAMESPACE::GUANoticeObserver {
public:
static FGUANoticeObserver Instance;
void OnLoadNoticeData(const GUA_NAMESPACE::GUANoticeResult ¬ice_result)
{
}
};
FGUANoticeObserver FGUANoticeObserver::Instance;
//Configure the callback
GUA_NAMESPACE::GUANoticeService::SetNoticeObserver(&FGUANoticeObserver::Instance);