getPlayerConnectionDetails method

Future<GetPlayerConnectionDetailsOutput> getPlayerConnectionDetails({
  1. required String gameSessionId,
  2. required List<String> playerIds,
})

This API works with the following fleet types: EC2 (server SDK 5.x or later), Container

Retrieves connection details for game clients to connect to game sessions.

Player gateway benefits: DDoS protection with negligible impact to latency.

To enable player gateway on your fleet, set PlayerGatewayMode to ENABLED or REQUIRED when calling CreateFleet or CreateContainerFleet.

How to use: After creating a game session and adding players, call this operation with the game session ID and player IDs. When player gateway is enabled, the response includes connection endpoints and player gateway tokens that your game clients can use to connect to the game session through player gateway. To learn more about player gateway integration, see DDoS protection with Amazon GameLift Servers player gateway.

When player gateway is disabled or in locations where player gateway is not supported, this operation returns game server connection information without player gateway tokens, so that your game clients directly connect to the game server endpoint.

May throw InternalServiceException. May throw InvalidGameSessionStatusException. May throw InvalidRequestException. May throw LimitExceededException. May throw NotFoundException. May throw UnauthorizedException. May throw UnsupportedRegionException.

Parameter gameSessionId : An identifier for the game session that is unique across all regions for which to retrieve player connection details. The value is always a full ARN in the following format: arn:aws:gamelift:.

Parameter playerIds : List of unique identifiers for players. Connection details are returned for each player in this list.

Implementation

Future<GetPlayerConnectionDetailsOutput> getPlayerConnectionDetails({
  required String gameSessionId,
  required List<String> playerIds,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'GameLift.GetPlayerConnectionDetails'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'GameSessionId': gameSessionId,
      'PlayerIds': playerIds,
    },
  );

  return GetPlayerConnectionDetailsOutput.fromJson(jsonResponse.body);
}