How to call a registered RPC method from a Match, server-side (in Typescript)

  1. Versions: Nakama 3.13.1, Docker
  2. Server Framework Runtime language TS/JS

Hello, I was wondering if it was at all possible to call a “server-to-server” RPC from within the server itself. In this case, as soon as the match is over, I want to make a call to some shared functionality that’s currently registered via an RPC, however I’m having a really difficult time finding a way to access said RPC. I’ve looked around the nk: nkruntime.Nakama, ctx: nkruntime.Context, and dispatcher: nkruntime.MatchDispatcher, but there seems to be no way to directly call the RPC.

I suppose something like a fetch call to, could be used, but it’ll require some authentication and such. Feels like really bad way to do it from the server itself.

I’ve been pulling my hair out over this, it feels like I’m missing something obvious. Any help or pointing in the correct direction would be really appreciated.

Hey @Raid why not just call what would be the RPC as a regular Go function? The client can call the RPC, and the server can just invoke the function.

This is what I ended up doing! There seems to be some limitations to which type of objects can be registered as a Match (in TypeScript), and I thought it’d be similar for RPC calls. But I figured it’d be easier to access the registered RPC methods, seeing that they get some context and such injected. It’s not a big issue or anything, just something I was wondering about. This’ll work fine for now. Thanks for the suggestion!

1 Like