

# Integrate Amazon GameLift Servers FleetIQ into a game client
Integrate a Game Client

This topic describes the tasks required to prepare your game client or matchmaking service to communicate with Amazon GameLift Servers FleetIQ in order to acquire a game server to host a game session.

Create a method that allows your game client or matchmaker to request a game server resource for players. You have a couple of options for how to do this: 
+ Have Amazon GameLift Servers FleetIQ choose an available game server. This option takes advantage of Amazon GameLift Servers FleetIQ optimizations to use low-cost Spot Instances and for automatic scaling.
+ Request all available game servers and select one to use (often referred to as "list and pick").

**Topics**
+ [

# Let Amazon GameLift Servers FleetIQ choose a game server
](gsg-integrate-gameclient-automatic.md)
+ [

# Choose your own game server
](gsg-integrate-gameclient-optimized.md)

# Let Amazon GameLift Servers FleetIQ choose a game server


To have Amazon GameLift Servers FleetIQ choose an available game server, call [ClaimGameServer()](https://docs.amazonaws.cn/gamelift/latest/apireference/API_ClaimGameServer.html) without specifying a game server ID. In this scenario, Amazon GameLift Servers FleetIQ does exercise its logic to find a game server on an instance that is viable for game hosting and optimized for automatic scaling.

```
Amazon gamelift claim-game-server \
    --game-server-group-name MyLiveGroup
```

In response to a claim request, Amazon GameLift Servers FleetIQ identifies the `GameServer` resource, connection information, and game data, which clients can use to connect to the game server. The game server's claim status is set to CLAIMED for 60 seconds. Either your game server or client service needs to update the game server's status on Amazon GameLift Servers FleetIQ after players connect or gameplay starts. This ensures that Amazon GameLift Servers FleetIQ does not provide this game server in response to subsequent requests for game server capacity. Update game server status by calling [UpdateGameServer()](https://docs.amazonaws.cn/gamelift/latest/apireference/API_UpdateGameServer.html).

```
Amazon gamelift update-game-server \
    --game-server-group-name MyLiveGroup \
    --game-server-id UniqueId-1234 \
    --health-check HEALTHY \
    --utilization-status UTILIZED
```

# Choose your own game server


With the "list and pick" method, your game client or matchmaker requests a list of available game servers by calling [ListGameServers()](https://docs.amazonaws.cn/gamelift/latest/apireference/API_ListGameServers.html). You might want to use game server data to provide additional information that players or your matchmaker can use when selecting a game server. To control how results are returned, you can request paginated results and sort game servers by registration date. The following request returns 20 active and available game servers in the specified game server group, sorted by registration time with the newest game servers listed first.

```
Amazon gamelift list-game-servers \
    --game-server-group-name MyLiveGroup \
    --limit 20 \
    --sort-order DESCENDING
```

Based on the list of available game servers, the client or matchmaking service selects a game server and claims it by calling [ClaimGameServer()](https://docs.amazonaws.cn/gamelift/latest/apireference/API_ClaimGameServer.html) with the specific game server ID. In this scenario, Amazon GameLift Servers FleetIQ does not exercise any of its instance type optimization logic, as described in [Amazon GameLift Servers FleetIQ logic](gsg-howitworks-logic.md).

```
Amazon gamelift claim-game-server \
    --game-server-group-name MyLiveGroup \
    --game-server-id UniqueId-1234
```