startMatchBackfill method

Future<StartMatchBackfillOutput> startMatchBackfill({
  1. required String configurationName,
  2. required List<Player> players,
  3. String? gameSessionArn,
  4. String? ticketId,
})

Finds new players to fill open slots in an existing game session. This operation can be used to add players to matched games that start with fewer than the maximum number of players or to replace players when they drop out. By backfilling with the same matchmaker used to create the original match, you ensure that new players meet the match criteria and maintain a consistent experience throughout the game session. You can backfill a match anytime after a game session has been created.

To request a match backfill, specify a unique ticket ID, the existing game session's ARN, a matchmaking configuration, and a set of data that describes all current players in the game session. If successful, a match backfill ticket is created and returned with status set to QUEUED. The ticket is placed in the matchmaker's ticket pool and processed. Track the status of the ticket to respond as needed.

The process of finding backfill matches is essentially identical to the initial matchmaking process. The matchmaker searches the pool and groups tickets together to form potential matches, allowing only one backfill ticket per potential match. Once the a match is formed, the matchmaker creates player sessions for the new players. All tickets in the match are updated with the game session's connection information, and the GameSession object is updated to include matchmaker data on the new players. For more detail on how match backfill requests are processed, see How Amazon GameLift FlexMatch Works.

Learn more

Backfill Existing Games with FlexMatch

How GameLift FlexMatch Works

Related operations

May throw InvalidRequestException. May throw NotFoundException. May throw InternalServiceException. May throw UnsupportedRegionException.

Parameter configurationName : Name of the matchmaker to use for this request. You can use either the configuration name or ARN value. The ARN of the matchmaker that was used with the original game session is listed in the GameSession object, MatchmakerData property.

Parameter players : Match information on all players that are currently assigned to the game session. This information is used by the matchmaker to find new players and add them to the existing game.

  • PlayerID, PlayerAttributes, Team -\\- This information is maintained in the GameSession object, MatchmakerData property, for all players who are currently assigned to the game session. The matchmaker data is in JSON syntax, formatted as a string. For more details, see Match Data.
  • LatencyInMs -\\- If the matchmaker uses player latency, include a latency value, in milliseconds, for the Region that the game session is currently in. Do not include latency values for any other Region.

Parameter gameSessionArn : Amazon Resource Name (ARN) that is assigned to a game session and uniquely identifies it. This is the same as the game session ID.

Parameter ticketId : A unique identifier for a matchmaking ticket. If no ticket ID is specified here, Amazon GameLift will generate one in the form of a UUID. Use this identifier to track the match backfill ticket status and retrieve match results.

Implementation

Future<StartMatchBackfillOutput> startMatchBackfill({
  required String configurationName,
  required List<Player> players,
  String? gameSessionArn,
  String? ticketId,
}) async {
  ArgumentError.checkNotNull(configurationName, 'configurationName');
  _s.validateStringLength(
    'configurationName',
    configurationName,
    1,
    256,
    isRequired: true,
  );
  ArgumentError.checkNotNull(players, 'players');
  _s.validateStringLength(
    'gameSessionArn',
    gameSessionArn,
    1,
    256,
  );
  _s.validateStringLength(
    'ticketId',
    ticketId,
    0,
    128,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'GameLift.StartMatchBackfill'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ConfigurationName': configurationName,
      'Players': players,
      if (gameSessionArn != null) 'GameSessionArn': gameSessionArn,
      if (ticketId != null) 'TicketId': ticketId,
    },
  );

  return StartMatchBackfillOutput.fromJson(jsonResponse.body);
}