

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

# Amazon GameLift Servers 服务器 SDK 5.x
<a name="reference-serversdk"></a>

本节提供了 Amazon GameLift Servers 服务器 SDK 5.x 的参考文档。服务器 SDK 提供游戏服务器用于与 Amazon GameLift Servers 服务交互的核心功能。例如，游戏服务器会接收该服务发送的提示来启动和停止游戏会话，并定期向该服务提供游戏会话状态更新。在部署游戏服务器进行托管之前，请将其与服务器 SDK 集成。

使用此服务器 SDK 参考将要托管的自定义多人游戏服务器与 Amazon GameLift Servers 集成。有关集成过程的指南，请参阅[借助服务器 SDK 将 Amazon GameLift Servers 添加到游戏服务器](gamelift-sdk-server-api.md)。

Amazon GameLift Servers 服务器 SDK 的最新主要版本是 5.x。以下托管功能需要使用版本 5.x：
+ Amazon GameLift Servers Anywhere
+ 适用于 Unreal Engine 和 Unity 的 Amazon GameLift Servers 插件

**注意**  
如果您需要使用服务器 SDK 版本 4.x 或更早版本，请参阅 [Amazon GameLift Servers 服务器 SDK 版本 4 及更早版本](reference-serversdk4.md)以获取文档和下载信息。

