TranslatorResultObserver
Register the callback of the Player Network SDK Translate module, the game needs to process the callback function. For more information on the callback data structure, see BaseResult.
note
It is strongly recommended to perform registration in the startup function of the game application.
Function definition
// configure callback
public static void AddTranslatorObserver(OnINTLResultHandler<INTLBaseResult> callback);
// remove callback
public static void RemoveTranslatorObserver(OnINTLResultHandler<INTLBaseResult> callback);
Code sample
// configure callback
public void AddTranslatorObserver()
{
INTLAPI.AddTranslatorResultObserver(OnTranslatorResultEvent);
}
// remove callback
public void RemoveTranslatorObserver()
{
INTLAPI.RemoveTranslatorResultObserver(OnTranslatorResultEvent);
}
// handle callback
private void OnTranslatorResultEvent(INTLTranslatorResult result)
{
if (result.MethodId == (int)INTLMethodID.INTL_TRANSLATOR_TRANSLATE)
{
// handle translate request result
// TranslatorResp from INTLTranslatorResult as below:
// succeed
{
"msg":"success",
"ret":0,
"seq":"11-0ce2f314-8771-4d97-955b-66f972dc0706-1723023056-7",
"translator_rsp":{
"debugInfo":null,
"message":"Success",
"result":[
{
"id":"c5b2802a287f58c9ce250f8c77fc6029",
"output":"xxxx",
"text":"xxxx"
}
],
"retCode":"0"
}
}
}
}