GameLift / Client / get_player_connection_details
get_player_connection_details¶
- GameLift.Client.get_player_connection_details(**kwargs)¶
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
PlayerGatewayModetoENABLEDorREQUIREDwhen 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.
See also: AWS API Documentation
Request Syntax
response = client.get_player_connection_details( GameSessionId='string', PlayerIds=[ 'string', ] )
- Parameters:
GameSessionId (string) –
[REQUIRED]
A unique identifier for the game session for which to retrieve player connection details.
PlayerIds (list) –
[REQUIRED]
List of unique identifiers for players. Connection details are returned for each player in this list.
(string) –
- Return type:
dict
- Returns:
Response Syntax
{ 'GameSessionId': 'string', 'PlayerConnectionDetails': [ { 'PlayerId': 'string', 'Endpoints': [ { 'IpAddress': 'string', 'Port': 123 }, ], 'PlayerGatewayToken': 'string', 'Expiration': datetime(2015, 1, 1) }, ] }
Response Structure
(dict) –
GameSessionId (string) –
A unique identifier for the game session for which the player connection details were retrieved.
PlayerConnectionDetails (list) –
A collection of player connection detail objects, one for each requested player.
(dict) –
Connection information for a game client to connect to a game session. This object contains the IP address(es), port(s), and authentication details your game client needs to establish a connection.
With player gateway enabled: Contains relay endpoints and a player gateway token. Your game client must prepend player gateway token to each payload for validation and connection through relay endpoints.
With player gateway disabled: Contains game server endpoint. Player gateway token and expiration fields are empty.
PlayerId (string) –
A unique identifier for a player associated with this connection.
Endpoints (list) –
List of connection endpoints for the game client. Your game client uses these IP address(es) and port(s) to connect to the game session.
When player gateway is enabled, these are relay endpoints with benefits such as DDoS protection. When disabled, this is the game server endpoint.
(dict) –
Network address(es) and port(s) for connecting to a game session.
IpAddress (string) –
IP address for connecting to the game session. When player gateway is enabled, this is a player gateway IP address. When player gateway is disabled, this is the game server IP address.
Port (integer) –
Port number for connecting to the game session. When player gateway is enabled, this is a player gateway port. When player gateway is disabled, this is the game server port.
PlayerGatewayToken (string) –
Access token that your game client must prepend to all traffic sent through player gateway. Player gateway verifies identity and authorizes connection based on this token.
This value is empty when player gateway is disabled.
Expiration (datetime) –
When player gateway is enabled, this is the timestamp indicating when player gateway token expires. Your game backend should call GetPlayerConnectionDetails to retrieve fresh connection information for your game clients before this time. Format is a number expressed in Unix time as milliseconds (for example
"1469498468.057").This value is empty when player gateway is disabled.
Exceptions
GameLift.Client.exceptions.UnauthorizedExceptionGameLift.Client.exceptions.NotFoundExceptionGameLift.Client.exceptions.InvalidGameSessionStatusExceptionGameLift.Client.exceptions.InvalidRequestExceptionGameLift.Client.exceptions.InternalServiceExceptionGameLift.Client.exceptions.LimitExceededExceptionGameLift.Client.exceptions.UnsupportedRegionException