-
Aryan Noshirvani authored
There was zero real-time infrastructure anywhere in this backend before this - LiveRoom only ever supported create/list. Added WS /social/rooms/{room_id}/ws: - Chat: broadcast to everyone in the room (including the sender - a simpler, more predictable rule than asymmetric exclusion; clients can dedupe by user_id if they update optimistically). - Reactions + a "fire meter":🔥 reactions accumulate into a count that decays over a 30s window (src/services/room_manager.py), so it reads as "how hot is it right now," not a lifetime total. - DJ handoff: request_aux queues a listener, pass_aux (DJ-only, an explicit rejection if a non-DJ tries) hands off to the front of the queue or a requested user_id. Confirmed via the actual LiveRoom.dj_id column, not just the in-memory session. - now_playing (DJ-only) updates LiveRoom.current_song_id live. - Presence (user_joined/user_left) and an initial state snapshot on connect (current DJ, current song, who's here, recent chat, fire count, queue) so a client joining mid-session isn't starting blind. Room state (connections, chat history, fire events, DJ queue) is in-memory and ephemeral by design (src/services/room_manager.py) - only dj_id/current_song_id persist to the DB, since that's the only part that should still be true if someone checks GET /social/rooms without being live-connected. An empty room's ephemeral state is discarded when the last person disconnects. Found and fixed a real deployment gap while verifying this against the actual running server rather than just the test suite: uvicorn had no WebSocket protocol implementation installed at all (no `websockets` or `wsproto` in requirements.txt) - Starlette's TestClient simulates WebSockets in-process and doesn't need one, so all 8 new tests passed happily while the real deployed server would have silently rejected every WebSocket connection. Added websockets>=13.0 to requirements.txt and confirmed a real end-to-end session (two live `websockets` client connections, not TestClient) against the actual running dev instance: chat, reactions, fire count, aux request/handoff, all working and persisting to the DB correctly. Co-Authored-By:Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BCxXmJVvDFJVHTUi4QgNzi
fc48e64c
| Name |
Last commit
|
Last update |
|---|---|---|
| deploy/systemd | ||
| scripts | ||
| src | ||
| tests | ||
| .env.example | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| Dockerfile | ||
| README.md | ||
| docker-compose.yml | ||
| requirements.txt | ||
| setup.sh |