GUAFriendBaseResultObserver
[MSDK & Player Network SDK] Register the callback of the friend module, the game needs to process the callback function. For more information on the callback data structure, see GUABaseResult.
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] |
---|---|---|---|
FriendBaseEvents | SendMessage, Share | - | AddFriend |
event OnResultHandler<GUABaseResult> FriendBaseEvents;
The list of methods used to process the callback events.
Callback Event | Common | [Player Network SDK Only] | [MSDK Only] |
---|---|---|---|
OnBaseResultNotify | SendMessage, Share | - | AddFriend |
class GUA_EXTERN GUAFriendObserver
{
public:
virtual ~GUAFriendObserver() {};
virtual void OnBaseResultNotify(const GUABaseResult &base_ret){};
}
Code Sample
- Unity
- Unreal Engine
// Add callbacks
UnionAdapterAPI.GetFriendService().FriendBaseEvents += OnFriendBaseEvent;
// Remove callbacks
UnionAdapterAPI.GetFriendService().FriendBaseEvents -= OnFriendBaseEvent;
// FriendBaseEvents callback
private void OnFriendBaseEvent(GUABaseResult baseRet)
{
string methodTag = "";
if (baseRet.MethodId == (int)GUAMethodID.GUA_FRIEND_SHARE)
{
methodTag = "Share";
}
else if (baseRet.MethodId == (int)GUAMethodID.GUA_FRIEND_SEND_MESSAGE)
{
methodTag = "SendMessage";
}
Debug.Log.(methodTag + baseRet.ToString());
}
// 1. Define an observer class that inherits from GUA_NAMESPACE::GUAFriendObserver at the engine level.
// 2. Implement a callback interface with the same method name such as OnBaseResultNotify
class FGUAFriendObserver : public GUA_NAMESPACE::GUAFriendObserver {
public:
static FGUAFriendObserver Instance;
void OnBaseResultNotify(const GUA_NAMESPACE::GUABaseResult& base_ret)
{
}
};
FGUAFriendObserver FGUAFriendObserver::Instance;
//Configure the callback
GUA_NAMESPACE::GUAFriendService::SetFriendObserver(&FGUAFriendObserver::Instance);