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.

Initialize a game server
The following steps describe the interactions that occur when you prepare your game server to host game sessions.
-
Amazon GameLift launches the server executable on an Amazon Elastic Compute Cloud (Amazon EC2) instance.
-
The game server calls:
-
InitSDK()
to initialize the server SDK. -
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.
-
-
Amazon GameLift updates the status of the server process to
ACTIVE
to enable game session placement. -
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.
-
The backend service calls the SDK operation
StartGameSessionPlacement()
. -
Amazon GameLift creates a new
GameSessionPlacement
ticket with statusPENDING
and returns it to the backend service. -
The backend service obtains a placement ticket status from a queue. For more information, see Set up event notification for game session placement.
-
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:-
Creates a
GameSession
object with the game session settings and player data from the placement request with anACTIVATING
status. -
Invokes the
onStartGameSession
callback on the server process. Amazon GameLift passes information to theGameSession
object indicating that the server process may set up the game session. -
Changes the server process's number of game sessions to
1
.
-
-
The server process runs the
onStartGameSession
callback function. When the server process is ready to accept player connections, it callsActivateGameSession()
and waits for player connections. -
Amazon GameLift updates the
GameSession
object with connection information for the server process. (This information includes the port setting that was reported withProcessReady()
.) Amazon GameLift also changes the status toACTIVE
. -
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.
-
The backend service calls the client API operation
CreatePlayerSession()
with a game session ID. -
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:-
Creates a new
PlayerSession
object and sets the status toRESERVED
. -
Responds to the backend service request with the
PlayerSession
object.
-
-
The backend service connects the game client directly to the server process with the player session ID.
-
The server calls the server API operation
AcceptPlayerSession()
to validate the player session ID. If validated, then Amazon GameLift passes thePlayerSession
object to the server process. The server process either accepts or rejects the connection. -
Amazon GameLift does one of the following:
-
If the connection is accepted, then Amazon GameLift sets the
PlayerSession
status toACTIVE
. -
If no response is received within 60 seconds of the backend server's original
CreatePlayerSession()
call, then Amazon GameLift changes thePlayerSession
status toTIMEDOUT
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.
-
A player disconnects from the game.
-
The server detects the lost connection and calls the server API operation
RemovePlayerSession()
. -
Amazon GameLift changes the
PlayerSession
status toCOMPLETED
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.
-
The server shuts down the game session and server.
-
The server calls
ProcessEnding()
to Amazon GameLift. -
Amazon GameLift does the following:
-
Uploads game session logs to Amazon Simple Storage Service (Amazon S3).
-
Changes the
GameSession
status toTERMINATED
. -
Changes the server process status to
TERMINATED
. -
Recycles instance resources.
-