Welcome back. This document introduces the core design of intelligence transmission between PSC and clients, laying the groundwork for your further development.
欢迎回来。本文档将介绍 PSC 与客户端之间情报传输的核心设计,为你后续的深度开发奠定基础。
PSC integrates diverse data sources to maximize utility, yet unverified sources risk degrading intelligence quality. The channel mechanism addresses this by isolating reliable sources from experimental ones—ensuring production users remain unaffected by instability while giving enthusiasts early access to test new feeds.
PSC 积极接入多源数据以提升实用性,但部分未经验证的数据源可能降低情报质量。因此,PSC 采用频道(Channel)机制,将稳定数据源与实验性数据源隔离,既保障生产环境用户的稳定性,也为开发者提供最新数据源的测试通道。
PSC currently offers two channels: stable and testing.
目前 PSC 提供两个频道:stable 与 testing。
stable: Data sources that have been validated through long-term use and proven reliable in the vast majority of scenarios.
经过破灾实控长期验证、在绝大多数场景下稳定可靠的数据源。
testing: Newly added experimental data sources. These sources are unverified with no availability guarantees—they may be removed or graduated to stable at any time.
最新接入的实验性数据源。这些新数据源尚未经过验证,不保证可用性,未来可能被移除或转入 stable 频道。
ATTENTION 注意
If your software integrating PSC is released publicly, you should NOT expose the testing channel to users. If you must offer it, you are required to clearly disclose that intelligence from this channel is unverified and unstable.
若您开发的软件将公开发布,原则上不应向用户提供 testing 频道的选项。如确需开放,必须明确告知用户该频道情报的不稳定性与未验证的风险。
To switch channels, disconnect from PSC and reconnect using the URL for the new channel.
切换频道时,断开当前 PSC 连接,然后使用新频道对应的 URL 重新连接即可。
When connecting to PSC, include your token as a plain-text string in the token query parameter of the URL. PSC authenticates by verifying the hash of your token.
连接 PSC 时,请将令牌以纯文本字符串形式置于 URL 的 token 查询参数中。PSC 通过验证该令牌的哈希值完成鉴权。
You must specify a channel when connecting to PSC. Include the channel name in the URL path, for example:
同时,你需要指定要连接的频道。将频道名置于 URL 路径中,完整示例如下:
ws://example.com:1145/stable?token=the-safest-token-in-the-world
Connect your client to PSC with a URL like this.
你的客户端将使用像这样的 URL 连接 PSC。
To improve transmission efficiency, all messages sent by PSC to clients are first compressed with Brotli and then encoded in Base64. This also applies to handshake messages and responses to active data requests.
为提高传输效率,PSC 向客户端发送的所有消息均先经 Brotli 压缩,再以 Base64 编码。此规则同时适用于握手消息及主动请求返回的数据。
After receiving a message, the client must first decode and decompress it. See the Python example below:
客户端收到消息后,首先需要对其进行解码与解压。Python 示例如下:
decoded = base64.b64decode(raw) # Decode 解码
decompressed = brotli.decompress(decoded) # Decompress 解压
The decoded and decompressed payload is a JSON object (unless otherwise specified for certain message types). Parse it using UTF-8 into a dictionary type native to your programming language, without escaping non-ASCII characters.
解码并解压后的字符串为一个 JSON 对象(文档另有注明的特殊消息除外)。客户端应使用 UTF-8 编码直接解析为编程语言原生的字典类型,无需对非 ASCII 字符进行转义。
Upon successful authentication, PSC immediately retrieves the client’s GeoIP information and sends a handshake message containing the PSC standard time, the client’s geographic location, and a list of currently active intelligence (such as ongoing earthquake early warnings), among other information. See the API Reference for detailed field definitions.
鉴权成功后,PSC 会立即获取客户端的 GeoIP 信息,并向客户端发送一条握手消息。该消息包含 PSC 标准时间、客户端地理位置,以及当前活跃的情报列表(如正在生效的地震预警)等信息。详细字段定义请参见 API 参考文档。
No client-side response is required for the handshake.
客户端无需对握手消息作出响应。
PSC does not implement a heartbeat mechanism. If the client sends heartbeat messages, PSC will keep the connection alive without responding, provided the message does not match an active data request command.
PSC 没有心跳机制。如果客户端自行发送心跳消息,PSC 会维持连接但不作任何回应——前提是消息内容未匹配任何主动数据请求指令。
PSC does not actively disconnect clients during normal operation. If a token is revoked by Project Podris administrators, PSC will forcibly terminate all active connections using that token.
PSC 在正常运行期间不会主动断开客户端连接。若某令牌被破灾实控管理员封禁,PSC 将强制断开该令牌的所有活跃连接。
If the connection drops unexpectedly, retry using exponential backoff. Excessive reconnection frequency may result in the client IP being blocked and reported to administrators.
客户端遭遇意外断连时,应使用指数退避策略进行重试。若重连频率过高,PSC 可能封禁该客户端 IP 并上报管理员。
All intelligence messages are dictionaries with a unified header at the top, containing fixed fields such as event_id, event_type, and event_source. The body fields sit at the same level immediately after the header and vary by intelligence type. See the API Reference for details.
所有情报消息均为一个字典,开头采用统一的报头结构,包含事件编号、情报类型、情报来源等固定字段。报体与报头处于同一层级,紧随报头之后,具体字段因情报类型而异。详见 API 参考文档。
INFO 信息
Intelligence messages refer to payloads carrying disaster intelligence (e.g., earthquake early warnings), distinct from system messages such as handshakes.
情报消息指承载灾害情报的消息(如地震预警),与握手消息等系统消息相区分。
PSC provides earthquake history retrieval and data generation services (e.g., focal mechanism beachballs). Clients must send specific commands with the required parameters to receive the corresponding data.
PSC 提供地震历史查询与实时数据生成服务(如震源机制球)。客户端须发送指定指令及参数,方可获取对应数据。
When sending commands to PSC, no encoding or compression is required—send them as plain text. Upon successful delivery, the next message received will be the response data. See the API Reference for details.
向 PSC 发送指令时无需编码或压缩,直接以纯文本发送即可。发送成功后,下一条接收到的消息即为返回数据。详见 API 参考文档。
In summary, a complete PSC client should implement the following: WebSocket connection establishment, handshake processing, intelligence parsing, channel switching, active data requests, and error handling with retry logic.
综上,一个完整的 PSC 客户端应实现以下功能:建立 WebSocket 连接、处理握手包、解析情报数据、频道切换、请求主动数据,以及错误处理与重试。
Next, proceed to the API Reference to explore the intelligence types distributed by PSC.
接下来,请阅读 API 参考文档,深入了解 PSC 分发的各类情报数据。