How to use register_rt_after()

I’m trying to make nakama notify all logged-in players when a new match has been created.

Based on the documentation, I assumed I need to hook on match creation like this

nk.register_rt_after(announce_new_match, "MatchCreate")

But this never seems to call my announce_new_match() function. What am I doing wrong?

Ah wait I think I understand. This doesn’t work for Authoritative matches!

@db0 An authoritative match has its own lifecycle. You can think of it as its own entity in your game which lives on the server. There’s a number of ways to find the match to join it (match listings, matchmaker, in-app notifications, status events, etc, etc.) How you share the match ID with other users depends on the requirements of your game.

The users can then join the match and will be told about who’s already in the match and any other participants who join and leave as socket events. Hope this helps.

Yeah I’m using a method which involves the client doing an rpc for a match listing function. I would have preferred this to be a “push” notifcation (with possible in-app notifications) instead of a scheduled “pull” notification from each client, but currently this is blocking me on this approach.

@db0 Can you describe the game design you have in mind? Why would you need to list matches immediately after you’ve created a match? I’ve never seen that use case.

I’m trying to create a lobby-like setup which is common in card games. A player will create a pre-game lobby and wait for other people to join.

The plan to list all matches after creating a match was to send an updated listing of all current matches to all logged-in players. I could send the newly created match in isolation, but I could see no other way to inform on deleted or already started matches as well.

Disclaimer: I’m pretty new at this so I discover as I go. It may be that my approach and expectations are completely wrong :slight_smile:

What you’re asking for is indeed possible:

  1. You can have all users join a stream as soon as they connect, and publish match info when matches start/end to that stream. These lifecycle events would be easy to publish from an authoritative match handler.
  2. Separately you list all matches to populate an “initial” match list view.

That said I would argue it’s not an ideal pattern. A full match list and constant updating view would quickly become too noisy/large to be useful. You might also consider privacy aspects, or perhaps you might want to avoid anyone and everyone using the list to gauge the “health” of the game.

I suggest using the matchmaker to let players find games, or at least more targeted match listings. You know your requirements best but as a player probably I’d find a small selection of suitable matches must more useful, rather than a giant list of matches I don’t care about or can’t join. (Match already full? Not my desired game mode? etc)

1 Like

I’m working on a godot-based card game framework rather than any specific game, so at the moment I’m creating functionality for both options. A lobby-listing style is really popular among online card-game cycles and what I’m more familiar with, so I started with that, but I do plan to implement a matchmaking system as well.

That will allow the designer of any game using my framework to use the approach that fits their game.

PS: A lobby system is actually better than a matchmaker when your game does not havea big playerbase. It allows for more play styles, without splitting the player-base and increasing seek times. Also, it’s a more social approach. MM games tend to feel impersonal. I’m coming to this from working/developing games with small but dedicated playerbases for a long time :slight_smile: