GUAQuereyFriendObserver
[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 GUAFriendResult.
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 | QueryFriends | - | - |
event OnResultHandler<GUAFriendResult> QuereyFriendEvents;
The list of methods used to process the callback events.
Callback Event | Common | [Player Network SDK Only] | [MSDK Only] |
---|---|---|---|
OnQueryFriendNotify | QueryFriends | - | - |
class GUA_EXTERN GUAFriendObserver
{
public:
virtual ~GUAFriendObserver() {};
virtual void OnQueryFriendNotify(const GUAFriendResult &friend_ret){};
};
Code Sample
- Unity
- Unreal Engine
// Add callbacks
UnionAdapterAPI.GetFriendService().QuereyFriendEvents += OnFriendQueryFriend;
// Remove callbacks
UnionAdapterAPI.GetFriendService().QuereyFriendEvents -= OnFriendQueryFriend;
// QuereyFriendEvents callback
private void OnFriendQueryFriend(GUAFriendResult friendRet)
{
string methodTag = "";
if (friendRet.MethodId == (int)GUAMethodID.GUA_FRIEND_QUERY_FRIENDS)
{
methodTag = "QueryFriends";
}
Debug.Log(methodTag + friendRet.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 OnQueryFriendNotify
class FGUAFriendObserver : public GUA_NAMESPACE::GUAFriendObserver {
public:
static FGUAFriendObserver Instance;
void OnQueryFriendNotify(const GUA_NAMESPACE::GUAFriendResult& friend_ret)
{
}
};
FGUAFriendObserver FGUAFriendObserver::Instance;
//Configure the callback
GUA_NAMESPACE::GUAFriendService::SetFriendObserver(&FGUAFriendObserver::Instance);