**Topics**
+ [Amazon GameLift Servers 服务器 SDK 5 中的更新](#reference-serversdk5-about)
+ [迁移到 Amazon GameLift Servers 服务器 SDK 5.x](reference-serversdk5-migration.md)
+ [适用于 Amazon GameLift Servers 的 C\$1\$1 服务器 SDK 5.x – 操作](integration-server-sdk5-cpp-actions.md)
+ [适用于 Amazon GameLift Servers 的 C\$1 服务器 SDK 5.x – 操作](integration-server-sdk5-csharp-actions.md)
+ [适用于 Amazon GameLift Servers 的 Go 服务器 SDK – 操作](integration-server-sdk-go-actions.md)
+ [适用于 Amazon GameLift Servers 的 C\$1\$1（Unreal）服务器 SDK 5.x – 操作](integration-server-sdk5-unreal-actions.md)

## Amazon GameLift Servers 服务器 SDK 5 中的更新
<a name="reference-serversdk5-about"></a>

托管的游戏服务器使用 Amazon GameLift Servers 服务器 SDK 与 Amazon GameLift Servers 服务通信，以启动和管理玩家的游戏会话。最新版本的 Amazon GameLift Servers 服务器 SDK 5 提供了大量改进功能并支持 Amazon GameLift Servers 的新功能。如果您的游戏服务器生成包目前使用的是 Amazon GameLift Servers 服务器 SDK 4 或更早版本，请按照本主题中的指南更新您的游戏。

Amazon GameLift Servers 服务器 SDK 5.0.0 及更高版本包含以下更新：
+ 扩展的语言 - 库支持以下语言：C\$1\$1、C\$1、Go。您可以构建适用于 Unreal Engine 的 C\$1\$1 库。
+ 游戏引擎插件支持 - 适用于 Unreal Engine 和 Unity 的 Amazon GameLift Servers 独立插件需要 Amazon GameLift Servers 服务器 SDK 5 库。这些插件提供用于集成、测试和将游戏部署到 Amazon GameLift Servers 进行托管的引导式工作流程。请参阅[Amazon GameLift Servers适用于 Unity 的插件（服务器 SDK 5.x）](unity-plug-in.md)和[Amazon GameLift Servers虚幻引擎插件](unreal-plugin.md)文档。
+ Amazon GameLift Servers Anywhere 支持 - 利用 Anywhere 实例集，您可以设置自己的托管资源，以使用 Amazon GameLift Servers 功能（包括对战）。添加 Amazon GameLift Servers 代理以自动执行游戏会话生命周期管理。使用 Anywhere 实例集通过本地硬件进行生产托管，或为快速迭代游戏开发设置测试环境。设置 [Anywhere 托管](gamelift-intro-flavors.md#gamelift-intro-flavors-hosting-anywhere) 和 [Amazon GameLift Servers 代理](https://github.com/aws/amazon-gamelift-agent)。
+ 更新的测试工具 - Amazon GameLift Servers Anywhere 功能可让您为游戏设置本地或基于云的测试环境。设置使用或不使用 Amazon GameLift Servers 代理的测试。这些工具取代了 Amazon GameLift Servers Local。请参阅[使用 Amazon GameLift Servers Anywhere 设置本地测试](integration-testing.md)。
+ 适用于 C\$1 的整合 .NET 解决方案 – C\$1 服务器 SDK 5.1\$1 在一个解决方案中支持 .NET 框架 4.6.2（从 4.6.1 升级）和 .NET 6.0。.NET 标准 2.1 在 Unity 构建的库中可用。
+ 新 `Compute` 资源 - 这种新资源整合了不同类型的托管资源。它包含基于云的托管资源（托管式 EC2 或容器实例集）和客户控制的托管资源（Anywhere 实例集）。它包含以下更新：
  + 针对 `Compute` 资源的新 API 调用包括：[ListCompute()](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_ListCompute.html)、[DescribeCompute()](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_DescribeCompute.html) 和 [GetComputeAccess()](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_GetComputeAccess.html)。这些操作将返回任何类型 Amazon GameLift Servers 实例集的托管资源信息。通常，对于具有使用服务器 SDK 5.x 的游戏服务器的实例集，请使用特定于计算的操作来替换特定于实例的操作。此外，这些操作适用于没有 Amazon GameLift Servers 代理的 Anywhere 实例集：[RegisterCompute()](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html)、[DeregisterCompute()](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_DeregisterCompute.html) 和 [GetComputeAuthToken()](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_GetComputeAuthToken.html)。
  + 包含 CloudWatch 维度 `FleetId`、`Location` 和 `ComputeType` 的新指标 `ActiveCompute`。该指标取代了之前的指标 `ActiveInstances`。
+ 用于远程访问的 Amazon EC2 Systems Manager（SSM）- 为了提高安全性，在连接到 Amazon GameLift Servers 托管式实例集中的实例时，请使用 SSM 而不是 SSH。请参阅[Connect 连接到舰队实例](fleets-remote-access.md)。

# 迁移到 Amazon GameLift Servers 服务器 SDK 5.x
<a name="reference-serversdk5-migration"></a>

要将游戏项目更新为使用服务器软件开发工具包版本 5.x，请进行以下更改：

**注意**  
如果您需要继续使用服务器 SDK 版本 4.x 或更早版本，请参阅 [Amazon GameLift Servers 服务器 SDK 版本 4 及更早版本](reference-serversdk4.md)以获取文档和下载信息。特别是对于 SDK 版本 4.0.2，您可以从[官方 GitHub 版本](https://github.com/amazon-gamelift/amazon-gamelift-servers-csharp-server-sdk/releases)中下载。

1. 获取适用于您的开发环境的最新 Amazon GameLift Servers 服务器 SDK 软件包 **[[下载网站](https://aws.amazon.com/gamelift/servers/getting-started-sdks/)]**。按照下载的软件包和版本`Readme`的文件中的安装说明进行操作。有关在游戏项目中使用服务器的信息 SDKs，请参阅以下说明。
   + [针对使用 C\$1\$1、C\$1 或 Go 的开发环境](gamelift-sdk-server-api.md)
   + [针对 Unreal Engine 项目（仅限适用于 Unreal 库的 C\$1\$1 服务器 SDK）](integration-engines-setup-unreal.md)
   + [针对 Unity 项目（仅限适用于 Unity 库的 C\$1 服务器 SDK）](integration-engines-unity-using.md)
   + [针对与适用于 Unreal Engine 的 Amazon GameLift Servers 插件结合使用](unreal-plugin.md)
   + [针对与适用于 Unity 的 Amazon GameLift Servers 插件结合使用](unity-plug-in.md)

1. 按如下方式更新服务器代码：
   + 将服务器代码回调函数 `onCreateGameSession()` 更改为 `onStartGameSession()`。
   + 根据需要更新 `InitSDK()` 输入：
     + 如果您计划在有 Amazon GameLift Servers 代理的情况下将游戏服务器生成包部署到 Amazon GameLift Servers 托管式 EC2 实例集或 Anywhere 实例集：

       调用 `InitSDK()` 而无需使用参数（[C\$1\$1](integration-server-sdk5-cpp-actions.md#integration-server-sdk5-cpp-initsdk)）（[C\$1](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-initsdk)）（[Unreal](integration-server-sdk5-unreal-actions.md#integration-server-sdk5-unreal-initsdk)）。此调用设置计算环境和与Amazon GameLift Servers服务的 WebSocket 连接。
     + 如果您计划在没有 Amazon GameLift Servers 代理的情况下将游戏服务器生成包部署到 Anywhere 实例集：

       使用服务器参数调用 `InitSDK()`（[C\$1\$1](integration-server-sdk5-cpp-actions.md#integration-server-sdk5-cpp-initsdk-anywhere)）（[C\$1](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-initsdk-anywhere)）（[Unreal](integration-server-sdk5-unreal-actions.md#integration-server-sdk5-unreal-initsdk-anywhere)）。游戏服务器进程使用这些参数与 Amazon GameLift Servers 服务建立连接。

1. 如果您的游戏服务器生成包或其他托管应用程序在运行时与其他 AWS 资源通信，您需要更改应用程序访问这些资源的方式。使用新服务器 SDK 操作 `GetFleetRoleCredentials()` 替换 `AssumeRoleCredentials`（对于游戏服务器），或使用共享凭证（对于其他应用程序）。有关如何实施此更改的更多信息，请参阅[将您的Amazon GameLift Servers托管游戏服务器连接到其他 AWS 资源](gamelift-sdk-server-resources.md)。

1. 如果您的项目调用了服务器 SDK 操作 `GetInstanceCertificate()` 来检索 TLS 证书，请将代码修改为使用新的 `GetComputeCertificate()`（[C\$1\$1](integration-server-sdk5-cpp-actions.md#integration-server-sdk5-cpp-getcomputecertificate)）（[C\$1](integration-server-sdk5-csharp-actions.md#integration-server-sdk5-csharp-getcomputecertificate)）（[Unreal](integration-server-sdk5-unreal-actions.md#integration-server-sdk5-unreal-getcomputecertificate)）。

1. 将游戏版本上传到时Amazon GameLift Servers（例如使用 [upload-build](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/gamelift/upload-build.html) 或 [CreateBuild()](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_CreateBuild.html)），请将`ServerSdkVersion`参数设置为您正在使用的 5.x 版本（此参数当前默认为 4.0.2）。该参数必须与游戏服务器生成包中的实际服务器 SDK 库匹配。如果为上传的游戏服务器生成包指定了错误的版本，那么使用该生成包创建的所有实例集都将失败。请参阅[为 Amazon GameLift Servers 创建游戏服务器生成包](gamelift-build-cli-uploading.md)。

   以下示例说明了如何指定服务器 SDK 版本：

   ```
   aws gamelift upload-build \
       --operating-system AMAZON_LINUX_2023 \
       --server-sdk-version "5.0.0" \
       --build-root "~/mygame" \
       --name "My Game Nightly Build" \
       --build-version "build 255" \
       --region us-west-2
   ```

1. 如果您使用脚本远程连接到托管式实例集，请更新脚本以使用新流程，如[Connect 连接到舰队实例](fleets-remote-access.md)中所述。

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

使用服务器 SDK 5.x 参考，将要托管的多人游戏与 Amazon GameLift Servers 集成。有关集成过程的指南，请参阅[借助服务器 SDK 将 Amazon GameLift Servers 添加到游戏服务器](gamelift-sdk-server-api.md)。

**注意**  
本主题介绍使用 C\$1\$1 标准库（`std`）构建时可以使用的 Amazon GameLift Servers C\$1\$1 API。具体而言，本文档适用于使用该`-DDGAMELIFT_USE_STD=1`选项编译的代码。

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

使用 Amazon GameLift Servers C\$1\$1 服务器 SDK 5.x 参考，将要托管的多人游戏与 Amazon GameLift Servers 集成。有关集成过程的指南，请参阅[借助服务器 SDK 将 Amazon GameLift Servers 添加到游戏服务器](gamelift-sdk-server-api.md)。

**注意**  
本主题介绍使用 C\$1\$1 标准库（`std`）构建时可以使用的 Amazon GameLift Servers C\$1\$1 API。具体而言，本文档适用于使用该`-DDGAMELIFT_USE_STD=1`选项编译的代码。

[适用于 Amazon GameLift Servers 的 C\$1\$1 服务器 SDK 5.x – 操作](integration-server-sdk5-cpp-actions.md)

**Topics**
+ [LogParameters](#integration-server-sdk5-cpp-dataypes-log)
+ [MetricsParameters](#integration-server-sdk5-cpp-datatypes-metricsparameters)
+ [ProcessParameters](#integration-server-sdk5-cpp-dataypes-process)
+ [UpdateGameSession](#integration-server-sdk5-cpp-dataypes-updategamesession)
+ [GameSession](#integration-server-sdk5-cpp-dataypes-gamesession)
+ [ServerParameters](#integration-server-sdk5-cpp-dataypes-serverparameters)
+ [StartMatchBackfillRequest](#integration-server-sdk5-cpp-dataypes-startmatchbackfillrequest)
+ [玩家](#integration-server-sdk5-cpp-dataypes-player)
+ [DescribePlayerSessionsRequest](#integration-server-sdk5-cpp-dataypes-playersessions)
+ [StopMatchBackfillRequest](#integration-server-sdk5-cpp-dataypes-stopmatchbackfillrequest)
+ [AttributeValue](#integration-server-sdk5-cpp-dataypes-attributevalue)
+ [GetFleetRoleCredentialsRequest](#integration-server-sdk5-cpp-dataypes-getfleetrolecredentialsrequest)
+ [AwsLongOutcome](#integration-server-sdk5-cpp-datatypes-awslongoutcome)
+ [AwsStringOutcome](#integration-server-sdk5-cpp-datatypes-awsstringoutcome)
+ [DescribePlayerSessionsOutcome](#integration-server-sdk5-cpp-datatypes-describeplayersessionsoutcome)
+ [DescribePlayerSessionsResult](#integration-server-sdk5-cpp-datatypes-describeplayersessionsresult)
+ [GenericOutcome](#integration-server-sdk5-cpp-datatypes-genericoutcome)
+ [GenericOutcomeCallable](#integration-server-sdk5-cpp-datatypes-genericoutcomecallable)
+ [PlayerSession](#integration-server-sdk5-cpp-datatypes-playersession)
+ [StartMatchBackfillOutcome](#integration-server-sdk5-cpp-datatypes-startmatchbackfilloutcome)
+ [StartMatchBackfillResult](#integration-server-sdk5-cpp-datatypes-startmatchbackfillresult)
+ [GetComputeCertificateOutcome](#integration-server-sdk5-cpp-datatypes-getcomputecertificateoutcome)
+ [GetComputeCertificateResult](#integration-server-sdk5-cpp-datatypes-getcomputecertificateresult)
+ [GetFleetRoleCredentialsOutcome](#integration-server-sdk5-cpp-datatypes-getfleetrolecredentialsoutcome)
+ [GetFleetRoleCredentialsResult](#integration-server-sdk5-cpp-datatypes-getfleetrolecredentialsresult)
+ [初始化 SDKOutcome](#integration-server-sdk5-cpp-datatypes-initsdkoutcome)
+ [GameLiftError](#integration-server-sdk5-cpp-datatypes-gamelifterror)
+ [枚举](#integration-server-sdk5-cpp-dataypes-enums)

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

一个对象，用于标识游戏会话期间生成的文件，您希望 Amazon GameLift Servers 在游戏会话结束后上传和存储这些文件。游戏服务器在 [ProcessReady()](integration-server-sdk5-cpp-actions.md#integration-server-sdk5-cpp-processready) 调用中，作为 `ProcessParameters` 对象的一部分向 Amazon GameLift Servers 提供 `LogParameters`。


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

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

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


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

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

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


|  |  | 
| --- |--- |
|  **属性**  | 描述 | 
| LogParameters | 一个对象，其中包含游戏会话期间生成的文件的目录路径。Amazon GameLift Servers 会复制并存储这些文件，以便将来访问。**类型**：`Aws::GameLift::Server::LogParameters`**必需**：否 | 
| OnHealthCheck | Amazon GameLift Servers 为向服务器进程请求运行状况报告而调用的回调函数。Amazon GameLift Servers 每隔 60 秒调用此函数一次，并等待 60 秒以获取响应。TRUE如果运行状况良好，则服务器进程会返回，FALSE如果不健康，则返回。如果没有返回任何响应，Amazon GameLift Servers 会将服务器进程记录为运行状况不佳。**类型**：`std::function<bool()> onHealthCheck`**必需**：否 | 
| OnProcessTerminate | Amazon GameLift Servers 为强制关闭服务器进程而调用的回调函数。调用此函数之后，Amazon GameLift Servers 会等待 5 分钟，以确保服务器进程关闭并通过 [ProcessEnding()](integration-server-sdk5-cpp-actions.md#integration-server-sdk5-cpp-processending) 调用作出响应，随后才会终止该服务器进程。**类型**：`std::function<void()> onProcessTerminate`**是否必需**：是 | 
| OnStartGameSession | 调Amazon GameLift Servers用以激活新游戏会话的回调函数。 Amazon GameLift Servers应客户端请求调用此函数[CreateGameSession](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_CreateGameSession.html)。回调函数将传递一个 [GameSession](#integration-server-sdk5-cpp-dataypes-gamesession) 对象。**类型**：`const std::function<void(Aws::GameLift::Model::GameSession)> onStartGameSession`**是否必需**：是 | 
| OnUpdateGameSession | Amazon GameLift Servers 为向服务器进程传递更新的游戏会话对象而调用的回调函数。当对战回填请求处理完毕时，Amazon GameLift Servers 会调用此函数以提供更新的对战构建器数据。它将传递一个 [GameSession](#integration-server-sdk5-cpp-dataypes-gamesession) 对象、一个状态更新（updateReason）以及对战回填票证 ID。**类型**：`std::function<void(Aws::GameLift::Server::Model::UpdateGameSession)> onUpdateGameSession`**必需**：否 | 
| 端口： | 服务器进程用于侦听新玩家连接的端口号。该值必须在部署此游戏服务器构建的任意实例集上所配置的端口范围内。此端口号包含在游戏会话和玩家会话对象中，游戏会话在连接到服务器进程时会使用该端口号。**类型**：`Integer`**是否必需**：是 | 

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

此数据类型更新为游戏会话对象，其中包括更新游戏会话的原因以及相关的回填票证 ID（如果使用回填来填充游戏会话中的玩家会话）。


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

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

此数据类型提供游戏会话的详细信息。


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

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

游戏服务器进程用来与 Amazon GameLift Servers 服务建立连接的信息。仅当游戏服务器生成包将在没有 Amazon GameLift Servers 代理的情况下部署到 Anywhere 实例集或容器实例集时，才需在调用 [InitSDK()](integration-server-sdk5-cpp-actions.md#integration-server-sdk5-cpp-initsdk-anywhere) 时包含这些参数。对于所有其他部署场景，请调用 [InitSDK()](integration-server-sdk5-cpp-actions.md#integration-server-sdk5-cpp-initsdk) 而不使用参数。


| Properties | **描述** | 
| --- | --- | 
| webSocketUrl |  当您为 Amazon GameLift Servers Anywhere 计算资源调用 [https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html) 时，`GameLiftServerSdkEndpoint` Amazon GameLift Servers 会返回结果。 **类型**：`std::string` **是否必需**：是   | 
| ProcessID |  注册到托管游戏的服务器进程的唯一标识符。 **类型**：`std::string` **是否必需**：是  | 
| hostId | HostID是在您注册计算机时ComputeName使用的。有关更多信息，请参阅[RegisterCompute](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html)。**类型**：`std::string`**是否必需**：是 | 
| FleetId | 计算注册到的实例集的唯一标识符。有关更多信息，请参阅[RegisterCompute](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html)。**类型**：`std::string`**是否必需**：是 | 
| AuthToken | 由 Amazon GameLift Servers 生成的身份验证令牌，用于向 Amazon GameLift Servers 对您的服务器进行身份验证。有关更多信息，请参阅[GetComputeAuthToken](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_GetComputeAuthToken.html)。**类型**：`std::string`**是否必需**：是 | 

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

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


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

## 玩家
<a name="integration-server-sdk5-cpp-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)。 **类型**：`std::map<std::string,AttributeValue>` **必需**：否  | 
| PlayerId |  玩家的唯一标识符。 **类型**：`std::string` **必需**：否  | 
| Team |  玩家在对战中被分配到的团队的名称。在对战规则集中定义团队名称。 **类型**：`std::string` **必需**：否  | 

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

一个对象，用于指定要检索哪些玩家会话。服务器进程通过向 Amazon GameLift Servers 调用 [DescribePlayerSessions()](integration-server-sdk5-cpp-actions.md#integration-server-sdk5-cpp-describeplayersessions) 来提供此信息。


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

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

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


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

## AttributeValue
<a name="integration-server-sdk5-cpp-dataypes-attributevalue"></a>

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


| Properties | 说明 | 
| --- | --- | 
| AttrType |  指定属性值的类型。可能的属性值类型包括： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/gameliftservers/latest/developerguide/integration-server-sdk5-cpp-datatypes.html) **必需**：否  | 
| S |  表示字符串属性值。 **类型**：`std::string` **必需**：否  | 
| N |  表示属性值。 **类型**：`double` **必需**：否  | 
| sl |  表示字符串属性值的数组。 **类型**：`std::vector<std::string>` **必需**：否  | 
| SDM |  表示字符串键和双精度值的字典。 **类型**：`std::map<std::string, double>` **必需**：否  | 

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

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


| Properties | **描述** | 
| --- | --- | 
| RoleArn | 服务角色的 Amazon 资源名称 (ARN)，用于扩展对您的 AWS 资源的有限访问权限。**类型**：`std::string`**必需**：否 | 
| RoleSessionName | 可用于唯一标识会话的角色会 AWS Security Token Service [AssumeRole](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html)话名称。此名称会显示在审计日志中，例如中的日志 CloudTrail。**类型**：`std::string` **必需**：否  | 

## AwsLongOutcome
<a name="integration-server-sdk5-cpp-datatypes-awslongoutcome"></a>

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


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：`long` **必需**：否  | 
| ResultWithOwnership |   操作的结果，转换为右值，以便调用代码可以拥有该对象的所有权。 **类型**：`long&&` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-cpp-datatypes-gamelifterror) **必需**：否  | 

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

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


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：`std::string` **必需**：否  | 
| ResultWithOwnership |   操作的结果，转换为右值，以便调用代码可以拥有该对象的所有权。 **类型**：`long&&` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-cpp-datatypes-gamelifterror) **必需**：否  | 

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

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


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：[DescribePlayerSessionsResult](#integration-server-sdk5-cpp-datatypes-describeplayersessionsresult) **必需**：否   | 
| ResultWithOwnership |   操作的结果，转换为右值，以便调用代码可以拥有该对象的所有权。 **类型**：`Aws::GameLift::Server::Model::DescribePlayerSessionsResult&&` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-cpp-datatypes-gamelifterror) **必需**：否  | 

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

一组对象，其中包含与请求相匹配的每个玩家会话的属性。


| Properties | 说明 | 
| --- | --- | 
| NextToken |  令牌指示结果的下一个连续页面的开头。使用之前的调用返回此操作的令牌。要指定结果集的开始，请不要指定值。如果指定玩家会话 ID，将忽略此参数。 **类型**：`std::string` **是否必需**：是  | 
| PlayerSessions |  **类型**：`IList<PlayerSession>` **必填**   | 
| ResultWithOwnership |   操作的结果，转换为右值，以便调用代码可以拥有该对象的所有权。 **类型**：`std::string&&` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-cpp-datatypes-gamelifterror) **必需**：否  | 

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

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


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

## GenericOutcomeCallable
<a name="integration-server-sdk5-cpp-datatypes-genericoutcomecallable"></a>

这种数据类型是一种异步的通用结果。它具有以下属性：


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

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

此数据类型表示 Amazon GameLift Servers 传递给游戏服务器的玩家会话。有关更多信息，请参阅 [PlayerSession](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_PlayerSession.html)。


| Properties | 说明 | 
| --- | --- | 
| CreationTime |  **类型**：`long` **必需**：否  | 
| FleetId |  **类型**：`std::string` **必需**：否  | 
| GameSessionId |  **类型**：`std::string` **必需**：否  | 
| IpAddress |  **类型**：`std::string` **必需**：否  | 
| PlayerData |  **类型**：`std::string` **必需**：否  | 
| PlayerId |  **类型**：`std::string` **必需**：否  | 
| PlayerSessionId |  **类型**：`std::string` **必需**：否  | 
| 端口： |  **类型**：`int` **必需**：否  | 
| Status |  用于筛选结果的玩家会话状态。如果提供 PlayerId 了 o PlayerSessionId r，则 PlayerSessionStatusFilter 对响应没有影响。 **类型：**`PlayerSessionStatus`枚举。可能的值包括： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/gameliftservers/latest/developerguide/integration-server-sdk5-cpp-datatypes.html) **必需**：否  | 
| TerminationTime |  **类型**：`long` **必需**：否  | 
| DnsName |  **类型**：`std::string` **必需**：否  | 

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

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


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：[StartMatchBackfillResult](#integration-server-sdk5-cpp-datatypes-startmatchbackfillresult) **必需**：否  | 
| ResultWithOwnership |   操作的结果，转换为右值，以便调用代码可以拥有该对象的所有权。 **类型**：`StartMatchBackfillResult&&` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-cpp-datatypes-gamelifterror) **必需**：否  | 

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

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


| Properties | 说明 | 
| --- | --- | 
| TicketId |  对战配置的唯一标识符。如果此处未指定任何票证 ID，则 Amazon GameLift Servers 将生成一个采用 UUID 形式的 ID。使用此标识符跟踪对战回填单状态并检索匹配结果。 **类型**：`std::string` **必需**：否  | 

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

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


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：[GetComputeCertificateResult](#integration-server-sdk5-cpp-datatypes-getcomputecertificateresult) **必需**：否   | 
| ResultWithOwnership |   操作的结果，转换为右值，以便调用代码可以拥有该对象的所有权。 **类型**：`Aws::GameLift::Server::Model::GetComputeCertificateResult&&` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-cpp-datatypes-gamelifterror) **必需**：否  | 

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

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


| Properties | 说明 | 
| --- | --- | 
| CertificatePath |  计算资源上 TLS 证书的路径。使用 Amazon GameLift Servers 托管式实例集时，此路径包含： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/gameliftservers/latest/developerguide/integration-server-sdk5-cpp-datatypes.html) **类型**：`std::string` **必需**：否  | 
| ComputeName |  您的计算资源的名称。 **类型**：`std::string` **必需**：否  | 

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

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


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：[GetFleetRoleCredentialsResult](#integration-server-sdk5-cpp-datatypes-getfleetrolecredentialsresult) **必需**：否   | 
| ResultWithOwnership |   操作的结果，转换为右值，以便调用代码可以拥有该对象的所有权。 **类型**：`Aws::GameLift::Server::Model::GetFleetRoleCredentialsResult` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[GameLiftError](#integration-server-sdk5-cpp-datatypes-gamelifterror) **必需**：否  | 

## GetFleetRoleCredentialsResult
<a name="integration-server-sdk5-cpp-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.md#integration-server-sdk5-csharp-datatypes-gamelifterror) **必需**：否  | 

## 初始化 SDKOutcome
<a name="integration-server-sdk5-cpp-datatypes-initsdkoutcome"></a>

**注意**  
`InitSDKOutcome`仅在使用`std`标志构建软件开发工具包 时才会返回。如果您使用`nostd`标志进行构建，则会改[GenericOutcome](#integration-server-sdk5-cpp-datatypes-genericoutcome)为返回。


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

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


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

## 枚举
<a name="integration-server-sdk5-cpp-dataypes-enums"></a>

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

**GameLiftErrorType**  
表示错误类型的字符串值。有效值包括：  
+ **错误的请求\$1异常** 
+ **GAMESESSION\$1ID\$1NOT\$1SET – 尚未设置**游戏会话 ID。
+ **内部服务异常** 
+ **LOCAL\$1CONNECTION\$1FAILED** – 与 Amazon GameLift Servers 的本地连接失败。
+ **NETWORK\$1NOT\$1INITIALIZED – 网络尚未初始化**。
+ **SERVICE\$1CALL\$1FAILED — 对服务的调用失败**。 AWS 
+ **网络套接字连接失败** 
+ **禁止网络套接字连接失败** 
+ **WEBSOCKET\$1CONNECT\$1FAILURE\$1INVALID\$1UR** 
+ **WEBSOCKET\$1CONNECT\$1FAILURE\$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** – 游戏会话未设置为接受或拒绝新玩家会话。

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

**Topics**
+ [适用于 Amazon GameLift Servers 的 C\$1\$1 服务器 SDK 5.x – 数据类型](integration-server-sdk5-cpp-datatypes.md)
+ [GetSdkVersion()](#integration-server-sdk5-cpp-getsdkversion)
+ [InitMetrics()](#integration-server-sdk5-cpp-initmetrics)
+ [InitSDK()](#integration-server-sdk5-cpp-initsdk)
+ [InitSDK()](#integration-server-sdk5-cpp-initsdk-anywhere)
+ [ProcessReady()](#integration-server-sdk5-cpp-processready)
+ [ProcessReadyAsync()](#integration-server-sdk5-cpp-processreadyasync)
+ [ProcessEnding()](#integration-server-sdk5-cpp-processending)
+ [ActivateGameSession()](#integration-server-sdk5-cpp-activategamesession)
+ [UpdatePlayerSessionCreationPolicy()](#integration-server-sdk5-cpp-updateplayersessioncreationpolicy)
+ [GetGameSessionId()](#integration-server-sdk5-cpp-getgamesessionid)
+ [GetTerminationTime()](#integration-server-sdk5-cpp-getterm)
+ [AcceptPlayerSession()](#integration-server-sdk5-cpp-acceptplayersession)
+ [RemovePlayerSession()](#integration-server-sdk5-cpp-removeplayersession)
+ [DescribePlayerSessions()](#integration-server-sdk5-cpp-describeplayersessions)
+ [StartMatchBackfill()](#integration-server-sdk5-cpp-startmatchbackfill)
+ [StopMatchBackfill()](#integration-server-sdk5-cpp-stopmatchbackfill)
+ [GetComputeCertificate()](#integration-server-sdk5-cpp-getcomputecertificate)
+ [GetFleetRoleCredentials()](#integration-server-sdk5-cpp-getfleetrolecredentials)
+ [Destroy](#integration-server-sdk5-cpp-ref-destroy)

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

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

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

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

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

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

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

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

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

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

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

```
Aws::GameLift::GenericOutcome InitMetrics();
Aws::GameLift::GenericOutcome InitMetrics(const Aws::GameLift::Server::MetricsParameters &metricsParameters);
```

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

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

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

如果成功，则返回一个表示成功的 [GenericOutcome](integration-server-sdk5-cpp-datatypes.md#integration-server-sdk5-cpp-datatypes-genericoutcome) 对象。如果不成功，将返回错误消息。

### 示例
<a name="integration-server-sdk5-cpp-initmetrics-example"></a>

```
// Initialize with default parameters (uses environment variables if available)
// Defaults: localhost:8125 for StatsD, localhost:8126 for crash reporter
// FlushInterval: 10000ms, MaxPacketSize: 512 bytes
Aws::GameLift::GenericOutcome outcome = Aws::GameLift::Server::InitMetrics();
if (outcome.IsSuccess()) {
    // Metrics system initialized successfully
}

// Initialize with custom parameters
Aws::GameLift::Server::MetricsParameters metricsParams("localhost", 8125, "crash-host", 8126, 5000, 1024);
Aws::GameLift::GenericOutcome customOutcome = Aws::GameLift::Server::InitMetrics(metricsParams);
if (customOutcome.IsSuccess()) {
    // Metrics system initialized with custom parameters
}
```

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

初始化 Amazon GameLift Servers 开发工具包。在与 Amazon GameLift Servers 相关的任何其他初始化步骤之前执行，在启动时调用此方法。此操作从主机环境读取服务器参数，以设置游戏服务器进程和 Amazon GameLift Servers 服务之间的通信。它使用幂等性令牌，因此当调用失败时，您可以放心地重试此调用。

如果游戏服务器生成包将在没有 Amazon GameLift Servers 代理的情况下部署到 Amazon GameLift Servers Anywhere 实例集或容器实例集，请调用 [InitSDK()](#integration-server-sdk5-cpp-initsdk-anywhere) 并指定一组服务器参数。

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

```
Server::InitSDKOutcome Server::initSdkOutcome = InitSDK();
```

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

返回一个[初始化 SDKOutcome](integration-server-sdk5-cpp-datatypes.md#integration-server-sdk5-cpp-datatypes-initsdkoutcome)对象，该对象指示服务器进程是否已准备好调用[ProcessReady()](#integration-server-sdk5-cpp-processready)。

### 示例
<a name="integration-server-sdk5-cpp-initsdk-example"></a>

```
//Call InitSDK to establish a local connection with the Amazon GameLift Servers Agent to enable further communication.
Aws::GameLift::Server::InitSDKOutcome initSdkOutcome = 
  Aws::GameLift::Server::InitSDK();
```

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

初始化 Amazon GameLift Servers 开发工具包。在与 Amazon GameLift Servers 相关的任何其他初始化步骤之前执行，在启动时调用此方法。此操作需要一组服务器参数来设置游戏服务器进程和 Amazon GameLift Servers 服务之间的通信。它使用幂等性令牌，因此当调用失败时，您可以放心地重试此调用。

如果游戏服务器生成包将在有 Amazon GameLift Servers 代理的情况下部署到 Amazon GameLift Servers 托管式 EC2 实例集，或者部署到 Amazon GameLift Servers Anywhere 实例集或容器实例集，请调用 [InitSDK()](#integration-server-sdk5-cpp-initsdk) 而不使用服务器参数。

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

```
Server::InitSDKOutcome Server::initSdkOutcome = InitSDK(serverParameters);
```

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

[ServerParameters](integration-server-sdk5-cpp-datatypes.md#integration-server-sdk5-cpp-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-cpp-initsdk-anywhere-return"></a>

返回一个[初始化 SDKOutcome](integration-server-sdk5-cpp-datatypes.md#integration-server-sdk5-cpp-datatypes-initsdkoutcome)对象，该对象指示服务器进程是否已准备好调用[ProcessReady()](#integration-server-sdk5-cpp-processready)。

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

### 示例
<a name="integration-server-sdk5-cpp-initsdk-anywhere-example"></a>

Amazon GameLift Servers Anywhere 示例

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

//Call InitSDK to establish a local connection with the Amazon GameLift Servers Agent to enable further communication.
Aws::GameLift::Server::InitSDKOutcome initSdkOutcome = Aws::GameLift::Server::InitSDK(serverParameters);
```

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

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

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

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

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

**processParameters**  
[ProcessParameters](integration-server-sdk5-cpp-datatypes.md#integration-server-sdk5-cpp-dataypes-process) 对象，用于传输有关服务器进程的以下信息：  
+ 游戏服务器代码中实现的回调方法的名称，Amazon GameLift Servers 服务调用其与服务器进程通信。
+ 服务器进程正在侦听的端口号。
+ 您希望 Amazon GameLift Servers 捕获和存储的任何游戏会话特定文件的路径。

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

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

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

此示例说明 [ProcessReady()](#integration-server-sdk5-cpp-processready) 调用和委派函数实施。

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

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

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

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

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

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

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

通知 Amazon GameLift Servers 服务，服务器进程已准备好托管游戏会话。在服务器进程准备好托管游戏会话后，应调用此方法。这些参数指定了 Amazon GameLift Servers 在特定环境下调用的回调函数的名称。游戏服务器代码必须执行这些函数。

此调用为异步操作。要进行同步调用，请使用 [ProcessReady()](#integration-server-sdk5-cpp-processready)。有关更多信息，请参阅[初始化服务器进程](gamelift-sdk-server-api.md#gamelift-sdk-server-initialize)。

### 语法
<a name="integration-server-sdk5-cpp-processreadyasync-syntax"></a>

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

### 参数
<a name="integration-server-sdk5-cpp-processreadyasync-parameter"></a>

**processParameters**  
[ProcessParameters](integration-server-sdk5-cpp-datatypes.md#integration-server-sdk5-cpp-dataypes-process) 对象，用于传输有关服务器进程的以下信息：  
+ 游戏服务器代码中实现的回调方法的名称，Amazon GameLift Servers 服务调用其与服务器进程通信。
+ 服务器进程正在侦听的端口号。
+ 您希望 Amazon GameLift Servers 捕获和存储的任何游戏会话特定文件的路径。
是否必需：是

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

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

### 示例
<a name="integration-server-sdk5-cpp-processreadyasync-example"></a>

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

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

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

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

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

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

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

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

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

```
Aws::GameLift::GenericOutcome processEndingOutcome = Aws::GameLift::Server::ProcessEnding();
```

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

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

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

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

```
Aws::GameLift::GenericOutcome processEndingOutcome = Aws::GameLift::Server::ProcessEnding();
Aws::GameLift::Server::Destroy();

// Exit the process with success or failure
if (processEndingOutcome.IsSuccess()) {
  exit(0);
}
else {
  cout << "ProcessEnding() failed. Error: " << processEndingOutcome.GetError().GetErrorMessage();
  exit(-1);
}
```

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

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

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

```
Aws::GameLift::GenericOutcome activateGameSessionOutcome = Aws::GameLift::Server::ActivateGameSession();
```

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

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

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

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

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

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

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

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

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

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

**playerCreationSession政策**  
类型：一个 `PlayerSessionCreationPolicy` [枚举](integration-server-sdk5-cpp-datatypes.md#integration-server-sdk5-cpp-dataypes-enums)值。  
是否必需：是

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

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

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

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

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

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

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

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

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

```
AwsStringOutcome GetGameSessionId()
```

### 参数
<a name="integration-server-sdk5-cpp-getgamesessionid-parameter"></a>

此操作没有参数。

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

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

对于未通过游戏会话激活的空闲进程，调用返回 `Success` = `True` 和 `GameSessionId` = `""`。

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

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

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

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

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

```
AwsDateTimeOutcome GetTerminationTime()
```

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

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

如果流程未收到 ProcessParameters. OnProcessTerminate() 回调，返回错误消息。有关关闭服务器进程的更多信息，请参阅[回应服务器进程关闭通知](gamelift-sdk-server-api.md#gamelift-sdk-server-terminate)。

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

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

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

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

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

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

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

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

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

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

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

此示例处理的连接请求包括验证和拒绝无效的玩家会话。 IDs

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

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

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

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

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

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

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

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

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

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

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

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

检索玩家会话数据，包括设置、会话元数据和玩家数据。使用此方法获取有关以下内容的信息：
+ 单人游戏会话
+ 游戏会话中的所有玩家会话
+ 与单个玩家 ID 关联的所有玩家会话

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

**[StartMatchBackfillRequest](integration-server-sdk5-cpp-datatypes.md#integration-server-sdk5-cpp-dataypes-startmatchbackfillrequest)**  
传达以下信息的 StartMatchBackfillRequest 对象：  
+ 要分配给回填请求的票证 ID。此信息是可选的；如果未提供任何 ID，则 Amazon GameLift Servers 将自动生成一个 ID。
+ 要将请求发送到的对战构建器。需要完整的配置 ARN。该值位于游戏会话的对战构建器数据中。
+ 要回填的游戏会话的 ID。
+ 游戏会话的当前玩家的可用对战数据。

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

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

### 示例
<a name="integration-server-sdk5-cpp-startmatchbackfill-example"></a>

```
// Build a backfill request
std::vector<Player> players;
Aws::GameLift::Server::Model::StartMatchBackfillRequest startBackfillRequest;
startBackfillRequest.SetTicketId("1111aaaa-22bb-33cc-44dd-5555eeee66ff");  // optional, autogenerated if not provided
startBackfillRequest.SetMatchmakingConfigurationArn("arn:aws:gamelift:us-west-2:111122223333:matchmakingconfiguration/MyMatchmakerConfig"); //from the game session matchmaker data
startBackfillRequest.SetGameSessionArn("the game session ARN");        // can use GetGameSessionId()
startBackfillRequest.SetPlayers(players);                                  // from the game session matchmaker data

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

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

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

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

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

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

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

**[StopMatchBackfillRequest](integration-server-sdk5-cpp-datatypes.md#integration-server-sdk5-cpp-dataypes-stopmatchbackfillrequest)**  
标识要取消的配对门票的 StopMatchBackfillRequest 对象：  
+ 要分配给回填请求的票证 ID
+ 回填请求所发送到的对战构建器
+ 与回填请求关联的游戏会话

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

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

### 示例
<a name="integration-server-sdk5-cpp-stopmatchbackfill-example"></a>

```
// Set backfill stop request parameters

Aws::GameLift::Server::Model::StopMatchBackfillRequest stopBackfillRequest;
stopBackfillRequest.SetTicketId("1111aaaa-22bb-33cc-44dd-5555eeee66ff");
stopBackfillRequest.SetGameSessionArn("the game session ARN"); // can use GetGameSessionId()
stopBackfillRequest.SetMatchmakingConfigurationArn("arn:aws:gamelift:us-west-2:111122223333:matchmakingconfiguration/MyMatchmakerConfig");
// from the game session matchmaker data

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

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

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

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

```
GetComputeCertificateOutcome Server::GetComputeCertificate()
```

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

返回 [GetComputeCertificateOutcome](integration-server-sdk5-cpp-datatypes.md#integration-server-sdk5-cpp-datatypes-getcomputecertificateoutcome)。

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

```
Aws::GameLift::GetComputeCertificateOutcome certificate = Aws::GameLift::Server::GetComputeCertificate();
```

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

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

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

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

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

[GetFleetRoleCredentialsRequest](integration-server-sdk5-cpp-datatypes.md#integration-server-sdk5-cpp-dataypes-getfleetrolecredentialsrequest)

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

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

### 示例
<a name="integration-server-sdk5-cpp-getfleetrolecredentials-example"></a>

```
// form the fleet credentials request 
Aws::GameLift::Server::Model::GetFleetRoleCredentialsRequest getFleetRoleCredentialsRequest; 
getFleetRoleCredentialsRequest.SetRoleArn("arn:aws:iam::123456789012:role/service-role/exampleGameLiftAction");

Aws::GameLift::GetFleetRoleCredentialsOutcome credentials = Aws::GameLift::Server::GetFleetRoleCredentials(getFleetRoleCredentialsRequest);
```

此示例说明如何使用可选`RoleSessionName`值为凭证会话分配名称以进行审计。如果您不提供角色会话名称，则使用默认值 *[host-id]* “*[fleet-id]*-”。

```
// form the fleet credentials request 
Aws::GameLift::Server::Model::GetFleetRoleCredentialsRequest getFleetRoleCredentialsRequest; 
getFleetRoleCredentialsRequest.SetRoleArn("arn:aws:iam::123456789012:role/service-role/exampleGameLiftAction");
getFleetRoleCredentialsRequest.SetRoleSessionName("MyFleetRoleSession"); 

Aws::GameLift::GetFleetRoleCredentialsOutcome credentials = Aws::GameLift::Server::GetFleetRoleCredentials(getFleetRoleCredentialsRequest);
```

## Destroy
<a name="integration-server-sdk5-cpp-ref-destroy"></a>

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

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

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

### 参数
<a name="integration-server-sdk5-cpp-ref-destroy-parameter"></a>

没有参数。

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

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

### 示例
<a name="integration-server-sdk5-cpp-ref-destroy-example"></a>

```
Aws::GameLift::GenericOutcome processEndingOutcome = Aws::GameLift::Server::ProcessEnding();
Aws::GameLift::Server::Destroy();

// Exit the process with success or failure
if (processEndingOutcome.IsSuccess()) {
  exit(0);
}
else {
  cout << "ProcessEnding() failed. Error: " << processEndingOutcome.GetError().GetErrorMessage();
  exit(-1);
}
```

# 适用于 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); 
  }
```

# 适用于 Amazon GameLift Servers 的 Go 服务器 SDK – 操作
<a name="integration-server-sdk-go-actions"></a>

使用服务器 SDK 5.x 参考，将要托管的多人游戏与 Amazon GameLift Servers 集成。有关集成过程的指南，请参阅[借助服务器 SDK 将 Amazon GameLift Servers 添加到游戏服务器](gamelift-sdk-server-api.md)。

`GameLiftServerAPI.go`定义了 Go 服务器软件开发工具包 操作。

# 适用于 Amazon GameLift Servers 的 Go 服务器 SDK – 数据类型
<a name="integration-server-sdk-go-datatypes"></a>

使用服务器 SDK 参考，将要托管的多人游戏与 Amazon GameLift Servers 集成。有关集成过程的指南，请参阅[借助服务器 SDK 将 Amazon GameLift Servers 添加到游戏服务器](gamelift-sdk-server-api.md)。

`GameLiftServerAPI.go`定义了 Go 服务器软件开发工具包 操作。

[适用于 Amazon GameLift Servers 的 Go 服务器 SDK – 操作](integration-server-sdk-go-actions.md)

**Topics**
+ [LogParameters](#integration-server-sdk-go-dataypes-log)
+ [MetricsParameters](#integration-server-sdk-go-dataypes-metrics)
+ [ProcessParameters](#integration-server-sdk-go-dataypes-process)
+ [UpdateGameSession](#integration-server-sdk-go-dataypes-updategamesession)
+ [GameSession](#integration-server-sdk-go-dataypes-gamesession)
+ [ServerParameters](#integration-server-sdk-go-dataypes-serverparameters)
+ [StartMatchBackfillRequest](#integration-server-sdk-go-dataypes-startmatchbackfillrequest)
+ [玩家](#integration-server-sdk-go-dataypes-player)
+ [DescribePlayerSessionsRequest](#integration-server-sdk-go-dataypes-playersessions)
+ [StopMatchBackfillRequest](#integration-server-sdk-go-dataypes-stopmatchbackfillrequest)
+ [GetFleetRoleCredentialsRequest](#integration-server-sdk-go-dataypes-getfleetrolecredentialsrequest)

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

一个对象，用于标识游戏会话期间生成的文件，您希望 Amazon GameLift Servers 在游戏会话结束后上传和存储这些文件。游戏服务器在 [ProcessReady()](integration-server-sdk-go-actions.md#integration-server-sdk-go-processready) 调用中，作为 `ProcessParameters` 对象的一部分向 Amazon GameLift Servers 提供 `LogParameters`。


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

## MetricsParameters
<a name="integration-server-sdk-go-dataypes-metrics"></a>

用于初始化指标系统的配置参数通信对象。此配置用于设置 StatsD 报告、崩溃报告和指标处理行为。游戏服务器通过调用 [InitMetrics()](integration-server-sdk-go-actions.md#integration-server-sdk-go-initmetrics) 向 Amazon GameLift Servers 提供 `MetricsParameters`。


|  |  | 
| --- |--- |
|  **属性**  | 描述 | 
| StatsdHost |  用于指标报告的 StatsD 服务器主机（例如“localhost”）。 **类型**：`string` **是否必需**：是  | 
| StatsdPort |  用于指标报告的 StatsD 服务器端口（例如 8125）。 **类型**：`int` **是否必需**：是  | 
| CrashReporterHost |  用于崩溃跟踪和进程监控的崩溃报告器主机。 **类型**：`string` **是否必需**：是  | 
| CrashReporterPort |  用于崩溃跟踪和进程监控的崩溃报告器端口。 **类型**：`int` **是否必需**：是  | 
| FlushIntervalMs |  指标刷新间隔（以毫秒为单位）。控制将指标发送到 StatsD 的频率。 **类型**：`int` **是否必需**：是  | 
| MaxPacketSize |  指标的最大数据包大小（以字节为单位）。限制发送到 StatsD 的 UDP 数据包的大小。 **类型**：`int` **是否必需**：是  | 

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

描述服务器进程与 Amazon GameLift Servers 之间通信的对象。服务器进程通过调用 [ProcessReady()](integration-server-sdk-go-actions.md#integration-server-sdk-go-processready) 向 Amazon GameLift Servers 提供此信息。


|  |  | 
| --- |--- |
|  **属性**  | 描述 | 
| LogParameters | 一个对象，其中包含游戏会话期间生成的文件的目录路径。Amazon GameLift Servers 会复制并存储这些文件，以便将来访问。**类型**：`LogParameters`**必需**：否 | 
| OnHealthCheck | Amazon GameLift Servers 为向服务器进程请求运行状况报告而调用的回调函数。Amazon GameLift Servers 每隔 60 秒调用此函数一次，并等待 60 秒以获取响应。TRUE如果运行状况良好，则服务器进程会返回，FALSE如果不健康，则返回。如果没有返回任何响应，Amazon GameLift Servers 会将服务器进程记录为运行状况不佳。**类型**：`OnHealthCheck func() bool`**必需**：否 | 
| OnProcessTerminate | Amazon GameLift Servers 为强制关闭服务器进程而调用的回调函数。调用此函数之后，Amazon GameLift Servers 会等待 5 分钟，以确保服务器进程关闭并通过 [ProcessEnding()](integration-server-sdk-go-actions.md#integration-server-sdk-go-processending) 调用作出响应，随后才会终止该服务器进程。**类型**：`OnProcessTerminate func()`**是否必需**：是 | 
| OnStartGameSession | Amazon GameLift Servers 为向服务器进程传递更新的游戏会话对象而调用的回调函数。当对战回填请求处理完毕时，Amazon GameLift Servers 会调用此函数以提供更新的对战构建器数据。它将传递一个 [GameSession](#integration-server-sdk-go-dataypes-gamesession) 对象、一个状态更新（updateReason）以及对战回填票证 ID。**类型**：`OnStartGameSession func (model.GameSession )`**是否必需**：是 | 
| OnUpdateGameSession | Amazon GameLift Servers 为向服务器进程传递更新的游戏会话信息而调用的回调函数。当对战回填请求处理完毕时，Amazon GameLift Servers 会调用此函数以提供更新的对战构建器数据。**类型**：`OnUpdateGameSession func (model.UpdateGameSession)`**必需**：否 | 
| Port | 服务器进程用于侦听新玩家连接的端口号。该值必须在部署此游戏服务器构建的任意实例集上所配置的端口范围内。此端口号包含在游戏会话和玩家会话对象中，游戏会话在连接到服务器进程时会使用该端口号。**类型**：`int`**是否必需**：是 | 

## UpdateGameSession
<a name="integration-server-sdk-go-dataypes-updategamesession"></a>

游戏会话对象的更新，包括更新游戏会话的原因，以及相关的回填票证 ID（如果使用回填填填填充游戏会话中的玩家会话）。


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

## GameSession
<a name="integration-server-sdk-go-dataypes-gamesession"></a>

游戏会话的详细信息。


| Properties | **描述** | 
| --- | --- | 
| GameSessionId |  会话的唯一标识符。`arn:aws:gamelift:<region>::gamesession/<fleet ID>/<custom ID string or idempotency token>` 事件具有以下 Amazon 资源名称 (ARN) 格式。 **类型**：`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 |  游戏会话的一组自定义属性，采用键值对格式。这些属性将通过启动新游戏会话的请求传递到游戏服务器进程。 **类型**：`map[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-sdk-go-datatypes.html) 连接到在支持 TLS 的队列上运行的游戏会话时，必须使用 DNS 名称，而不是 IP 地址。 **类型**：`String` **必需**：否  | 

## ServerParameters
<a name="integration-server-sdk-go-dataypes-serverparameters"></a>

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


| Properties | **描述** | 
| --- | --- | 
| WebSocketURL |  当您为 Amazon GameLift Servers Anywhere 计算资源调用 [https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html) 时，`GameLiftServerSdkEndpoint` Amazon GameLift Servers 会返回结果。 **类型**：`string` **是否必需**：是  | 
| ProcessID |  注册到托管游戏的服务器进程的唯一标识符。 **类型**：`string` **是否必需**：是  | 
| HostID |  托管新服务器进程的计算资源的唯一标识符。 `HostID`是在您注册计算机时`ComputeName`使用的。有关更多信息，请参阅 [RegisterCompute](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html)。 **类型**：`string` **是否必需**：是  | 
| FleetID | 计算注册到的实例集的唯一标识符。有关更多信息，请参阅 [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-sdk-go-dataypes-startmatchbackfillrequest"></a>

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


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

## 玩家
<a name="integration-server-sdk-go-dataypes-player"></a>

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


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

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

一个对象，用于指定要检索哪些玩家会话。服务器进程通过向 Amazon GameLift Servers 调用 [DescribePlayerSessions()](integration-server-sdk-go-actions.md#integration-server-sdk-go-describeplayersessions) 来提供此信息。


| Properties | **描述** | 
| --- | --- | 
| GameSessionID |  游戏会话的唯一标识符。使用此参数可请求指定游戏会话的所有玩家会话。 游戏会话 ID 的格式为`arn:aws:gamelift:<region>::gamesession/fleet-<fleet ID>/<ID string>`。`GameSessionID`是自定义 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-sdk-go-datatypes.html) **类型**：`String` **必需**：否  | 
| NextToken |  令牌指示结果的下一个连续页面的开头。要指定结果集的开始，请不要指定值。如果指定玩家会话 ID，将忽略此参数。 **类型**：`String` **必需**：否  | 
| Limit |  要返回的最大结果数量。如果指定玩家会话 ID，将忽略此参数。 **类型**：`int` **必需**：否  | 

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

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


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

## GetFleetRoleCredentialsRequest
<a name="integration-server-sdk-go-dataypes-getfleetrolecredentialsrequest"></a>

将对 AWS 资源的有限访问权限扩展到游戏服务器的角色证书。有关更多信息，请参阅[为 Amazon GameLift Servers 设置 IAM 服务角色](setting-up-role.md)。


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

[适用于 Amazon GameLift Servers 的 Go 服务器 SDK – 数据类型](integration-server-sdk-go-datatypes.md)

**Topics**
+ [适用于 Amazon GameLift Servers 的 Go 服务器 SDK – 数据类型](integration-server-sdk-go-datatypes.md)
+ [GetSdkVersion()](#integration-server-sdk-go-getsdkversion)
+ [InitMetrics()](#integration-server-sdk-go-initmetrics)
+ [InitMetricsFromEnvironment()](#integration-server-sdk-go-initmetricsfromenv)
+ [InitSDK()](#integration-server-sdk-go-initsdk)
+ [ProcessReady()](#integration-server-sdk-go-processready)
+ [ProcessEnding()](#integration-server-sdk-go-processending)
+ [ActivateGameSession()](#integration-server-sdk-go-activategamesession)
+ [UpdatePlayerSessionCreationPolicy()](#integration-server-sdk-go-updateplayersessioncreationpolicy)
+ [GetGameSessionId()](#integration-server-sdk-go-getgamesessionid)
+ [GetTerminationTime()](#integration-server-sdk-go-getterm)
+ [AcceptPlayerSession()](#integration-server-sdk-go-acceptplayersession)
+ [RemovePlayerSession()](#integration-server-sdk-go-removeplayersession)
+ [DescribePlayerSessions()](#integration-server-sdk-go-describeplayersessions)
+ [StartMatchBackfill()](#integration-server-sdk-go-startmatchbackfill)
+ [StopMatchBackfill()](#integration-server-sdk-go-stopmatchbackfill)
+ [GetComputeCertificate()](#integration-server-sdk-go-getcomputecertificate)
+ [GetFleetRoleCredentials()](#integration-server-sdk-go-getfleetrolecredentials)
+ [Destroy](#integration-server-sdk-go-destroy)

## GetSdkVersion()
<a name="integration-server-sdk-go-getsdkversion"></a>

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

### 语法
<a name="integration-server-sdk-go-getsdkversion-syntax"></a>

```
func GetSdkVersion() (string, error)
```

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

如果成功，返回以 对象返回当前软件开发工具包的版本。返回的字符串仅包含版本号 (例如：如果不成功，将返回错误消息。

### 示例
<a name="integration-server-sdk-go-getsdkversion-example"></a>

```
version, err := server.GetSdkVersion()
```

## InitMetrics()
<a name="integration-server-sdk-go-initmetrics"></a>

初始化 Amazon GameLift Servers SDK 的指标收集。此方法设置指标报告，有助于监控服务器性能和运行状况。请在 [InitSDK()](#integration-server-sdk-go-initsdk) 之后、[ProcessReady()](#integration-server-sdk-go-processready) 之前调用此方法。

### 语法
<a name="integration-server-sdk-go-initmetrics-syntax"></a>

```
func InitMetrics() error
func InitMetrics(metricsParameters MetricsParameters) error
```

### 参数
<a name="integration-server-sdk-go-initmetrics-parameter"></a>

MetricsParameters （可选）  
用于配置指标收集的 `MetricsParameters` 对象。如果未提供，则使用默认指标配置。该 MetricsParameters结构包含以下字段：  
+ `StatsdHost` – StatsD 服务器的主机名或 IP 地址。
+ `StatsdPort` – StatsD 服务器进程的端口号。
+ `CrashReporterHost` – 崩溃报告服务的主机名或 IP 地址。
+ `CrashReporterPort` – 崩溃报告服务的端口号。
+ `FlushIntervalMs` – 刷新指标数据的时间间隔（以毫秒为单位）。
+ `MaxPacketSize` – 指标数据包的最大大小（以字节为单位）。
有关 MetricsParameters 结构的更多信息，请参阅适用于 [C\$1 数据类型的服务器 SDK 5.x](https://docs.aws.amazon.com/gameliftservers/latest/developerguide/integration-server-sdk5-csharp-datatypes.html)。

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

如果成功，则返回 `nil` 错误，表示指标收集已成功初始化。

### 示例
<a name="integration-server-sdk-go-initmetrics-example"></a>

使用默认配置初始化指标：

```
err := server.InitMetrics()
```

使用自定义配置初始化指标：

```
metricsParams := MetricsParameters{
    StatsdHost:        "localhost",
    StatsdPort:        8125,
    CrashReporterHost: "localhost",
    CrashReporterPort: 9125,
    FlushIntervalMs:   5000,
    MaxPacketSize:     1024,
}

err := server.InitMetrics(metricsParams)
```

## InitMetricsFromEnvironment()
<a name="integration-server-sdk-go-initmetricsfromenv"></a>

使用环境变量中的配置初始化 Amazon GameLift Servers SDK 的指标收集。此方法使用从运行时环境中派生的默认设置来设置指标报告。

请在 [InitSDK()](#integration-server-sdk-go-initsdk) 之后、[ProcessReady()](#integration-server-sdk-go-processready) 之前调用此方法。

### 语法
<a name="integration-server-sdk-go-initmetricsfromenv-syntax"></a>

```
func InitMetricsFromEnvironment() error
```

### 返回值
<a name="integration-server-sdk-go-initmetricsfromenv-return"></a>

如果成功，则返回 `nil` 错误，表示已使用环境配置成功初始化指标收集。

### 示例
<a name="integration-server-sdk-go-initmetricsfromenv-example"></a>

```
err := server.InitMetricsFromEnvironment()
```

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

初始化 Amazon GameLift Servers 开发工具包。在与 Amazon GameLift Servers 相关的任何其他初始化发生之前，在启动时调用此方法。此方法在服务器和 Amazon GameLift Servers 服务之间设置通信。

### 语法
<a name="integration-server-sdk-go-initsdk-syntax"></a>

```
func InitSDK(params ServerParameters) error 
```

### 参数
<a name="integration-server-sdk-go-initsdk-parameter"></a>

[ServerParameters](integration-server-sdk-go-datatypes.md#integration-server-sdk-go-dataypes-serverparameters)  
要在 Amazon GameLift Servers Anywhere 实例集上初始化游戏服务器，请使用以下信息构造 `ServerParameters` 对象：  
+  WebSocket 用于连接到游戏服务器的 URL。
+ 用于托管游戏服务器的进程的 ID。
+ 托管游戏服务器进程的计算的 ID。
+ 包含您的 Amazon GameLift Servers Anywhere 计算的 Amazon GameLift Servers 实例集的 ID。
+ Amazon GameLift Servers 操作生成的授权令牌。
要在 Amazon GameLift Servers 托管式 EC2 实例集上初始化游戏服务器，请构造一个不带参数的 `ServerParameters` 对象。通过此次调用，Amazon GameLift Servers 代理为您设置计算环境并自动连接到 Amazon GameLift Servers 服务。

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

如果成功，则返回`nil`错误，表示服务器进程已准备好调用[ProcessReady()](#integration-server-sdk-go-processready)。

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

### 示例
<a name="integration-server-sdk-go-initsdk-example"></a>

Amazon GameLift Servers Anywhere 示例

```
//Define the server parameters
serverParameters := ServerParameters {
  WebSocketURL: "wss://us-west-1.api.amazongamelift.com",
  ProcessID: "PID1234",
  HostID: "HardwareAnywhere",
  FleetID: "aarn:aws:gamelift:us-west-1:111122223333:fleet/fleet-9999ffff-88ee-77dd-66cc-5555bbbb44aa",
  AuthToken: "1111aaaa-22bb-33cc-44dd-5555eeee66ff"
}

//Call InitSDK to establish a local connection with the Amazon GameLift Servers Agent to enable further communication.
err := server.InitSDK(serverParameters)
```

Amazon GameLift Servers 托管式 EC2 示例

```
//Define the server parameters
serverParameters := ServerParameters {}

//Call InitSDK to establish a local connection with the Amazon GameLift Servers Agent to enable further communication.
err := server.InitSDK(serverParameters)
```

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

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

### 语法
<a name="integration-server-sdk-go-processready-syntax"></a>

```
func ProcessReady(param ProcessParameters) error
```

### 参数
<a name="integration-server-sdk-go-processready-parameter"></a>

**ProcessParameters**  
[ProcessParameters](integration-server-sdk-go-datatypes.md#integration-server-sdk-go-dataypes-process) 对象，用于传输有关服务器进程的以下信息：  
+ 游戏服务器代码中实现的回调方法的名称，Amazon GameLift Servers 服务调用其与服务器进程通信。
+ 服务器进程正在侦听的端口号。
+ [LogParameters](integration-server-sdk-go-datatypes.md#integration-server-sdk-go-dataypes-log) 数据类型包含您希望 Amazon GameLift Servers 服务器捕获并存储的任何游戏会话特定文件的路径。

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

如果方法失败，则返回带有错误消息的错误。如果刷新成功，则返回 `nil`。

### 示例
<a name="integration-server-sdk-go-processready-example"></a>

此示例说明 [ProcessReady()](#integration-server-sdk-go-processready) 调用和委派函数实施。

```
// Define the process parameters
processParams := ProcessParameters {
  OnStartGameSession: gameProcess.OnStartGameSession,
  OnUpdateGameSession: gameProcess.OnGameSessionUpdate,
  OnProcessTerminate: gameProcess.OnProcessTerminate,
  OnHealthCheck: gameProcess.OnHealthCheck,
  Port: port,
  LogParameters: LogParameters {    // logging and error example
    []string {"C:\\game\\logs", "C:\\game\\error"}
  }
}

err := server.ProcessReady(processParams)
```

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

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

### 语法
<a name="integration-server-sdk-go-processending-syntax"></a>

```
func ProcessEnding() error
```

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

返回 0 错误代码或定义的错误代码。

### 示例
<a name="integration-server-sdk-go-processending-example"></a>

```
// operations to end game sessions and the server process
defer func() {
  err := server.ProcessEnding()
  server.Destroy()
  if err != nil {
    fmt.Println("ProcessEnding() failed. Error: ", err)
    os.Exit(-1)
  } else {
    os.Exit(0)
  }
}
```

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

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

### 语法
<a name="integration-server-sdk-go-activategamesession-syntax"></a>

```
func ActivateGameSession() error
```

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

如果方法失败，则返回带有错误消息的错误。

### 示例
<a name="integration-server-sdk-go-activategamesession-example"></a>

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

```
func OnStartGameSession(GameSession gameSession) {
  // game-specific tasks when starting a new game session, such as loading map   
  // Activate when ready to receive players   
  err := server.ActivateGameSession();
}
```

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

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

### 语法
<a name="integration-server-sdk-go-updateplayersessioncreationpolicy-syntax"></a>

```
func UpdatePlayerSessionCreationPolicy(policy model.PlayerSessionCreationPolicy) error
```

### 参数
<a name="integration-server-sdk-go-updateplayersessioncreationpolicy-parameter"></a>

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

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

如果发生故障，则返回带有错误消息的错误。

### 示例
<a name="integration-server-sdk-go-updateplayersessioncreationpolicy-example"></a>

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

```
err := server.UpdatePlayerSessionCreationPolicy(model.AcceptAll)
```

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

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

### 语法
<a name="integration-server-sdk-go-getgamesessionid-syntax"></a>

```
func GetGameSessionID() (string, error)
```

### 参数
<a name="integration-server-sdk-go-getgamesessionid-parameter"></a>

此操作没有参数。

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

如果成功，以 对象返回游戏会话 ID。对于尚未通过游戏会话激活的空闲进程，该调用会返回一个空字符串和`nil`错误。

### 示例
<a name="integration-server-sdk-go-getgamesessionid-example"></a>

```
gameSessionID, err := server.GetGameSessionID()
```

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

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

### 语法
<a name="integration-server-sdk-go-getterm-syntax"></a>

```
func GetTerminationTime() (int64, error)
```

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

如果成功，则返回服务器进程计划关闭和`nil`错误终止的时间戳（以纪元秒为单位）。该值是终止时间，以经过的刻度表示。`0001 00:00:00`例如，日期时间值等`2020-09-13 12:26:40 -000Z`于`637355968000000000`刻度。如果没有可用的终止时间，将返回一条错误消息。

### 示例
<a name="integration-server-sdk-go-getterm-example"></a>

```
terminationTime, err := server.GetTerminationTime()
```

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

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

### 语法
<a name="integration-server-sdk-go-acceptplayersession-syntax"></a>

```
func AcceptPlayerSession(playerSessionID string) error
```

### 参数
<a name="integration-server-sdk-go-acceptplayersession-parameter"></a>

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

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

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

### 示例
<a name="integration-server-sdk-go-acceptplayersession-example"></a>

此示例处理的连接请求包括验证和拒绝无效的玩家会话。 IDs

```
func ReceiveConnectingPlayerSessionID(conn Connection, playerSessionID string) {
    err := server.AcceptPlayerSession(playerSessionID)
    if err != nil {
        connection.Accept()
    } else {
        connection.Reject(err.Error())
    }
}
```

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

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

### 语法
<a name="integration-server-sdk-go-removeplayersession-syntax"></a>

```
func RemovePlayerSession(playerSessionID string) error
```

### 参数
<a name="integration-server-sdk-go-removeplayersession-parameter"></a>

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

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

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

### 示例
<a name="integration-server-sdk-go-removeplayersession-example"></a>

```
err := server.RemovePlayerSession(playerSessionID)
```

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

检索玩家会话数据，包括设置、会话元数据和玩家数据。使用此方法获取有关以下内容的信息：
+ 单人游戏会话
+ 游戏会话中的所有玩家会话
+ 与单个玩家 ID 关联的所有玩家会话

### 语法
<a name="integration-server-sdk-go-describeplayersessions-syntax"></a>

```
func DescribePlayerSessions(req request.DescribePlayerSessionsRequest) (result.DescribePlayerSessionsResult, error) {
	return srv.describePlayerSessions(&req)
}
```

### 参数
<a name="integration-server-sdk-go-describeplayersessions-parameter"></a>

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

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

如果成功，将返回一个 `DescribePlayerSessionsResult` 对象，包含一组与请求参数相匹配的玩家会话对象。

### 示例
<a name="integration-server-sdk-go-describeplayersessions-example"></a>

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

```
// create request
describePlayerSessionsRequest := request.NewDescribePlayerSessions() 
describePlayerSessionsRequest.GameSessionID, _ = server.GetGameSessionID() // get ID for the current game session
describePlayerSessionsRequest.Limit = 10                                 // return the first 10 player sessions
describePlayerSessionsRequest.PlayerSessionStatusFilter = "ACTIVE"         // Get all player sessions actively connected to the game session

describePlayerSessionsResult, err := server.DescribePlayerSessions(describePlayerSessionsRequest)
```

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

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

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

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

### 语法
<a name="integration-server-sdk-go-startmatchbackfill-syntax"></a>

```
func StartMatchBackfill(req request.StartMatchBackfillRequest) (result.StartMatchBackfillResult, error)
```

### 参数
<a name="integration-server-sdk-go-startmatchbackfill-parameter"></a>

**[StartMatchBackfillRequest](integration-server-sdk-go-datatypes.md#integration-server-sdk-go-dataypes-startmatchbackfillrequest)**  
 StartMatchBackfillRequest 对象传达以下信息：  
+ 要分配给回填请求的票证 ID。此信息是可选的；如果未提供任何 ID，则 Amazon GameLift Servers 将自动生成一个 ID。
+ 要将请求发送到的对战构建器。需要完整的配置 ARN。该值位于游戏会话的对战构建器数据中。
+ 要回填的游戏会话的 ID。
+ 游戏会话的当前玩家的可用对战数据。

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

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

### 示例
<a name="integration-server-sdk-go-startmatchbackfill-example"></a>

```
// form the request
startBackfillRequest := request.NewStartMatchBackfill()
startBackfillRequest.RequestID = "1111aaaa-22bb-33cc-44dd-5555eeee66ff"          // optional
startBackfillRequest.MatchmakingConfigurationArn = "arn:aws:gamelift:us-west-2:111122223333:matchmakingconfiguration/MyMatchmakerConfig"
var matchMaker model.MatchmakerData
if err := matchMaker.UnmarshalJSON([]byte(gameSession.MatchmakerData)); err != nil {    
    return
}
startBackfillRequest.Players = matchMaker.Players
res, err := server.StartMatchBackfill(startBackfillRequest)

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

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

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

### 语法
<a name="integration-server-sdk-go-stopmatchbackfill-syntax"></a>

```
func StopMatchBackfill(req request.StopMatchBackfillRequest) error
```

### 参数
<a name="integration-server-sdk-go-stopmatchbackfill-parameter"></a>

**[StopMatchBackfillRequest](integration-server-sdk-go-datatypes.md#integration-server-sdk-go-dataypes-stopmatchbackfillrequest)**  
标识要取消的配对门票的 StopMatchBackfillRequest 对象：  
+ 要分配给回填请求的票证 ID
+ 回填请求所发送到的对战构建器
+ 与回填请求关联的游戏会话

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

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

### 示例
<a name="integration-server-sdk-go-stopmatchbackfill-example"></a>

```
stopBackfillRequest := request.NewStopMatchBackfill()  // Use this function to create request
stopBackfillRequest.TicketID = "1111aaaa-22bb-33cc-44dd-5555eeee66ff"
stopBackfillRequest.MatchmakingConfigurationArn = "arn:aws:gamelift:us-west-2:111122223333:matchmakingconfiguration/MyMatchmakerConfig"
                
//error
err := server.StopMatchBackfill(stopBackfillRequest)
```

## GetComputeCertificate()
<a name="integration-server-sdk-go-getcomputecertificate"></a>

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

### 语法
<a name="integration-server-sdk-go-getcomputecertificate-syntax"></a>

```
func GetComputeCertificate() (result.GetComputeCertificateResult, error)
```

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

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

### 示例
<a name="integration-server-sdk-go-getcomputecertificate-example"></a>

```
tlsCertificate, err := server.GetFleetRoleCredentials(getFleetRoleCredentialsRequest)
```

## GetFleetRoleCredentials()
<a name="integration-server-sdk-go-getfleetrolecredentials"></a>

检索您创建的用于将权限扩展 AWS 服务 到Amazon GameLift Servers其他角色的服务角色证书。这些凭据允许您的游戏服务器使用您的 AWS 资源。有关更多信息，请参阅 [为 Amazon GameLift Servers 设置 IAM 服务角色](setting-up-role.md)。

### 语法
<a name="integration-server-sdk-go-getfleetrolecredentials-syntax"></a>

```
func GetFleetRoleCredentials(
  req request.GetFleetRoleCredentialsRequest,
) (result.GetFleetRoleCredentialsResult, error) {
  return srv.getFleetRoleCredentials(&req)
}
```

### 参数
<a name="integration-server-sdk-go-getfleetrolecredentials-parameters"></a>

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

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

返回包含以下内容的`GetFleetRoleCredentialsResult`对象：
+ AssumedRoleUserArn -服务角色所属用户的亚马逊资源名称 (ARN)。
+ AssumedRoleId -服务角色所属用户的 ID。
+ AccessKeyId -用于对您的 AWS 资源进行身份验证和提供访问权限的访问密钥 ID。
+ SecretAccessKey -用于身份验证的私有访问密钥 ID。
+ SessionToken -用于识别与您的 AWS 资源交互的当前活动会话的令牌。
+ 过期-您的会话凭证到期之前的时间。

### 示例
<a name="integration-server-sdk-go-getfleetrolecredentials-example"></a>

```
// form the customer credentials request
getFleetRoleCredentialsRequest := request.NewGetFleetRoleCredentials()
getFleetRoleCredentialsRequest.RoleArn = "arn:aws:iam::123456789012:role/service-role/exampleGameLiftAction"

credentials, err := server.GetFleetRoleCredentials(getFleetRoleCredentialsRequest)
```

## Destroy
<a name="integration-server-sdk-go-destroy"></a>

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

### 语法
<a name="integration-server-sdk-go-destroy-syntax"></a>

```
func Destroy() error {
	return srv.destroy()
}
```

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

如果方法失败，则返回带有错误消息的错误。

### 示例
<a name="integration-server-sdk-go-destroy-example"></a>

```
// operations to end game sessions and the server process
defer func() {
  err := server.ProcessEnding()
  server.Destroy()
  if err != nil {
    fmt.Println("ProcessEnding() failed. Error: ", err)
    os.Exit(-1)
  } else {
    os.Exit(0)
  }
}
```

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

使用 Amazon GameLift Servers Unreal 服务器 SDK 5.x 参考，帮助您为多人游戏准备好与 Amazon GameLift Servers 配合使用。有关集成过程的详细信息，请参阅[借助服务器 SDK 将 Amazon GameLift Servers 添加到游戏服务器](gamelift-sdk-server-api.md)。如果您使用的是适用于 Unreal 的 Amazon GameLift Servers 插件，还可以参阅[Amazon GameLift Servers虚幻引擎插件](unreal-plugin.md)。

**注意**  
本主题介绍在为 Unreal Engine 构建时可以使用的 Amazon GameLift Servers C\$1\$1 API。具体而言，本文档适用于使用该`-DBUILD_FOR_UNREAL=1`选项编译的代码。

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

使用 Amazon GameLift Servers Unreal 服务器 SDK 5.x 参考，帮助您为多人游戏准备好与 Amazon GameLift Servers 配合使用。有关集成过程的详细信息，请参阅[借助服务器 SDK 将 Amazon GameLift Servers 添加到游戏服务器](gamelift-sdk-server-api.md)。如果您使用的是适用于 Unreal 的 Amazon GameLift Servers 插件，还可以参阅[Amazon GameLift Servers虚幻引擎插件](unreal-plugin.md)。

**注意**  
本主题介绍在为 Unreal Engine 构建时可以使用的 Amazon GameLift Servers C\$1\$1 API。具体而言，本文档适用于使用该`-DBUILD_FOR_UNREAL=1`选项编译的代码。

[适用于 Amazon GameLift Servers 的 C\$1\$1（Unreal）服务器 SDK 5.x – 操作](integration-server-sdk5-unreal-actions.md)

**Topics**
+ [FProcess参数](#integration-server-sdk5-unreal-dataypes-process)
+ [UpdateGameSession](#integration-server-sdk5-unreal-dataypes-updategamesession)
+ [GameSession](#integration-server-sdk5-unreal-dataypes-gamesession)
+ [FServer参数](#integration-server-sdk5-unreal-dataypes-serverparameters)
+ [FStartMatchBackfillRequest](#integration-server-sdk5-unreal-dataypes-startmatchbackfillrequest)
+ [FPlayer](#integration-server-sdk5-unreal-dataypes-player)
+ [FGameLiftDescribePlayerSessionsRequest](#integration-server-sdk5-unreal-dataypes-playersessions)
+ [FStopMatchBackfillRequest](#integration-server-sdk5-unreal-dataypes-stopmatchbackfillrequest)
+ [FAttribute价值](#integration-server-sdk5-unreal-dataypes-attributevalue)
+ [FGameLiftGetFleetRoleCredentialsRequest](#integration-server-sdk5-unreal-dataypes-getfleetrolecredentialsrequest)
+ [FGameLiftLongOutcome](#integration-server-sdk5-unreal-dataypes-awslongoutcome)
+ [FGameLiftStringOutcome](#integration-server-sdk5-unreal-dataypes-awsstringoutcome)
+ [FGameLiftDescribePlayerSessionsOutcome](#integration-server-sdk5-unreal-dataypes-describeplayersessionsoutcome)
+ [FGameLiftDescribePlayerSessionsResult](#integration-server-sdk5-unreal-dataypes-describeplayersessionresult)
+ [FGeneric结果](#integration-server-sdk5-unreal-dataypes-genericoutcome)
+ [FGameLiftPlayerSession](#integration-server-sdk5-unreal-dataypes-playersession)
+ [FGameLiftGetComputeCertificateOutcome](#integration-server-sdk5-unreal-dataypes-getcomputecertificateoutcome)
+ [FGameLiftGetComputeCertificateResult](#integration-server-sdk5-unreal-dataypes-getcomputecertificateresult)
+ [FGameLiftGetFleetRoleCredentialsOutcome](#integration-server-sdk5-unreal-dataypes-getfleetrolecredentialsoutcome)
+ [FGetFleetRoleCredentialsResult](#integration-server-sdk5-unreal-dataypes-getfleetrolecredentialsresult)
+ [FGameLiftError](#integration-server-sdk5-unreal-dataypes-gamelifterror)
+ [枚举](#integration-server-sdk5-unreal-dataypes-enums)

## FProcess参数
<a name="integration-server-sdk5-unreal-dataypes-process"></a>

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


|  |  | 
| --- |--- |
|  **属性**  | 描述 | 
| LogParameters | 一个对象，其中包含游戏会话期间生成的文件的目录路径。Amazon GameLift Servers 会复制并存储这些文件，以便将来访问。**类型**：`TArray<FString>`**必需**：否 | 
| OnHealthCheck | Amazon GameLift Servers 为向服务器进程请求运行状况报告而调用的回调函数。Amazon GameLift Servers 每隔 60 秒调用此函数一次，并等待 60 秒以获取响应。TRUE如果运行状况良好，则服务器进程会返回，FALSE如果不健康，则返回。如果没有返回任何响应，Amazon GameLift Servers 会将服务器进程记录为运行状况不佳。此属性是一个委托函数，定义为`DECLARE_DELEGATE_RetVal(bool, FOnHealthCheck)`;  **类型**：`FOnHealthCheck`**必需**：否 | 
| OnProcessTerminate | Amazon GameLift Servers 为强制关闭服务器进程而调用的回调函数。调用此函数之后，Amazon GameLift Servers 会等待 5 分钟，以确保服务器进程关闭并通过 [ProcessEnding()](integration-server-sdk5-unreal-actions.md#integration-server-sdk5-unreal-processending) 调用作出响应，随后才会终止该服务器进程。**类型**：`FSimpleDelegate`**是否必需**：是 | 
| OnStartGameSession | 调Amazon GameLift Servers用以激活新游戏会话的回调函数。 Amazon GameLift Servers应客户端请求调用此函数[CreateGameSession](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_CreateGameSession.html)。回调函数将传递一个 [GameSession](#integration-server-sdk5-unreal-dataypes-gamesession) 对象。此属性是一个委托函数，定义为 `DECLARE_DELEGATE_OneParam(FOnStartGameSession, Aws::GameLift::Server::Model::GameSession);`  **类型**：`FOnStartGameSession`**是否必需**：是 | 
| OnUpdateGameSession | Amazon GameLift Servers 为向服务器进程传递更新的游戏会话对象而调用的回调函数。当对战回填请求处理完毕时，Amazon GameLift Servers 会调用此函数以提供更新的对战构建器数据。它将传递一个 [GameSession](#integration-server-sdk5-unreal-dataypes-gamesession) 对象、一个状态更新（updateReason）以及对战回填票证 ID。此属性是一个委托函数，定义为 `DECLARE_DELEGATE_OneParam(FOnUpdateGameSession, Aws::GameLift::Server::Model::UpdateGameSession);` **类型**：`FOnUpdateGameSession`**必需**：否 | 
| 端口： | 服务器进程用于侦听新玩家连接的端口号。该值必须在部署此游戏服务器构建的任意实例集上所配置的端口范围内。此端口号包含在游戏会话和玩家会话对象中，游戏会话在连接到服务器进程时会使用该端口号。**类型**：`int`**是否必需**：是 | 

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

此数据类型更新为游戏会话对象，其中包括更新游戏会话的原因以及相关的回填票证 ID（如果使用回填来填充游戏会话中的玩家会话）。


| Properties | **描述** | 
| --- | --- | 
| GameSession | 一个 [GameSession](#integration-server-sdk5-unreal-dataypes-gamesession) 对象。该GameSession对象包含描述游戏会话的属性。**类型**：`Aws::GameLift::Server::GameSession`**必需**：否 | 
| UpdateReason | 更新游戏会话的原因。**类型**：`enum class UpdateReason` [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/gameliftservers/latest/developerguide/integration-server-sdk5-unreal-datatypes.html) **必需**：否   | 
| BackfillTicketId | 尝试更新游戏会话的回填票证的 ID。**类型**：`char[]`**必需**：否 | 

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

此数据类型提供游戏会话的详细信息。


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

## FServer参数
<a name="integration-server-sdk5-unreal-dataypes-serverparameters"></a>

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


| Properties | **描述** | 
| --- | --- | 
| webSocketUrl |  当您为 Amazon GameLift Servers Anywhere 计算资源调用 [https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html) 时，`GameLiftServerSdkEndpoint` Amazon GameLift Servers 会返回结果。 **类型**：`char[]` **是否必需**：是   | 
| ProcessID |  注册到托管游戏的服务器进程的唯一标识符。 **类型**：`char[]` **是否必需**：是  | 
| hostId | HostID是在您注册计算机时ComputeName使用的。有关更多信息，请参阅[RegisterCompute](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html)。**类型**：`char[]`**是否必需**：是 | 
| FleetId | 计算注册到的实例集的唯一标识符。有关更多信息，请参阅[RegisterCompute](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_RegisterCompute.html)。**类型**：`char[]`**是否必需**：是 | 
| AuthToken | 由 Amazon GameLift Servers 生成的身份验证令牌，用于向 Amazon GameLift Servers 对您的服务器进行身份验证。有关更多信息，请参阅[GetComputeAuthToken](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_GetComputeAuthToken.html)。**类型**：`char[]`**是否必需**：是 | 

## FStartMatchBackfillRequest
<a name="integration-server-sdk5-unreal-dataypes-startmatchbackfillrequest"></a>

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


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

## FPlayer
<a name="integration-server-sdk5-unreal-dataypes-player"></a>

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


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

## FGameLiftDescribePlayerSessionsRequest
<a name="integration-server-sdk5-unreal-dataypes-playersessions"></a>

一个对象，用于指定要检索哪些玩家会话。服务器进程通过向 Amazon GameLift Servers 调用 [DescribePlayerSessions()](integration-server-sdk5-unreal-actions.md#integration-server-sdk5-unreal-describeplayersessions) 来提供此信息。


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

## FStopMatchBackfillRequest
<a name="integration-server-sdk5-unreal-dataypes-stopmatchbackfillrequest"></a>

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


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

## FAttribute价值
<a name="integration-server-sdk5-unreal-dataypes-attributevalue"></a>

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


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

## FGameLiftGetFleetRoleCredentialsRequest
<a name="integration-server-sdk5-unreal-dataypes-getfleetrolecredentialsrequest"></a>

此数据类型提供角色凭证，可将对 AWS 资源的有限访问权限扩展到游戏服务器。有关更多信息，请参阅[为 Amazon GameLift Servers 设置 IAM 服务角色](setting-up-role.md)。


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

## FGameLiftLongOutcome
<a name="integration-server-sdk5-unreal-dataypes-awslongoutcome"></a>

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


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：`long` **必需**：否  | 
| ResultWithOwnership |   操作的结果，转换为右值，以便调用代码可以拥有该对象的所有权。 **类型**：`long&&` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[FGameLiftError](#integration-server-sdk5-unreal-dataypes-gamelifterror) **必需**：否  | 

## FGameLiftStringOutcome
<a name="integration-server-sdk5-unreal-dataypes-awsstringoutcome"></a>

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


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：`FString` **必需**：否  | 
| ResultWithOwnership |   操作的结果，转换为右值，以便调用代码可以拥有该对象的所有权。 **类型**：`FString&&` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[FGameLiftError](#integration-server-sdk5-unreal-dataypes-gamelifterror) **必需**：否  | 

## FGameLiftDescribePlayerSessionsOutcome
<a name="integration-server-sdk5-unreal-dataypes-describeplayersessionsoutcome"></a>

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


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：[FGameLiftDescribePlayerSessionsResult](#integration-server-sdk5-unreal-dataypes-describeplayersessionresult) **必需**：否   | 
| ResultWithOwnership |   操作的结果，转换为右值，以便调用代码可以拥有该对象的所有权。 **类型**：`FGameLiftDescribePlayerSessionsResult&&` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[FGameLiftError](#integration-server-sdk5-unreal-dataypes-gamelifterror) **必需**：否  | 

## FGameLiftDescribePlayerSessionsResult
<a name="integration-server-sdk5-unreal-dataypes-describeplayersessionresult"></a>


| Properties | 说明 | 
| --- | --- | 
| PlayerSessions |   **类型**：`TArray<FGameLiftPlayerSession>` **是否必需**：是  | 
| NextToken |  令牌指示结果的下一个连续页面的开头。要指定结果集的开始，请不要指定值。如果指定玩家会话 ID，将忽略此参数。 **类型**：`FString` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[FGameLiftError](#integration-server-sdk5-unreal-dataypes-gamelifterror) **必需**：否  | 

## FGeneric结果
<a name="integration-server-sdk5-unreal-dataypes-genericoutcome"></a>

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


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

## FGameLiftPlayerSession
<a name="integration-server-sdk5-unreal-dataypes-playersession"></a>


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

## FGameLiftGetComputeCertificateOutcome
<a name="integration-server-sdk5-unreal-dataypes-getcomputecertificateoutcome"></a>

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


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：[FGameLiftGetComputeCertificateResult](#integration-server-sdk5-unreal-dataypes-getcomputecertificateresult) **必需**：否   | 
| ResultWithOwnership |   操作的结果，转换为右值，以便调用代码可以拥有该对象的所有权。 **类型**：`FGameLiftGetComputeCertificateResult&&` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[FGameLiftError](#integration-server-sdk5-unreal-dataypes-gamelifterror) **必需**：否  | 

## FGameLiftGetComputeCertificateResult
<a name="integration-server-sdk5-unreal-dataypes-getcomputecertificateresult"></a>

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


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

## FGameLiftGetFleetRoleCredentialsOutcome
<a name="integration-server-sdk5-unreal-dataypes-getfleetrolecredentialsoutcome"></a>

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


| Properties | 说明 | 
| --- | --- | 
| 结果 |  操作的结果。 **类型**：[FGetFleetRoleCredentialsResult](#integration-server-sdk5-unreal-dataypes-getfleetrolecredentialsresult) **必需**：否   | 
| ResultWithOwnership |   操作的结果，转换为右值，以便调用代码可以拥有该对象的所有权。 **类型**：`FGameLiftGetFleetRoleCredentialsResult&&` **必需**：否  | 
| 成功 |  操作是否成功。 **类型**：`bool` **是否必需**：是  | 
| 错误 |  操作失败时发生的错误。 **类型**：[FGameLiftError](#integration-server-sdk5-unreal-dataypes-gamelifterror) **必需**：否  | 

## FGetFleetRoleCredentialsResult
<a name="integration-server-sdk5-unreal-dataypes-getfleetrolecredentialsresult"></a>


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

## FGameLiftError
<a name="integration-server-sdk5-unreal-dataypes-gamelifterror"></a>


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

## 枚举
<a name="integration-server-sdk5-unreal-dataypes-enums"></a>

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

**FAttribute类型**  
+ **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 – 请求验证失败**。

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

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

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

**Topics**
+ [适用于 Amazon GameLift Servers 的 C\$1\$1（Unreal）服务器 SDK 5.x – 数据类型](integration-server-sdk5-unreal-datatypes.md)
+ [GetSdkVersion()](#integration-server-sdk5-unreal-getsdkversion)
+ [InitSDK()](#integration-server-sdk5-unreal-initsdk)
+ [InitSDK()](#integration-server-sdk5-unreal-initsdk-anywhere)
+ [ProcessReady()](#integration-server-sdk5-unreal-processready)
+ [ProcessEnding()](#integration-server-sdk5-unreal-processending)
+ [ActivateGameSession()](#integration-server-sdk5-unreal-activategamesession)
+ [UpdatePlayerSessionCreationPolicy()](#integration-server-sdk5-unreal-updateplayersessioncreationpolicy)
+ [GetGameSessionId()](#integration-server-sdk5-unreal-getgamesessionid)
+ [GetTerminationTime()](#integration-server-sdk5-unreal-getterm)
+ [AcceptPlayerSession()](#integration-server-sdk5-unreal-acceptplayersession)
+ [RemovePlayerSession()](#integration-server-sdk5-unreal-removeplayersession)
+ [DescribePlayerSessions()](#integration-server-sdk5-unreal-describeplayersessions)
+ [StartMatchBackfill()](#integration-server-sdk5-unreal-startmatchbackfill)
+ [StopMatchBackfill()](#integration-server-sdk5-unreal-stopmatchbackfill)
+ [GetComputeCertificate()](#integration-server-sdk5-unreal-getcomputecertificate)
+ [GetFleetRoleCredentials()](#integration-server-sdk5-unreal-getfleetrolecredentials)
+ [Destroy](#integration-server-sdk5-unreal-ref-destroy)

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

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

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

```
FGameLiftStringOutcome GetSdkVersion();
```

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

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

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

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

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

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

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

```
FGameLiftGenericOutcome InitSDK()
```

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

如果成功，返回 InitSdkOutcome 对象，指示服务器进程已准备好调用 。

### 示例
<a name="integration-server-sdk5-unreal-initsdk-example"></a>

```
//Call InitSDK to establish a local connection with the Amazon GameLift Servers Agent to enable further communication.
FGameLiftGenericOutcome initSdkOutcome = GameLiftSdkModule->InitSDK();
```

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

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

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

```
FGameLiftGenericOutcome InitSDK(serverParameters)
```

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

[FServer参数](integration-server-sdk5-unreal-datatypes.md#integration-server-sdk5-unreal-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-unreal-initsdk-anywhere-return"></a>

如果成功，返回 InitSdkOutcome 对象，指示服务器进程已准备好调用 。

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

### 示例
<a name="integration-server-sdk5-unreal-initsdk-anywhere-example"></a>

```
//Define the server parameters
FServerParameters serverParameters;
parameters.m_authToken = "1111aaaa-22bb-33cc-44dd-5555eeee66ff"; 
parameters.m_fleetId = "arn:aws:gamelift:us-west-1:111122223333:fleet/fleet-9999ffff-88ee-77dd-66cc-5555bbbb44aa";
parameters.m_hostId = "HardwareAnywhere"; 
parameters.m_processId = "PID1234";
parameters.m_webSocketUrl = "wss://us-west-1.api.amazongamelift.com"; 

//Call InitSDK to establish a local connection with the Amazon GameLift Servers Agent to enable further communication.
FGameLiftGenericOutcome initSdkOutcome = GameLiftSdkModule->InitSDK(serverParameters);
```

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

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

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

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

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

**processParameters**  
[FProcess参数](integration-server-sdk5-unreal-datatypes.md#integration-server-sdk5-unreal-dataypes-process) 对象，用于传输有关服务器进程的以下信息：  
+ 游戏服务器代码中实现的回调方法的名称，Amazon GameLift Servers 服务调用其与服务器进程通信。
+ 服务器进程正在侦听的端口号。
+ 您希望 Amazon GameLift Servers 捕获和存储的任何游戏会话特定文件的路径。

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

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

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

此示例说明 [ProcessReady()](#integration-server-sdk5-unreal-processready) 调用和委派函数实施。

```
//Calling ProcessReady tells Amazon GameLift Servers this game server is ready to receive incoming game sessions!
UE_LOG(GameServerLog, Log, TEXT("Calling Process Ready"));
FGameLiftGenericOutcome processReadyOutcome = GameLiftSdkModule->ProcessReady(*params);
```

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

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

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

```
FGameLiftGenericOutcome ProcessEnding()
```

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

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

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

```
//OnProcessTerminate callback. Amazon GameLift Servers will invoke this callback before shutting down an instance hosting this game server.
//It gives this game server a chance to save its state, communicate with services, etc., before being shut down.
//In this case, we simply tell Amazon GameLift Servers we are indeed going to shutdown.
params->OnTerminate.BindLambda([=]() {
  UE_LOG(GameServerLog, Log, TEXT("Game Server Process is terminating"));
  GameLiftSdkModule->ProcessEnding();
});
```

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

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

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

```
FGameLiftGenericOutcome ActivateGameSession()
```

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

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

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

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

```
//When a game session is created, Amazon GameLift Servers sends an activation request to the game server and passes along the game session object containing game properties and other settings.
//Here is where a game server should take action based on the game session object.
//Once the game server is ready to receive incoming player connections, it should invoke GameLiftServerAPI.ActivateGameSession()
auto onGameSession = [=](Aws::GameLift::Server::Model::GameSession gameSession)
{
  FString gameSessionId = FString(gameSession.GetGameSessionId());
  UE_LOG(GameServerLog, Log, TEXT("GameSession Initializing: %s"), *gameSessionId);
  GameLiftSdkModule->ActivateGameSession();
};
```

## UpdatePlayerSessionCreationPolicy()
<a name="integration-server-sdk5-unreal-updateplayersessioncreationpolicy"></a>

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

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

```
FGameLiftGenericOutcome UpdatePlayerSessionCreationPolicy(EPlayerSessionCreationPolicy policy)
```

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

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

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

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

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

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

```
FGameLiftGenericOutcome outcome = GameLiftSdkModule->UpdatePlayerSessionCreationPolicy(Aws::GameLift::Model::EPlayerSessionCreationPolicy::ACCEPT_ALL);
```

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

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

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

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

```
FGameLiftStringOutcome GetGameSessionId()
```

### 参数
<a name="integration-server-sdk5-unreal-getgamesessionid-parameter"></a>

此操作没有参数。

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

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

对于未通过游戏会话激活的空闲进程，调用返回 `Success` = `True` 和 `GameSessionId` = `""`。

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

```
//When a game session is created, Amazon GameLift Servers sends an activation request to the game server and passes along the game session object containing game properties and other settings.
//Here is where a game server should take action based on the game session object.
//Once the game server is ready to receive incoming player connections, it should invoke GameLiftServerAPI.ActivateGameSession()
auto onGameSession = [=](Aws::GameLift::Server::Model::GameSession gameSession)
{
  FString gameSessionId = FString(gameSession.GetGameSessionId());
  UE_LOG(GameServerLog, Log, TEXT("GameSession Initializing: %s"), *gameSessionId);
  GameLiftSdkModule->ActivateGameSession();
};
```

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

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

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

```
AwsDateTimeOutcome GetTerminationTime()
```

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

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

如果进程未收到` ProcessParameters.OnProcessTerminate()`回调，则会返回一条错误消息。有关关闭服务器进程的更多信息，请参阅[回应服务器进程关闭通知](gamelift-sdk-server-api.md#gamelift-sdk-server-terminate)。

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

```
AwsDateTimeOutcome TermTimeOutcome = GameLiftSdkModule->GetTerminationTime();
```

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

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

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

```
FGameLiftGenericOutcome AcceptPlayerSession(const FString& playerSessionId)
```

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

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

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

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

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

此示例处理的连接请求包括验证和拒绝无效的玩家会话。 IDs

```
bool GameLiftManager::AcceptPlayerSession(const FString& playerSessionId, const FString& playerId)
{
  #if WITH_GAMELIFT
  UE_LOG(GameServerLog, Log, TEXT("Accepting GameLift PlayerSession: %s . PlayerId: %s"), *playerSessionId, *playerId);
  FString gsId = GetCurrentGameSessionId();
  if (gsId.IsEmpty()) {
    UE_LOG(GameServerLog, Log, TEXT("No GameLift GameSessionId. Returning early!"));
    return false;
  }
  
  if (!GameLiftSdkModule->AcceptPlayerSession(playerSessionId).IsSuccess()) {
    UE_LOG(GameServerLog, Log, TEXT("PlayerSession not Accepted."));
    return false;
  }

  // Add PlayerSession from internal data structures keeping track of connected players
  connectedPlayerSessionIds.Add(playerSessionId);
  idToPlayerSessionMap.Add(playerSessionId, PlayerSession{ playerId, playerSessionId });
  return true;
  #else
  return false;
  #endif
}
```

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

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

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

```
FGameLiftGenericOutcome RemovePlayerSession(const FString& playerSessionId)
```

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

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

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

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

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

```
bool GameLiftManager::RemovePlayerSession(const FString& playerSessionId)
{
  #if WITH_GAMELIFT
  UE_LOG(GameServerLog, Log, TEXT("Removing GameLift PlayerSession: %s"), *playerSessionId);

  if (!GameLiftSdkModule->RemovePlayerSession(playerSessionId).IsSuccess()) {
    UE_LOG(GameServerLog, Log, TEXT("PlayerSession Removal Failed"));
    return false;
  }

  // Remove PlayerSession from internal data structures that are keeping track of connected players
  connectedPlayerSessionIds.Remove(playerSessionId);
  idToPlayerSessionMap.Remove(playerSessionId);

  // end the session if there are no more players connected
  if (connectedPlayerSessionIds.Num() == 0) {
    EndSession();
  }

  return true;
  #else
  return false;
  #endif
}
```

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

检索玩家会话数据，包括设置、会话元数据和玩家数据。使用此方法获取有关以下内容的信息：
+ 单人游戏会话
+ 游戏会话中的所有玩家会话
+ 与单个玩家 ID 关联的所有玩家会话

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

```
FGameLiftDescribePlayerSessionsOutcome DescribePlayerSessions(const FGameLiftDescribePlayerSessionsRequest &describePlayerSessionsRequest)
```

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

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

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

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

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

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

```
void GameLiftManager::DescribePlayerSessions()
{
  #if WITH_GAMELIFT
  FString localPlayerSessions;
  for (auto& psId : connectedPlayerSessionIds)
  {
    PlayerSession ps = idToPlayerSessionMap[psId];
    localPlayerSessions += FString::Printf(TEXT("%s : %s  ; "), *(ps.playerSessionId), *(ps.playerId));
  }
  UE_LOG(GameServerLog, Log, TEXT("LocalPlayerSessions: %s"), *localPlayerSessions);

  UE_LOG(GameServerLog, Log, TEXT("Describing PlayerSessions in this GameSession"));
  FGameLiftDescribePlayerSessionsRequest request;
  request.m_gameSessionId = GetCurrentGameSessionId();

  FGameLiftDescribePlayerSessionsOutcome outcome = GameLiftSdkModule->DescribePlayerSessions(request);
  LogDescribePlayerSessionsOutcome(outcome);
  #endif
}
```

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

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

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

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

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

```
FGameLiftStringOutcome StartMatchBackfill (FStartMatchBackfillRequest &startBackfillRequest);
```

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

**[FStartMatchBackfillRequest](integration-server-sdk5-unreal-datatypes.md#integration-server-sdk5-unreal-dataypes-startmatchbackfillrequest)**  
传达以下信息的 StartMatchBackfillRequest 对象：  
+ 要分配给回填请求的票证 ID。此信息是可选的；如果未提供任何 ID，则 Amazon GameLift Servers 将自动生成一个 ID。
+ 要将请求发送到的对战构建器。需要完整的配置 ARN。该值位于游戏会话的对战构建器数据中。
+ 要回填的游戏会话的 ID。
+ 游戏会话的当前玩家的可用对战数据。

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

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

### 示例
<a name="integration-server-sdk5-unreal-startmatchbackfill-example"></a>

```
FGameLiftStringOutcome FGameLiftServerSDKModule::StartMatchBackfill(const FStartMatchBackfillRequest& request) 
{
  #if WITH_GAMELIFT
  Aws::GameLift::Server::Model::StartMatchBackfillRequest sdkRequest;
  sdkRequest.SetTicketId(TCHAR_TO_UTF8(*request.m_ticketId));
  sdkRequest.SetGameSessionArn(TCHAR_TO_UTF8(*request.m_gameSessionArn));
  sdkRequest.SetMatchmakingConfigurationArn(TCHAR_TO_UTF8(*request.m_matchmakingConfigurationArn));
  for (auto player : request.m_players) {
    Aws::GameLift::Server::Model::Player sdkPlayer;
    sdkPlayer.SetPlayerId(TCHAR_TO_UTF8(*player.m_playerId));
    sdkPlayer.SetTeam(TCHAR_TO_UTF8(*player.m_team));
    for (auto entry : player.m_latencyInMs) {
      sdkPlayer.WithLatencyMs(TCHAR_TO_UTF8(*entry.Key), entry.Value);
    }

    std::map<std::string, Aws::GameLift::Server::Model::AttributeValue> sdkAttributeMap;
    for (auto attributeEntry : player.m_playerAttributes) {
      FAttributeValue value = attributeEntry.Value;
      Aws::GameLift::Server::Model::AttributeValue attribute;
      switch (value.m_type) {
        case FAttributeType::STRING:
          attribute = Aws::GameLift::Server::Model::AttributeValue(TCHAR_TO_UTF8(*value.m_S));
        break;
        case FAttributeType::DOUBLE:
          attribute = Aws::GameLift::Server::Model::AttributeValue(value.m_N);
        break;
        case FAttributeType::STRING_LIST:
          attribute = Aws::GameLift::Server::Model::AttributeValue::ConstructStringList();
          for (auto sl : value.m_SL) {
            attribute.AddString(TCHAR_TO_UTF8(*sl));
          };
        break;
        case FAttributeType::STRING_DOUBLE_MAP:
          attribute = Aws::GameLift::Server::Model::AttributeValue::ConstructStringDoubleMap();
          for (auto sdm : value.m_SDM) {
            attribute.AddStringAndDouble(TCHAR_TO_UTF8(*sdm.Key), sdm.Value);
          };
        break;
      }
      sdkPlayer.WithPlayerAttribute((TCHAR_TO_UTF8(*attributeEntry.Key)), attribute);
    }
    sdkRequest.AddPlayer(sdkPlayer);
  }
  auto outcome = Aws::GameLift::Server::StartMatchBackfill(sdkRequest);
  if (outcome.IsSuccess()) {
    return FGameLiftStringOutcome(outcome.GetResult().GetTicketId());
  }
  else {
    return FGameLiftStringOutcome(FGameLiftError(outcome.GetError()));
  }
  #else
  return FGameLiftStringOutcome("");
  #endif
}
```

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

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

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

```
FGameLiftGenericOutcome StopMatchBackfill (FStopMatchBackfillRequest &stopBackfillRequest);
```

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

**[FStopMatchBackfillRequest](integration-server-sdk5-unreal-datatypes.md#integration-server-sdk5-unreal-dataypes-stopmatchbackfillrequest)**  
标识要取消的配对门票的 StopMatchBackfillRequest 对象：  
+ 要分配给回填请求的票证 ID
+ 回填请求所发送到的对战构建器
+ 与回填请求关联的游戏会话

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

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

### 示例
<a name="integration-server-sdk5-unreal-stopmatchbackfill-example"></a>

```
FGameLiftGenericOutcome FGameLiftServerSDKModule::StopMatchBackfill(const FStopMatchBackfillRequest& request)
{
  #if WITH_GAMELIFT
  Aws::GameLift::Server::Model::StopMatchBackfillRequest sdkRequest;
  sdkRequest.SetTicketId(TCHAR_TO_UTF8(*request.m_ticketId));
  sdkRequest.SetGameSessionArn(TCHAR_TO_UTF8(*request.m_gameSessionArn));
  sdkRequest.SetMatchmakingConfigurationArn(TCHAR_TO_UTF8(*request.m_matchmakingConfigurationArn));
  auto outcome = Aws::GameLift::Server::StopMatchBackfill(sdkRequest);
  if (outcome.IsSuccess()) {
    return FGameLiftGenericOutcome(nullptr);
  }
  else {
    return FGameLiftGenericOutcome(FGameLiftError(outcome.GetError()));
  }
  #else
  return FGameLiftGenericOutcome(nullptr);
  #endif
}
```

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

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

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

```
FGameLiftGetComputeCertificateOutcome FGameLiftServerSDKModule::GetComputeCertificate()
```

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

返回一个包含以下内容的`GetComputeCertificateResponse`对象：
+ CertificatePath：计算资源上 TLS 证书的路径。
+ HostName：您的计算资源的主机名。

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

```
FGameLiftGetComputeCertificateOutcome FGameLiftServerSDKModule::GetComputeCertificate()
{
  #if WITH_GAMELIFT
  auto outcome = Aws::GameLift::Server::GetComputeCertificate();
  if (outcome.IsSuccess()) {
    auto& outres = outcome.GetResult();
    FGameLiftGetComputeCertificateResult result;
    result.m_certificate_path = UTF8_TO_TCHAR(outres.GetCertificatePath());
    result.m_computeName = UTF8_TO_TCHAR(outres.GetComputeName());
    return FGameLiftGetComputeCertificateOutcome(result);
  }
  else {
    return FGameLiftGetComputeCertificateOutcome(FGameLiftError(outcome.GetError()));
  }
  #else
  return FGameLiftGetComputeCertificateOutcome(FGameLiftGetComputeCertificateResult());
  #endif
}
```

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

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

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

```
FGameLiftGetFleetRoleCredentialsOutcome FGameLiftServerSDKModule::GetFleetRoleCredentials(const FGameLiftGetFleetRoleCredentialsRequest &request)
```

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

[FGameLiftGetFleetRoleCredentialsRequest](integration-server-sdk5-unreal-datatypes.md#integration-server-sdk5-unreal-dataypes-getfleetrolecredentialsrequest)

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

返回 [FGameLiftGetFleetRoleCredentialsOutcome](integration-server-sdk5-unreal-datatypes.md#integration-server-sdk5-unreal-dataypes-getfleetrolecredentialsoutcome) 对象。

### 示例
<a name="integration-server-sdk5-unreal-getfleetrolecredentials-example"></a>

```
FGameLiftGetFleetRoleCredentialsOutcome FGameLiftServerSDKModule::GetFleetRoleCredentials(const FGameLiftGetFleetRoleCredentialsRequest &request)
{
  #if WITH_GAMELIFT
  Aws::GameLift::Server::Model::GetFleetRoleCredentialsRequest sdkRequest;
  sdkRequest.SetRoleArn(TCHAR_TO_UTF8(*request.m_roleArn));
  sdkRequest.SetRoleSessionName(TCHAR_TO_UTF8(*request.m_roleSessionName));

  auto outcome = Aws::GameLift::Server::GetFleetRoleCredentials(sdkRequest);

  if (outcome.IsSuccess()) {
    auto& outres = outcome.GetResult();
    FGameLiftGetFleetRoleCredentialsResult result;
    result.m_assumedUserRoleArn = UTF8_TO_TCHAR(outres.GetAssumedUserRoleArn());
    result.m_assumedRoleId = UTF8_TO_TCHAR(outres.GetAssumedRoleId());
    result.m_accessKeyId = UTF8_TO_TCHAR(outres.GetAccessKeyId());
    result.m_secretAccessKey = UTF8_TO_TCHAR(outres.GetSecretAccessKey());
    result.m_sessionToken = UTF8_TO_TCHAR(outres.GetSessionToken());
    result.m_expiration = FDateTime::FromUnixTimestamp(outres.GetExpiration());
    return FGameLiftGetFleetRoleCredentialsOutcome(result);
  }
  else {
    return FGameLiftGetFleetRoleCredentialsOutcome(FGameLiftError(outcome.GetError()));
  }
  #else
  return FGameLiftGetFleetRoleCredentialsOutcome(FGameLiftGetFleetRoleCredentialsResult());
  #endif
}
```

## Destroy
<a name="integration-server-sdk5-unreal-ref-destroy"></a>

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

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

```
FGameLiftGenericOutcome Destroy();
```

### 参数
<a name="integration-server-sdk5-unreal-ref-destroy-parameter"></a>

没有参数。

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

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

### 示例
<a name="integration-server-sdk5-unreal-ref-destroy-example"></a>

```
// First call ProcessEnding()
FGameLiftGenericOutcome processEndingOutcome = GameLiftSdkModule->ProcessEnding();
  
// Then call Destroy() to free the SDK from memory
FGameLiftGenericOutcome destroyOutcome = GameLiftSdkModule->Destroy();
  
// Exit the process with success or failure
if (processEndingOutcome.IsSuccess() && destroyOutcome.IsSuccess()) 
    {
    UE_LOG(GameServerLog, Log, TEXT("Server process ending successfully"));
}
else {
    if (!processEndingOutcome.IsSuccess()) {
        const FGameLiftError& error = processEndingOutcome.GetError();
        UE_LOG(GameServerLog, Error, TEXT("ProcessEnding() failed. Error: %s"),
        error.m_errorMessage.IsEmpty() ? TEXT("Unknown error") : *error.m_errorMessage);
    }
    if (!destroyOutcome.IsSuccess()) {
        const FGameLiftError& error = destroyOutcome.GetError();
        UE_LOG(GameServerLog, Error, TEXT("Destroy() failed. Error: %s"),
        error.m_errorMessage.IsEmpty() ? TEXT("Unknown error") : *error.m_errorMessage);
    }
}
```