

# C\$1 server SDK 5.x for Amazon GameLift Servers -- Actions
<a name="integration-server-sdk5-csharp-actions"></a>

Use the server SDK 5.x 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). If you're using the Amazon GameLift Servers plugin for Unity, see also [Amazon GameLift Servers plugin for Unity (server SDK 5.x)](unity-plug-in.md).

# C\$1 server SDK 5.x for Amazon GameLift Servers -- Data types
<a name="integration-server-sdk5-csharp-datatypes"></a>

Use the Amazon GameLift Servers C\$1 server SDK 5.x 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). If you're using the Amazon GameLift Servers plugin for Unity, see also [Amazon GameLift Servers plugin for Unity (server SDK 5.x)](unity-plug-in.md).

[C\$1 server SDK 5.x for Amazon GameLift Servers -- Actions](integration-server-sdk5-csharp-actions.md)

**Topics**
+ [LogParameters](#integration-server-sdk5-csharp-dataypes-log)
+ [MetricsParameters](#integration-server-sdk5-csharp-datatypes-metricsparameters)
+ [ProcessParameters](#integration-server-sdk5-csharp-dataypes-process)
+ [UpdateGameSession](#integration-server-sdk5-csharp-dataypes-updategamesession)
+ [GameSession](#integration-server-sdk5-csharp-dataypes-gamesession)
+ [ServerParameters](#integration-server-sdk5-csharp-dataypes-serverparameters)
+ [StartMatchBackfillRequest](#integration-server-sdk5-csharp-dataypes-startmatchbackfillrequest)
+ [Player](#integration-server-sdk5-csharp-dataypes-player)
+ [DescribePlayerSessionsRequest](#integration-server-sdk5-csharp-dataypes-playersessions)
+ [StopMatchBackfillRequest](#integration-server-sdk5-csharp-dataypes-stopmatchbackfillrequest)
+ [GetFleetRoleCredentialsRequest](#integration-server-sdk5-csharp-dataypes-getfleetrolecredentialsrequest)
+ [AttributeValue](#integration-server-sdk5-csharp-datatypes-attributevalue)
+ [AwsStringOutcome](#integration-server-sdk5-csharp-datatypes-awsstringoutcome)
+ [GenericOutcome](#integration-server-sdk5-csharp-datatypes-genericoutcome)
+ [MetricsManagerOutcome](#integration-server-sdk5-csharp-datatypes-metricsmanageroutcome)
+ [DescribePlayerSessionsOutcome](#integration-server-sdk5-csharp-datatypes-describeplayersessionsoutcome)
+ [DescribePlayerSessionsResult](#integration-server-sdk5-csharp-datatypes-describeplayersessionsresult)
+ [PlayerSession](#integration-server-sdk5-csharp-datatypes-playersession)
+ [StartMatchBackfillOutcome](#integration-server-sdk5-csharp-datatypes-startmatchbackfilloutcome)
+ [StartMatchBackfillResult](#integration-server-sdk5-csharp-datatypes-startmatchbackfillresult)
+ [GetComputeCertificateOutcome](#integration-server-sdk5-csharp-datatypes-getcomputecertificateoutcome)
+ [GetComputeCertificateResult](#integration-server-sdk5-csharp-datatypes-getcomputecertificateresult)
+ [GetFleetRoleCredentialsOutcome](#integration-server-sdk5-csharp-datatypes-getfleetrolecredentialsoutcome)
+ [GetFleetRoleCredentialsResult](#integration-server-sdk5-csharp-datatypes-getfleetrolecredentialsresult)
+ [AwsDateTimeOutcome](#integration-server-sdk5-csharp-datatypes-awsdatetimeoutcome)
+ [GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror)
+ [Enums](#integration-server-sdk5-csharp-datatypes-enums)

## LogParameters
<a name="integration-server-sdk5-csharp-dataypes-log"></a>

Use this data type to identify which files generated during a game session that you want the game server to upload to Amazon GameLift Servers after the game session ends. The game server communicates `LogParameters to` Amazon GameLift Servers in a [ProcessReady()](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-processready) call.


|  |  | 
| --- |--- |
|  **Properties**  | Description | 
| LogPaths |  The list of directory paths to game server log files you want Amazon GameLift Servers to store for future access. The server process generates these files during each game session. You define file paths and names in your game server and store them 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 path would be `c:\game\MyGame\sessionLogs` on a Windows instance. **Type:** `List<String>` **Required:** No  | 

## MetricsParameters
<a name="integration-server-sdk5-csharp-datatypes-metricsparameters"></a>

Use this data type to configure metrics collection and crash reporting for the game server. The game server communicates `MetricsParameters` to Amazon GameLift Servers in an [InitMetrics()](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-initmetrics) call.


|  |  | 
| --- |--- |
|  **Properties**  | Description | 
| StatsdHost |  The hostname or IP address of the StatsD server for metrics collection. **Type:** `String` **Required:** No  | 
| StatsdPort |  The port number of the StatsD server for metrics collection. **Type:** `Integer` **Required:** No  | 
| CrashReporterHost |  The hostname or IP address of the crash reporter server. **Type:** `String` **Required:** No  | 
| CrashReporterPort |  The port number of the crash reporter server. **Type:** `Integer` **Required:** No  | 
| FlushIntervalMs |  The interval in milliseconds for flushing metrics data to the server. **Type:** `Integer` **Required:** No  | 
| MaxPacketSize |  The maximum size in bytes for metrics packets sent to the server. **Type:** `Integer` **Required:** No  | 

## ProcessParameters
<a name="integration-server-sdk5-csharp-dataypes-process"></a>

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


|  |  | 
| --- |--- |
|  **Properties**  | Description | 
| LogParameters | The object with a list of directory paths to game session log files.**Type:** `Aws::GameLift::Server::LogParameters`**Required:** Yes | 
| OnHealthCheck | The name of callback function that Amazon GameLift Servers 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, if none is received, Amazon GameLift Servers records the server process as unhealthy.**Type:** `void OnHealthCheckDelegate()`**Required:** Yes | 
| OnProcessTerminate | The name of callback function that Amazon GameLift Servers 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-sdk5-csharp-actions.md#integration-server-sdk5-csharp-processending) call before it shuts down the server process.**Type:** `void OnProcessTerminateDelegate()`**Required:** Yes | 
| OnStartGameSession | The name of callback function that Amazon GameLift Servers 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/gameliftservers/latest/apireference/API_CreateGameSession.html). The callback function takes a [GameSession](#integration-server-sdk5-csharp-dataypes-gamesession) object.**Type:** `void OnStartGameSessionDelegate(GameSession)`**Required:** Yes | 
| OnUpdateGameSession | The name of callback function that Amazon GameLift Servers invokes to pass an updated game session object to the server process. Amazon GameLift Servers calls this function when a match backfill request has been processed to provide updated matchmaker data. It passes a [GameSession](#integration-server-sdk5-csharp-dataypes-gamesession) object, a status update (updateReason), and the match backfill ticket ID.**Type:** void OnUpdateGameSessionDelegate([UpdateGameSession](#integration-server-sdk5-csharp-dataypes-updategamesession))**Required:** No | 
| Port | The port number that 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 | 

## UpdateGameSession
<a name="integration-server-sdk5-csharp-dataypes-updategamesession"></a>

Updated information for a game session object, includes the reason that the game session was updated. If the update is related to a match backfill action, this data type includes the backfill ticket ID.


| Properties | **Description** | 
| --- | --- | 
| GameSession | A [GameSession](#integration-server-sdk5-csharp-dataypes-gamesession) object. The GameSession object contains properties describing a game session. **Type:** `GameSession GameSession()`**Required:** Yes | 
| UpdateReason | The reason that the game session is being updated.**Type:** `UpdateReason UpdateReason()`**Required:** Yes | 
| BackfillTicketId | The ID of the backfill ticket attempting to update the game session.**Type:** `String`**Required:** Yes | 

## GameSession
<a name="integration-server-sdk5-csharp-dataypes-gamesession"></a>

Details of a game session. 


| Properties | **Description** | 
| --- | --- | 
| GameSessionId |  A unique identifier for the game session. A game session ARN has the following format: `arn:aws:gamelift:<region>::gamesession/<fleet ID>/<custom ID string or idempotency token>`. **Type:** `String` **Required**: No  | 
| Name |  A descriptive label of the game session.  **Type:** `String` **Required**: No  | 
| FleetId |  A unique identifier for the fleet that the game session is running on. **Type:** `String` **Required**: No  | 
| MaximumPlayerSessionCount |  The maximum number of player connections to the game session. **Type:** `Integer` **Required**: No  | 
| Port |  The port number for the game session. To connect to an Amazon GameLift Servers game server, an app needs both the IP address and port number. **Type:** `Integer` **Required**: No  | 
| IpAddress |  The IP address of the game session. To connect to an Amazon GameLift Servers game server, an app needs both the IP address and port number. **Type:** `String` **Required**: No  | 
| GameSessionData |  A set of custom game session properties, formatted as a single string value.  **Type:** `String` **Required**: No  | 
| MatchmakerData |  The information about the matchmaking process that was used to create the game session, in JSON syntax, formatted as a string. In addition the matchmaking configuration used, it contains data on all players assigned to the match, including player attributes and team assignments. **Type:** `String` **Required**: No  | 
| GameProperties |  A set of custom properties for a game session, formatted as key:value pairs. These properties are passed with a request to start a new game session. **Type:** `Dictionary<string, string>` **Required**: No  | 
| DnsName |  The DNS identifier assigned to the instance that's running the game session. Values have the following format: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/gameliftservers/latest/developerguide/integration-server-sdk5-csharp-datatypes.html) When connecting to a game session that's running on a TLS-enabled fleet, you must use the DNS name, not the IP address. **Type:** `String` **Required**: No  | 

## ServerParameters
<a name="integration-server-sdk5-csharp-dataypes-serverparameters"></a>

Information used to maintain the connection between an Amazon GameLift Servers Anywhere server and the Amazon GameLift Servers service. This information is used when launching new server processes with [InitSDK()](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-initsdk). For servers hosted on Amazon GameLift Servers managed EC2 instances, use an empty object.


| Properties | **Description** | 
| --- | --- | 
| WebSocketUrl |  The `GameLiftServerSdkEndpoint` returned when you `RegisterCompute` as part of Amazon GameLift Servers Anywhere. **Type:** `String` **Required**: Yes  | 
| ProcessId |  A unique identifier registered to the server process hosting your game. **Type:** `String` **Required**: Yes  | 
| HostId |  A unique identifier for the host with the server processes hosting your game. The hostId is the ComputeName used when you registered your compute. For more information see, [RegisterCompute](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html) **Type:** `String` **Required**: Yes  | 
| FleetId | The fleet ID of the fleet that the compute is registered to. For more information see, [RegisterCompute](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html).**Type:** `String`**Required**: Yes | 
| AuthToken | The authentication token generated by Amazon GameLift Servers that authenticates your server to Amazon GameLift Servers. For more information see, [GetComputeAuthToken](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_GetComputeAuthToken.html).**Type:** `String`**Required**: Yes | 

## StartMatchBackfillRequest
<a name="integration-server-sdk5-csharp-dataypes-startmatchbackfillrequest"></a>

Information used to create a matchmaking backfill request. The game server communicates this information to Amazon GameLift Servers in a [StartMatchBackfill()](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-startmatchbackfill) call.


| Properties | **Description** | 
| --- | --- | 
| GameSessionArn |  The unique game session identifier. The API operation `[GetGameSessionId](https://docs.aws.amazon.com/gameliftservers/latest/developerguide/integration-server-sdk5-csharp-actions.html#integration-server-sdk5-csharp-getgamesessionid)` returns the identifier in ARN format. **Type:** `String` **Required**: Yes  | 
| MatchmakingConfigurationArn |  The unique identifier, in the form of an ARN, for the matchmaker to use for this request. The matchmaker ARN for the original game session is in the game session object in the matchmaker data property. Learn more about matchmaker data in [Work with matchmaker data](https://docs.aws.amazon.com/gameliftservers/latest/flexmatchguide/match-server.html#match-server-data.html). **Type:** `String` **Required**: Yes  | 
| Players |  A set of data that represents 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. **Type:** `List<Player>` **Required**: Yes  | 
| TicketId |  The unique identifier for a matchmaking or match backfill request ticket. If you don't provide a value, Amazon GameLift Servers generates one. Use this identifier to track the match backfill ticket status or cancel the request if needed.  **Type:** `String` **Required**: No  | 

## Player
<a name="integration-server-sdk5-csharp-dataypes-player"></a>

Represents a player in matchmaking. When a matchmaking request starts, a player has a player ID, attributes, and possibly latency data. Amazon GameLift Servers adds team information after a match is made.


| Properties | **Description** | 
| --- | --- | 
| LatencyInMS |  A set of values expressed in milliseconds, that indicate the amount of latency that a player experiences when connected to a location.  If this property is used, the player is only matched for locations listed. If a matchmaker has a rule that evaluates player latency, players must report latency to be matched. **Type:** `Dictionary<string, int>` **Required**: No  | 
| PlayerAttributes |  A collection of key:value pairs that contain player information for use in matchmaking. Player attribute keys must match the PlayerAttributes used in a matchmaking rule set. For more information about player attributes, see [AttributeValue](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_AttributeValue.html). **Type:** `Dictionary<string, AttributeValue` **Required**: No  | 
| PlayerId |  A unique identifier for a player. **Type:** `String` **Required**: No  | 
| Team |  The name of the team that the player is assigned to in a match. You define team name in the matchmaking rule set. **Type:** `String` **Required**: No  | 

## DescribePlayerSessionsRequest
<a name="integration-server-sdk5-csharp-dataypes-playersessions"></a>

This data type is used to specify which player session(s) to retrieve. It can be used in several ways: (1) provide a PlayerSessionId to request a specific player session; (2) provide a GameSessionId to request all player sessions in the specified game session; or (3) 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 as sequential pages.


| Properties | **Description** | 
| --- | --- | 
| GameSessionId |  The 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 (if one was specified when the game session was created) a generated string.  **Type:** `String` **Required**: No  | 
| PlayerSessionId |  The unique identifier for a player session. **Type:** `String` **Required**: No  | 
| PlayerId |  The unique identifier for a player. See [Generate player IDs](player-sessions-player-identifiers.md). **Type:** `String` **Required**: No  | 
| PlayerSessionStatusFilter |  The player session status to filter results on. Possible player session statuses include the following: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/gameliftservers/latest/developerguide/integration-server-sdk5-csharp-datatypes.html) **Type:** `String` **Required**: No  | 
| NextToken |  The token indicating the start of the next page of results. To specify the start of the result set, don't provide a value. If you provide a player session ID, this parameter is ignored. **Type:** `String` **Required**: No  | 
| Limit |  The maximum number of results to return. If you provide a player session ID, this parameter is ignored. **Type:** `int` **Required**: No  | 

## StopMatchBackfillRequest
<a name="integration-server-sdk5-csharp-dataypes-stopmatchbackfillrequest"></a>

Information used to cancel a matchmaking backfill request. The game server communicates this information to Amazon GameLift Servers service in a [StopMatchBackfill()](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-stopmatchbackfill) call.


| Properties | **Description** | 
| --- | --- | 
| GameSessionArn |  The unique game session identifier of the request being canceled. **Type:** `string` **Required**: Yes  | 
| MatchmakingConfigurationArn |  The unique identifier of the matchmaker this request was sent to. **Type:** `string` **Required**: Yes  | 
| TicketId |  The unique identifier of the backfill request ticket to be canceled. **Type:** `string` **Required**: Yes  | 

## GetFleetRoleCredentialsRequest
<a name="integration-server-sdk5-csharp-dataypes-getfleetrolecredentialsrequest"></a>

This data type gives the game server limited access to your other AWS resources. For more information see, [Set up an IAM service role for Amazon GameLift Servers](setting-up-role.md).


| Properties | **Description** | 
| --- | --- | 
| RoleArn | The Amazon Resource Name (ARN) of the service role that extends limited access to your AWS resources. **Type:** `string` **Required**: Yes  | 
| RoleSessionName | The name of the session that describes the use of the role credentials. **Type:** `string` **Required**: No  | 

## AttributeValue
<a name="integration-server-sdk5-csharp-datatypes-attributevalue"></a>

Use these values in [Player](#integration-server-sdk5-csharp-dataypes-player) attribute key-value pairs. This object lets you specify an attribute value using any of the valid data types: string, number, string array, or data map. Each `AttributeValue` object can use only one of the available properties.


| Properties | Description | 
| --- | --- | 
| attrType |  Specifies the type of attribute value. **Type:** An `AttrType` [enum](#integration-server-sdk5-csharp-datatypes-enums) value.  **Required:** No  | 
| S |  Represents a string attribute value. **Type:** `string` **Required:** Yes  | 
| N |  Represents a numeric attribute value. **Type:** `double` **Required:** Yes  | 
| SL |  Represents an array of string attribute values. **Type:** `string[]` **Required:** Yes  | 
| SDM |  Represents a dictionary of string keys and double values. **Type:** `Dictionary<string, double>` **Required:** Yes  | 

## AwsStringOutcome
<a name="integration-server-sdk5-csharp-datatypes-awsstringoutcome"></a>

This data type results from an action and produces an object with the following properties:


| Properties | Description | 
| --- | --- | 
| Result |  The result of the action. **Type:** `string` **Required:** No  | 
| Success |  Whether the action was successful or not. **Type:** `bool` **Required**: Yes  | 
| Error |  The error that occurred if the action was unsuccessful. **Type:** [GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **Required:** No  | 

## GenericOutcome
<a name="integration-server-sdk5-csharp-datatypes-genericoutcome"></a>

This data type results from an action and produces an object with the following properties:


| Properties | Description | 
| --- | --- | 
| Success |  Whether the action was successful or not. **Type:** `bool` **Required**: Yes  | 
| Error |  The error that occurred if the action was unsuccessful. **Type:** [GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **Required:** No  | 

## MetricsManagerOutcome
<a name="integration-server-sdk5-csharp-datatypes-metricsmanageroutcome"></a>

Represents the result of an [InitMetrics()](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-initmetrics) call. Contains either a MetricsManager instance on success or error information on failure.


|  |  | 
| --- |--- |
| Result |  The MetricsManager instance for collecting and reporting metrics. **Type:** `MetricsManager` **Required:** No  | 
| Success |  Whether the action was successful or not. **Type:** `bool` **Required**: Yes  | 
| Error |  The error that occurred if the action was unsuccessful. **Type:** [GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **Required:** No  | 

## DescribePlayerSessionsOutcome
<a name="integration-server-sdk5-csharp-datatypes-describeplayersessionsoutcome"></a>

This data type results from an action and produces an object with the following properties:


| Properties | Description | 
| --- | --- | 
| Result |  The result of the action. **Type:** [DescribePlayerSessionsResult](#integration-server-sdk5-csharp-datatypes-describeplayersessionsresult) **Required:** No   | 
| Success |  Whether the action was successful or not. **Type:** `bool` **Required**: Yes  | 
| Error |  The error that occurred if the action was unsuccessful. **Type:** [GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **Required:** No  | 

## DescribePlayerSessionsResult
<a name="integration-server-sdk5-csharp-datatypes-describeplayersessionsresult"></a>


| Properties | Description | 
| --- | --- | 
| NextToken |  The token indicating the start of the next page of results. To specify the start of the result set, don't provide a value. If you provide a player session ID, this parameter is ignored. **Type:** `string` **Required:** Yes  | 
| PlayerSessions |  A collection of objects containing properties for each player session that matches the request.  **Type:** `IList<PlayerSession>` **Required:**   | 
| Success |  Whether the action was successful or not. **Type:** `bool` **Required**: Yes  | 
| Error |  The error that occurred if the action was unsuccessful. **Type:** [GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **Required:** No  | 

## PlayerSession
<a name="integration-server-sdk5-csharp-datatypes-playersession"></a>


| Properties | Description | 
| --- | --- | 
| CreationTime |  **Type:** `long` **Required:** Yes  | 
| FleetId |  **Type:** `string` **Required:** Yes  | 
| GameSessionId |  **Type:** `string` **Required:** Yes  | 
| IpAddress |  **Type:** `string` **Required:** Yes  | 
| PlayerData |  **Type:** `string` **Required:** Yes  | 
| PlayerId |  **Type:** `string` **Required:** Yes  | 
| PlayerSessionId |  **Type:** `string` **Required:** Yes  | 
| Port |  **Type:** `int` **Required:** Yes  | 
| Status |  **Type:** A `PlayerSessionStatus` [enum](#integration-server-sdk5-csharp-datatypes-enums). **Required:** Yes  | 
| TerminationTime |  **Type:** `long` **Required:** Yes  | 
| DnsName |  **Type:** `string` **Required:** Yes  | 

## StartMatchBackfillOutcome
<a name="integration-server-sdk5-csharp-datatypes-startmatchbackfilloutcome"></a>

This data type results from an action and produces an object with the following properties:


| Properties | Description | 
| --- | --- | 
| Result |  The result of the action. **Type:** [StartMatchBackfillResult](#integration-server-sdk5-csharp-datatypes-startmatchbackfillresult) **Required:** No  | 
| Success |  Whether the action was successful or not. **Type:** `bool` **Required**: Yes  | 
| Error |  The error that occurred if the action was unsuccessful. **Type:** [GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **Required:** No  | 

## StartMatchBackfillResult
<a name="integration-server-sdk5-csharp-datatypes-startmatchbackfillresult"></a>


| Properties | Description | 
| --- | --- | 
| TicketId |  **Type:** `string` **Required:** Yes  | 

## GetComputeCertificateOutcome
<a name="integration-server-sdk5-csharp-datatypes-getcomputecertificateoutcome"></a>

This data type results from an action and produces an object with the following properties:


| Properties | Description | 
| --- | --- | 
| Result |  The result of the action. **Type:** [GetComputeCertificateResult](#integration-server-sdk5-csharp-datatypes-getcomputecertificateresult) **Required:** No   | 
| Success |  Whether the action was successful or not. **Type:** `bool` **Required**: Yes  | 
| Error |  The error that occurred if the action was unsuccessful. **Type:** [GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **Required:** No  | 

## GetComputeCertificateResult
<a name="integration-server-sdk5-csharp-datatypes-getcomputecertificateresult"></a>

The path to the TLS certificate on your compute and the compute's host name.


| Properties | Description | 
| --- | --- | 
| CertificatePath |  **Type:** `string` **Required:** Yes  | 
| ComputeName |  **Type:** `string` **Required:** Yes  | 

## GetFleetRoleCredentialsOutcome
<a name="integration-server-sdk5-csharp-datatypes-getfleetrolecredentialsoutcome"></a>

This data type results from an action and produces an object with the following properties:


| Properties | Description | 
| --- | --- | 
| Result |  The result of the action. **Type:** [GetFleetRoleCredentialsResult](#integration-server-sdk5-csharp-datatypes-getfleetrolecredentialsresult) **Required:** No  | 
| Success |  Whether the action was successful or not. **Type:** `bool` **Required**: Yes  | 
| Error |  The error that occurred if the action was unsuccessful. **Type:** [GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **Required:** No  | 

## GetFleetRoleCredentialsResult
<a name="integration-server-sdk5-csharp-datatypes-getfleetrolecredentialsresult"></a>


| Properties | Description | 
| --- | --- | 
| AccessKeyId |  The access key ID to authenticate and provide access to your AWS resources. **Type:** `string` **Required:** No  | 
| AssumedRoleId |  The ID of the user that the service role belongs to. **Type:** `string` **Required:** No  | 
| AssumedRoleUserArn |  The Amazon Resource Name (ARN) of the user that the service role belongs to. **Type:** `string` **Required:** No  | 
| Expiration |  The amount of time until your session credentials expire. **Type:** `DateTime` **Required:** No  | 
| SecretAccessKey |  The secret access key ID for authentication. **Type:** `string` **Required:** No  | 
| SessionToken |  A token to identify the current active session interacting with your AWS resources. **Type:** `string` **Required:** No  | 
| Success |  Whether the action was successful or not. **Type:** `bool` **Required**: Yes  | 
| Error |  The error that occurred if the action was unsuccessful. **Type:** [GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **Required:** No  | 

## AwsDateTimeOutcome
<a name="integration-server-sdk5-csharp-datatypes-awsdatetimeoutcome"></a>

This data type results from an action and produces an object with the following properties:


| Properties | Description | 
| --- | --- | 
| Result |  The result of the action. **Type:** `DateTime` **Required:** No   | 
| Success |  Whether the action was successful or not. **Type:** `bool` **Required**: Yes  | 
| Error |  The error that occurred if the action was unsuccessful. **Type:** [GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **Required:** No  | 

## GameLiftError
<a name="integration-server-sdk5-csharp-datatypes-gamelifterror"></a>


| Properties | Description | 
| --- | --- | 
| ErrorType |  The type of error. **Type:** A `GameLiftErrorType` [enum](#integration-server-sdk5-csharp-datatypes-enums). **Required:** No   | 
| ErrorName |  The name of the error.  **Type:** `string`  **Required:** No   | 
| ErrorMessage |  The error message.  **Type:** `string`  **Required:** No   | 

## Enums
<a name="integration-server-sdk5-csharp-datatypes-enums"></a>

Enums defined for the server SDK for Amazon GameLift Servers (C\$1) are defined as follows:

**AttrType**  
+ **NONE**
+ **STRING**
+ **DOUBLE**
+ **STRING\$1LIST**
+ **STRING\$1DOUBLE\$1MAP**

**GameLiftErrorType**  
String value indicating the error type. Valid values include:  
+ **SERVICE\$1CALL\$1FAILED** – A call to an AWS service has failed. 
+ **LOCAL\$1CONNECTION\$1FAILED** – The local connection to Amazon GameLift Servers failed. 
+ **NETWORK\$1NOT\$1INITIALIZED** – The network has not been initialized. 
+ **GAMESESSION\$1ID\$1NOT\$1SET** – The game session ID has not been set. 
+ **BAD\$1REQUEST\$1EXCEPTION** 
+ **INTERNAL\$1SERVICE\$1EXCEPTION** 
+ **ALREADY\$1INITIALIZED** – The Amazon GameLift Servers Server or Client has already been initialized with Initialize(). 
+ **FLEET\$1MISMATCH** – The target fleet does not match the fleet of a gameSession or playerSession. 
+ **GAMELIFT\$1CLIENT\$1NOT\$1INITIALIZED** – The Amazon GameLift Servers client has not been initialized. 
+ **GAMELIFT\$1SERVER\$1NOT\$1INITIALIZED** – The Amazon GameLift Servers server has not been initialized. 
+ **GAME\$1SESSION\$1ENDED\$1FAILED** – the server SDK for Amazon GameLift Servers could not contact the service to report the game session ended. 
+ **GAME\$1SESSION\$1NOT\$1READY** – The Amazon GameLift Servers Server Game Session was not activated. 
+ **GAME\$1SESSION\$1READY\$1FAILED** – the server SDK for Amazon GameLift Servers could not contact the service to report the game session is ready. 
+ **INITIALIZATION\$1MISMATCH** – A client method was called after Server::Initialize(), or vice versa. 
+ **NOT\$1INITIALIZED** – The Amazon GameLift Servers Server or Client has not been initialized with Initialize(). 
+ **NO\$1TARGET\$1ALIASID\$1SET** – A target aliasId has not been set. 
+ **NO\$1TARGET\$1FLEET\$1SET** – A target fleet has not been set. 
+ **PROCESS\$1ENDING\$1FAILED** – the server SDK for Amazon GameLift Servers could not contact the service to report the process is ending. 
+ **PROCESS\$1NOT\$1ACTIVE** – The server process is not yet active, not bound to a GameSession, and cannot accept or process PlayerSessions. 
+ **PROCESS\$1NOT\$1READY** – The server process is not yet ready to be activated. 
+ **PROCESS\$1READY\$1FAILED** – the server SDK for Amazon GameLift Servers could not contact the service to report the process is ready. 
+ **SDK\$1VERSION\$1DETECTION\$1FAILED** – SDK version detection failed. 
+ **STX\$1CALL\$1FAILED** – A call to the XStx server backend component has failed. 
+ **STX\$1INITIALIZATION\$1FAILED** – The XStx server backend component has failed to initialize. 
+ **UNEXPECTED\$1PLAYER\$1SESSION** – An unregistered player session was encountered by the server. 
+ **WEBSOCKET\$1CONNECT\$1FAILURE** 
+ **WEBSOCKET\$1CONNECT\$1FAILURE\$1FORBIDDEN** 
+ **WEBSOCKET\$1CONNECT\$1FAILURE\$1INVALID\$1URL** 
+ **WEBSOCKET\$1CONNECT\$1FAILURE\$1TIMEOUT** 
+ **WEBSOCKET\$1RETRIABLE\$1SEND\$1MESSAGE\$1FAILURE** – Retriable failure to send a message to the GameLift Service WebSocket. 
+ **WEBSOCKET\$1SEND\$1MESSAGE\$1FAILURE** – Failure to send a message to the GameLift Service WebSocket. 
+ **MATCH\$1BACKFILL\$1REQUEST\$1VALIDATION** – Validation of the request failed. 
+ **PLAYER\$1SESSION\$1REQUEST\$1VALIDATION** – Validation of the request failed. 

**PlayerSessionCreationPolicy**  
String value indicating whether the game session accepts new players. Valid values include:   
+ **ACCEPT\$1ALL** – Accept all new player sessions. 
+ **DENY\$1ALL** – Deny all new player sessions. 
+ **NOT\$1SET** – The game session is not set to accept or deny new player sessions. 

**PlayerSessionStatus**  
+ **ACTIVE**
+ **COMPLETED**
+ **NOT\$1SET**
+ **RESERVED**
+ **TIMEDOUT**

[C\$1 server SDK 5.x for Amazon GameLift Servers -- Data types](integration-server-sdk5-csharp-datatypes.md)

**Topics**
+ [C\$1 server SDK 5.x for Amazon GameLift Servers -- Data types](integration-server-sdk5-csharp-datatypes.md)
+ [GetSdkVersion()](#integration-server-sdk5-csharp-getsdkversion)
+ [InitMetrics()](#integration-server-sdk5-csharp-initmetrics)
+ [InitSDK()](#integration-server-sdk5-csharp-initsdk)
+ [InitSDK()](#integration-server-sdk5-csharp-initsdk-anywhere)
+ [ProcessReady()](#integration-server-sdk5-csharp-processready)
+ [ProcessEnding()](#integration-server-sdk5-csharp-processending)
+ [ActivateGameSession()](#integration-server-sdk5-csharp-activategamesession)
+ [UpdatePlayerSessionCreationPolicy()](#integration-server-sdk5-csharp-updateplayersessioncreationpolicy)
+ [GetGameSessionId()](#integration-server-sdk5-csharp-getgamesessionid)
+ [GetTerminationTime()](#integration-server-sdk5-csharp-getterm)
+ [AcceptPlayerSession()](#integration-server-sdk5-csharp-acceptplayersession)
+ [RemovePlayerSession()](#integration-server-sdk5-csharp-removeplayersession)
+ [DescribePlayerSessions()](#integration-server-sdk5-csharp-describeplayersessions)
+ [StartMatchBackfill()](#integration-server-sdk5-csharp-startmatchbackfill)
+ [StopMatchBackfill()](#integration-server-sdk5-csharp-stopmatchbackfill)
+ [GetComputeCertificate()](#integration-server-sdk5-csharp-getcomputecertificate)
+ [GetFleetRoleCredentials()](#integration-server-sdk5-csharp-getfleetrolecredentials)
+ [Destroy()](#integration-server-sdk5-csharp-destroy)

## GetSdkVersion()
<a name="integration-server-sdk5-csharp-getsdkversion"></a>

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

### Syntax
<a name="integration-server-sdk5-csharp-getsdkversion-syntax"></a>

```
AwsStringOutcome GetSdkVersion();
```

### Return value
<a name="integration-server-sdk5-csharp-getsdkversion-return"></a>

If successful, returns the current SDK version as an [AwsStringOutcome](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-awsstringoutcome) object. The returned string includes the version number (example `5.0.0`). If not successful, returns an error message.

### Example
<a name="integration-server-sdk5-csharp-getsdkversion-example"></a>

```
var getSdkVersionOutcome = GameLiftServerAPI.GetSdkVersion();
```

## InitMetrics()
<a name="integration-server-sdk5-csharp-initmetrics"></a>

Initializes the metrics system for collecting and reporting server performance data. For best results, call this method before [InitSDK()](#integration-server-sdk5-csharp-initsdk) to enable metrics collection during SDK initialization.

### Syntax
<a name="integration-server-sdk5-csharp-initmetrics-syntax"></a>

```
MetricsManagerOutcome InitMetrics();
MetricsManagerOutcome InitMetrics(MetricsParameters metricsParameters);
```

### Parameters
<a name="integration-server-sdk5-csharp-initmetrics-parameter"></a>

[MetricsParameters](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-metricsparameters) (optional)  
Configuration parameters for metrics collection. If not provided, uses default values that can be overridden by environment variables.

### Return value
<a name="integration-server-sdk5-csharp-initmetrics-return"></a>

If successful, returns a [MetricsManagerOutcome](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-metricsmanageroutcome) object containing the MetricsManager instance. If not successful, returns an error message.

### Example
<a name="integration-server-sdk5-csharp-initmetrics-example"></a>

```
// Initialize with default parameters (uses environment variables if available)
var outcome = GameLiftServerAPI.InitMetrics();
if (outcome.Success) {
    var metricsManager = outcome.Result;
} else {
    Console.WriteLine("Failed to initialize metrics: " + outcome.Error.ErrorMessage);
}

// Initialize with custom parameters
var metricsParams = new MetricsParameters("localhost", 8125, "crash-host", 9999, 1000, 1024);
var customOutcome = GameLiftServerAPI.InitMetrics(metricsParams);
if (customOutcome.Success) {
    var metricsManager = customOutcome.Result;
}
```

## InitSDK()
<a name="integration-server-sdk5-csharp-initsdk"></a>

Initializes the Amazon GameLift Servers SDK for a managed EC2 fleet. Call this method on launch, before any other initialization related to Amazon GameLift Servers occurs. This method reads server parameters from the host environment to set up communication between the server and the Amazon GameLift Servers service. It uses an idempotency token, so you safely retry this call when it fails.

### Syntax
<a name="integration-server-sdk5-csharp-initsdk-syntax"></a>

```
GenericOutcome InitSDK();
```

### Return value
<a name="integration-server-sdk5-csharp-initsdk-return"></a>

If successful, returns an InitSdkOutcome object to indicate that the server process is ready to call [ProcessReady()](#integration-server-sdk5-csharp-processready). 

### Example
<a name="integration-server-sdk5-csharp-initsdk-example"></a>

```
//Call InitSDK to establish a local connection with the GameLift agent to enable further communication.
GenericOutcome initSDKOutcome = GameLiftServerAPI.InitSDK();
```

## InitSDK()
<a name="integration-server-sdk5-csharp-initsdk-anywhere"></a>

Initializes the Amazon GameLift Servers SDK for an Anywhere fleet. Call this method on launch, before any other initialization related to Amazon GameLift Servers occurs. This method requires explicit server parameters to set up communication between the server and the Amazon GameLift Servers service. It uses an idempotency token, so you safely retry this call when it fails.

### Syntax
<a name="integration-server-sdk5-csharp-initsdk-anywhere-syntax"></a>

```
GenericOutcome InitSDK(ServerParameters serverParameters);
```

### Parameters
<a name="integration-server-sdk5-csharp-initsdk-anywhere-parameter"></a>

[ServerParameters](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-dataypes-serverparameters)  
To initialize a game server on an Amazon GameLift Servers Anywhere fleet, construct a `ServerParameters` object with the following information:  
+ The URL of the WebSocket used to connect to your game server. 
+ The ID of the process used to host your game server. 
+ The ID of the compute hosting your game server processes. 
+ The ID of the Amazon GameLift Servers fleet containing your Amazon GameLift Servers Anywhere compute.
+ The authorization token generated by the Amazon GameLift Servers operation. 

### Return value
<a name="integration-server-sdk5-csharp-initsdk-anywhere-return"></a>

If successful, returns an InitSdkOutcome object to indicate that the server process is ready to call [ProcessReady()](#integration-server-sdk5-csharp-processready). 

**Note**  
If calls to `InitSDK()` are failing for game builds deployed to Anywhere fleets, check the `ServerSdkVersion` parameter used when creating the build resource. You must explicitly set this value to the server SDK version in use. The default value for this parameter is 4.x, which is not compatible. To resolve this issue, create a new build and deploy it to a new fleet.

### Example
<a name="integration-server-sdk5-csharp-initsdk-anywhere-example"></a>

```
//Define the server parameters
string websocketUrl = "wss://us-west-1.api.amazongamelift.com";
string processId = "PID1234";
string fleetId = "aarn:aws:gamelift:us-west-1:111122223333:fleet/fleet-9999ffff-88ee-77dd-66cc-5555bbbb44aa";
string hostId = "HardwareAnywhere";
string authToken = "1111aaaa-22bb-33cc-44dd-5555eeee66ff";
ServerParameters serverParameters = 
  new ServerParameters(webSocketUrl, processId, hostId, fleetId, authToken);

//Call InitSDK to establish a local connection with the GameLift agent to enable further communication.
GenericOutcome initSDKOutcome = GameLiftServerAPI.InitSDK(serverParameters);
```

## ProcessReady()
<a name="integration-server-sdk5-csharp-processready"></a>

Notifies Amazon GameLift Servers that the server process is ready to host game sessions. Call this method after invoking [InitSDK()](#integration-server-sdk5-csharp-initsdk). This method should be called only once per process.

### Syntax
<a name="integration-server-sdk5-csharp-processready-syntax"></a>

```
GenericOutcome ProcessReady(ProcessParameters processParameters)
```

### Parameters
<a name="integration-server-sdk5-csharp-processready-parameter"></a>

**[ProcessParameters](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-dataypes-process)**  
A `ProcessParameters` object holds information about the server process.

### Return value
<a name="integration-server-sdk5-csharp-processready-return"></a>

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

### Example
<a name="integration-server-sdk5-csharp-processready-example"></a>

This example illustrates both the method and delegate function implementations.

```
// Set parameters and call ProcessReady
ProcessParameters processParams = new ProcessParameters(
  this.OnStartGameSession,
  this.OnProcessTerminate,
  this.OnHealthCheck,
  this.OnUpdateGameSession,
  port,
  new LogParameters(new List<string>()  
  // Examples of log and error files written by the game server
  {
    "C:\\game\\logs",
    "C:\\game\\error"
  })
);
GenericOutcome processReadyOutcome = GameLiftServerAPI.ProcessReady(processParams);
```

## ProcessEnding()
<a name="integration-server-sdk5-csharp-processending"></a>

Notifies Amazon GameLift Servers that the server process is terminating. Call this method after all other cleanup tasks (including shutting down the active game session) and before terminating the process. Depending on the result of `ProcessEnding()`, the process exits with success (0) or error (-1) and generates a fleet event. If the process terminates with an error, the fleet event generated is `SERVER_PROCESS_TERMINATED_UNHEALTHY`.

### Syntax
<a name="integration-server-sdk5-csharp-processending-syntax"></a>

```
GenericOutcome ProcessEnding()
```

### Return value
<a name="integration-server-sdk5-csharp-processending-return"></a>

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

### Example
<a name="integration-server-sdk5-csharp-processending-example"></a>

This example calls `ProcessEnding()` and `Destroy()` before terminating the server process with a success or error exit code.

```
GenericOutcome processEndingOutcome = GameLiftServerAPI.ProcessEnding();
GameLiftServerAPI.Destroy();

if (processEndingOutcome.Success)
  {
    Environment.Exit(0);
  }
else
  {
    Console.WriteLine("ProcessEnding() failed. Error: " + processEndingOutcome.Error.ToString());
    Environment.Exit(-1);  
  }
```

## ActivateGameSession()
<a name="integration-server-sdk5-csharp-activategamesession"></a>

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

### Syntax
<a name="integration-server-sdk5-csharp-activategamesession-syntax"></a>

```
GenericOutcome ActivateGameSession()
```

### Return value
<a name="integration-server-sdk5-csharp-activategamesession-return"></a>

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

### Example
<a name="integration-server-sdk5-csharp-activategamesession-example"></a>

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

```
void OnStartGameSession(GameSession gameSession)
{
  // game-specific tasks when starting a new game session, such as loading map   
  // When ready to receive players   
  GenericOutcome activateGameSessionOutcome = GameLiftServerAPI.ActivateGameSession();
}
```

## UpdatePlayerSessionCreationPolicy()
<a name="integration-server-sdk5-csharp-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.

### Syntax
<a name="integration-server-sdk5-csharp-updateplayersessioncreationpolicy-syntax"></a>

```
GenericOutcome UpdatePlayerSessionCreationPolicy(PlayerSessionCreationPolicy playerSessionPolicy)
```

### Parameters
<a name="integration-server-sdk5-csharp-updateplayersessioncreationpolicy-parameter"></a>

**playerSessionPolicy**  
String value that indicates whether the game session accepts new players.   
Valid values include:  
+ **ACCEPT\$1ALL** – Accept all new player sessions.
+ **DENY\$1ALL** – Deny all new player sessions.

### Return value
<a name="integration-server-sdk5-csharp-updateplayersessioncreationpolicy-return"></a>

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

### Example
<a name="integration-server-sdk5-csharp-updateplayersessioncreationpolicy-example"></a>

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

```
GenericOutcome updatePlayerSessionPolicyOutcome = 
  GameLiftServerAPI.UpdatePlayerSessionCreationPolicy(PlayerSessionCreationPolicy.ACCEPT_ALL);
```

## GetGameSessionId()
<a name="integration-server-sdk5-csharp-getgamesessionid"></a>

Retrieves the ID of the game session hosted by the active server process.

For idle processes that aren't activated with a game session, the call returns a [GameLiftError](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-gamelifterror).

### Syntax
<a name="integration-server-sdk5-csharp-getgamesessionid-syntax"></a>

```
AwsStringOutcome GetGameSessionId()
```

### Return value
<a name="integration-server-sdk5-csharp-getgamesessionid-return"></a>

If successful, returns the game session ID as an [AwsStringOutcome](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-awsstringoutcome) object. If not successful, returns an error message."

### Example
<a name="integration-server-sdk5-csharp-getgamesessionid-example"></a>

```
AwsStringOutcome getGameSessionIdOutcome = GameLiftServerAPI.GetGameSessionId();
```

## GetTerminationTime()
<a name="integration-server-sdk5-csharp-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 Amazon GameLift Servers. Amazon GameLift Servers calls `onProcessTerminate()` for the following reasons: 
+ When the server process has reported poor health or has not responded to Amazon GameLift Servers.
+ When terminating the instance during a scale-down event.
+ When an instance is terminated due to a [spot-instance interruption](spot-tasks.md).

### Syntax
<a name="integration-server-sdk5-csharp-getterm-syntax"></a>

```
AwsDateTimeOutcome GetTerminationTime()
```

### Return value
<a name="integration-server-sdk5-csharp-getterm-return"></a>

If successful, returns the termination time as an [AwsDateTimeOutcome](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-awsdatetimeoutcome) 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-sdk5-csharp-getterm-example"></a>

```
AwsDateTimeOutcome getTerminationTimeOutcome = GameLiftServerAPI.GetTerminationTime(); 
```

## AcceptPlayerSession()
<a name="integration-server-sdk5-csharp-acceptplayersession"></a>

Notifies Amazon GameLift Servers 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. After the player session is validated, Amazon GameLift Servers changes the status of the player slot from RESERVED to ACTIVE. 

### Syntax
<a name="integration-server-sdk5-csharp-acceptplayersession-syntax"></a>

```
GenericOutcome AcceptPlayerSession(String playerSessionId)
```

### Parameters
<a name="integration-server-sdk5-csharp-acceptplayersession-parameter"></a>

playerSessionId  
Unique ID issued by GameLift when a new player session is created.

### Return value
<a name="integration-server-sdk5-csharp-acceptplayersession-return"></a>

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

### Example
<a name="integration-server-sdk5-csharp-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, String playerSessionId)
{
  GenericOutcome acceptPlayerSessionOutcome = GameLiftServerAPI.AcceptPlayerSession(playerSessionId);
  if(acceptPlayerSessionOutcome.Success)
  {
    connectionToSessionMap.emplace(connection, playerSessionId);
    connection.Accept();
  }
  else 
  {
    connection.Reject(acceptPlayerSessionOutcome.Error.ErrorMessage);
  }       
}
```

## RemovePlayerSession()
<a name="integration-server-sdk5-csharp-removeplayersession"></a>

Notifies Amazon GameLift Servers that a player has disconnected from the server process. In response, Amazon GameLift Servers changes the player slot to available. 

### Syntax
<a name="integration-server-sdk5-csharp-removeplayersession-syntax"></a>

```
GenericOutcome RemovePlayerSession(String playerSessionId)
```

### Parameters
<a name="integration-server-sdk5-csharp-removeplayersession-parameter"></a>

**playerSessionId**  
Unique ID issued by Amazon GameLift Servers when a new player session is created.

### Return value
<a name="integration-server-sdk5-csharp-removeplayersession-return"></a>

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

### Example
<a name="integration-server-sdk5-csharp-removeplayersession-example"></a>

```
GenericOutcome removePlayerSessionOutcome = GameLiftServerAPI.RemovePlayerSession(playerSessionId);
```

## DescribePlayerSessions()
<a name="integration-server-sdk5-csharp-describeplayersessions"></a>

Retrieves player session data which includes 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-sdk5-csharp-describeplayersessions-syntax"></a>

```
DescribePlayerSessionsOutcome DescribePlayerSessions(DescribePlayerSessionsRequest describePlayerSessionsRequest)
```

### Parameters
<a name="integration-server-sdk5-csharp-describeplayersessions-parameter"></a>

**[DescribePlayerSessionsRequest](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-dataypes-playersessions)**  
A [DescribePlayerSessionsRequest](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-dataypes-playersessions) object that describes which player sessions to retrieve.

### Return value
<a name="integration-server-sdk5-csharp-describeplayersessions-return"></a>

If successful, returns a [DescribePlayerSessionsOutcome](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-describeplayersessionsoutcome) object that contains a set of player session objects that fit the request parameters.

### Example
<a name="integration-server-sdk5-csharp-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 will return the first 10 player session records matching the request.

```
// Set request parameters 
DescribePlayerSessionsRequest describePlayerSessionsRequest = new DescribePlayerSessionsRequest()
{
  GameSessionId = GameLiftServerAPI.GetGameSessionId().Result,    //gets the ID for the current game session
  Limit = 10,
  PlayerSessionStatusFilter = 
    PlayerSessionStatusMapper.GetNameForPlayerSessionStatus(PlayerSessionStatus.ACTIVE)
}; 
// Call DescribePlayerSessions
DescribePlayerSessionsOutcome describePlayerSessionsOutcome = 
  GameLiftServerAPI.DescribePlayerSessions(describePlayerSessionsRequest);
```

## StartMatchBackfill()
<a name="integration-server-sdk5-csharp-startmatchbackfill"></a>

Sends a request to find new players for open slots in a game session created with FlexMatch. For more information, see [FlexMatch backfill feature](https://docs.aws.amazon.com/gameliftservers/latest/flexmatchguide/match-backfill.html).

This action is asynchronous. If new players are matched, Amazon GameLift Servers delivers updated matchmaker data using 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-sdk5-csharp-stopmatchbackfill) to cancel the original request.

### Syntax
<a name="integration-server-sdk5-csharp-startmatchbackfill-syntax"></a>

```
StartMatchBackfillOutcome StartMatchBackfill (StartMatchBackfillRequest startBackfillRequest);
```

### Parameters
<a name="integration-server-sdk5-csharp-startmatchbackfill-parameter"></a>

**[StartMatchBackfillRequest](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-dataypes-startmatchbackfillrequest)**  
A `StartMatchBackfillRequest` object holds information about the backfill request.

### Return value
<a name="integration-server-sdk5-csharp-startmatchbackfill-return"></a>

Returns a [StartMatchBackfillOutcome](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-startmatchbackfilloutcome) object with the match backfill ticket ID, or failure with an error message. 

### Example
<a name="integration-server-sdk5-csharp-startmatchbackfill-example"></a>

```
// Build a backfill request
StartMatchBackfillRequest startBackfillRequest = new StartMatchBackfillRequest()
{
  TicketId = "1111aaaa-22bb-33cc-44dd-5555eeee66ff", //optional
  MatchmakingConfigurationArn = "arn:aws:gamelift:us-west-2:111122223333:matchmakingconfiguration/MyMatchmakerConfig", 
  GameSessionId = GameLiftServerAPI.GetGameSessionId().Result,    // gets ID for current game session
  MatchmakerData matchmakerData = 
    MatchmakerData.FromJson(gameSession.MatchmakerData),  // gets matchmaker data for current players
  // get matchmakerData.Players
  // remove data for players who are no longer connected
  Players = ListOfPlayersRemainingInTheGame
};

// Send backfill request
StartMatchBackfillOutcome startBackfillOutcome = GameLiftServerAPI.StartMatchBackfill(startBackfillRequest);

// Implement callback function for backfill
void OnUpdateGameSession(GameSession myGameSession)
{
  // game-specific tasks to prepare for the newly matched players and update matchmaker data as needed  
}
```

## StopMatchBackfill()
<a name="integration-server-sdk5-csharp-stopmatchbackfill"></a>

Cancels an active match backfill request. For more information, see [FlexMatch backfill feature](https://docs.aws.amazon.com/gameliftservers/latest/flexmatchguide/match-backfill.html).

### Syntax
<a name="integration-server-sdk5-csharp-stopmatchbackfill-syntax"></a>

```
GenericOutcome StopMatchBackfill (StopMatchBackfillRequest stopBackfillRequest);
```

### Parameters
<a name="integration-server-sdk5-csharp-stopmatchbackfill-parameter"></a>

**[StopMatchBackfillRequest](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-dataypes-stopmatchbackfillrequest)**  
A `StopMatchBackfillRequest` object that provides details about the matchmaking ticket you are stopping.

### Return value
<a name="integration-server-sdk5-csharp-stopmatchbackfill-return"></a>

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

### Example
<a name="integration-server-sdk5-csharp-stopmatchbackfill-example"></a>

```
// Set backfill stop request parameters
StopMatchBackfillRequest stopBackfillRequest = new StopMatchBackfillRequest(){
  TicketId = "1111aaaa-22bb-33cc-44dd-5555eeee66ff", //optional, if not provided one is autogenerated
  MatchmakingConfigurationArn = "arn:aws:gamelift:us-west-2:111122223333:matchmakingconfiguration/MyMatchmakerConfig",
  GameSessionId = GameLiftServerAPI.GetGameSessionId().Result    //gets the ID for the current game session
};
GenericOutcome stopBackfillOutcome = GameLiftServerAPI.StopMatchBackfillRequest(stopBackfillRequest);
```

## GetComputeCertificate()
<a name="integration-server-sdk5-csharp-getcomputecertificate"></a>

 Retrieves the path to the TLS certificate used to encrypt the network connection between the game server and your game client. You can use the certificate path when you register your compute device to a Amazon GameLift Servers Anywhere fleet. For more information see, [RegisterCompute](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html).

### Syntax
<a name="integration-server-sdk5-csharp-getcomputecertificate-syntax"></a>

```
GetComputeCertificateOutcome GetComputeCertificate();
```

### Return value
<a name="integration-server-sdk5-csharp-getcomputecertificate-return"></a>

Returns a GetComputeCertificateResponse object that contains the following: 
+  CertificatePath: The path to the TLS certificate on your compute resource. When using an Amazon GameLift Servers managed fleet, this path contains:
  + `certificate.pem`: The end-user certificate. The full certificate chain is the combination of `certificateChain.pem` appended to this certificate.
  + `certificateChain.pem`: The certificate chain that contains the root certificate and intermediate certificates.
  + `rootCertificate.pem`: The root certificate.
  + `privateKey.pem`: The private key for the end-user certificate.
+ ComputeName: The name of your compute resource.

### Example
<a name="integration-server-sdk5-csharp-getcomputecertificate-example"></a>

```
GetComputeCertificateOutcome getComputeCertificateOutcome = GameLiftServerAPI.GetComputeCertificate();
```

## GetFleetRoleCredentials()
<a name="integration-server-sdk5-csharp-getfleetrolecredentials"></a>

Retrieves IAM role credentials that authorize Amazon GameLift Servers to interact with other AWS services. For more information, see [Connect your Amazon GameLift Servers hosted game server to other AWS resources](gamelift-sdk-server-resources.md).

### Syntax
<a name="integration-server-sdk5-csharp-getfleetrolecredentials-syntax"></a>

```
GetFleetRoleCredentialsOutcome GetFleetRoleCredentials(GetFleetRoleCredentialsRequest request);
```

### Parameters
<a name="integration-server-sdk5-csharp-getfleetrolecredentials-parameters"></a>

[GetFleetRoleCredentialsRequest](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-dataypes-getfleetrolecredentialsrequest)  
Role credentials that extend limited access to your AWS resources to the game server.

### Return value
<a name="integration-server-sdk5-csharp-getfleetrolecredentials-return"></a>

Returns a [GetFleetRoleCredentialsOutcome](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-getfleetrolecredentialsoutcome) object.

### Example
<a name="integration-server-sdk5-csharp-getfleetrolecredentials-example"></a>

```
// form the fleet credentials request  
GetFleetRoleCredentialsRequest getFleetRoleCredentialsRequest = new GetFleetRoleCredentialsRequest(){  
  RoleArn = "arn:aws:iam::123456789012:role/service-role/exampleGameLiftAction"  
};
GetFleetRoleCredentialsOutcome GetFleetRoleCredentialsOutcome credentials = GetFleetRoleCredentials(getFleetRoleCredentialsRequest);
```

## Destroy()
<a name="integration-server-sdk5-csharp-destroy"></a>

Frees the Amazon GameLift Servers game server SDK from memory. As a best practice, call this method after `ProcessEnding()` and before terminating the process. If you're using an Anywhere fleet and you're not terminating server processes after every game session, call `Destroy()` and then `InitSDK()` to reinitialize before notifying Amazon GameLift Servers that the process is ready to host a game session with `ProcessReady()`.

### Syntax
<a name="integration-server-sdk5-csharp-destroy-syntax"></a>

```
GenericOutcome Destroy()
```

### Return value
<a name="integration-server-sdk5-csharp-destroy-return"></a>

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

### Example
<a name="integration-server-sdk5-csharp-destroy-example"></a>

```
// Operations to end game sessions and the server process
GenericOutcome processEndingOutcome = GameLiftServerAPI.ProcessEnding();

// Shut down and destroy the instance of the GameLift Game Server SDK
GenericOutcome destroyOutcome = GameLiftServerAPI.Destroy();

// Exit the process with success or failure
if (processEndingOutcome.Success)
  { 
    Environment.Exit(0); 
  }
else
  {
    Console.WriteLine("ProcessEnding() failed. Error: " + processEndingOutcome.Error.ToString());
    Environment.Exit(-1); 
  }
```