How to use gRpc?

Hello Everyone.
I am developing a multiplayer game in Unity using Mirror as game server framework and Nakama for the backend (Authentication, scores, items, etc).
So when the Game ends my Game server is sending the score updates to Nakama using the server to server feature like this:

var client = new Client("http", "api.mygame.com", Convert.ToUInt16(7350), serverKey, UnityWebRequestAdapter.Instance);
            return await client.RpcAsync(httpKey, "myRpcFunc", jsonPayload);

I would like to use gRpc in my server to server communications. Is it possible? How can I do it?

Thanks in advance,
Claudio

Hello @calamas,

You can setup your own grpc client by using the appropriate dotnet protoc generator with the correct grpc-gateway plugins and feeding it the Nakama proto definitions.

You should then be able to use the generated stubs to connect to the Nakama gRPC port.

Best

As a follow-up, may I enquire why you would like to use grpc for S2S calls?

Thanks for your response.
Do you have any code example of the use of a gRpc function?

My game is being developed in Unity with Mirror. When the Mirror game server instance ends the game, I am sending the score update of each player to nakama. I am currently using an http call like this one:

var client = new Client("http", "api.mygame.com", Convert.ToUInt16(7350), serverKey, UnityWebRequestAdapter.Instance);
            return await client.RpcAsync(httpKey, "myRpcFunc", jsonPayload);

I think that, as gRpc is more efficient than http, it would be better to send this using gRpc in order to reduce network traffic. Does my approach have logic or am I misunderstanding something about the gRpc calls and its usage?

Regards,
@calamas

You are correct in that it would be more efficient on the network and bandwidth, but the trade-off is that it would require more set-up and code, as you’d need to manage the connection yourself and lose all the niceties that the SDK gives you (such as automatic retries, and others).
Honestly, I don’t think it’s worth it unless you absolutely need to highly optimise performance and bandwitdh.

Ok. I was thinking that I would be able to use the sdk the same way I am using it with http with all its advantages, but with gRpc. I will be following your advice and stick with http.

Thanks for your time