game-common / pragma.matchmaking / MatchmakingPlugin / matchPartiesWithGame /

matchPartiesWithGame #

open fun matchPartiesWithGame(queueKey: MatchmakingRpc.MatchmakingQueueKey, anchor: Matchmaking.Matchable, game: Matchmaking.GameInstance): GameInstanceUpdate?

Called during the main matchmaking loop. The Matchmaking.GameInstance represents a live game instance that has re-entered matchmaking, and this method will not be called until a Matchmaking.GameInstance has re-entered matchmaking requesting more players. The Matchmaking.Matchable contains parties that could be added to the Matchmaking.GameInstance. This method is called many times, evaluating each party that has joined the matchmaking queue.

Things that can be done in this method:

  • If parties can be moved into the Matchmaking.GameInstance create and return a GameInstanceUpdate.
  • Return null to continue searching for more players.

If returning a GameInstanceUpdate:

  • Add parties to the game instance by calling GameInstanceUpdate.addParties. You can optionally set their team number or use the default team number 0.
  • Assign players to a team as necessary using GameInstanceUpdate.setTeamByPlayers.
  • Call the GameInstanceUpdate.continueMatchmaking method if the Matchmaking.GameInstance should continue to find players.

Any parties moved into the GameInstanceUpdate will be connected to the game server after this method completes.

If this method throws an exception both the Matchmaking.GameInstance and Matchmaking.Matchable will be removed from the queue along with the players in the Matchmaking.Matchable, who are notified.

Used by:

  • MatchmakingService (runs forever, see MatchmakingConfig)

Parameters #

queueKey

There are separate queues for each distinct MatchmakingQueueKey.

game

The current Matchmaking.GameInstance that matchmaking is attempting to provide more players.

anchor

A set of parties to be considered from the same matchmaking queue.