2016/08/04 - Amazon GameLift - 1 new api methods
Changes Provides a new Search API for GameLift, which allows game developers to retrieve filtered and sorted lists of their GameSessions.
Retrieves a list of game sessions in a fleet that match a set of search criteria and sorts them in a specified order. Currently game session searches are limited to a single fleet. Search results include only game sessions that are in ACTIVE status.
You can search or sort by the following game session attributes:
gameSessionId -- ID value assigned to a game session. This unique value is returned in a GameSession object when a new game session is created.
gameSessionName -- Name assigned to a game session. This value is set when requesting a new game session with CreateGameSession or updating with UpdateGameSession . Game session names do not need to be unique to a game session.
creationTimeMillis -- Value indicating when a game session was created. It is expressed in Unix time as milliseconds.
playerSessionCount -- Number of players currently connected to a game session. This value changes rapidly as players join the session or drop out.
maximumSessions -- Maximum number of player sessions allowed for a game session. This value is set when requesting a new game session with CreateGameSession or updating with UpdateGameSession .
hasAvailablePlayerSessions -- Boolean value indicating whether or not a game session has reached its maximum number of players. When searching with this attribute, the search value must be true or false . It is highly recommended that all search requests include this filter attribute to optimize search performance and return only sessions that players can join.
To search or sort, specify either a fleet ID or an alias ID, and provide a search filter expression, a sort expression, or both. Use the pagination parameters to retrieve results as a set of sequential pages. If successful, a collection of GameSession objects matching the request is returned.
Note
Returned values for playerSessionCount and hasAvailablePlayerSessions change quickly as players join sessions and others drop out. Results should be considered a snapshot in time. Be sure to refresh search results often, and handle sessions that fill up before a player can join.
Request Syntax
client.search_game_sessions( FleetId='string', AliasId='string', FilterExpression='string', SortExpression='string', Limit=123, NextToken='string' )
string
Unique identifier for a fleet. Each request must reference either a fleet ID or alias ID, but not both.
string
Unique identifier for a fleet alias. Each request must reference either a fleet ID or alias ID, but not both.
string
String containing the search criteria for the session search. If no filter expression is included, the request returns results for all game sessions in the fleet that are in ACTIVE status.
A filter expression can contain one or multiple conditions. Each condition consists of the following:
Operand -- Name of a game session attribute. Valid values are gameSessionName , gameSessionId , creationTimeMillis , playerSessionCount , maximumSessions , hasAvailablePlayerSessions .
Comparator -- Valid comparators are: = , <> , < , > , <= , >= .
Value -- Value to be searched for. Values can be numbers, boolean values (true/false) or strings. String values are case sensitive, enclosed in single quotes. Special characters must be escaped. Boolean and string values can only be used with the comparators = and <> . For example, the following filter expression searches on gameSessionName : "FilterExpression": "gameSessionName = 'Matt\\'s Awesome Game 1'" .
To chain multiple conditions in a single expression, use the logical keywords AND , OR , and NOT and parentheses as needed. For example: x AND y AND NOT z , NOT (x OR y) .
Session search evaluates conditions from left to right using the following precedence rules:
= , <> , < , > , <= , >=
Parentheses
NOT
AND
OR
For example, this filter expression retrieves game sessions hosting at least ten players that have an open player slot: "maximumSessions>=10 AND hasAvailablePlayerSessions=true" .
string
Instructions on how to sort the search results. If no sort expression is included, the request returns results in random order. A sort expression consists of the following elements:
Operand -- Name of a game session attribute. Valid values are gameSessionName , gameSessionId , creationTimeMillis , playerSessionCount , maximumSessions , hasAvailablePlayerSessions .
Order -- Valid sort orders are ASC (ascending) and DESC (descending).
For example, this sort expression returns the oldest active sessions first: "SortExpression": "creationTimeMillis ASC" . Results with a null value for the sort operand are returned at the end of the list.
integer
Maximum number of results to return. Use this parameter with NextToken to get results as a set of sequential pages. The maximum number of results returned is 20, even if this value is not set or is set higher than 20.
string
Token indicating the start of the next sequential page of results. Use the token that is returned with a previous call to this action. To specify the start of the result set, do not specify a value.
dict
Response Syntax
{ 'GameSessions': [ { 'GameSessionId': 'string', 'Name': 'string', 'FleetId': 'string', 'CreationTime': datetime(2015, 1, 1), 'TerminationTime': datetime(2015, 1, 1), 'CurrentPlayerSessionCount': 123, 'MaximumPlayerSessionCount': 123, 'Status': 'ACTIVE'|'ACTIVATING'|'TERMINATED'|'TERMINATING', 'GameProperties': [ { 'Key': 'string', 'Value': 'string' }, ], 'IpAddress': 'string', 'Port': 123, 'PlayerSessionCreationPolicy': 'ACCEPT_ALL'|'DENY_ALL' }, ], 'NextToken': 'string' }
Response Structure
(dict) --
Represents the returned data in response to a request action.
GameSessions (list) --
Collection of objects containing game session properties for each session matching the request.
(dict) --
Properties describing a game session.
GameSessionId (string) --
Unique identifier for a game session.
Name (string) --
Descriptive label associated with a game session. Session names do not need to be unique.
FleetId (string) --
Unique identifier for a fleet.
CreationTime (datetime) --
Time stamp indicating when this data object was created. Format is a number expressed in Unix time as milliseconds (ex: "1469498468.057".
TerminationTime (datetime) --
Time stamp indicating when this data object was terminated. Format is a number expressed in Unix time as milliseconds (ex: "1469498468.057".
CurrentPlayerSessionCount (integer) --
Number of players currently in the game session.
MaximumPlayerSessionCount (integer) --
Maximum number of players allowed in the game session.
Status (string) --
Current status of the game session. A game session must be in an ACTIVE status to have player sessions.
GameProperties (list) --
Set of custom properties for the game session.
(dict) --
Set of key-value pairs containing information a server process requires to set up a game session. This object allows you to pass in any set of data needed for your game. For more information, see the Amazon GameLift Developer Guide .
Key (string) --
Value (string) --
IpAddress (string) --
IP address of the game session. To connect to a GameLift server process, an app needs both the IP address and port number.
Port (integer) --
Port number for the game session. To connect to a GameLift server process, an app needs both the IP address and port number.
PlayerSessionCreationPolicy (string) --
Indicates whether or not the game session is accepting new players.
NextToken (string) --
Token indicating where to resume retrieving results on the next call to this action. If no token is returned, these results represent the end of the list.
Note
If a request has a limit that exactly matches the number of remaining results, a token is returned even though there are no more results to retrieve.