-
Notifications
You must be signed in to change notification settings - Fork 90
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Issue Description
When clicking the start broadcast button multiple times in quick succession, multiple WebRTC sessions are created simultaneously, leading to:
- Multiple audio streams
- Resource leaks
- Inconsistent state management
- Potential memory leaks
Current Behavior
The current implementation allows multiple sessions to be created before previous sessions are properly terminated.
Code Fix
// Add these state variables
const [isConnecting, setIsConnecting] = useState(false);
const [isSessionActive, setIsSessionActive] = useState(false);
// Replace the current startSession function with this protected version
async function startSession() {
// Prevent multiple connection attempts
if (isConnecting || isSessionActive) {
console.warn('Session already active or connecting');
return;
}
try {
setIsConnecting(true);
setStatus('Requesting microphone access...');
// ... rest of the existing connection logic ...
} catch (err) {
console.error('startSession error:', err);
setStatus(`Error: ${err}`);
stopSession();
} finally {
setIsConnecting(false);
}
}cameronking4
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working