heroiclabs / nakama-cpp

Generic C/C++ client for Nakama server.
https://heroiclabs.com/docs/cpp-client-guide
Apache License 2.0
69 stars 25 forks source link

Feature: Add possibility to add parameters to RPC request #29

Open Ruhrpottpatriot opened 4 years ago

Ruhrpottpatriot commented 4 years ago

From within UE4 I call an rpc function like this:

        auto successFunc = [](const Nakama::NRpc& rpc)
        {
            UE_LOG_ONLINE_SESSION(Log, TEXT("Session Create Success"));
        };
        Nakama::ErrorCallback errorFunc = [](const Nakama::NError& error) 
        {
            UE_LOG_ONLINE_SESSION(Error, TEXT("Session Create Error: %s"), UTF8_TO_TCHAR(error.message.c_str()));
        };

        std::string foo = R"({"owning_user_id": "Test","owning_username":"TestName","session_name": "GameSession","session_state": 0})";
        client->rpc(sessionPtr, "sessions/create", foo, successFunc, errorFunc);

In some cases there might be the need to add url parameters or headers to an RPC request. However this is currently not possible.

For example a user might have an RPC that updates data of a player-party. Showing the intent by using PUT could make api intent clearer. Another example would be a server whose response to a procedure can be a different MIME type and the client passes the type via header.