Skip to content

Register callbacks for receiving chat strings

The remote play chat feature can be implemented in such a way that when a user types a string during remote play, it is sent to the host PC's game chat window.

1) When the user enters a string in the text box dedicated to remote play on the web as shown below and presses the enter key, the string is sent to the host PC game. * The maximum input length for remote play is 150 characters, and the reading directions are LTR (Left to Right) and RTL (Right to Left).

2) In host PC games, strings are received through pre-registered callback functions.

3) In host PC games, the corresponding string is passed to the game chat window.

Registering Callback Functions

To use the chat feature in Remote Play, you need to register callback functions after importing the Remote Play plugin.

By registering the callback functions, the chat feature will be ready to use during Remote Play, allowing the game to apply the strings received from Remote Play to the chat functionality according to each game environment.

The strings received in the game through the callback functions are encoded in UTF-8 and converted to Base64. Additionally, they include reading direction information, enabling multilingual support.

Register the callback function with HiveRemotePlayManager.RegisterCallback as shown below.

using AOT; // Required for MonoPInvokeCallback

public class {YourCustomClass} : MonoBehaviour { // YourCustomClass: Class used in your user game
#if !UNITY_EDITOR && UNITY_STANDALONE_WIN
    [MonoPInvokeCallback (typeof(HiveRemotePlayManager.RemotePlayCallbackType))]
    public static void RegisterRemoteCallbackFunction(int type, string remotePlayJsonData)
    {
        Debug.Log("REMOTE Callback DATA :" + remotePlayJsonData); // Receiving json data sent from RemoteSDK.
    }
#endif

    void Start() {
#if !UNITY_EDITOR && UNITY_STANDALONE_WIN
        HiveRemotePlayManager.RegisterCallback(RegisterRemoteCallbackFunction);
#endif
    }
}

Add the following content to [Your_Project_Root]/Source/[Your_Project_Name]/[Your_Project_Name].build.cs. Replace [Your_Project_Name] with the actual name of your project.

public class <Your_Project_Name> : ModuleRules
{
    public <Your_Project_Name>(ReadOnlyTargetRules Target) : base(Target)
    {
        ...
        PublicDependencyModuleNames.AddRange(new string[] { "HiveRemotePlay" });
        ...
    }
}

An example of the code used during project implementation is as follows.

#include "RemotePluginInterface.h"  // Required in the project's build.cs: PublicDependencyModuleNames.AddRange(new string[] { "HiveRemotePlay" });

// Example API 1. Temporal API Name
void SendRemotePlayKeyCallback(int _type, const char* _pData) {
    UE_LOG(LogTemp, VeryVerbose, TEXT("==================SendRemotePlayKeyCallback================\n"));
    char typeBuffer[35];
    char* typeStr;
    typeStr = _itoa(_type, typeBuffer, 10);
    UE_LOG(LogTemp, VeryVerbose, TEXT("type : %s \n"), *FString(typeStr));
    UE_LOG(LogTemp, VeryVerbose, TEXT("type : %s \n"), *FString(_pData)); // Example: {"version":"1.0.250300","eventType":"Message","eventValue":{"value":"MTFIZWxsbyBrZXkgaW5wdXQgMQ==","action":"LTR"},"etc":{}} 
}

// Example API 2. Call this API after signing in, EX) inner sign-in Callback
void RegisterHiveRemoteCallback {
    RegisterCallback(SendRemotePlayKeyCallback);
}

Chat string protocol

The protocol for the chat string received through the callback function in the game is as follows.

Web - Client JSON protocol

Key Value Type Description ETC
version version number Json version information Refer to example
eventType eventType string Event type - only Message item exists Refer to example
eventValue eventValue object Event value object Refer to example
eventValue - value eventValue - value string Event value Refer to example
eventValue - action eventValue - action string Event action Refer to example
etc etc object For extension purposes Refer to example

Chat string data example

The chat string received through the callback function in the game has the following JSON data format.

{
    "version"        : "1.0.2411.0",
    "eventType"       : "Message" ,
    "eventValue"     : {
                            "value"  : "Something Message",
                            "action" : "LTR | RTL"
                       },
    "etc"            : { }
}
// value    : Base64  (UTF-8 문장) 인코딩
// action   : LTR (아랍어를 제외한 문자) | RTL (아랍어)