

# C\$1\$1 server SDK for Amazon GameLift Servers 4.x -- Actions
<a name="integration-server-sdk-cpp-ref-actions"></a>

Use the server SDK reference to integrate your multiplayer game for hosting with Amazon GameLift Servers. For guidance about the integration process, see [Add Amazon GameLift Servers to your game server with the server SDK](gamelift-sdk-server-api.md).

**Note**  
This reference is for an earlier version of the server SDK for Amazon GameLift Servers. For the latest version, see [C\$1\$1 server SDK 5.x for Amazon GameLift Servers -- Actions](integration-server-sdk5-cpp-actions.md).

# C\$1\$1 server SDK for Amazon GameLift Servers 4.x -- Data types
<a name="integration-server-sdk-cpp-ref-datatypes"></a>

Use the server SDK reference to integrate your multiplayer game for hosting with Amazon GameLift Servers. For guidance about the integration process, see [Add Amazon GameLift Servers to your game server with the server SDK](gamelift-sdk-server-api.md).

**Note**  
This reference is for an earlier version of the server SDK for Amazon GameLift Servers. For the latest version, see [C\$1\$1 server SDK 5.x for Amazon GameLift Servers -- Data types](integration-server-sdk5-cpp-datatypes.md).

This API is defined in `GameLiftServerAPI.h`, `LogParameters.h`, and `ProcessParameters.h`.

[C\$1\$1 server SDK for Amazon GameLift Servers 4.x -- Actions](integration-server-sdk-cpp-ref-actions.md)

## DescribePlayerSessionsRequest
<a name="integration-server-sdk-cpp-ref-dataypes-playersessions"></a>

This data type is used to specify which player session(s) to retrieve. You can use it as follows: 
+ Provide a PlayerSessionId to request a specific player session.
+ Provide a GameSessionId to request all player sessions in the specified game session.
+ Provide a PlayerId to request all player sessions for the specified player.

For large collections of player sessions, use the pagination parameters to retrieve results in sequential blocks.

### Contents
<a name="integration-server-sdk-cpp-ref-dataypes-playersessions-contents"></a>

**GameSessionId**  
Unique game session identifier. Use this parameter to request all player sessions for the specified game session. Game session ID format is as follows: `arn:aws:gamelift:<region>::gamesession/fleet-<fleet ID>/<ID string>`. The value of <ID string> is either a custom ID string or (if one was specified when the game session was created) a generated string.   
Type: String  
Required: No

**Limit**  
Maximum number of results to return. Use this parameter with *NextToken* to get results as a set of sequential pages. If a player session ID is specified, this parameter is ignored.  
Type: Integer  
Required: No

**NextToken**  
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. If a player session ID is specified, this parameter is ignored.  
Type: String  
Required: No

**PlayerId**  
Unique identifier for a player. Player IDs are defined by the developer. See [Generate player IDs](player-sessions-player-identifiers.md).  
Type: String  
Required: No

**PlayerSessionId**  
Unique identifier for a player session.  
Type: String  
Required: No

**PlayerSessionStatusFilter**  
Player session status to filter results on. Possible player session statuses include the following:  
+ RESERVED – The player session request has been received, but the player has not yet connected to the server process and/or been validated.
+ ACTIVE – The player has been validated by the server process and is currently connected.
+ COMPLETED – The player connection has been dropped.
+ TIMEDOUT – A player session request was received, but the player did not connect and/or was not validated within the time-out limit (60 seconds).
Type: String  
Required: No

## LogParameters
<a name="integration-server-sdk-cpp-ref-dataypes-log"></a>

