游戏创意与功能

你的下一项功能

聊天管理

保留玩家消息、显式实时订阅和有界审核。

SDK:develop 分支需要玩家会话
Godot
聊天管理功能示意图
可见的结果

两个现有会话打开项目频道,发送一次、读取快照并举报保留消息。私聊需要好友,群聊需要有效成员资格。

视频稍后提供

此步骤尚无视频。指南和MCP请求已可使用。

聊天管理

准备同一个项目

  1. 在仪表盘中选择与游戏配置相同的项目。

    聊天管理 →
  2. 首次请求不需要额外定义。没有对应游戏数据时,空结果也有效。

    两个现有会话打开项目频道,发送一次、读取快照并举报保留消息。私聊需要好友,群聊需要有效成员资格。

    PHP simpleServer的所有Chat路由均返回501 NOT_SUPPORTED。

实现此功能

你可以预览指南。运行需要有效的项目密钥。 准备项目

已安装 SDK、导入项目配置,且玩家已登录。

此 SDK 示例使用 develop。请检查已安装的 SDK 是否具备所需 API。

先通过快速入门连接目标玩家,再通过明确的按钮或场景操作调用read_chat_snapshot(channel_id)。仅打开文件不会发送请求。

GDScript
res://scripts/chat.gd
horizOn 调用
1extends Node
2​
3# Explicit read after restoring the SAME existing signed-in player.
4func read_chat_snapshot(channel_id: String) -> void:
5 var user = Horizon.auth.getCurrentUser()
6 if user == null:
7 return
8 var result = await Horizon.chat.requestChannelSnapshot(user.userId, channel_id, "", [])
9 if not result.success:
10 push_warning(result.errorCode)
11 return
12 print("Snapshot epoch: ", result.data.channel.epoch)
13 # This raw result never authorizes, opens or populates a managed feed.
14 # watchChannel(user.userId, channel_id) waits for a confirmed subscription.
15 # getCached(channel_id) is visible only while that watch is authorized.
16 # No timer polling, disconnected HTTP fallback or automatic send/retry.
17# Executable durable send/report UI: addons/horizon_sdk/examples/features/chat_example.gd.
18# Persist the original project+player intent before sendMessage; host is only a request fence.
19# Keep operationId, issuedAt, text and original report IDs/reason unchanged after timeout.
20# getOperation 404 is not a confirmed failure. PHP returns 501 NOT_SUPPORTED.
打开完整SDK示例 ↗

两名玩家,一个频道

两个现有会话打开项目频道,发送一次、读取快照并举报保留消息。私聊需要好友,群聊需要有效成员资格。

受管信息流需订阅确认后使用事件/resync、一个Sync和变更标记。无轮询或断线替代,权限撤销时隐藏缓存文本。

发送前按项目和玩家保存精确原始请求。主机和会话仅用于请求边界。不得替换结果未知的ID、时间、文本或修订号。

操作404不能证明失败。超时或OPERATION_EXPIRED后保留原始请求,仅用匹配回执核对。

复用原始举报ID和原因。removed表示成功重放,REPORT_EXPIRED不能创建新举报。

PHP simpleServer的所有Chat路由均返回501 NOT_SUPPORTED。

测试你的新功能。

两个现有会话打开项目频道,发送一次、读取快照并举报保留消息。私聊需要好友,群聊需要有效成员资格。

在仪表盘中选择与游戏配置相同的项目。

接口
  • GET/chat/limits
  • POST/chat/channels/open
  • POST/chat/channels/{channelId}/sync
  • POST/chat/channels/{channelId}/messages
  • GET/chat/operations/{operationId}
  • POST/chat/channels/{channelId}/messages/{messageId}/report
API 参考中的全部接口
排行榜功能示意图
下一步建议

为每一局添加最高分。

每局结束后保存分数并展示领先者。继续使用现有连接和玩家会话。