Skip to content

Creator-only scoring, real-time score sync, and WebRTC live streaming - #1

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1787494581-creator-only-scoring-live-stream
Open

Creator-only scoring, real-time score sync, and WebRTC live streaming#1
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1787494581-creator-only-scoring-live-stream

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Makes the match creator the single scoring/streaming authority, pushes every score change to all viewers in real time, and turns "Start Live Streaming" into an actual broadcast that every viewer can watch — without redesigning the existing UI.

Server — authorization + real-time score push

  • gullyCricket.js: new isMatchCreator(match, user) guard; start-innings, ball, stream, and micro-poll routes now require auth and return 403 for non-creators.
  • After every innings start / recorded ball, broadcastScoreUpdate emits matchScoreUpdate { matchId, match, innings } to the existing viewers:${matchId} room, where innings are the same buildInningsSummary payloads the REST API returns — so socket and fetch state can never diverge.

Server — WebRTC signaling (server.js)

  • matchBroadcasters: Map<matchId, socketId>; broadcasterReady verifies the socket token belongs to the match creator before registering.
  • Relays watcherRequestStream → watcherJoin → webrtcOffer/webrtcAnswer/webrtcIceCandidate between broadcaster and each watcher; cleans up and emits broadcasterDisconnected on stop/disconnect.

Client

  • New utils/liveStreamRtc.js: createBroadcaster(socket, getStream) (one RTCPeerConnection per watcher, replaceStream for camera flips) and createWatcher(socket, matchId, onStream).
  • LiveScoringPage: scoring pad/innings form render only for the creator (viewers get the live scoreboard + a waiting note); the old large stream widget is replaced by a small corner control ("🎥 Start Live Streaming" for the creator, "🔴 Watch Live" link for viewers while live) plus a small floating camera thumbnail; page also subscribes to matchScoreUpdate/matchStreamUpdate.
  • LiveStreamPage: viewers auto-connect to the creator's WebRTC broadcast when isLiveStreaming (video element shows the remote stream); stream/poll controls are creator-only; score HUD (incl. Big Screen fullscreen mode) and a new score pill in the chat title bar are driven by server innings summaries and update live on every ball.
  • MatchDetailPage: dashboard score now uses innings summaries and updates live; action labels are creator-aware ("Start Scoring" vs "Live Score").
  • Stream toggle and micro-poll creation now send the Clerk bearer token.

Note: WebRTC uses Google STUN servers only; a TURN server would be needed for viewers behind strict/symmetric NATs.

Verified with node --check on server files and CI=true npm run build (compiles clean, no warnings).

Link to Devin session: https://app.devin.ai/sessions/0fd99286f89041719b60d5e53ba54869
Requested by: @Deva-TECH-droid

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@vercel

vercel Bot commented Aug 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
poll-verse-ai Ready Ready Preview Aug 23, 2026 2:26pm
poll-verse-ai-wtmp Ready Ready Preview Aug 23, 2026 2:26pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants