FAForever / server

The servercode for the Forged Alliance Forever lobby
http://www.faforever.com
GNU General Public License v3.0
66 stars 61 forks source link

RFC: Take matchmaking requests from RabbitMQ #675

Open Brutus5000 opened 4 years ago

Brutus5000 commented 4 years ago

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.

Askaholic commented 4 years ago

Some thoughts:

Brutus5000 commented 4 years ago
Askaholic commented 4 years ago

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?

Brutus5000 commented 4 years ago

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.

Askaholic commented 3 years ago

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

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.

Brutus5000 commented 3 years ago

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

Askaholic commented 3 years ago

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 commented 3 years ago

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.

Brutus5000 commented 3 years ago

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.

Askaholic commented 3 years ago

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