This data type is used to identify which files generated during a game session that you want Amazon GameLift Servers to upload and store once the game session ends. This information is communicated to the Amazon GameLift Servers service in a [ProcessReady()](integration-server-sdk-cpp-ref-actions.md#integration-server-sdk-cpp-ref-processready) call.

### Contents
<a name="integration-server-sdk-cpp-ref-dataypes-log-contents"></a>

**logPaths**  
Directory paths to game server log files that you want Amazon GameLift Servers to store for future access. These files are generated during each game session. File paths and names are defined in your game server and stored in the root game build directory. The log paths must be absolute. For example, if your game build stores game session logs in a path like `MyGame\sessionlogs\`, then the log path would be `c:\game\MyGame\sessionLogs` (on a Windows instance) or `/local/game/MyGame/sessionLogs` (on a Linux instance).   
Type: std:vector<std::string>  
Required: No

## ProcessParameters
<a name="integration-server-sdk-cpp-ref-dataypes-process"></a>

This data type contains the set of parameters sent to the Amazon GameLift Servers service in a [ProcessReady()](integration-server-sdk-cpp-ref-actions.md#integration-server-sdk-cpp-ref-processready) call.

### Contents
<a name="integration-server-sdk-cpp-ref-dataypes-process-contents"></a>

**port**  
Port number the server process listens on for new player connections. The value must fall into the port range configured for any fleet deploying this game server build. This port number is included in game session and player session objects, which game sessions use when connecting to a server process.   
Type: Integer   
Required: Yes

**logParameters**  
Object with a list of directory paths to game session log files.   
Type: Aws::GameLift::Server::[LogParameters](#integration-server-sdk-cpp-ref-dataypes-log)  
Required: No

**onStartGameSession**  
Name of callback function that the Amazon GameLift Servers service invokes to activate a new game session. Amazon GameLift Servers calls this function in response to the client request [CreateGameSession](https://docs.aws.amazon.com/gamelift/latest/apireference/API_CreateGameSession.html). The callback function passes a [GameSession](https://docs.aws.amazon.com/gamelift/latest/apireference/API_GameSession.html) object (defined in the *Amazon GameLift Servers Service API Reference*).   
Type: `const std::function<void(Aws::GameLift::Model::GameSession)> onStartGameSession`   
Required: Yes

**onProcessTerminate**  
Name of callback function that the Amazon GameLift Servers service invokes to force the server process to shut down. After calling this function, Amazon GameLift Servers waits five minutes for the server process to shut down and respond with a [ProcessEnding()](integration-server-sdk-cpp-ref-actions.md#integration-server-sdk-cpp-ref-processending) call. If no response is receive, it shuts down the server process.  
Type: `std::function<void()> onProcessTerminate`  
Required: No

**onHealthCheck**  
Name of callback function that the Amazon GameLift Servers service invokes to request a health status report from the server process. Amazon GameLift Servers calls this function every 60 seconds. After calling this function Amazon GameLift Servers waits 60 seconds for a response, and if none is received. records the server process as unhealthy.  
Type: `std::function<bool()> onHealthCheck`  
Required: No

**onUpdateGameSession**  
Name of callback function that the Amazon GameLift Servers service invokes to pass an updated game session object to the server process. Amazon GameLift Servers calls this function when a [match backfill](https://docs.aws.amazon.com/gamelift/latest/flexmatchguide/match-backfill.html) request has been processed in order to provide updated matchmaker data. It passes a [GameSession](https://docs.aws.amazon.com/gamelift/latest/apireference/API_GameSession.html) object, a status update (`updateReason`), and the match backfill ticket ID.   
Type: `std::function<void(Aws::GameLift::Server::Model::UpdateGameSession)> onUpdateGameSession`   
Required: No

## StartMatchBackfillRequest
<a name="integration-server-sdk-cpp-ref-dataypes-startmatchbackfillrequest"></a>

This data type is used to send a matchmaking backfill request. The information is communicated to the Amazon GameLift Servers service in a [StartMatchBackfill()](integration-server-sdk-cpp-ref-actions.md#integration-server-sdk-cpp-ref-startmatchbackfill) call.

### Contents
<a name="integration-server-sdk-cpp-ref-dataypes-startbackfill-contents"></a>

**GameSessionArn**  
 Unique game session identifier. The API action [GetGameSessionId()](integration-server-sdk-cpp-ref-actions.md#integration-server-sdk-cpp-ref-getgamesessionid) returns the identifier in ARN format.  
Type: String  
Required: Yes

**MatchmakingConfigurationArn**  
Unique identifier, in the form of an ARN, for the matchmaker to use for this request. To find the matchmaker that was used to create the original game session, look in the game session object, in the matchmaker data property. Learn more about matchmaker data in [ Word with matchmaker data](https://docs.aws.amazon.com/gamelift/latest/flexmatchguide/match-server.html#match-server-data).   
Type: String  
Required: Yes

**Players**  
A set of data representing all players who are currently in the game session. The matchmaker uses this information to search for new players who are good matches for the current players. See the *Amazon GameLift Servers API Reference Guide* for a description of the Player object format. To find player attributes, IDs, and team assignments, look in the game session object, in the matchmaker data property. If latency is used by the matchmaker, gather updated latency for the current region and include it in each player's data.   
Type: std:vector[<player>](https://docs.aws.amazon.com/gamelift/latest/apireference/API_Player.html)  
Required: Yes

**TicketId**  
Unique identifier for a matchmaking or match backfill request ticket. If no value is provided here, Amazon GameLift Servers will generate one in the form of a UUID. Use this identifier to track the match backfill ticket status or cancel the request if needed.   
Type: String  
Required: No

## StopMatchBackfillRequest
<a name="integration-server-sdk-cpp-ref-dataypes-stopmatchbackfillrequest"></a>

This data type is used to cancel a matchmaking backfill request. The information is communicated to the Amazon GameLift Servers service in a [StopMatchBackfill()](integration-server-sdk-cpp-ref-actions.md#integration-server-sdk-cpp-ref-stopmatchbackfill) call.

### Contents
<a name="integration-server-sdk-cpp-ref-dataypes-stopbackfill-contents"></a>

**GameSessionArn**  
Unique game session identifier associated with the request being canceled.   
Type: String  
Required: Yes

**MatchmakingConfigurationArn**  
Unique identifier of the matchmaker this request was sent to.   
Type: String  
Required: Yes

**TicketId**  
Unique identifier of the backfill request ticket to be canceled.  
Type: String  
Required: Yes

[C\$1\$1 server SDK for Amazon GameLift Servers 4.x -- Data types](integration-server-sdk-cpp-ref-datatypes.md)

**Topics**
+ [C\$1\$1 server SDK for Amazon GameLift Servers 4.x -- Data types](integration-server-sdk-cpp-ref-datatypes.md)
+ [AcceptPlayerSession()](#integration-server-sdk-cpp-ref-acceptplayersession)
+ [ActivateGameSession()](#integration-server-sdk-cpp-ref-activategamesession)
+ [DescribePlayerSessions()](#integration-server-sdk-cpp-ref-describeplayersessions)
+ [GetGameSessionId()](#integration-server-sdk-cpp-ref-getgamesessionid)
+ [GetInstanceCertificate()](#integration-server-sdk-cpp-ref-getinstancecertificate)
+ [GetSdkVersion()](#integration-server-sdk-cpp-ref-getsdk)
+ [GetTerminationTime()](#integration-server-sdk-cpp-ref-getterm)
+ [InitSDK()](#integration-server-sdk-cpp-ref-initsdk)
+ [ProcessEnding()](#integration-server-sdk-cpp-ref-processending)
+ [ProcessReady()](#integration-server-sdk-cpp-ref-processready)
+ [ProcessReadyAsync()](#integration-server-sdk-cpp-ref-processreadyasync)
+ [RemovePlayerSession()](#integration-server-sdk-cpp-ref-removeplayersession)
+ [StartMatchBackfill()](#integration-server-sdk-cpp-ref-startmatchbackfill)
+ [StopMatchBackfill()](#integration-server-sdk-cpp-ref-stopmatchbackfill)
+ [TerminateGameSession()](#integration-server-sdk-cpp-ref-terminategamesession)
+ [UpdatePlayerSessionCreationPolicy()](#integration-server-sdk-cpp-ref-updateplayersessioncreationpolicy)
+ [Destroy()](#integration-server-sdk-cpp-ref-destroy)

## AcceptPlayerSession()
<a name="integration-server-sdk-cpp-ref-acceptplayersession"></a>

Notifies the Amazon GameLift Servers service that a player with the specified player session ID has connected to the server process and needs validation. Amazon GameLift Servers 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 Servers changes the status of the player slot from RESERVED to ACTIVE. 

### Syntax
<a name="integration-server-sdk-cpp-ref-acceptplayersession-syntax"></a>

```
GenericOutcome AcceptPlayerSession(const std::string& playerSessionId);
```

### Parameters
<a name="integration-server-sdk-cpp-ref-acceptplayersession-parameter"></a>

**playerSessionId**  
Unique ID issued by the Amazon GameLift Servers service in response to a call to the AWS SDK Amazon GameLift Servers API action [CreatePlayerSession](https://docs.aws.amazon.com/gamelift/latest/apireference/API_CreatePlayerSession.html). The game client references this ID when connecting to the server process.  
Type: std::string  
Required: Yes

### Return value
<a name="integration-server-sdk-cpp-ref-acceptplayersession-return"></a>

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

### Example
<a name="integration-server-sdk-cpp-ref-acceptplayersession-example"></a>

This example illustrates a function for handling a connection request, including validating and rejecting invalid player session IDs. 

```
void ReceiveConnectingPlayerSessionID (Connection& connection, const std::string& playerSessionId){
    Aws::GameLift::GenericOutcome connectOutcome = 
        Aws::GameLift::Server::AcceptPlayerSession(playerSessionId);
    if(connectOutcome.IsSuccess())
    {
        connectionToSessionMap.emplace(connection, playerSessionId);
        connection.Accept();
    }
    else 
    {
        connection.Reject(connectOutcome.GetError().GetMessage();
    }       
}
```

## ActivateGameSession()
<a name="integration-server-sdk-cpp-ref-activategamesession"></a>

Notifies the Amazon GameLift Servers service that the server process has started 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
<a name="integration-server-sdk-cpp-ref-activategamesession-syntax"></a>

```
GenericOutcome ActivateGameSession();
```

### Parameters
<a name="integration-server-sdk-cpp-ref-activategamesession-parameter"></a>

This action has no parameters.

### Return value
<a name="integration-server-sdk-cpp-ref-activategamesession-return"></a>

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

### Example
<a name="integration-server-sdk-cpp-ref-activategamesession-example"></a>

This example shows `ActivateGameSession()` being called as part of the `onStartGameSession()` callback function. 

```
void onStartGameSession(Aws::GameLift::Model::GameSession myGameSession)
{
   // game-specific tasks when starting a new game session, such as loading map
   GenericOutcome outcome = Aws::GameLift::Server::ActivateGameSession();
}
```

## DescribePlayerSessions()
<a name="integration-server-sdk-cpp-ref-describeplayersessions"></a>

Retrieves player session data, including settings, session metadata, and player data. Use this action to get information for a single player session, for all player sessions in a game session, or for all player sessions associated with a single player ID.

### Syntax
<a name="integration-server-sdk-cpp-ref-describeplayersessions-syntax"></a>

```
DescribePlayerSessionsOutcome DescribePlayerSessions ( 
    const Aws::GameLift::Server::Model::DescribePlayerSessionsRequest &describePlayerSessionsRequest);
```

### Parameters
<a name="integration-server-sdk-cpp-ref-describeplayersessions-parameter"></a>

**describePlayerSessionsRequest**  
A [DescribePlayerSessionsRequest](integration-server-sdk-cpp-ref-datatypes.md#integration-server-sdk-cpp-ref-dataypes-playersessions) object describing which player sessions to retrieve.  
Required: Yes

### Return value
<a name="integration-server-sdk-cpp-ref-describeplayersessions-return"></a>

If successful, returns a `DescribePlayerSessionsOutcome` object containing a set of player session objects that fit the request parameters. Player session objects have a structure identical to the AWS SDK Amazon GameLift Servers API [PlayerSession](https://docs.aws.amazon.com/gamelift/latest/apireference/API_PlayerSession.html) data type.

### Example
<a name="integration-server-sdk-cpp-ref-describeplayersessions-example"></a>

This example illustrates a request for all player sessions actively connected to a specified game session. By omitting `NextToken` and setting the `Limit` value to 10, Amazon GameLift Servers returns the first 10 player sessions records matching the request.

```
// Set request parameters
Aws::GameLift::Server::Model::DescribePlayerSessionsRequest request;
request.SetPlayerSessionStatusFilter(Aws::GameLift::Server::Model::PlayerSessionStatusMapper::GetNameForPlayerSessionStatus(Aws::GameLift::Server::Model::PlayerSessionStatus::Active));
request.SetLimit(10);
request.SetGameSessionId("the game session ID");    // can use GetGameSessionId()

// Call DescribePlayerSessions
Aws::GameLift::DescribePlayerSessionsOutcome playerSessionsOutcome = 
    Aws::GameLift::Server::DescribePlayerSessions(request);
```

## GetGameSessionId()
<a name="integration-server-sdk-cpp-ref-getgamesessionid"></a>

Retrieves a unique identifier for the game session currently being hosted by the server process, if the server process is active. The identifier is returned in ARN format: `arn:aws:gamelift:<region>::gamesession/fleet-<fleet ID>/<ID string>`. 

For idle process that are not yet activated with a game session, the call returns `Success`=`True` and `GameSessionId`=`""` (an empty string).

### Syntax
<a name="integration-server-sdk-cpp-ref-getgamesessionid-syntax"></a>

```
AwsStringOutcome GetGameSessionId();
```

### Parameters
<a name="integration-server-sdk-cpp-ref-getgamesessionid-parameter"></a>

This action has no parameters.

### Return value
<a name="integration-server-sdk-cpp-ref-getgamesessionid-return"></a>

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

### Example
<a name="integration-server-sdk-cpp-ref-getgamesessionid-example"></a>

```
Aws::GameLift::AwsStringOutcome sessionIdOutcome = 
    Aws::GameLift::Server::GetGameSessionId();
```

## GetInstanceCertificate()
<a name="integration-server-sdk-cpp-ref-getinstancecertificate"></a>

Retrieves the file location of a pem-encoded TLS certificate that is associated with the fleet and its instances. AWS Certificate Manager generates this certificate when you create a new fleet with the certificate configuration set to GENERATED. Use this certificate to establish a secure connection with a game client and to encrypt client/server communication. 

### Syntax
<a name="integration-server-sdk-cpp-ref-getinstancecertificate-syntax"></a>

```
GetInstanceCertificateOutcome GetInstanceCertificate();
```

### Parameters
<a name="integration-server-sdk-cpp-ref-getinstancecertificate-parameter"></a>

This action has no parameters.

### Return value
<a name="integration-server-sdk-cpp-ref-getinstancecertificate-return"></a>

If successful, returns a `GetInstanceCertificateOutcome` object containing the location of the fleet's TLS certificate file and certificate chain, which are stored on the instance. A root certificate file, extracted from the certificate chain, is also stored on the instance. If not successful, returns an error message. 

For more information about the certificate and certificate chain data, see [GetCertificate Response Elements](https://docs.aws.amazon.com/acm/latest/APIReference/API_GetCertificate.html#API_GetCertificate_ResponseElements) in the AWS Certificate Manager API Reference.

### Example
<a name="integration-server-sdk-cpp-ref-getinstancecertificate-example"></a>

```
Aws::GameLift::GetInstanceCertificateOutcome certificateOutcome = 
    Aws::GameLift::Server::GetInstanceCertificate();
```

## GetSdkVersion()
<a name="integration-server-sdk-cpp-ref-getsdk"></a>

Returns the current version number of the SDK in use.

### Syntax
<a name="integration-server-sdk-cpp-ref-getsdk-syntax"></a>

```
AwsStringOutcome GetSdkVersion();
```

### Parameters
<a name="integration-server-sdk-cpp-ref-getsdk-parameter"></a>

This action has no parameters.

### Return value
<a name="integration-server-sdk-cpp-ref-getsdk-return"></a>

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

### Example
<a name="integration-server-sdk-cpp-ref-getsdk-example"></a>

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

## GetTerminationTime()
<a name="integration-server-sdk-cpp-ref-getterm"></a>

Returns the time that a server process is scheduled to be shut down, if a termination time is available. A server process takes this action after receiving an `onProcessTerminate()` callback from the Amazon GameLift Servers service. Amazon GameLift Servers may call `onProcessTerminate()` for the following reasons: (1) when the server process has reported poor health or has not responded to Amazon GameLift Servers, (2) when terminating the instance during a scale-down event, or (3) when an instance is being terminated due to a [Spot interruption](spot-tasks.md). 

If the process has received an `onProcessTerminate()` callback, the value returned is the estimated termination time. If the process has not received an `onProcessTerminate()` callback, an error message is returned. Learn more about [shutting down a server process](gamelift-sdk-server-api.md#gamelift-sdk-server-terminate).

### Syntax
<a name="integration-server-sdk-cpp-ref-getterm-syntax"></a>

```
AwsLongOutcome GetTerminationTime();
```

### Parameters
<a name="integration-server-sdk-cpp-ref-getterm-parameter"></a>

This action has no parameters.

### Return value
<a name="integration-server-sdk-cpp-ref-getterm-return"></a>

If successful, returns the termination time as an `AwsLongOutcome` object. The value is the termination time, expressed in elapsed ticks since 0001 00:00:00. For example, the date time value 2020-09-13 12:26:40 -000Z is equal to 637355968000000000 ticks. If no termination time is available, returns an error message.

### Example
<a name="integration-server-sdk-cpp-ref-getterm-example"></a>

```
Aws::GameLift::AwsLongOutcome TermTimeOutcome = 
    Aws::GameLift::Server::GetTerminationTime();
```

## InitSDK()
<a name="integration-server-sdk-cpp-ref-initsdk"></a>

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

### Syntax
<a name="integration-server-sdk-cpp-ref-initsdk-syntax"></a>

```
InitSDKOutcome InitSDK();
```

### Parameters
<a name="integration-server-sdk-cpp-ref-initsdk-parameter"></a>

This action has no parameters.

### Return value
<a name="integration-server-sdk-cpp-ref-initsdk-return"></a>

If successful, returns an InitSdkOutcome object indicating that the server process is ready to call [ProcessReady()](#integration-server-sdk-cpp-ref-processready). 

### Example
<a name="integration-server-sdk-cpp-ref-initsdk-example"></a>

```
Aws::GameLift::Server::InitSDKOutcome initOutcome = 
    Aws::GameLift::Server::InitSDK();
```

## ProcessEnding()
<a name="integration-server-sdk-cpp-ref-processending"></a>

Notifies the Amazon GameLift Servers 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.

Once the method exits with a code of 0, you can terminate the process with a successful exit code. You can also exit the process with an error code. If you exit with an error code, the fleet event will indicated the process terminated abnormally (`SERVER_PROCESS_TERMINATED_UNHEALTHY`). 

### Syntax
<a name="integration-server-sdk-cpp-ref-processending-syntax"></a>

```
GenericOutcome ProcessEnding();
```

### Parameters
<a name="integration-server-sdk-cpp-ref-processending-parameter"></a>

This action has no parameters.

### Return value
<a name="integration-server-sdk-cpp-ref-processending-return"></a>

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

### Example
<a name="integration-server-sdk-cpp-ref-processending-example"></a>

```
Aws::GameLift::GenericOutcome outcome = Aws::GameLift::Server::ProcessEnding();
if (outcome.Success)
    exit(0);  // exit with success
// otherwise, exit with error code
exit(errorCode);
```

## ProcessReady()
<a name="integration-server-sdk-cpp-ref-processready"></a>

Notifies the Amazon GameLift Servers service that the server process is ready to host game sessions. Call this method after successfully invoking [InitSDK()](#integration-server-sdk-cpp-ref-initsdk) and completing setup tasks that are required before the server process can host a game session. This method should be called only once per process.

This call is synchronous. To make an asynchronous call, use [ProcessReadyAsync()](#integration-server-sdk-cpp-ref-processreadyasync). See [Initialize the server process](gamelift-sdk-server-api.md#gamelift-sdk-server-initialize) for more details.

### Syntax
<a name="integration-server-sdk-cpp-ref-processready-syntax"></a>

```
GenericOutcome ProcessReady(
    const Aws::GameLift::Server::ProcessParameters &processParameters);
```

### Parameters
<a name="integration-server-sdk-cpp-ref-processready-parameter"></a>

**processParameters**  
A [ProcessParameters](integration-server-sdk-cpp-ref-datatypes.md#integration-server-sdk-cpp-ref-dataypes-process) object communicating the following information about the server process:  
+ Names of callback methods, implemented in the game server code, that the Amazon GameLift Servers 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 Servers to capture and store.
Required: Yes

### Return value
<a name="integration-server-sdk-cpp-ref-processready-return"></a>

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

### Example
<a name="integration-server-sdk-cpp-ref-processready-example"></a>

This example illustrates both the [ProcessReady()](#integration-server-sdk-cpp-ref-processready) call and callback function implementations.

```
// Set parameters and call ProcessReady
std::string serverLog("serverOut.log");        // Example of a log file written by the game server
std::vector<std::string> logPaths;
logPaths.push_back(serverLog);

int listenPort = 9339;

Aws::GameLift::Server::ProcessParameters processReadyParameter = Aws::GameLift::Server::ProcessParameters(
    std::bind(&Server::onStartGameSession, this, std::placeholders::_1),
    std::bind(&Server::onProcessTerminate, this),
    std::bind(&Server::OnHealthCheck, this),
    std::bind(&Server::OnUpdateGameSession, this),
    listenPort,
    Aws::GameLift::Server::LogParameters(logPaths)); 

Aws::GameLift::GenericOutcome outcome = 
   Aws::GameLift::Server::ProcessReady(processReadyParameter);

// Implement callback functions
void Server::onStartGameSession(Aws::GameLift::Model::GameSession myGameSession)
{
   // game-specific tasks when starting a new game session, such as loading map
   GenericOutcome outcome = 
       Aws::GameLift::Server::ActivateGameSession (maxPlayers);
}

void Server::onProcessTerminate()
{
   // game-specific tasks required to gracefully shut down a game session, 
   // such as notifying players, preserving game state data, and other cleanup
   GenericOutcome outcome = Aws::GameLift::Server::ProcessEnding();
}

bool Server::onHealthCheck()
{
    bool health;
    // complete health evaluation within 60 seconds and set health
    return health;
}
```

## ProcessReadyAsync()
<a name="integration-server-sdk-cpp-ref-processreadyasync"></a>

Notifies the Amazon GameLift Servers service that the server process is ready to host game sessions. This method should be called once the server process is ready to host a game session. The parameters specify the names of callback functions for Amazon GameLift Servers to call in certain circumstances. Game server code must implement these functions.

This call is asynchronous. To make a synchronous call, use [ProcessReady()](#integration-server-sdk-cpp-ref-processready). See [Initialize the server process](gamelift-sdk-server-api.md#gamelift-sdk-server-initialize) for more details.

### Syntax
<a name="integration-server-sdk-cpp-ref-processreadyasync-syntax"></a>

```
GenericOutcomeCallable ProcessReadyAsync(
    const Aws::GameLift::Server::ProcessParameters &processParameters);
```

### Parameters
<a name="integration-server-sdk-cpp-ref-processreadyasync-parameter"></a>

**processParameters**  
A [ProcessParameters](integration-server-sdk-cpp-ref-datatypes.md#integration-server-sdk-cpp-ref-dataypes-process) object communicating the following information about the server process:  
+ Names of callback methods, implemented in the game server code, that the Amazon GameLift Servers 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 Servers to capture and store.
Required: Yes

### Return value
<a name="integration-server-sdk-cpp-ref-processreadyasync-return"></a>

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

### Example
<a name="integration-server-sdk-cpp-ref-processreadyasync-example"></a>

```
// Set parameters and call ProcessReady
std::string serverLog("serverOut.log");        // This is an example of a log file written by the game server
std::vector<std::string> logPaths;
logPaths.push_back(serverLog);

int listenPort = 9339;

Aws::GameLift::Server::ProcessParameters processReadyParameter = Aws::GameLift::Server::ProcessParameters(
    std::bind(&Server::onStartGameSession, this, std::placeholders::_1),
    std::bind(&Server::onProcessTerminate, this),
    std::bind(&Server::OnHealthCheck, this),
    std::bind(&Server::OnUpdateGameSession, this),
    listenPort,
    Aws::GameLift::Server::LogParameters(logPaths));

Aws::GameLift::GenericOutcomeCallable outcome = 
   Aws::GameLift::Server::ProcessReadyAsync(processReadyParameter);

// Implement callback functions
void onStartGameSession(Aws::GameLift::Model::GameSession myGameSession)
{
   // game-specific tasks when starting a new game session, such as loading map
   GenericOutcome outcome = Aws::GameLift::Server::ActivateGameSession (maxPlayers);
}

void onProcessTerminate()
{
   // game-specific tasks required to gracefully shut down a game session, 
   // such as notifying players, preserving game state data, and other cleanup
   GenericOutcome outcome = Aws::GameLift::Server::ProcessEnding();
}

bool onHealthCheck()
{
    // perform health evaluation and complete within 60 seconds
    return health;
}
```

## RemovePlayerSession()
<a name="integration-server-sdk-cpp-ref-removeplayersession"></a>

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

### Syntax
<a name="integration-server-sdk-cpp-ref-removeplayersession-syntax"></a>

```
GenericOutcome RemovePlayerSession(
    const std::string& playerSessionId);
```

### Parameters
<a name="integration-server-sdk-cpp-ref-removeplayersession-parameter"></a>

**playerSessionId**  
Unique ID issued by the Amazon GameLift Servers service in response to a call to the AWS SDK Amazon GameLift Servers API action [CreatePlayerSession](https://docs.aws.amazon.com/gamelift/latest/apireference/API_CreatePlayerSession.html). The game client references this ID when connecting to the server process.  
Type: std::string  
Required: Yes

### Return value
<a name="integration-server-sdk-cpp-ref-removeplayersession-return"></a>

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

### Example
<a name="integration-server-sdk-cpp-ref-removeplayersession-example"></a>

```
Aws::GameLift::GenericOutcome disconnectOutcome = 
    Aws::GameLift::Server::RemovePlayerSession(playerSessionId);
```

## StartMatchBackfill()
<a name="integration-server-sdk-cpp-ref-startmatchbackfill"></a>

Sends a request to find new players for open slots in a game session created with FlexMatch. See also the AWS SDK action [StartMatchBackfill()](https://docs.aws.amazon.com/gamelift/latest/apireference/API_StartMatchBackfill.html). 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](https://docs.aws.amazon.com/gameliftservers/latest/flexmatchguide/match-backfill.html).

This action is asynchronous. If new players are successfully matched, the Amazon GameLift Servers service delivers updated matchmaker data by invoking the callback function `OnUpdateGameSession()`.

A server process can have only one active match backfill request at a time. To send a new request, first call [StopMatchBackfill()](#integration-server-sdk-cpp-ref-stopmatchbackfill) to cancel the original request.

### Syntax
<a name="integration-server-sdk-cpp-ref-startmatchbackfill-syntax"></a>

```
StartMatchBackfillOutcome StartMatchBackfill ( 
    const Aws::GameLift::Server::Model::StartMatchBackfillRequest &startBackfillRequest);
```

### Parameters
<a name="integration-server-sdk-cpp-ref-startmatchbackfill-parameter"></a>

**StartMatchBackfillRequest**  
A [StartMatchBackfillRequest](integration-server-sdk-cpp-ref-datatypes.md#integration-server-sdk-cpp-ref-dataypes-startmatchbackfillrequest) 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 Servers 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
<a name="integration-server-sdk-cpp-ref-startmatchbackfill-return"></a>

Returns a StartMatchBackfillOutcome object with the match backfill ticket or failure with an error message. Ticket status can be tracked using the AWS SDK action [DescribeMatchmaking()](https://docs.aws.amazon.com/gamelift/latest/apireference/API_DescribeMatchmaking.html).

### Example
<a name="integration-server-sdk-cpp-ref-startmatchbackfill-example"></a>

```
// Build a backfill request
std::vector<Player> players;
Aws::GameLift::Server::Model::StartMatchBackfillRequest startBackfillRequest;
startBackfillRequest.SetTicketId("a ticket ID");                                         //optional, autogenerated if not provided
startBackfillRequest.SetMatchmakingConfigurationArn("the matchmaker configuration ARN"); //from the game session matchmaker data
startBackfillRequest.SetGameSessionArn("the game session ARN");                          // can use GetGameSessionId()
startBackfillRequest.SetPlayers(players);                                                  //from the game session matchmaker data

// Send backfill request
Aws::GameLift::StartMatchBackfillOutcome backfillOutcome = 
    Aws::GameLift::Server::StartMatchBackfill(startBackfillRequest);

// Implement callback function for backfill
void Server::OnUpdateGameSession(Aws::GameLift::Server::Model::GameSession gameSession, Aws::GameLift::Server::Model::UpdateReason updateReason, std::string backfillTicketId)
{
   // handle status messages
   // perform game-specific tasks to prep for newly matched players
}
```

## StopMatchBackfill()
<a name="integration-server-sdk-cpp-ref-stopmatchbackfill"></a>

Cancels an active match backfill request that was created with [StartMatchBackfill()](#integration-server-sdk-cpp-ref-startmatchbackfill). See also the AWS SDK action [StopMatchmaking()](https://docs.aws.amazon.com/gamelift/latest/apireference/API_StopMatchmaking.html). Learn more about the [FlexMatch backfill feature](https://docs.aws.amazon.com/gameliftservers/latest/flexmatchguide/match-backfill.html).

### Syntax
<a name="integration-server-sdk-cpp-ref-stopmatchbackfill-syntax"></a>

```
GenericOutcome StopMatchBackfill ( 
    const Aws::GameLift::Server::Model::StopMatchBackfillRequest &stopBackfillRequest);
```

### Parameters
<a name="integration-server-sdk-cpp-ref-stopmatchbackfill-parameter"></a>

**StopMatchBackfillRequest**  
A [StopMatchBackfillRequest](integration-server-sdk-cpp-ref-datatypes.md#integration-server-sdk-cpp-ref-dataypes-stopmatchbackfillrequest) 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
<a name="integration-server-sdk-cpp-ref-stopmatchbackfill-return"></a>

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

### Example
<a name="integration-server-sdk-cpp-ref-stopmatchbackfill-example"></a>

```
// Set backfill stop request parameters

Aws::GameLift::Server::Model::StopMatchBackfillRequest stopBackfillRequest;
stopBackfillRequest.SetTicketId("the ticket ID");
stopBackfillRequest.SetGameSessionArn("the game session ARN");                           // can use GetGameSessionId()
stopBackfillRequest.SetMatchmakingConfigurationArn("the matchmaker configuration ARN");  // from the game session matchmaker data

Aws::GameLift::GenericOutcome stopBackfillOutcome = 
    Aws::GameLift::Server::StopMatchBackfillRequest(stopBackfillRequest);
```

## TerminateGameSession()
<a name="integration-server-sdk-cpp-ref-terminategamesession"></a>

**This method is deprecated with version 4.0.1. Instead, the server process should call [ProcessEnding()](#integration-server-sdk-cpp-ref-processending) after a game session has ended.**

Notifies the Amazon GameLift Servers service that the server process has ended the current game session. This action is called when the server process will remain active and ready to host a new game session. It should be called only after your game session termination procedure is complete, because it signals to Amazon GameLift Servers that the server process is immediately available to host a new game session. 

This action is not called if the server process will be shut down after the game session stops. Instead, call [ProcessEnding()](#integration-server-sdk-cpp-ref-processending) to signal that both the game session and the server process are ending. 

### Syntax
<a name="integration-server-sdk-cpp-ref-terminategamesession-syntax"></a>

```
GenericOutcome TerminateGameSession();
```

### Parameters
<a name="integration-server-sdk-cpp-ref-terminategamesession-parameter"></a>

This action has no parameters.

### Return value
<a name="integration-server-sdk-cpp-ref-terminategamesession-return"></a>

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

## UpdatePlayerSessionCreationPolicy()
<a name="integration-server-sdk-cpp-ref-updateplayersessioncreationpolicy"></a>

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 AWS SDK action [UpdateGameSession()](https://docs.aws.amazon.com/gamelift/latest/apireference/API_UpdateGameSession.html).

### Syntax
<a name="integration-server-sdk-cpp-ref-updateplayersessioncreationpolicy-syntax"></a>

```
GenericOutcome UpdatePlayerSessionCreationPolicy(
    Aws::GameLift::Model::PlayerSessionCreationPolicy newPlayerSessionPolicy);
```

### Parameters
<a name="integration-server-sdk-cpp-ref-updateplayersessioncreationpolicy-parameter"></a>

**newPlayerSessionPolicy**  
String value indicating whether the game session accepts new players.   
Type: Aws::GameLift::Model::PlayerSessionCreationPolicy enum. Valid values include:   
+ **ACCEPT\$1ALL** – Accept all new player sessions.
+ **DENY\$1ALL** – Deny all new player sessions.
Required: Yes

### Return value
<a name="integration-server-sdk-cpp-ref-updateplayersessioncreationpolicy-return"></a>

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

### Example
<a name="integration-server-sdk-cpp-ref-updateplayersessioncreationpolicy-example"></a>

This example sets the current game session's join policy to accept all players.

```
Aws::GameLift::GenericOutcome outcome = Aws::GameLift::Server::UpdatePlayerSessionCreationPolicy(Aws::GameLift::Model::PlayerSessionCreationPolicy::ACCEPT_ALL);
```

## Destroy()
<a name="integration-server-sdk-cpp-ref-destroy"></a>

Cleans up memory allocated by initSDK() during game server initialization. Use this method after you end a game server process to avoid wasting server memory.

### Syntax
<a name="integration-server-sdk-cpp-ref-destroy-syntax"></a>

```
GenericOutcome Aws::GameLift::Server::Destroy();
```

### Parameters
<a name="integration-server-sdk-cpp-ref-destroy-parameter"></a>

There are no parameters.

### Return value
<a name="integration-server-sdk-cpp-ref-destroy-return"></a>

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

### Example
<a name="integration-server-sdk-cpp-ref-destroy-example"></a>

This example cleans up the memory allocated by initSDK after a game server process has ended.

```
if (Aws::GameLift::Server::ProcessEnding().IsSuccess()) {
  Aws::GameLift::Server::Destroy();
  exit(0);
}
```