This API works with the following fleet types: EC2, Anywhere, Container
Reserves open slots in a game session for a group of players. New player sessions can be created in any game session with an open slot that is in ACTIVE status and has a player creation policy of ACCEPT_ALL. To add a single player to a game session, use CreatePlayerSession
To create player sessions, specify a game session ID and a list of player IDs. Optionally, provide a set of player data for each player ID.
If successful, a slot is reserved in the game session for each player, and new PlayerSession objects are returned with player session IDs. Each player references their player session ID when sending a connection request to the game session, and the game server can use it to validate the player reservation with the Amazon GameLift Servers service. Player sessions cannot be updated.
The maximum number of players per game session is 200. It is not adjustable.
Related actions
All APIs by task
Parameters:
-
game_session_id
(Optional[ArnStringModel], default:
None
)
–
An identifier for the game session that is unique across all regions to add players to. The value is always a full ARN in the following format: For Home Region game session - arn:aws:gamelift:::gamesession//. For Remote Location game session - arn:aws:gamelift:::gamesession///.
-
player_ids
(Optional[PlayerIdList], default:
None
)
–
List of unique identifiers for the players to be added.
-
player_data_map
(Optional[PlayerDataMap], default:
None
)
–
Map of string pairs, each specifying a player ID and a set of developer-defined information related to the player. Amazon GameLift Servers does not use this data, so it can be formatted as needed for use in the game. Any player data strings for player IDs that are not included in the PlayerIds parameter are ignored.
Raises:
-
GameSessionFullException
–
The game instance is currently full and cannot allow the requested player(s) to join. Clients can retry such requests immediately or after a waiting period.
-
InternalServiceException
–
The service encountered an unrecoverable internal failure while processing the request. Clients can retry such requests immediately or after a waiting period.
-
InvalidGameSessionStatusException
–
The requested operation would cause a conflict with the current state of a resource associated with the request and/or the game instance. Resolve the conflict before retrying.
-
InvalidRequestException
–
One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.
-
NotFoundException
–
The requested resource was not found. The resource was either not created yet or deleted.
-
TerminalRoutingStrategyException
–
The service is unable to resolve the routing for a particular alias because it has a terminal RoutingStrategy associated with it. The message returned in this exception is the message defined in the routing strategy itself. Such requests should only be retried if the routing strategy for the specified alias is modified.
-
UnauthorizedException
–
The client failed authentication. Clients should not retry such requests.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_gamelift/_services/async_game_lift.py
| async def create_player_sessions(
self,
*,
config_overrides: Optional[AsyncGameLiftClientConfig] = None,
game_session_id: Optional[
"capo_gamelift.types.arn_string_model.ArnStringModel"
] = None,
player_ids: Optional["capo_gamelift.types.player_id_list.PlayerIdList"] = None,
player_data_map: Optional[
"capo_gamelift.types.player_data_map.PlayerDataMap"
] = None,
) -> "capo_gamelift.types.create_player_sessions_output.CreatePlayerSessionsOutput":
"""<p> <b>This API works with the following fleet types:</b> EC2, Anywhere, Container</p> <p>Reserves open slots in a game session for a group of players. New player sessions can be created in any game session with an open slot that is in <code>ACTIVE</code> status and has a player creation policy of <code>ACCEPT_ALL</code>. To add a single player to a game session, use <a href="https://docs.aws.amazon.com/gamelift/latest/apireference/API_CreatePlayerSession.html">CreatePlayerSession</a> </p> <p>To create player sessions, specify a game session ID and a list of player IDs. Optionally, provide a set of player data for each player ID. </p> <p>If successful, a slot is reserved in the game session for each player, and new <code>PlayerSession</code> objects are returned with player session IDs. Each player references their player session ID when sending a connection request to the game session, and the game server can use it to validate the player reservation with the Amazon GameLift Servers service. Player sessions cannot be updated.</p> <p>The maximum number of players per game session is 200. It is not adjustable. </p> <p> <b>Related actions</b> </p> <p> <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets">All APIs by task</a> </p>
Args:
game_session_id: <p>An identifier for the game session that is unique across all regions to add players to. The value is always a full ARN in the following format: For Home Region game session - <code>arn:aws:gamelift:<home_region>::gamesession/<fleet ID>/<ID string></code>. For Remote Location game session - <code>arn:aws:gamelift:<home_region>::gamesession/<fleet ID>/<location>/<ID string></code>.</p>
player_ids: <p>List of unique identifiers for the players to be added.</p>
player_data_map: <p>Map of string pairs, each specifying a player ID and a set of developer-defined information related to the player. Amazon GameLift Servers does not use this data, so it can be formatted as needed for use in the game. Any player data strings for player IDs that are not included in the <code>PlayerIds</code> parameter are ignored. </p>
Raises:
capo_gamelift.errors.game_session_full_exception.GameSessionFullException: <p>The game instance is currently full and cannot allow the requested player(s) to join. Clients can retry such requests immediately or after a waiting period.</p>
capo_gamelift.errors.internal_service_exception.InternalServiceException: <p>The service encountered an unrecoverable internal failure while processing the request. Clients can retry such requests immediately or after a waiting period.</p>
capo_gamelift.errors.invalid_game_session_status_exception.InvalidGameSessionStatusException: <p>The requested operation would cause a conflict with the current state of a resource associated with the request and/or the game instance. Resolve the conflict before retrying.</p>
capo_gamelift.errors.invalid_request_exception.InvalidRequestException: <p>One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.</p>
capo_gamelift.errors.not_found_exception.NotFoundException: <p>The requested resource was not found. The resource was either not created yet or deleted.</p>
capo_gamelift.errors.terminal_routing_strategy_exception.TerminalRoutingStrategyException: <p>The service is unable to resolve the routing for a particular alias because it has a terminal <code>RoutingStrategy</code> associated with it. The message returned in this exception is the message defined in the routing strategy itself. Such requests should only be retried if the routing strategy for the specified alias is modified. </p>
capo_gamelift.errors.unauthorized_exception.UnauthorizedException: <p>The client failed authentication. Clients should not retry such requests.</p>
capo_gamelift.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_gamelift.types.create_player_sessions_input.CreatePlayerSessionsInput]",
) -> AsyncOperationResponse[
"capo_gamelift.types.create_player_sessions_output.CreatePlayerSessionsOutput"
]:
import capo_gamelift._operations.game_lift.create_player_sessions
(
output,
http_response,
) = await capo_gamelift._operations.game_lift.create_player_sessions.async_create_player_sessions(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
def _redact_input(
input_: "capo_gamelift.types.create_player_sessions_input.CreatePlayerSessionsInput",
) -> dict[str, Any]:
import capo_gamelift.types.create_player_sessions_input
return capo_gamelift.types.create_player_sessions_input.redact_sensitive(
input_
)
def _redact_output(
output: "capo_gamelift.types.create_player_sessions_output.CreatePlayerSessionsOutput",
) -> dict[str, Any]:
import capo_gamelift.types.create_player_sessions_output
return capo_gamelift.types.create_player_sessions_output.redact_sensitive(
output
)
interceptors_, options_ = self.operation_options(
config_overrides,
OperationLogging(
"CreatePlayerSessions",
redact_input=_redact_input,
redact_output=_redact_output,
),
)
input_: capo_gamelift.types.create_player_sessions_input.CreatePlayerSessionsInput = {}
if game_session_id is not None:
input_["game_session_id"] = game_session_id
if player_ids is not None:
input_["player_ids"] = player_ids
if player_data_map is not None:
input_["player_data_map"] = player_data_map
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|