Creator-only scoring, real-time score sync, and WebRTC live streaming - #1
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
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: newisMatchCreator(match, user)guard;start-innings,ball,stream, andmicro-pollroutes now require auth and return 403 for non-creators.broadcastScoreUpdateemitsmatchScoreUpdate { matchId, match, innings }to the existingviewers:${matchId}room, whereinningsare the samebuildInningsSummarypayloads the REST API returns — so socket and fetch state can never diverge.Server — WebRTC signaling (
server.js)matchBroadcasters: Map<matchId, socketId>;broadcasterReadyverifies the socket token belongs to the match creator before registering.watcherRequestStream → watcherJoin → webrtcOffer/webrtcAnswer/webrtcIceCandidatebetween broadcaster and each watcher; cleans up and emitsbroadcasterDisconnectedon stop/disconnect.Client
utils/liveStreamRtc.js:createBroadcaster(socket, getStream)(oneRTCPeerConnectionper watcher,replaceStreamfor camera flips) andcreateWatcher(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 tomatchScoreUpdate/matchStreamUpdate.LiveStreamPage: viewers auto-connect to the creator's WebRTC broadcast whenisLiveStreaming(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").Note: WebRTC uses Google STUN servers only; a TURN server would be needed for viewers behind strict/symmetric NATs.
Verified with
node --checkon server files andCI=true npm run build(compiles clean, no warnings).Link to Devin session: https://app.devin.ai/sessions/0fd99286f89041719b60d5e53ba54869
Requested by: @Deva-TECH-droid