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

buildMatch #

open fun buildMatch(queueKey: MatchmakingQueueKey, potentialMatch: PotentialMatch, matchable: Matchable)

Called during the main matchmaking loop. The PotentialMatch represents a collection of parties that could form the teams for a match. The Matchable are parties that could be added to the PotentialMatch. This method is called many times, evaluating each party that has joined the matchmaking queue. If the PotentialMatch is marked as ready to start, it will be removed from the matchmaking queue and sent to the game server. If a PotentialMatch is compared against every other Matchable in the queue and not marked as ready to start, the next matchmaking loop will run with a new PotentialMatch seeded with a different set of parties.

Things that can be done in this method:

  • Move parties between the PotentialMatch and the Matchable by calling PotentialMatch.movePartiesFrom and Matchable.movePartiesFrom
  • Assign players to a team by calling PotentialMatch.assignPlayersToTeam and Matchable.assignPlayersToTeam
  • If the PotentialMatch is ready to start, start it now by calling PotentialMatch.startMatch

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

Used by:

  • MatchmakingService (runs forever, see MatchmakingConfig)

Parameters #

queueKey

There are separate queues for each distinct MatchmakingQueueKey.

potentialMatch

The current PotentialMatch that matchmaking is attempting to fill and start.

matchable

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

open fun buildMatch(queueKey: MatchmakingQueueKey, activeMatch: ActiveMatch, matchable: Matchable)

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

Things that can be done in this method:

  • Move parties from the Matchable into the ActiveMatch by calling ActiveMatch.movePartiesFrom
  • Assign players to a team by calling ActiveMatch.assignPlayersToTeam

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

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

Used by:

  • MatchmakingService (runs forever, see MatchmakingConfig)

Parameters #

queueKey

There are separate queues for each distinct MatchmakingQueueKey.

activeMatch

The current ActiveMatch that matchmaking is attempting to provide more players.

matchable

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