[PR #5186] [MERGED] horizon-server: an event stream in the control API (joins, leaves, kicks, chat, deaths, log) #6128

Closed
opened 2026-11-03 06:12:40 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5186
Author: @ludovic111
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: server-admin/events


📝 Commits (2)

  • 48ccd93 horizon-server: an event stream in the control API
  • bef1eff horizon-server events: a stream starts when it's asked for, not when its headers are out

📊 Changes

13 files changed (+493 additions, -25 deletions)

View changed files

📝 crates/horizon-client/src/game/dedicated.rs (+9 -0)
➕ crates/horizon-client/src/game/dedicated/events.rs (+69 -0)
📝 crates/horizon-client/src/game/dedicated/status.rs (+5 -1)
📝 crates/horizon-client/src/game/lan.rs (+23 -8)
📝 crates/horizon-client/src/game/lan_actions.rs (+6 -0)
📝 crates/horizon-server/src/api.rs (+16 -2)
➕ crates/horizon-server/src/events.rs (+279 -0)
📝 crates/horizon-server/src/main.rs (+1 -0)
📝 crates/horizon-server/src/supervisor.rs (+13 -5)
📝 docs/api/server-reference.md (+1 -0)
📝 docs/api/server.md (+10 -4)
📝 docs/server.md (+3 -1)
📝 tools/server_admin_e2e.py (+58 -4)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Roadmap server-admin, part 3: an event stream, so a Discord bridge, a panel or an agent sees what happens without polling the log or parsing lines.

What it adds

  • GET /api/v1/events (server-sent events with Accept: text/event-stream, otherwise JSON): every log line (log), the supervisor's phase, and the game's typed join (with the address), leave and kick (with the reason), chat (the message) and death (vanilla's death message) events, each with the player's name and UUID and a number. ?types=chat,death picks some; Last-Event-ID or ?since=N resumes after a reconnection (the last 2000 are kept); a comment every 15 s keeps quiet streams open.
    id: 34
    event: chat
    data: {"id":34,"type":"chat","name":"Kim0","uuid":"93e029a5-…","message":"hello from Kim0","time":1793454528897}
    
  • Game side (game/dedicated/events.rs): the dedicated server records the typed events at the places it already logs them (join and leave in game/lan.rs, chat from HostEvent::PlayerChat, deaths in lan_actions.rs where the death message is broadcast, kicks in kick_uuid), and answers server-events SINCE on its control endpoint. Nothing changes for a LAN host or single player (all behind options.dedicated), and nothing about what players see.
  • Supervisor side (horizon-server/src/events.rs): fetches server-events every 250 ms while the game runs, and numbers log lines, phase changes and game events in one sequence.

Tests

  • Unit: events numbered and read from a number (game and supervisor), a live SSE stream filtered by type, the JSON form.
  • tools/server_admin_e2e.py opens a stream before two bots join and checks both joins (with the address), Kim0's chat (a raw unsigned chat packet through horizon-bots --raw), the kick and the leave with the reason, /kill Lou0's death message, and the same death polled as JSON. Passed on the Mac mini (39 checks).

pr_ready below ran against main before #5163 and #5165 merged, so its scope counts them too; this PR alone is +492 −25 (13 files). Parity: the 36 harnesses the game files reach, 0 failed.

pr_ready (tools/pr_ready.py on ludovics-mac-mini, against origin/main at bd541458c, 38 min 14 s)

Check Result
Scope ⚠️ 20 files, +1795 −87; 1768 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (2 min 27 s)
rustfmt ✅ (22 s)
clippy ✅ (1 min 16 s)
tests: horizon-client, horizon-server ✅ 1407 passed (5 min 22 s)
doc tests ✅ 0 passed (29 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ✅ 36 affected, 35 passed (28 min 3 s)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/5186 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `server-admin/events` --- ### 📝 Commits (2) - [`48ccd93`](https://github.com/horizon-rust/horizon/commit/48ccd932677b01dc8cda3bc846941d2736e46e94) horizon-server: an event stream in the control API - [`bef1eff`](https://github.com/horizon-rust/horizon/commit/bef1eff277871f7be5bc0eed944eb76565188809) horizon-server events: a stream starts when it's asked for, not when its headers are out ### 📊 Changes **13 files changed** (+493 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/dedicated.rs` (+9 -0) ➕ `crates/horizon-client/src/game/dedicated/events.rs` (+69 -0) 📝 `crates/horizon-client/src/game/dedicated/status.rs` (+5 -1) 📝 `crates/horizon-client/src/game/lan.rs` (+23 -8) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+6 -0) 📝 `crates/horizon-server/src/api.rs` (+16 -2) ➕ `crates/horizon-server/src/events.rs` (+279 -0) 📝 `crates/horizon-server/src/main.rs` (+1 -0) 📝 `crates/horizon-server/src/supervisor.rs` (+13 -5) 📝 `docs/api/server-reference.md` (+1 -0) 📝 `docs/api/server.md` (+10 -4) 📝 `docs/server.md` (+3 -1) 📝 `tools/server_admin_e2e.py` (+58 -4) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Roadmap `server-admin`, part 3: an event stream, so a Discord bridge, a panel or an agent sees what happens without polling the log or parsing lines. ## What it adds - `GET /api/v1/events` (server-sent events with `Accept: text/event-stream`, otherwise JSON): every log line (`log`), the supervisor's `phase`, and the game's typed `join` (with the address), `leave` and `kick` (with the reason), `chat` (the message) and `death` (vanilla's death message) events, each with the player's name and UUID and a number. `?types=chat,death` picks some; `Last-Event-ID` or `?since=N` resumes after a reconnection (the last 2000 are kept); a comment every 15 s keeps quiet streams open. ``` id: 34 event: chat data: {"id":34,"type":"chat","name":"Kim0","uuid":"93e029a5-…","message":"hello from Kim0","time":1793454528897} ``` - Game side (`game/dedicated/events.rs`): the dedicated server records the typed events at the places it already logs them (join and leave in `game/lan.rs`, chat from `HostEvent::PlayerChat`, deaths in `lan_actions.rs` where the death message is broadcast, kicks in `kick_uuid`), and answers `server-events SINCE` on its control endpoint. Nothing changes for a LAN host or single player (all behind `options.dedicated`), and nothing about what players see. - Supervisor side (`horizon-server/src/events.rs`): fetches `server-events` every 250 ms while the game runs, and numbers log lines, phase changes and game events in one sequence. ## Tests - Unit: events numbered and read from a number (game and supervisor), a live SSE stream filtered by type, the JSON form. - `tools/server_admin_e2e.py` opens a stream before two bots join and checks both joins (with the address), Kim0's chat (a raw unsigned chat packet through `horizon-bots --raw`), the kick and the leave with the reason, `/kill Lou0`'s death message, and the same death polled as JSON. Passed on the Mac mini (39 checks). pr_ready below ran against main before #5163 and #5165 merged, so its scope counts them too; this PR alone is +492 −25 (13 files). Parity: the 36 harnesses the game files reach, 0 failed. **pr_ready** (`tools/pr_ready.py` on ludovics-mac-mini, against origin/main at bd541458c, 38 min 14 s) | Check | Result | | --- | --- | | Scope | ⚠️ 20 files, +1795 −87; 1768 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (2 min 27 s) | | rustfmt | ✅ (22 s) | | clippy | ✅ (1 min 16 s) | | tests: horizon-client, horizon-server | ✅ 1407 passed (5 min 22 s) | | doc tests | ✅ 0 passed (29 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ✅ 36 affected, 35 passed (28 min 3 s) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:12:40 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#6128
No description provided.