请参阅设置游戏会话置放通知。 - Amazon GameLift Servers
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

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

请参阅设置游戏会话置放通知。

您可以使用Events 来监控各个放置请求的状态。我们建议为所有有大量投放活动的游戏设置事件通知。

有两个选项可用于设置事件通知。

  • 有 Amazon GameLift Servers 使用队列向亚马逊简单通知服务 (Amazon SNS) Simple Notification Service 主题发布事件通知。

  • 使用自动发布的 Amazon EventBridge 事件及其工具套件来管理事件。

有关发出的游戏会话放置事件的列表 Amazon GameLift Servers,请参阅 游戏会话放置事件

设置 SNS 主题。

对于 Amazon GameLift Servers 要将游戏会话队列生成的所有事件发布到某个主题,请将通知目标字段设置为主题。

要为设置一个 SNS 主题 Amazon GameLift Servers 事件通知
  1. 登录 Amazon Web Services Management Console 并在 v3/home 上打开亚马逊 SNS 控制台。https://console.aws.amazon.com/sns/

  2. 在 SNS 控制面板中,选择 Create topic (创建主题),然后按照说明创建主题。

  3. Create Policy(创建策略)下,执行以下操作。

    1. 选择高级方法。

    2. 将以粗体显示的 JSON 数据块添加到现有策略。

      { "Version": "2008-10-17", "Id": "__default_policy_ID", "Statement": [ { "Sid": "__default_statement_ID", "Effect": "Allow", "Principal": { "AWS": "*" }, "Action": [ "SNS:GetTopicAttributes", "SNS:SetTopicAttributes", "SNS:AddPermission", "SNS:RemovePermission", "SNS:DeleteTopic", "SNS:Subscribe", "SNS:ListSubscriptionsByTopic", "SNS:Publish" ], "Resource": "arn:aws:sns:your_region:your_account:your_topic_name", "Condition": { "StringEquals": { "AWS:SourceAccount": "your_account" } } }, { "Sid": "__console_pub_0", "Effect": "Allow", "Principal": { "Service": "gamelift.amazonaws.com" }, "Action": "sns:Publish", "Resource": "arn:aws:sns:your_region:your_account:your_topic_name", "Condition": { "ArnLike": { "aws:SourceArn": "arn:aws:gamelift:your_region:your_account:gamesessionqueue/your_queue_name" } } } ] }
    3. (可选)通过向资源策略添加条件,为主题添加其他访问控制。

  4. 选择创建主题

  5. 创建 SNS 主题后,在创建队列时将其添加到队列中,或者编辑现有队列以将其添加。

使用服务器端加密设置 Amazon SNS 主题

借助服务器端加密(SSE),您可以采用加密主题的方式存储敏感数据。SSE 使用 Amazon Key Management Service (Amazon KMS)中托管的密钥保护 Amazon SNS 主题中消息的内容。有关 Amazon S3 如何执行加密的更多信息,请参阅 Amazon Simple Storage Service 开发人员指南中的使用服务器端加密保护数据

要使用服务器端加密设置 SNS 主题,请查看下面的主题:

创建 KMS 密钥时,请使用以下 KMS 密钥策略:

{ "Effect": "Allow", "Principal": { "Service": "gamelift.amazonaws.com" }, "Action": [ "kms:Decrypt", "kms:GenerateDataKey" ], "Resource": "*", "Condition": { "ArnLike": { "aws:SourceArn": "arn:aws:gamelift:your_region:your_account:gamesessionqueue/your_queue_name" }, "StringEquals": { "kms:EncryptionContext:aws:sns:topicArn": "arn:aws:sns:your_region:your_account:your_sns_topic_name" } } }

设置 EventBridge

Amazon GameLift Servers 自动将所有游戏会话放置事件发布到 EventBridge。使用 EventBridge 可以设置规则,将事件路由到目标进行处理。例如,您可以设置一条规则,将事件路由PlacementFulfilled到一个 Amazon Lambda 函数,该函数处理连接到游戏会话之前的任务。有关的更多信息 EventBridge,请参阅 Amazon 是什么 EventBridge? 在《亚马逊 EventBridge 用户指南》中。

以下是一些可与之配合使用的 EventBridge 规则示例 Amazon GameLift Servers 队列:

匹配所有赛事 Amazon GameLift Servers 队列

{ "source": [ "aws.gamelift" ], "detail-type": [ "GameLift Queue Placement Event" ] }

匹配特定队列中的事件

{ "source": [ "aws.gamelift" ], "detail-type": [ "GameLift Queue Placement Event" ], "resources": [ "arn:aws:gamelift:your_region:your_account:gamesessionqueue/your_queue_name" ] }