Amazon GameLift
Developer Guide (Version )

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

Amazon GameLift Server API Reference for Unreal Engine: Actions

This Amazon GameLift Server API reference can help you prepare your Unreal Engine game projects for use with Amazon GameLift. For details on the integration process, see Add Amazon GameLift to Your Game Server.

This API is defined in GameLiftServerSDK.h and GameLiftServerSDKModels.h.

To set up the Unreal Engine plugin and see code examples Add Amazon GameLift to an Unreal Engine Game Server Project.

AcceptPlayerSession()

Notifies the Amazon GameLift service that a player with the specified player session ID has connected to the server process and needs validation. Amazon GameLift verifies that the player session ID is valid—that is, that the player ID has reserved a player slot in the game session. Once validated, Amazon GameLift changes the status of the player slot from RESERVED to ACTIVE.

Syntax

FGameLiftGenericOutcome AcceptPlayerSession(const FString& playerSessionId)

Parameters

playerSessionId

Unique ID issued by the Amazon GameLift service in response to a call to the AWS SDK Amazon GameLift API action CreatePlayerSession. The game client references this ID when connecting to the server process.

Type: FString

Required: No

Return Value

Returns a generic outcome consisting of success or failure with an error message.

ActivateGameSession()

Notifies the Amazon GameLift service that the server process has activated a game session and is now ready to receive player connections. This action should be called as part of the onStartGameSession() callback function, after all game session initialization has been completed.

Syntax

FGameLiftGenericOutcome ActivateGameSession()

Parameters

This action has no parameters.

Return Value

Returns a generic outcome consisting of success or failure with an error message.

GetGameSessionId()

Retrieves the ID of the game session currently being hosted by the server process, if the server process is active.

Syntax

FGameLiftStringOutcome GetGameSessionId()

Parameters

This action has no parameters.

Return Value

If successful, returns the game session ID as an FGameLiftStringOutcome object. If not successful, returns an error message.

GetSdkVersion()

Returns the current version number of the SDK built into the server process.

Syntax

FGameLiftStringOutcome GetSdkVersion();

Parameters

This action has no parameters.

Return Value

If successful, returns the current SDK version as an FGameLiftStringOutcome object. The returned string includes the version number only (ex. "3.1.5"). If not successful, returns an error message.

Example

Aws::GameLift::AwsStringOutcome SdkVersionOutcome = Aws::GameLift::Server::GetSdkVersion();

InitSDK()

Initializes the Amazon GameLift SDK. This method should be called on launch, before any other Amazon GameLift-related initialization occurs.

Syntax

FGameLiftGenericOutcome InitSDK()

Parameters

This action has no parameters.

Return Value

Returns a generic outcome consisting of success or failure with an error message.

ProcessEnding()

Notifies the Amazon GameLift service that the server process is shutting down. This method should be called after all other cleanup tasks, including shutting down all active game sessions. This method should exit with an exit code of 0; a non-zero exit code results in an event message that the process did not exit cleanly.

Syntax

FGameLiftGenericOutcome ProcessEnding()

Parameters

This action has no parameters.

Return Value

Returns a generic outcome consisting of success or failure with an error message.

ProcessReady()

Notifies the Amazon GameLift service that the server process is ready to host game sessions. This method should be called after successfully invoking InitSDK() and completing any setup tasks required before the server process can host a game session.

Syntax

FGameLiftGenericOutcome ProcessReady(FProcessParameters &processParameters)

Parameters

FProcessParameters

A FProcessParameters object communicating the following information about the server process:

  • Names of callback methods, implemented in the game server code, that the Amazon GameLift service invokes to communicate with the server process.

  • Port number that the server process is listening on.

  • Path to any game session-specific files that you want Amazon GameLift to capture and store.

Required: Yes

Return Value

Returns a generic outcome consisting of success or failure with an error message.

Example

See the sample code in Using the Unreal Engine Plugin.

RemovePlayerSession()

Notifies the Amazon GameLift service that a player with the specified player session ID has disconnected from the server process. In response, Amazon GameLift changes the player slot to available, which allows it to be assigned to a new player.

Syntax

FGameLiftGenericOutcome RemovePlayerSession(const FString& playerSessionId)

Parameters

playerSessionId

Unique ID issued by the Amazon GameLift service in response to a call to the AWS SDK Amazon GameLift API action CreatePlayerSession. The game client references this ID when connecting to the server process.

Type: FString

Required: No

Return Value

Returns a generic outcome consisting of success or failure with an error message.

StartMatchBackfill()

Sends a request to find new players for open slots in a game session created with FlexMatch. See also the AWS SDK action StartMatchBackfill(). With this action, match backfill requests can be initiated by a game server process that is hosting the game session. Learn more about the FlexMatch backfill feature in Backfill Existing Games with FlexMatch.

A server process can have only one active match backfill request at a time. To send a new request, first call StopMatchBackfill() to cancel the original request.

Syntax

FGameLiftStringOutcome StartMatchBackfill (FStartMatchBackfillRequest &startBackfillRequest);

Parameters

FStartMatchBackfillRequest

A FStartMatchBackfillRequest object that communicates the following information:

  • A ticket ID to assign to the backfill request. This information is optional; if no ID is provided, Amazon GameLift will autogenerate one.

  • The matchmaker to send the request to. The full configuration ARN is required. This value can be acquired from the game session's matchmaker data.

  • The ID of the game session that is being backfilled.

  • Available matchmaking data for the game session's current players.

Required: Yes

Return Value

If successful, returns the match backfill ticket as a FGameLiftStringOutcome object. If not successful, returns an error message. Ticket status can be tracked using the AWS SDK action DescribeMatchmaking().

StopMatchBackfill()

Cancels an active match backfill request that was created with StartMatchBackfill(). See also the AWS SDK action StopMatchmaking(). Learn more about the FlexMatch backfill feature in Backfill Existing Games with FlexMatch.

Syntax

FGameLiftGenericOutcome StopMatchBackfill (FStopMatchBackfillRequest &stopBackfillRequest);

Parameters

StopMatchBackfillRequest

A FStopMatchBackfillRequest object identifying the matchmaking ticket to cancel:

  • ticket ID assigned to the backfill request being canceled

  • matchmaker the backfill request was sent to

  • game session associated with the backfill request

Required: Yes

Return Value

Returns a generic outcome consisting of success or failure with an error message.

TerminateGameSession()

Notifies the Amazon GameLift service that the server process has shut down the game session. (Currently, each server process hosts only one game session at a time, so there's no need to specify which session.) This action should be called at the end of the game session shutdown process. After calling this action, the server process can call ProcessReady() to signal its availability to host a new game session. Alternatively, it can call ProcessEnding() to shut down the server process and terminate the instance.

Syntax

FGameLiftGenericOutcome TerminateGameSession()

Parameters

This action has no parameters.

Return Value

Returns a generic outcome consisting of success or failure with an error message.

UpdatePlayerSessionCreationPolicy()

Updates the current game session's ability to accept new player sessions. A game session can be set to either accept or deny all new player sessions. (See also the UpdateGameSession() action in the Amazon GameLift Service API Reference).

Syntax

FGameLiftGenericOutcome UpdatePlayerSessionCreationPolicy(EPlayerSessionCreationPolicy policy)

Parameters

Policy

Value indicating whether the game session accepts new players.

Type: EPlayerSessionCreationPolicy enum. Valid values include:

  • ACCEPT_ALL – Accept all new player sessions.

  • DENY_ALL – Deny all new player sessions.

Required: Yes

Return Value

Returns a generic outcome consisting of success or failure with an error message.