server icon indicating copy to clipboard operation
server copied to clipboard

RFC: Take matchmaking requests from RabbitMQ

Open Brutus5000 opened this issue 4 years ago • 10 comments

This should be the missing piece in my envisioned galactic war architecture.

Similar to ladder or tmm I need a way to force players into an automatch (no lobby). As this is not always successfull, I also need a feedback loop.

So we should implement a rabbitmq protocol such as:

routing key request.match.create:

{
  "requestId": "<random uuid>",
  "matchmakerQueueId": 1,
  "featuredMod": 13,
  "gameName": "Battle on Yavin IV #12",
  "mapName": "NeroxisMapGenerator_1.11.2_magic_seed",
  "participants": [
   {
       "playerId": 13443,
       "team": 2,
       "slot": 1,
       "faction": "aeon"
   },
   {
       "playerId": 13443,
       "team": 3,
       "slot": 2,
       "faction": "uef"
   },
]
}

routing key success.match.create:

{
  "requestId": "<uuid of original request>",
  "gameId": 98765
}

routing key error.match.create:

{
  "requestId": "<uuid of original request>",
  "errorCode": 123,
  "args": [
  {
     "playerId": 13443
   }
  ]
}

The error codes need to be defined precisely as it might cause punishments if it fails because a player was already in a game or similar.

Brutus5000 avatar Sep 29 '20 22:09 Brutus5000

Some thoughts:

  • You mentioned GW is essentially a matchmaker. Would we want to link those games to a particular matchmaker queue? In that case we might include a queue id in the request. Maybe it's not such a big deal because GW is also a mod, so games will always be played on the GW featured mod right? Is there a particular logic for including the featured mod in the request message, or just future proofing?
  • Maybe send map file path instead of map version. That would allow more flexibility with playing on maps that are not in the vault such as map generator maps. Plus I think the server already just uses the file paths everywhere.
  • One issue we have in the protocol right now is that we are inconsistent about how we serialize factions. Sometimes it's by number, but we've been trying to move towards strings instead. I'm actually not convinced one way or the other, but it's something to think about.

Askaholic avatar Oct 05 '20 20:10 Askaholic

  • file path instead of map version: Agreed, I'd like to move to generated maps anyway.
  • factions: Agreed, a more expressive protocol is better
  • Matchmaker queue: We can do that. What would be the benefits? I don't know enough about the queue logic. The most critical issue I see with GW matchmaking is, that people start other non-GW games (ladder, custom) and then the matchmaking fails. Can we prevent that using matchmaker queues?

Brutus5000 avatar Oct 06 '20 07:10 Brutus5000

The main reason we have the game to queue association right now is so that we can look up a player's last few matches in that queue and make sure they don't get the same map twice in a row. But I imagine there are lots of useful statistics you can extract about the matchmaker if you know how many games are being generated by the queues. For GW this same thing could probably be achieved just by looking at the featured mod, but maybe it would be nicer to just have everything use the same system instead of writing special cases for GW.

The lobby server is able to prevent people from joining games while they're in queue and vice versa. However, that's because it knows when you join a queue and keeps track of that state internally. If the GW matchmaking is happening outside of the lobby server, then we might need to add some communication for when a player starts/stops searching. I'm not sure how that would even look. Like do you go to the GW tab and click "Join" somewhere?

Askaholic avatar Oct 06 '20 21:10 Askaholic

I'm not sure how that would even look. Like do you go to the GW tab and click "Join" somewhere?

This is an open question for now. From a client perspective that makes most sense to avoid unintentional/forbidden user actions.

I'll add the field.

Brutus5000 avatar Oct 07 '20 21:10 Brutus5000

Your issue in the gw-backend repo mentions some more parameters:

  • Additional mods or build restrictions
  • ~~Player's selected reinforcements~~

I think the additional mods should be OK since I would want the game_launch command to be able to support those anyways for other matchmakers. Probably same with build restrictions. But reinforcements are gw specific so I don't think they would be a good fit for this message. Those would have to be communicated to the client through the gw server.

Askaholic avatar Apr 05 '21 22:04 Askaholic

Fine for me. Shared stuff goes into the lobby protocol, gw-specific stuff needs to be handled elsewhere.

Brutus5000 avatar Apr 06 '21 10:04 Brutus5000

I read through some of the rabbitmq tutorials in the docs and it looks like AMQP already has support for a correlation_id in the message properties, so I don’t think we need to reimplement this with the requestId field in our message. See the section on correlation id here: https://www.rabbitmq.com/tutorials/tutorial-six-python.html

Askaholic avatar Apr 20 '21 18:04 Askaholic

I think I'd prefer snake case keys for consistency. So far our other rabbitmq messages as well as other server messages all use snake case keys. The only weird thing is that our routing keys use camel case.

Askaholic avatar May 03 '21 22:05 Askaholic

And the API is all camel case. We won't reach consistency across FAF. :( But I'll never understand the desire to add additional useless characters anyway.

Brutus5000 avatar May 04 '21 21:05 Brutus5000

I think we also want a game_name field as well for the game title.

Askaholic avatar May 06 '21 20:05 Askaholic