feat: Implement automatic host reassignment when host leaves#6
Open
balaraj74 wants to merge 7 commits intoacmpesuecc:mainfrom
Open
feat: Implement automatic host reassignment when host leaves#6balaraj74 wants to merge 7 commits intoacmpesuecc:mainfrom
balaraj74 wants to merge 7 commits intoacmpesuecc:mainfrom
Conversation
- Track hostId in server room objects to identify current host - Automatically promote first remaining participant when host disconnects - Notify all clients with 'host-promoted' message including new host details - Enable promoted joiners to acquire media and stream audio as new host - Add role-based permissions so only host can start/end calls - Maintain session continuity instead of closing when host leaves Fixes #1
feat: Implement automatic host reassignment when host leaves
|
Thank you from Opening this Pull Request, @balaraj74 ! A Maintainer will review it soon! |
Contributor
|
@balaraj74 where are you? I wanna discuss this in person. |
Author
|
I am in sem hall 1 5th row |
Contributor
|
okk coming |
Contributor
|
im in your row, in an acm hoodie |
Author
|
where are you |
Contributor
|
@balaraj74 im so sorry i went to sem hall 2 (accidentally instead of sem hall 1). Can you come here |
Author
|
ok i will |
Author
|
I am in sem hall 2 |
Contributor
where? |
Contributor
|
im in 5th row, wearing acm hoodie |
Author
|
Where are you |
Contributor
|
are u in sem hall 2 |
Author
|
No I came back |
Author
|
I search everywhere |
Author
|
Can I upload the screenshot for the review insted |
Author
- Display local audio wrapper and hide remote audio for new host - Show start and end buttons, hide exit button - Enable start button with updated text "Start Jam (You are Host)" - Add proper event listener to acquire audio and stream to participants - Fix button references at top of join.js file This ensures promoted hosts can actually stream audio instead of just receiving a notification without controls.
Previously, host promotion only worked when host disconnected/closed tab. Now when host clicks "End Jam" button: - Server removes host from room - Broadcasts client-left message - Promotes first remaining participant to host - Sends host-promoted notification to all clients This ensures session continuity whether host disconnects or ends session properly.
- Added detailed console.log statements throughout host promotion flow - Get fresh references to DOM elements when promoted to avoid stale references - Use inline-block display for buttons to ensure visibility - Added server-side logging to track promotion messages being sent - Created TESTING_GUIDE.md with step-by-step test instructions - Improved error handling and user feedback This will help debug and verify that host promotion is working correctly.
…ates - Server-side: Track host in active rooms, automatically promote first participant when host leaves (disconnect or end-call) - Server broadcasts room-update with participants and hostId to all clients - Client-side: Add helper functions for room state caching, UI toggles (enableHostUI/enableListenerUI) - Client-side: Handle host-promoted and room-update messages to sync host state - Client-side: Promoted participant gets host controls (Start/End Jam buttons) with proper label - UI: Display participants list with crown (👑) icon for current host - UI: Listener participants show Exit button, hosts show Start/End Jam buttons - Enhanced logging for debugging room state transitions
feat: Implement host reassignment with automatic promotion
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.




{PR Name}
Closes #1
Which issue(s) does this PR address?
Right now, if the host leaves or disconnects, everyone gets kicked out and the jam ends. That's pretty annoying when you're in the middle of a session! This fix makes sure the jam keeps going by automatically making someone else the host.
Why do we need this PR?
On the server side:
We now keep track of who's hosting each room
When the host leaves, we pick the next person in line to be the new host
Everyone gets notified about who the new host is
On the client side:
What logical changes are present in this PR?
When someone joins as host, we let the server know
If you get promoted to host, you'll see a popup telling you## Is there some additional work to be done later that is NOT covered in this PR?
give this
The new host can then start streaming audio to everyone else
How did you test the changes in this PR?
I ran the server locally and made sure:
Are there any breaking changes in this PR?
Everything starts up properly
The server correctly tracks who's the host
When the host disconnects, someone else gets promoted
The new host gets notified and can take over
Nope! Everything that worked before still works the same way.
Yeah, a few nice-to-haves for later:
Is there some additional work to be done later that is NOT covered in this PR?
give this
Better UI showing who's currently hosting
Let hosts manually pass control to someone else
Add some automated tests to make sure this keeps working