C++: RPC callback contains no id


I’m using the C++ API for making a multiplayer simple client for a game developed in Unity. This client is just for connecting to matches and basically being a development time “bot”. The API works fine and I can connect, seek matches, join matches etc. Now I need to run a few RPC calls to get some data from the server. The one RPC call that I tried so far works kinda ok, but the response is missing important data. My code is like below:

NClientPtr client;
NSessionPtr session;
client->rpc(session, "get_stuff", opt::nullopt, rpcOkCallback, errorCallback);

void rpcOkCallback(const NRpc& rpc) {
    std::cout << "RPC data received" << std::endl;
    std::cout << "    id:       " << rpc.id << std::endl;
    std::cout << "    payload:  " << rpc.payload << std::endl;
    std::cout << "    HTTP key: " << rpc.httpKey << std::endl;

This gives me:

RPC data received
    payload: <correct JSON data>
    HTTP key:

The payload contains what it should, but the id and httpKey fields are always empty. I would assume that id should be get_stuff in this case. I also can’t really find any docs at all that would explain what values they can have, but the NRpc struct implies that all fields should always be populated:

    /// Execute an Lua function on the server.
    struct NAKAMA_API NRpc
        std::string id;            ///< The identifier of the function.
        std::string payload;       ///< The payload of the function which must be a JSON object.
        std::string httpKey;       ///< The authentication key used when executed as a non-client HTTP request.

It’s in our case a Go function, but I assume the mention of Lua in the comment is just bit rot.

So, should the id be filled in or do I need to keep track of what RPC call I’m currently executing.

Hey @chakie this looks like an oversight on the server itself. Could you file an issue on Nakama on Github? GitHub - heroiclabs/nakama: Distributed server for social and realtime games and apps.

Ok, so it’s something that affects all SDK:s? I created an issue Reply to RPC call from the C++ SDK is missing data · Issue #688 · heroiclabs/nakama · GitHub but mostly just linked back to this question.

Well, the issue was closed immediately. Maybe the docs should be updated to reflect in what cases a struct like NRpc is supposed to contain values.