DetectNetWortResultObserver [Player Network SDK Only]
Register the callback for network diagnostics, the game needs to process the callback function. For more information on the callback data structure, see GUADetectNetWortResult.
note
It is strongly recommended to perform registration in the startup function of the game application.[Player Network SDK Only].
Function Definition
- Unity
- Unreal Engine
The list of methods used to process the callback events.
Callback Event | Common | [Player Network SDK Only] | [MSDK Only] |
---|---|---|---|
DetectNetWortResultEvents | - | StartDetectNetwork | - |
event OnResultHandler<GUADetectNetworkResult> DetectNetWortResultEvents;
The list of methods used to process the callback events.
Callback Event | Common | [Player Network SDK Only] | [MSDK Only] |
---|---|---|---|
OnDetectNetworkResultNotify | - | StartDetectNetwork | - |
class GUA_EXTERN GUADetectNetworkObserver
{
public:
virtual ~GUADetectNetworkObserver(){};
virtual void OnDetectNetworkResultNotify(const GUADetectNetworkResult &detect_network_ret) {};
};
Code Sample
- Unity
- Unreal Engine
UnionAdapterAPI.GetToolsService().DetectNetWortResultEvents += OnDetectNetWortResultEvents;
UnionAdapterAPI.GetToolsService().DetectNetWortResultEvents -= OnDetectNetWortResultEvents;
private void OnDetectNetWortResultEvents(GUADetectNetworkResult result)
{
string methodTag = "";
if (result.MethodId == (int)GUAMethodID.GUA_TOOLS_DETECT_NETWORK)
{
methodTag = "OnDetectNetworkResult";
}
Debug.Log(methodTag + result.ToString());
}
// 1. Define an observer class that inherits from GUA_NAMESPACE::GUADetectNetworkObserver at the engine level.
// 2. Implement a callback interface with the same method name such as OnDetectNetworkResultNotify
class FGUADetectNetworkObserver : public GUA_NAMESPACE::GUADetectNetworkObserver {
public:
static FGUADetectNetworkObserver Instance;
void OnDetectNetworkResultNotify(const GUA_NAMESPACE::GUADetectNetworkResult &ret)
{
}
};
FGUADetectNetworkObserver FGUADetectNetworkObserver::Instance;
//Configure the callback
GUA_NAMESPACE::GUAToolsService::SetDetectNetworkObserver(&FGUADetectNetworkObserver::Instance);