Amazon GameLift
Developer Guide (Version )

Add FlexMatch to a Game Server

This topic describes how to add Amazon GameLift FlexMatch functionality to your game server. Use FlexMatch to customize a matchmaking experience for your players.

To set up your game server for matchmaking for your players, you must have first completed the following tasks:

  • Successfully integrate Amazon GameLift into your game server. See Add Amazon GameLift to Your Game Server for more details.

  • Create a matchmaking configuration, rule set, and game session queue. See Design a FlexMatch Matchmaker for more details.

  • Integrate your game client to make matchmaking requests. You'll need to make requests in order to test your game server integration.

Once you've integrated Amazon GameLift into your game server, most of the mechanisms you'll need to communicate with Amazon GameLift about matched games are already in place. To enable your game server to accommodate matchmaking requests, you need to change your code for starting a game session. This code is in your implementation of the callback function onStartGameSession(). For more details on implementing this function, see Start a Game Session.

To set up your game server for matchmaking:

  1. Add code to create a game session based on the matchmaking request. When Amazon GameLift sends an onStartGameSession() request to your game server to start a new game session, it includes a game session object (see GameSession). This object contains information your game server needs to start a game session for the match, including custom game session data and match data generated by the matchmaker which includes team structure and player assignments.

  2. Report ready. When the game session is started and ready to accept players, report back to the Amazon GameLift service with the API call ActivateGameSession(). This step is the same as when starting a non-matched game session.

  3. Handle player connections. As with non-matched games, players connect to the new game session with a player session ID and must be validated (see Validate a New Player). In addition, a player connection request must include a player ID for matched games. Add code to your game server to match a connected player's player ID to their correct team assignment in the match.

Game Data

The GameSession object is passed to your game server when Amazon GameLift calls the callback function onStartGameSession.

All game session start requests include the following information: game session ID, name, maximum player count, and the IP address and port that players will use to connect to the new game session. If provided, developer-defined game properties (key:value pairs) and game session data (strings) are also included.

For matched games, the GameSession object contains the following additional information:

  • Matchmaker data – This set of information specifies the match details, including the players, teams, and player and team attributes. For example, the following matchmaker data describes a match with two teams, red team and blue team, with two players on each team.

    { "matchId": "123456-abcd-4324-922f-88cd8c490422", "teams": [{ "name": "red", "players": [{ "playerId": "Player-1", "attributes": { "skill": { "attributeType": "DOUBLE", "valueAttribute": 2.0 } } }, { "playerId": "Player-2", "attributes": { "skill": { "attributeType": "DOUBLE", "valueAttribute": 3.0 } } } ] }, { "name": "blue", "players": [{ "playerId": "Player-3", "attributes": { "skill": { "attributeType": "DOUBLE", "valueAttribute": 3.0 } } }, { "playerId": "Player-4", "attributes": { "skill": { "attributeType": "DOUBLE", "valueAttribute": 2.0 } } } ] } ] }

On this page: