

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

# 适用于 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`**是否必需**：是 | 