

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 适用于 Amazon GameLift Servers 的 C\$1 服务器 SDK 5.x – 操作
<a name="integration-server-sdk5-csharp-actions"></a>

使用服务器 SDK 5.x 参考，将要托管的多人游戏与 Amazon GameLift Servers 集成。有关集成过程的指南，请参阅[借助服务器 SDK 将 Amazon GameLift Servers 添加到游戏服务器](gamelift-sdk-server-api.md)。如果您使用的是适用于 Unity 的 Amazon GameLift Servers 插件，还可以参阅[Amazon GameLift Servers适用于 Unity 的插件（服务器 SDK 5.x）](unity-plug-in.md)。

# 适用于 Amazon GameLift Servers 的 C\$1 服务器 SDK 5.x – 数据类型
<a name="integration-server-sdk5-csharp-datatypes"></a>

使用 Amazon GameLift Servers C\$1 服务器 SDK 5.x 参考，将要托管的多人游戏与 Amazon GameLift Servers 集成。有关集成过程的指南，请参阅[借助服务器 SDK 将 Amazon GameLift Servers 添加到游戏服务器](gamelift-sdk-server-api.md)。如果您使用的是适用于 Unity 的 Amazon GameLift Servers 插件，还可以参阅[Amazon GameLift Servers适用于 Unity 的插件（服务器 SDK 5.x）](unity-plug-in.md)。

