Repository navigation
feat: room events over live777 cable datachannel (dual with SSE) - #59
Merged
Merged
Conversation
With EVENTS_CABLE enabled (default off), every published room event is
also injected into a per-room {roomId}-events live777 stream via the
cable messages API (POST /api/streams/{stream}/cables/events/messages),
so browsers can receive the identical payloads/revisions over a WHEP
datachannel instead of SSE. SSE is untouched and stays the fallback.
- src/cable.rs: CableEvents worker — one bounded (4096) global queue
drained sequentially (enqueue happens under write_gate, so inject
order == commit order); unknown stream -> create -> retry once;
failures warn-and-continue; a full queue drops new events (loss
converges via the full-state snapshots).
- src/proxy.rs: a WHEP subscribe to an -events stream ensures it exists
before forwarding (live777 reaps publisher-less streams), authorized
via the new store.whep_events_authorization (active participant of
the room's current meeting; sessions reaped on turnover/kick with the
existing media-session sweep).
- GET /room/{id} advertises eventsStream to active participants only.
Requires live777 with the cable messages API (binbat/live777#522).
Tests: mock-upstream coverage of inject order/payloads/auth,
create-on-404 retry, queue bound, the authorize matrix, the
advertise/omit matrix, and kick revoking the events session.
When GET /room/{id} advertises eventsStream, subscribe it over WHEP
with a pre-offer 'events' datachannel (m=application) and feed decoded
binary frames into the same dispatch as SSE (revision dedup,
message/caption/snapshot). The transport is re-evaluated on every room
refetch; both never run simultaneously for the same generation.
- The vendored WHEPClient needs an absolute URL (location.origin).
- Reconnect with exponential backoff (500ms doubling, 10s cap, reset on
open): 401/403 are terminal, 404 is retryable (the events stream may
be reaped or not created yet).
- Resync meeting state on every channel open, first one included: the
cable has no retained initial snapshot like the SSE endpoint sends,
so events fired while the channel was connecting are healed by the
fresh snapshot the resync's presence PATCH triggers.
- Chat unread survives snapshot healing: track seen message ids
(re-based on each snapshot) and count unseen, non-own,
ts >= joinAt (second-granularity) messages as unread; live message
events dedupe by the same set.
applySnapshot treats the first snapshot as the baseline (initializes
lastMuteAllAt without acting). On the cable transport the first snapshot
arrives after WHEP connect + resync — much later than the SSE endpoint's
connect-time initial snapshot — so a mute-all fired in that window was
silently absorbed as the baseline instead of muting me (caught by the
members mute-all e2e on the cable leg).
Seed lastMuteAllAt from GET /room/{id} at mount instead (the frontend
Room type gains the muteAllAt field the server already sends). Joining
an already-muted meeting still does not self-mute; only the first-join
baseline moves from first-snapshot to REST. restoreMeeting deliberately
does not re-seed, so a mute-all during a reconnect gap still applies.
The ticket-stub and EventSource-counting tests in recovery.spec.ts are meaningless when room events ride the cable datachannel (the app never touches those endpoints): a closed ticket connection, first-snapshot meeting stubs, ticket 401/403/404, and the one-active-event-source invariant. Skip them via a shared EVENTS_CABLE flag (tests/helper.ts) that mirrors the server's unset/empty/0/false = off convention. The transport-agnostic recovery tests keep running on both legs.
The cable messages API (binbat/live777#522) is merged but unreleased, and no registry image tracks live777 main (image pushes happen on version tags only): - compose.yml builds the live777 service from the live777 git context pinned to commit d1ef16a (tagged liveion-main:local; `docker compose build live777` refreshes). - The e2e job replaces the 0.10.2 service container with a buildx build of the same pin (LIVE777_REF at the top of test.yml, gha layer cache) started as a plain container. - The e2e job runs twice via a transport matrix (sse, cable), so the datachannel events path is covered in CI; reports upload per transport. Verified locally against the pinned image: full suite 54 passed + 7 skipped on the cable leg (SSE-transport specs), 61 passed on SSE.
"changes the processed camera image without restarting it" runs two virtual-background swaps with 30s-bound enable/poll waits inside the default 60s test timeout, so a loaded CI runner can time it out mid-click (seen repeatedly on the e2e legs; locally green 21/21). Matches the other heavy specs that raise their budget explicitly.
a-wing
force-pushed
the
feat/cable-events
branch
from
November 24, 2026 04:09
036fe3b to
8705922
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in second transport for room events (snapshot/message/caption) over a Live777 cable (WebRTC datachannel), running dual with the existing SSE. Requires live777 ≥ 0.11.0 (cable messages API, binbat/live777#522 — merged to live777 main); with the pinned 0.10.2 image the toggle stays off and nothing changes.
EVENTS_CABLEenv (unset/empty/0/false= off, default off) enables dual-push: every published room event is injected into a per-room{roomId}-eventslive777 stream viaPOST /api/streams/{stream}/cables/events/messages.GET /room/{id}advertiseseventsStreamto active participants only; the WebApp WHEP-subscribes it with a pre-offereventsdatachannel (m=application) and receives the identical payloads/revisions as binary frames. SSE stays the fallback and is untouched when the toggle is off.write_gate, so inject order == commit order); unknown stream →POST /api/streams/{stream}→ retry once; failures warn-and-continue (event loss converges via revision + snapshots).{roomId}-events: active participant of the room's current meeting; sessions reaped on meeting turnover via the existing media-session sweep.Implementation
src/cable.rs— stream-id derive/parse,CableEventsworker (reqwest mirrorsrevoke_media_sessions; nojsonfeature, body viaserde_json::to_string).src/store.rs—whep_events_authorization.webapp/components/use/cableEvents.ts— datachannel events client (generation-guarded, 500ms reconnect, terminal on 401/403/404).webapp/components/layout.vue— shared event dispatcher for both transports; transport re-evaluated on every room refetch; never both per generation.Bugs found in live joint debugging (fixed in the third commit)
WHEPClientneeds an absolute URL (location.origin), otherwise every view throwsInvalid base URLand retries forever.ts >= joinAt(second-granularity) messages as unread; live events dedupe by the same set.Tests
npm run test:rust— 70 passed, incl. 7 new mock-upstream cable API tests (inject order/bodies, 404→create→retry, auth header, authorize matrix, advertise matrix, disabled-by-default).npm run lint,npm run buildclean.d1ef16a):tests/meeting.spec.ts+tests/chat.spec.ts+tests/media-lifecycle.spec.ts— 11/11 withEVENTS_CABLE=1(cable) and 11/11 without (SSE). CI keeps the toggle off (playwright env passthrough) until the live777 image is bumped past 0.10.2.Notes / follow-ups
compose.yml/CI live777 pin untouched (0.10.2); enabling requires ≥0.11.0 or live777 main.endedframes stay on SSE semantics (clients detect end/kick from the broadcast snapshot: meetingNo mismatch / own leaveAt).?session=targeted injects are available upstream when we want stricter per-user termination.