How to connect Dedicated Server instance with Nakama Match Instance

I am building a multiplayer game using unreal engine.

  • The game has a client where players sign in to the game with nakama.
  • Than they join matchmaking using nakama.
  • When the nakama match is created the nakama match communicates with Agones to allocate a game server.
  • Once the game server is ready the nakama match than broadcasts the ip and port of the game server to the presences in the match.

In the scenario above the communication between the game client and the nakama match instance is handled by the nakama sdk.
But my understanding is (correct me if I am wrong) such functionality does not exist for the game server and the game server can not use the nakama sdk to comunicate with nakama (server to server).

I want the game server to be able to communicate with the nakama match instance for the following:

1- The game server should be able to call rpc functions on the match it is associated with to relay important information and events such as who won and lost so the match can than grant winners prizes
2- The game server should be able to validate that the players connecting to it are part of the nakama match associated with it.

I should be able to pass the match id as command line variable to the game server (but I would appreciate suggestions)

But I don’t know what to do after as I don’t know how to call rpc functions on a specific match without using nakama sdks. How can this be achieved?

EDIT: I read that the nakama match should be removed once the players are connected to the dedicated server and that is ok by me. But it is important that I can somehow validate that the players connecting to the game server are the presences in the match so at the end of the game when using server to server rpc call I grant the correct users the rewards etc.

Hello @alireza,

This seems like a good candidate for a new feature that was recently introduced in Nakama: fleet manager support.

You can see an example of its implementation here (for Amazon GameLift): GitHub - heroiclabs/nakama-gamelift: Nakama Fleet Manager and AWS GameLift adapter. .

It would be great if the OSS community would like to contribute to the implementation of the interface for Agones too.

Otherwise, you can communicate with a match using the Signal API: Function Reference - Heroic Labs Documentation .

This runtime function can be exposed as a S2S call and will allow you for a match to respond to arbitrary inputs. You must implement the input handling logic in the dedicated MatchSignal match handler.

Hope this helps.

1 Like

Ok I have to change the answer to my own as I found a very great way to handle this.
This is more related to Agones but I would guess a lot of people will be using this combination and it would benefit nakama developers to know of it, without having to learn, understand and implement Fleet Manager for Agones.
Basically when sending a game server allocation request to agones you can provide info through labels and annotations .

  • Labels primary usage is to group game servers.
  • Annotations is what we want. we can put data such as Game Mode or Access Keys to agones game server so it knows what it should do before players actually connect.

For example an unreal engine dedicated server map might be a big open world. maybe we want it to be loaded even when in ready state, but maybe we don’t. maybe the players select what map they want to play when requesting match making by passing it in their nakama match making request using string and number parameters.

And after players have been matched by nakama you can provide the matched player ids and requested map to agones using annotations.

The agones unreal engine plugin provides you two options to get this information or listen to when these information have been changed so this way when the game server is allocated it can open the correct map for players to connect to.

That use case was a bit arbitrary and basic, as maybe the game server could have handled it internally after all clients have connected (some extra delay XD)

But more importantly you can provide access keys and user ids to agones.

This way agones can validate client connections and match them to their correct nakama user ids so when using server to server rpc calls on nakama you have the correct user ids to use for rewards, progression etc.