[适用于 Amazon GameLift Servers 的 C\$1 服务器 SDK 5.x – 操作](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)
+ [玩家](#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)
+ [枚举](#integration-server-sdk5-csharp-datatypes-enums)

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

使用此数据类型来标识游戏会话期间生成的哪些文件需要在游戏会话结束后由游戏服务器上传到 Amazon GameLift Servers。游戏服务器通过 [ProcessReady()](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-processready) 调用将 `LogParameters to` 传达给 Amazon GameLift Servers。


|  |  | 
| --- |--- |
|  **属性**  | 描述 | 
| LogPaths |  您希望 Amazon GameLift Servers 用于存储供以后访问的游戏服务器日志文件的目录路径列表。服务器进程在每个游戏会话期间生成这些文件。文件路径和名称在游戏服务器中定义并存储在根游戏构建目录中。 日志路径必须是绝对的。例如，如果您的游戏构建在类似于 `MyGame\sessionLogs\` 的路径中存储游戏会话日志，则日志路径将为 (在 Windows 实例上) 或 (在 Linux 实例上)。 **类型**：`List<String>` **必需**：否  | 

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

使用此数据类型配置游戏服务器的指标收集和崩溃报告功能。游戏服务器通过 [InitMetrics()](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-initmetrics) 调用将 `MetricsParameters` 传达给 Amazon GameLift Servers。


|  |  | 
| --- |--- |
|  **属性**  | 描述 | 
| StatsdHost |  用于指标收集的 StatsD 服务器的主机名或 IP 地址。 **类型**：`String` **必需**：否  | 
| StatsdPort |  用于收集指标的 StatsD 服务器的端口号。 **类型**：`Integer` **必需**：否  | 
| CrashReporterHost |  崩溃报告服务器的主机名或 IP 地址。 **类型**：`String` **必需**：否  | 
| CrashReporterPort |  崩溃报告服务器的端口号。 **类型**：`Integer` **必需**：否  | 
| FlushIntervalMs |  将指标数据刷新到服务器的时间间隔（以毫秒为单位）。 **类型**：`Integer` **必需**：否  | 
| MaxPacketSize |  发送到服务器的指标数据包的最大大小（以字节为单位）。 **类型**：`Integer` **必需**：否  | 

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

此数据类型包含一组在 [ProcessReady()](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-processready) 调用中发送到 Amazon GameLift Servers 的参数。


|  |  | 
| --- |--- |
|  **属性**  | 描述 | 
| LogParameters | 包含游戏会话日志文件目录路径列表的对象。**类型**：`Aws::GameLift::Server::LogParameters`**是否必需**：是 | 
| OnHealthCheck | Amazon GameLift Servers 为向服务器进程请求运行状况报告而调用的回调函数的名称。Amazon GameLift Servers 每隔 60 秒调用此函数一次。调用此函数后，Amazon GameLift Servers 将等待 60 秒接收响应，如果未收到响应，则 Amazon GameLift Servers 会将该服务器进程记录为运行状况不佳。**类型**：`void OnHealthCheckDelegate()`**是否必需**：是 | 
| OnProcessTerminate | Amazon GameLift Servers 为强制关闭服务器进程而调用的回调函数的名称。调用此函数之后，Amazon GameLift Servers 等待五分钟以便服务器进程关闭，然后使用 [ProcessEnding()](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-processending) 调用响应，再关闭服务器进程。**类型**：`void OnProcessTerminateDelegate()`**是否必需**：是 | 
| OnStartGameSession | 为激活新游戏会话而Amazon GameLift Servers调用的回调函数的名称。 Amazon GameLift Servers调用此函数是为了响应客户端的请求[CreateGameSession](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_CreateGameSession.html)。回调函数将采用一个 [GameSession](#integration-server-sdk5-csharp-dataypes-gamesession) 对象。**类型**：`void OnStartGameSessionDelegate(GameSession)`**是否必需**：是 | 
| OnUpdateGameSession | Amazon GameLift Servers 为向服务器进程传递更新的游戏会话对象而调用的回调函数的名称。当对战回填请求处理完毕时，Amazon GameLift Servers 会调用此函数以提供更新的对战构建器数据。它将传递一个 [GameSession](#integration-server-sdk5-csharp-dataypes-gamesession) 对象、一个状态更新（updateReason）以及对战回填票证 ID。**类型：**void OnUpdateGameSessionDelegate ([UpdateGameSession](#integration-server-sdk5-csharp-dataypes-updategamesession))**必需**：否 | 
| 端口： | 服务器进程用于侦听新玩家连接的端口号。该值必须在部署此游戏服务器构建的任意实例集上所配置的端口范围内。此端口号包含在游戏会话和玩家会话对象中，游戏会话在连接到服务器进程时会使用该端口号。**类型**：`Integer`**是否必需**：是 | 

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

更新了游戏会话对象的信息，包括更新游戏会话的原因。如果更新与匹配回填操作相关，则此数据类型包括回填票证 ID。


| Properties | **描述** | 
| --- | --- | 
| GameSession | 一个 [GameSession](#integration-server-sdk5-csharp-dataypes-gamesession) 对象。该GameSession对象包含描述游戏会话的属性。**类型**：`GameSession GameSession()`**是否必需**：是 | 
| UpdateReason | 更新游戏会话的原因。**类型**：`UpdateReason UpdateReason()`**是否必需**：是 | 
| BackfillTicketId | 尝试更新游戏会话的回填票证的 ID。**类型**：`String`**是否必需**：是 | 

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

游戏会话的详细信息。


| Properties | **描述** | 
| --- | --- | 
| GameSessionId |  会话的唯一标识符。游戏会话ARN具有以下格式:. `arn:aws:gamelift:<region>::gamesession/<fleet ID>/<custom ID string or idempotency token>`  **类型**：`String` **必需**：否  | 
| Name |  游戏会话的描述性标签。 **类型**：`String` **必需**：否  | 
| FleetId |  运行游戏会话的集的唯一标识符。 **类型**：`String` **必需**：否  | 
| MaximumPlayerSessionCount |   机群中已连接到游戏会话的玩家数量。 **类型**：`Integer` **必需**：否  | 
| 端口： |  游戏会话的端口号。要连接到Amazon GameLift Servers游戏服务器，应用程序需要 IP 地址和端口号。 **类型**：`Integer` **必需**：否  | 
| IpAddress |  游戏会话的 IP 地址。要连接到Amazon GameLift Servers游戏服务器，应用程序需要 IP 地址和端口号。 **类型**：`String` **必需**：否  | 
| GameSessionData |  一组自定义游戏会话属性，采用单个字符串值格式。 **类型**：`String` **必需**：否  | 
| MatchmakerData |  有关用于创建游戏会话的对战过程的信息，采用 JSON 语法，格式为字符串。除了使用的对战配置外，它还包含分配到对战的所有玩家的数据，包括玩家属性和队伍分配。 **类型**：`String` **必需**：否  | 
| GameProperties |  游戏会话的一组自定义属性，采用键值对格式。这些属性将通过启动新游戏会话的请求传递到游戏服务器进程。 **类型**：`Dictionary<string, string>` **必需**：否  | 
| DnsName |  分配给正在运行游戏会话的实例的 DNS 标识符。CRL 采用以下格式： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/gameliftservers/latest/developerguide/integration-server-sdk5-csharp-datatypes.html) 连接到在支持 TLS 的队列上运行的游戏会话时，必须使用 DNS 名称，而不是 IP 地址。 **类型**：`String` **必需**：否  | 

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

用于维护 Amazon GameLift Servers Anywhere 服务器与 Amazon GameLift Servers 服务之间连接的信息。使用启动新的服务器进程时会使用此信息[InitSDK()](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-initsdk)。对于托管在 Amazon GameLift Servers 托管式 EC2 实例上的服务器，请使用空对象。


| Properties | **描述** | 
| --- | --- | 
| WebSocketUrl |  这是在 Amazon GameLift Servers Anywhere 中，当您执行 `RegisterCompute` 时返回的 `GameLiftServerSdkEndpoint`。 **类型**：`String` **是否必需**：是  | 
| ProcessId |  注册到托管游戏的服务器进程的唯一标识符。 **类型**：`String` **是否必需**：是  | 
| HostId |  托管游戏的服务器进程的主机的唯一标识符。HostID 是您注册 ComputeName 计算机时使用的。欲了解更多信息，请参阅 [RegisterCompute](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html) **类型**：`String` **是否必需**：是  | 
| FleetId | 计算注册到的队列的实例集 ID。有关更多信息，请参阅[RegisterCompute](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html)。**类型**：`String`**是否必需**：是 | 
| AuthToken | 由 Amazon GameLift Servers 生成的身份验证令牌，用于向 Amazon GameLift Servers 对您的服务器进行身份验证。有关更多信息，请参阅[GetComputeAuthToken](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_GetComputeAuthToken.html)。**类型**：`String`**是否必需**：是 | 

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

用于创建对战回填请求的信息。游戏服务器通过调用 [StartMatchBackfill()](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-startmatchbackfill) 将这些信息传达给 Amazon GameLift Servers。


| Properties | **描述** | 
| --- | --- | 
| GameSessionArn |  游戏会话的唯一标识符。此 API 操作 `[GetGameSessionId](https://docs.aws.amazon.com/gameliftservers/latest/developerguide/integration-server-sdk5-csharp-actions.html#integration-server-sdk5-csharp-getgamesessionid)` 返回采用 ARN 格式的标识符。 **类型**：`String` **是否必需**：是  | 
| MatchmakingConfigurationArn |  采用 ARN 格式的唯一标识符，适用于用于此请求的对战构建器。要查找用于创建原始游戏会话的对战构建器，请查看对战构建器数据属性中的游戏会话对象。在[使用对战构建器数据](https://docs.aws.amazon.com/gameliftservers/latest/flexmatchguide/match-server.html#match-server-data.html)中了解有关对战构建器数据的更多信息。 **类型**：`String` **是否必需**：是  | 
| 玩家 |  一组表示当前正在游戏会话中的所有玩家的数据。对战构建器使用此信息搜索与当前玩家非常匹配的新玩家。 **类型**：`List<Player>` **是否必需**：是  | 
| TicketId |  对战或匹配回填请求票证的唯一标识符。如果不提供值，Amazon GameLift Servers 会生成值。使用此标识符可跟踪对战回填票证状态或取消请求（如需要）。 **类型**：`String` **必需**：否  | 

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

代表对战中的玩家。启动对战请求时，玩家会有玩家 ID、属性数据以及可能的延迟数据。对战结束后，Amazon GameLift Servers 会添加团队信息。


| Properties | **描述** | 
| --- | --- | 
| LatencyInMS |  一组以毫秒为单位的值，表示玩家在连接到某个位置时所经历的延迟量。 如果使用此属性，则仅匹配列出的位置的玩家。如果对战构建器具有评估玩家延迟的规则，玩家必须报告延迟才能进行匹配。 **类型**：`Dictionary<string, int>` **必需**：否  | 
| PlayerAttributes |  键/值对的集合，其中包含用于对战的玩家信息。玩家属性键必须与配对规则集中 PlayerAttributes 使用的属性密钥相匹配。 有关玩家属性的更多信息，请参阅[AttributeValue](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_AttributeValue.html)。 **类型**：`Dictionary<string, AttributeValue` **必需**：否  | 
| PlayerId |  玩家的唯一标识符。 **类型**：`String` **必需**：否  | 
| Team |  玩家在对战中被分配到的团队的名称。在对战规则集中定义团队名称。 **类型**：`String` **必需**：否  | 

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

此数据类型用于指定检索哪些玩家会话。它可以通过多种方式使用：(1) 提供 a PlayerSessionId 以请求特定的玩家会话；(2) 提供 a GameSessionId 以请求指定游戏会话中的所有玩家会话；或 (3) 提供 a PlayerId 以请求指定玩家的所有玩家会话。对于大型玩家会话集合，请使用分页参数以连续页面格式检索结果。


| Properties | **描述** | 
| --- | --- | 
| GameSessionId |  游戏会话的唯一标识符。使用此参数可请求指定游戏会话的所有玩家会话。游戏会话 ID 的格式如下所示：`arn:aws:gamelift:<region>::gamesession/fleet-<fleet ID>/<ID string>`。<ID string> 的值为自定义 ID 字符串（如果在创建游戏会话时指定了一个）或者是生成的字符串。 **类型**：`String` **必需**：否  | 
| PlayerSessionId |  玩家会话的唯一标识符。 **类型**：`String` **必需**：否  | 
| PlayerId |   玩家的唯一标识符。请参阅[生成玩家 ID](player-sessions-player-identifiers.md)。 **类型**：`String` **必需**：否  | 
| PlayerSessionStatusFilter |  用于筛选结果的玩家会话状态。可能的玩家会话状态包括以下内容： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/gameliftservers/latest/developerguide/integration-server-sdk5-csharp-datatypes.html) **类型**：`String` **必需**：否  | 
| NextToken |  令牌指示结果的下一个连续页面的开头。要指定结果集的开始，请不要指定值。如果指定玩家会话 ID，将忽略此参数。 **类型**：`String` **必需**：否  | 
| 限制 |  要返回的最大结果数量。如果指定玩家会话 ID，将忽略此参数。 **类型**：`int` **必需**：否  | 

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

用于取消对战回填请求的信息。游戏服务器通过调用 [StopMatchBackfill()](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-stopmatchbackfill) 将此信息传达给 Amazon GameLift Servers 服务。


| Properties | **描述** | 
| --- | --- | 
| GameSessionArn |  与被取消的请求关联的唯一游戏会话标识符。 **类型**：`string` **是否必需**：是  | 
| MatchmakingConfigurationArn |  此请求发送到的对战构建器的唯一标识符。 **类型**：`string` **是否必需**：是  | 
| TicketId |  要取消的回填请求票证的唯一标识符。 **类型**：`string` **是否必需**：是  | 

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

这种数据类型使游戏服务器只能有限地访问您的其他 AWS 资源。有关更多信息，请参阅[为 Amazon GameLift Servers 设置 IAM 服务角色](setting-up-role.md)。


| Properties | **描述** | 
| --- | --- | 
| RoleArn | 服务角色的 Amazon 资源名称 (ARN)，用于扩展对您的 AWS 资源的有限访问权限。**类型**：`string` **是否必需**：是  | 
| RoleSessionName | 描述角色证书使用情况的会话名称。**类型**：`string` **必需**：否  | 

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

在[玩家](#integration-server-sdk5-csharp-dataypes-player)属性密钥-值对中使用。此对象允许您使用任何有效的数据类型来指定属性值：字符串、数字、字符串数组或数据映射。每个`AttributeValue`对象只能使用一个可用属性。


| Properties | 说明 | 
| --- | --- | 
| 属性类型 |  指定属性值的类型。 **类型：**一个 `AttrType` [枚举](#integration-server-sdk5-csharp-datatypes-enums)值。 **必需**：否  | 
| S |  表示字符串属性值。 **类型**：`string` **是否必需**：是  | 
| N |  表示属性值。 **类型**：`double` **是否必需**：是  | 
| sl |  表示字符串属性值的数组。 **类型**：`string[]` **是否必需**：是  | 
| SDM |  表示字符串键和双精度值的字典。 **类型**：`Dictionary<string, double>` **是否必需**：是  | 

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

此数据类型由操作生成，并生成具有以下属性的对象：


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：`string` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **必需**：否  | 

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

此数据类型由操作生成，并生成具有以下属性的对象：


| Properties | 说明 | 
| --- | --- | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **必需**：否  | 

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

表示调用 [InitMetrics()](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-initmetrics) 的结果。包含成功时的 MetricsManager 实例或失败时的错误信息。


|  |  | 
| --- |--- |
| 结果 |  用于收集和报告指标的 MetricsManager 实例。 **类型**：`MetricsManager` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **必需**：否  | 

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

此数据类型由操作生成，并生成具有以下属性的对象：


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：[DescribePlayerSessionsResult](#integration-server-sdk5-csharp-datatypes-describeplayersessionsresult) **必需**：否   | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **必需**：否  | 

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


| Properties | 说明 | 
| --- | --- | 
| NextToken |  令牌指示结果的下一个连续页面的开头。要指定结果集的开始，请不要指定值。如果指定玩家会话 ID，将忽略此参数。 **类型**：`string` **是否必需**：是  | 
| PlayerSessions |  一组对象，其中包含与请求相匹配的每个玩家会话的属性。 **类型**：`IList<PlayerSession>` **必填**   | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **必需**：否  | 

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


| Properties | 说明 | 
| --- | --- | 
| CreationTime |  **类型**：`long` **是否必需**：是  | 
| FleetId |  **类型**：`string` **是否必需**：是  | 
| GameSessionId |  **类型**：`string` **是否必需**：是  | 
| IpAddress |  **类型**：`string` **是否必需**：是  | 
| PlayerData |  **类型**：`string` **是否必需**：是  | 
| PlayerId |  **类型**：`string` **是否必需**：是  | 
| PlayerSessionId |  **类型**：`string` **是否必需**：是  | 
| 端口： |  **类型**：`int` **是否必需**：是  | 
| Status |  **类型：`PlayerSessionStatus`**[枚举](#integration-server-sdk5-csharp-datatypes-enums)。 **是否必需**：是  | 
| TerminationTime |  **类型**：`long` **是否必需**：是  | 
| DnsName |  **类型**：`string` **是否必需**：是  | 

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

此数据类型由操作生成，并生成具有以下属性的对象：


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：[StartMatchBackfillResult](#integration-server-sdk5-csharp-datatypes-startmatchbackfillresult) **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **必需**：否  | 

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


| Properties | 说明 | 
| --- | --- | 
| TicketId |  **类型**：`string` **是否必需**：是  | 

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

此数据类型由操作生成，并生成具有以下属性的对象：


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：[GetComputeCertificateResult](#integration-server-sdk5-csharp-datatypes-getcomputecertificateresult) **必需**：否   | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **必需**：否  | 

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

计算机上 TLS 证书的路径和计算机的主机名。


| Properties | 说明 | 
| --- | --- | 
| CertificatePath |  **类型**：`string` **是否必需**：是  | 
| ComputeName |  **类型**：`string` **是否必需**：是  | 

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

此数据类型由操作生成，并生成具有以下属性的对象：


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：[GetFleetRoleCredentialsResult](#integration-server-sdk5-csharp-datatypes-getfleetrolecredentialsresult) **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **必需**：否  | 

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


| Properties | 说明 | 
| --- | --- | 
| AccessKeyId |  用于对您的 AWS 资源进行身份验证和提供访问权限的访问密钥 ID。 **类型**：`string` **必需**：否  | 
| AssumedRoleId |  服务角色所属的用户 ID。 **类型**：`string` **必需**：否  | 
| AssumedRoleUserArn |  用户应承担的角色的 Amazon 资源名称 (ARN)。 **类型**：`string` **必需**：否  | 
| 过期 |  您的会话凭证到期之前的时间。 **类型**：`DateTime` **必需**：否  | 
| SecretAccessKey |  指定 S3 验证的访问密钥 ID。 **类型**：`string` **必需**：否  | 
| SessionToken |  用于识别与您的 AWS 资源交互的当前活动会话的令牌。 **类型**：`string` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **必需**：否  | 

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

此数据类型由操作生成，并生成具有以下属性的对象：


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：`DateTime` **必需**：否   | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-csharp-datatypes-gamelifterror) **必需**：否  | 

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


| Properties | 说明 | 
| --- | --- | 
| ErrorType |  错误的类型。 **类型：`GameLiftErrorType`**[枚举](#integration-server-sdk5-csharp-datatypes-enums)。 **必需**：否   | 
| ErrorName |  错误类型的名称。  **类型**：`string` **必需**：否   | 
| ErrorMessage |  错误消息。  **类型**：`string` **必需**：否   | 

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

为适用于 Amazon GameLift Servers（C\$1）的服务器 SDK 定义了以下枚举类型：

**AttrType**  
+ **NONE**
+ **string**
+ DOUBLE
+ **字符串列表**
+ **字符串\$1DOUBLE\$1MAP**

**GameLiftErrorType**  
表示错误类型的字符串值。有效值包括：  
+ **SERVICE\$1CALL\$1FAILED — 对服务的调用失败**。 AWS 
+ **LOCAL\$1CONNECTION\$1FAILED** – 与 Amazon GameLift Servers 的本地连接失败。
+ **NETWORK\$1NOT\$1INITIALIZED – 网络尚未初始化**。
+ **GAMESESSION\$1ID\$1NOT\$1SET – 尚未设置**游戏会话 ID。
+ **错误的请求\$1异常** 
+ **内部服务异常** 
+ **ALREADY\$1INITIALIZED** – Amazon GameLift Servers 服务器或客户端已使用 Initialize() 进行初始化。
+ **FLEET\$1MISMATCH** – 目标实例集与 GameSession 或 PlayerSession 的实例集不匹配。
+ **GAMELIFT\$1CLIENT\$1NOT\$1INITIALIZED** – Amazon GameLift Servers 客户端尚未初始化。
+ **GAMELIFT\$1SERVER\$1NOT\$1INITIALIZED** – Amazon GameLift Servers 服务器尚未初始化。
+ **GAME\$1SESSION\$1ENDED\$1FAILED** – 适用于 Amazon GameLift Servers 的服务器 SDK 无法联系服务部门报告游戏会话已结束。
+ **GAME\$1SESSION\$1NOT\$1READY** – Amazon GameLift Servers 服务器游戏会话未激活。
+ **GAME\$1SESSION\$1READY\$1FAILED** – 适用于 Amazon GameLift Servers 的服务器 SDK 无法联系服务部门报告游戏会话已准备就绪。
+ INITI@@ **ALIZATION\$1MISMATCH – 在 Server::In** itialization () 之后调用了客户端方法，反之亦然。
+ **NOT\$1INITIALIZED** – Amazon GameLift Servers 服务器或客户端尚未使用 Initialize() 进行初始化。
+ **NO\$1TARGET\$1ALIASID\$1SET – 尚未设置**目标 AliasID。
+ **NO\$1TARGET\$1FLEET\$1SET – 尚未设置**目标实例集。
+ **PROCESS\$1ENDING\$1FAILED** – 适用于 Amazon GameLift Servers 的服务器 SDK 无法联系服务部门报告流程即将结束。
+ **PROCESS\$1NOT\$1AC** TIVE — 服务器进程尚未处于活动状态，未绑定到 GameSession，也无法接受或处理。 PlayerSessions
+ **PROCESS\$1NOT\$1READ** Y – 服务器进程尚未准备好激活。
+ **PROCESS\$1READY\$1FAILED** – 适用于 Amazon GameLift Servers 的服务器 SDK 无法联系服务部门报告流程已准备就绪。
+ **SDK\$1VERSION\$1DETECTION\$1FAILED – 软件开发工具包 版本检测失败。**
+ **STX\$1CALL\$1FAILED — 对 XStx 服务器后端组件的调用失败**。
+ **STX\$1INITIALIZATION\$1FAILED — XStx 服务器后端组件初始化失败**。
+ E@@ **XPRENTED\$1PLAYER\$1SESSION – 服务器遇到了未注册的玩家会话**。
+ **网络套接字连接失败** 
+ **禁止网络套接字连接失败** 
+ **WEBSOCKET\$1CONNECT\$1FAILURE\$1INVALID\$1UR** 
+ **WEBSOCKET\$1CONNECT\$1FAILURE\$1** 
+ **WEBSOCKET\$1RETRIABLE\$1SEND\$1MESSAGE\$1FAILURE — 向服务发送消息时**可重试失败。 GameLift WebSocket
+ **WEBSOCKET\$1SEND\$1MESSAGE\$1FAILURE — 无法向服务发送消息**。 GameLift WebSocket
+ **MATCH\$1BACKFILL\$1REQUEST\$1VALIDATION – 请求验证失败**。
+ **PLAYER\$1SESSION\$1REQUEST\$1VALIDATION – 请求验证失败**。

**PlayerSessionCreationPolicy**  
用于指示游戏会话是否接受新玩家的字符串值。有效值包括：  
+ **ACCEPT\$1ALL** - 接受所有新玩家会话。
+ **DENY\$1ALL** - 拒绝所有新玩家会话。
+ **NOT\$1SET** – 游戏会话未设置为接受或拒绝新玩家会话。

**PlayerSessionStatus**  
+ ACTIVE (处于活动状态)
+ **COMPLETED**
+ **NOT\$1SET**
+ 预留
+ 超时

[适用于 Amazon GameLift Servers 的 C\$1 服务器 SDK 5.x – 数据类型](integration-server-sdk5-csharp-datatypes.md)

**Topics**
+ [适用于 Amazon GameLift Servers 的 C\$1 服务器 SDK 5.x – 数据类型](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>

返回当前内置到服务器进程中的开发工具包的版本号。

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

```
AwsStringOutcome GetSdkVersion();
```

### 返回值
<a name="integration-server-sdk5-csharp-getsdkversion-return"></a>

如果成功，返回以 [AwsStringOutcome](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-awsstringoutcome) 对象返回当前 SDK 的版本。返回的字符串仅包含版本号 (例如：如果不成功，将返回错误消息。

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

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

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

初始化指标系统，用于收集和报告服务器性能数据。为了获得最佳结果，请在调用 [InitSDK()](#integration-server-sdk5-csharp-initsdk) 之前调用此方法，以便在 SDK 初始化期间启用指标收集。

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

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

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

[MetricsParameters](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-metricsparameters)（可选）  
指标收集的配置参数。如果未提供，则使用可以被环境变量覆盖的默认值。

### 返回值
<a name="integration-server-sdk5-csharp-initmetrics-return"></a>

如果成功，则返回包含该 MetricsManager 实例的[MetricsManagerOutcome](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-metricsmanageroutcome)对象。如果不成功，将返回错误消息。

### 示例
<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>

为托管式 EC2 实例集初始化 Amazon GameLift Servers SDK。在与 Amazon GameLift Servers 相关的任何其他初始化发生之前，在启动时调用此方法。此方法从主机环境读取服务器参数，以设置服务器与 Amazon GameLift Servers 服务之间的通信。它使用幂等性令牌，因此当调用失败时，您可以放心地重试此调用。

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

```
GenericOutcome InitSDK();
```

### 返回值
<a name="integration-server-sdk5-csharp-initsdk-return"></a>

如果成功，则返回一个 InitSdkOutcome 对象，表示服务器进程已准备好调用[ProcessReady()](#integration-server-sdk5-csharp-processready)。

### 示例
<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>

为 Anywhere 实例集初始化 Amazon GameLift Servers SDK。在与 Amazon GameLift Servers 相关的任何其他初始化发生之前，在启动时调用此方法。此方法需要明确的服务器参数来设置服务器和 Amazon GameLift Servers 服务之间的通信。它使用幂等性令牌，因此当调用失败时，您可以放心地重试此调用。

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

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

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

[ServerParameters](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-dataypes-serverparameters)  
要在 Amazon GameLift Servers Anywhere 实例集上初始化游戏服务器，请使用以下信息构造 `ServerParameters` 对象：  
+  WebSocket 用于连接到您的游戏服务器的 URL。
+ 用于托管游戏服务器的进程的 ID。
+ 托管游戏服务器进程的计算的 ID。
+ 包含您的 Amazon GameLift Servers Anywhere 计算的 Amazon GameLift Servers 实例集的 ID。
+ Amazon GameLift Servers 操作生成的授权令牌。

### 返回值
<a name="integration-server-sdk5-csharp-initsdk-anywhere-return"></a>

如果成功，则返回一个 InitSdkOutcome 对象，表示服务器进程已准备好调用[ProcessReady()](#integration-server-sdk5-csharp-processready)。

**注意**  
如果对部署到 `InitSDK()` Anywhere 队列的游戏版本调用失败，请检查创建编译资源时使用的`ServerSdkVersion`参数。您必须将此值明确设置为正在使用的服务器软件开发工具包 版本。此参数的默认值为 4.x，这不兼容。要解决此问题，请创建新版本并将其部署到新队列。

### 示例
<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>

通知 Amazon GameLift Servers，该服务器进程已准备好托管游戏会话。调用后调用[InitSDK()](#integration-server-sdk5-csharp-initsdk)此方法。每个进程只能调用一次此方法。

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

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

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

**[ProcessParameters](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-dataypes-process)**  
`ProcessParameters`对象保存有关服务器进程的信息。

### 返回值
<a name="integration-server-sdk5-csharp-processready-return"></a>

返回由成功或失败组成的通用结果，并显示错误消息。

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

此示例说明 调用和委派函数实施。

```
// 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>

通知 Amazon GameLift Servers，该服务器进程即将终止。请在已完成所有其他清理任务（包括关闭活动游戏会话）但尚未终止进程时调用此方法。根据的结果`ProcessEnding()`，进程以成功 (0) 或错误 (-1) 退出并生成队列事件。如果进程因错误而终止，则生成的实例集事件为 `SERVER_PROCESS_TERMINATED_UNHEALTHY`。

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

```
GenericOutcome ProcessEnding()
```

### 返回值
<a name="integration-server-sdk5-csharp-processending-return"></a>

返回由成功或失败组成的通用结果，并显示错误消息。

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

此示例在使用成功或错误退出代码终止服务器进程`Destroy()`之前调`ProcessEnding()`用和。

```
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>

通知 Amazon GameLift Servers，该服务器进程已激活游戏会话，现在已准备好接收玩家连接。此操作应作为 `onStartGameSession()` 回调函数的一部分，在所有游戏会话初始化已完成之后调用。

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

```
GenericOutcome ActivateGameSession()
```

### 返回值
<a name="integration-server-sdk5-csharp-activategamesession-return"></a>

返回由成功或失败组成的通用结果，并显示错误消息。

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

此示例显示了 `ActivateGameSession()` 作为 `onStartGameSession()` 委派函数的一部分调用。

```
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>

更新当前游戏会话接受新玩家会话的能力。可将游戏会话设置为接受或拒绝所有新的玩家会话。

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

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

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

**playerSessionPolicy**  
用于指示游戏会话是否接受新玩家的字符串值。  
有效值包括：  
+ **ACCEPT\$1ALL** - 接受所有新玩家会话。
+ **DENY\$1ALL** - 拒绝所有新玩家会话。

### 返回值
<a name="integration-server-sdk5-csharp-updateplayersessioncreationpolicy-return"></a>

返回由成功或失败组成的通用结果，并显示错误消息。

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

此示例将当前游戏会话的接入策略设为接受所有玩家。

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

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

检索当前由服务器进程托管的游戏会话的 ID (如果服务器进程处于活动状态)。

对于未通过游戏会话激活的空闲进程，该调用将返回[GameLiftError](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-gamelifterror)。

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

```
AwsStringOutcome GetGameSessionId()
```

### 返回值
<a name="integration-server-sdk5-csharp-getgamesessionid-return"></a>

如果成功，以 [AwsStringOutcome](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-awsstringoutcome) 对象返回游戏会话 ID。如果不成功，将返回错误消息。

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

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

## GetTerminationTime()
<a name="integration-server-sdk5-csharp-getterm"></a>

如果终止时间可用，则返回安排服务器进程关闭的时间。服务器进程在收到来自 Amazon GameLift Servers 的 `onProcessTerminate()` 回调后执行此操作。Amazon GameLift Servers 会出于以下原因调用 `onProcessTerminate()`：
+ 服务器进程报告运行状况不佳或未响应 Amazon GameLift Servers。
+ 在缩减事件期间终止实例时。
+ 当实例因竞价[型实例中断而终](spot-tasks.md)止时。

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

```
AwsDateTimeOutcome GetTerminationTime()
```

### 返回值
<a name="integration-server-sdk5-csharp-getterm-return"></a>

如果成功，则以[AwsDateTimeOutcome](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-awsdatetimeoutcome)对象形式返回终止时间。该值是终止时间，以此后经过的刻度表示。`0001 00:00:00`例如，日期时间值等`2020-09-13 12:26:40 -000Z`于`637355968000000000`刻度。如果没有可用的终止时间，将返回一条错误消息。

### 示例
<a name="integration-server-sdk5-csharp-getterm-example"></a>

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

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

通知 Amazon GameLift Servers，具有所指定玩家会话 ID 的玩家已连接到服务器进程并且需要进行验证。Amazon GameLift Servers 将验证该玩家会话 ID 是否有效。玩家会话经过验证后，Amazon GameLift Servers 会将玩家位置的状态从 RESERVED 更改为 ACTIVE。

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

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

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

playerSessionId  
创建新玩家会话 GameLift 时颁发的唯一 ID。

### 返回值
<a name="integration-server-sdk5-csharp-acceptplayersession-return"></a>

返回由成功或失败组成的通用结果，并显示错误消息。

### 示例
<a name="integration-server-sdk5-csharp-acceptplayersession-example"></a>

此示例说明了处理连接请求的函数，包括验证和拒绝无效的玩家会话。 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>

通知 Amazon GameLift Servers，有玩家已断开与服务器进程的连接。作为回应，Amazon GameLift Servers 会将玩家位置更改为可用。

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

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

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

**playerSessionId**  
创建新玩家会话时由 Amazon GameLift Servers 颁发的唯一 ID。

### 返回值
<a name="integration-server-sdk5-csharp-removeplayersession-return"></a>

返回由成功或失败组成的通用结果，并显示错误消息。

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

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

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

检索玩家会话数据，包括设置、会话元数据和玩家数据。使用此操作获取单个玩家会话的信息、游戏会话中所有玩家会话的信息或者与单个玩家 ID 相关联的所有玩家会话的信息。

### 语法
<a name="integration-server-sdk5-csharp-describeplayersessions-syntax"></a>

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

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

**[DescribePlayerSessionsRequest](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-dataypes-playersessions)**  
[DescribePlayerSessionsRequest](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-dataypes-playersessions) 对象描述要检索的玩家会话。

### 返回值
<a name="integration-server-sdk5-csharp-describeplayersessions-return"></a>

如果成功，将返回一个 [DescribePlayerSessionsOutcome](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-describeplayersessionsoutcome) 对象，包含一组与请求参数相匹配的玩家会话对象。

### 示例
<a name="integration-server-sdk5-csharp-describeplayersessions-example"></a>

此示例演示了将所有玩家会话主动连接到指定游戏会话的请求。省略*NextToken*并将 Limi *t* 值设置为 10，Amazon GameLift Servers将返回与请求匹配的前 10 个玩家会话记录。

```
// 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>

发送请求以为使用 FlexMatch 创建的游戏会话中的开放位置查找新玩家。有关更多信息，请参阅 [FlexMatch 回填功能](https://docs.aws.amazon.com/gameliftservers/latest/flexmatchguide/match-backfill.html)。

此操作为异步操作。如果成功匹配了新玩家，则 Amazon GameLift Servers 会使用回调函数 `OnUpdateGameSession()` 提供更新的对战构建器数据。

服务器进程每次只能具有一个活动的对战回填请求。要发送新请求，请先调用 [StopMatchBackfill()](#integration-server-sdk5-csharp-stopmatchbackfill) 以取消原始请求。

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

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

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

**[StartMatchBackfillRequest](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-dataypes-startmatchbackfillrequest)**  
`StartMatchBackfillRequest`对象包含有关回填请求的信息。

### 返回值
<a name="integration-server-sdk5-csharp-startmatchbackfill-return"></a>

返回带有匹配回填票证 ID 的 StartMatchBackfillOutcome 对象或包含错误消息的失败。

### 示例
<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>

取消活动的对战回填请求。有关更多信息，请参阅 [FlexMatch 回填功能](https://docs.aws.amazon.com/gameliftservers/latest/flexmatchguide/match-backfill.html)。

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

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

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

**[StopMatchBackfillRequest](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-dataypes-stopmatchbackfillrequest)**  
一个 `StopMatchBackfillRequest` 对象，提供有关您要停止的对战票证的详细信息。

### 返回值
<a name="integration-server-sdk5-csharp-stopmatchbackfill-return"></a>

返回由成功或失败组成的通用结果，并显示错误消息。

### 示例
<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>

 检索用于加密游戏服务器和游戏客户端之间网络连接的 TLS 证书的路径。当您将计算设备注册到 Amazon GameLift Servers Anywhere 实例集时，您可以使用该证书路径。有关更多信息，请参阅[RegisterCompute](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html)。

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

```
GetComputeCertificateOutcome GetComputeCertificate();
```

### 返回值
<a name="integration-server-sdk5-csharp-getcomputecertificate-return"></a>

返回一个包含以下内容的 GetComputeCertificateResponse 对象：
+  CertificatePath：计算资源上的 TLS 证书的路径。使用 Amazon GameLift Servers 托管式实例集时，此路径包含：
  + `certificate.pem`：最终用户证书。完整的证书链是`certificateChain.pem`附加到此证书的组合。
  + `certificateChain.pem`：包含根证书和中间证书的证书链。
  +  根证书。
  + `privateKey.pem`：最终用户证书的私钥。
+ ComputeName：您的计算资源的名称。

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

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

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

检索授权 Amazon GameLift Servers 与其他 AWS 服务互动的 IAM 角色凭证。有关更多信息，请参阅 [将您的Amazon GameLift Servers托管游戏服务器连接到其他 AWS 资源](gamelift-sdk-server-resources.md)。

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

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

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

[GetFleetRoleCredentialsRequest](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-dataypes-getfleetrolecredentialsrequest)  
角色证书，用于将有限的 AWS 资源访问权限扩展到游戏服务器。

### 返回值
<a name="integration-server-sdk5-csharp-getfleetrolecredentials-return"></a>

返回 [GetFleetRoleCredentialsOutcome](integration-server-sdk5-csharp-datatypes.md#integration-server-sdk5-csharp-datatypes-getfleetrolecredentialsoutcome) 对象。

### 示例
<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>

从内存中释放 Amazon GameLift Servers 游戏服务器 SDK。作为最佳实操，请在终止进程之后`ProcessEnding()`和之前调用此方法。如果您使用的是 Anywhere 实例集，并且没有在每次游戏会话后终止服务器进程，请先调用 `Destroy()`，再通过 `InitSDK()` 重新初始化，最后使用 `ProcessReady()` 通知 Amazon GameLift Servers 该进程已准备好托管游戏会话。

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

```
GenericOutcome Destroy()
```

### 返回值
<a name="integration-server-sdk5-csharp-destroy-return"></a>

返回由成功或失败组成的通用结果，并显示错误消息。

### 示例
<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); 
  }
```