Amazon GameLift and game client server interactions - Amazon GameLift
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Amazon GameLift and game client server interactions

This topic describes the interactions between the game client, a backend service, a game server, and Amazon GameLift.

The following diagram illustrates interactions between the game client, backend service, Amazon GameLift SDK, managed EC2 game server, Amazon GameLift server SDK, and Amazon GameLift. For a detailed description of the interactions shown, see the following sections on this page.

Game client/server interactions for the use cases listed in the following sections.

Initialize a game server

The following steps describe the interactions that occur when you prepare your game server to host game sessions.

  1. Amazon GameLift launches the server executable on an Amazon Elastic Compute Cloud (Amazon EC2) instance.

  2. The game server calls:

    1. InitSDK() to initialize the server SDK.

    2. ProcessReady() to communicate game session readiness, connection information, and location of game session log files.

    The server process then waits for a callback from Amazon GameLift.

  3. Amazon GameLift updates the status of the server process to ACTIVE to enable game session placement.

  4. Amazon GameLift begins calling the onHealthCheck callback and continues to call it periodically while the server process is active. The server process can report healthy or not healthy within one minute.

Create a game session

After you've initialized your game server, the following interactions occur when you create game sessions to host your players.

  1. The backend service calls the SDK operation StartGameSessionPlacement().

  2. Amazon GameLift creates a new GameSessionPlacement ticket with status PENDING and returns it to the backend service.

  3. The backend service obtains a placement ticket status from a queue. For more information, see Set up event notification for game session placement.

  4. Amazon GameLift starts game session placement by selecting an appropriate fleet and searching for an active server process in a fleet with 0 game sessions. When Amazon GameLift locates a server process, Amazon GameLift does the following:

    1. Creates a GameSession object with the game session settings and player data from the placement request with an ACTIVATING status.

    2. Invokes the onStartGameSession callback on the server process. Amazon GameLift passes information to the GameSession object indicating that the server process may set up the game session.

    3. Changes the server process's number of game sessions to 1.

  5. The server process runs the onStartGameSession callback function. When the server process is ready to accept player connections, it calls ActivateGameSession() and waits for player connections.

  6. Amazon GameLift updates the GameSession object with connection information for the server process. (This information includes the port setting that was reported with ProcessReady().) Amazon GameLift also changes the status to ACTIVE.

  7. The backend service calls DescribeGameSessionPlacement() to detect the updated ticket status. The backend service then uses the connection information to connect the game client to the server process and join the game session.

Add a player to a game

This sequence describes the process of adding a player to an existing game session. Player sessions can also be requested as part of a game session placement request.

  1. The backend service calls the client API operation CreatePlayerSession() with a game session ID.

  2. Amazon GameLift checks the game session status (must be ACTIVE), and looks for an open player slot in the game session. If a slot is available, then Amazon GameLift does the following:

    1. Creates a new PlayerSession object and sets the status to RESERVED.

    2. Responds to the backend service request with the PlayerSession object.

  3. The backend service connects the game client directly to the server process with the player session ID.

  4. The server calls the server API operation AcceptPlayerSession() to validate the player session ID. If validated, then Amazon GameLift passes the PlayerSession object to the server process. The server process either accepts or rejects the connection.

  5. Amazon GameLift does one of the following:

    1. If the connection is accepted, then Amazon GameLift sets the PlayerSession status to ACTIVE.

    2. If no response is received within 60 seconds of the backend server's original CreatePlayerSession() call, then Amazon GameLift changes the PlayerSession status to TIMEDOUT and reopens the player slot in the game session.

Remove a player

When removing players from a game session to create space for new players to join, the following interactions occur.

  1. A player disconnects from the game.

  2. The server detects the lost connection and calls the server API operation RemovePlayerSession().

  3. Amazon GameLift changes the PlayerSession status to COMPLETED and reopens the player slot in the game session.

Shut down the game session

This sequence of interactions occurs when a server process shuts down the current game session.

  1. The server shuts down the game session and server.

  2. The server calls ProcessEnding() to Amazon GameLift.

  3. Amazon GameLift does the following:

    1. Uploads game session logs to Amazon Simple Storage Service (Amazon S3).

    2. Changes the GameSession status to TERMINATED.

    3. Changes the server process status to TERMINATED.

    4. Recycles instance resources.