diff --git a/client/src/MediaControl.tsx b/client/src/MediaControl.tsx index c2c32de..14fd06d 100644 --- a/client/src/MediaControl.tsx +++ b/client/src/MediaControl.tsx @@ -9,6 +9,7 @@ import Videocam from "@mui/icons-material/Videocam"; import Box from "@mui/material/Box"; import IconButton from "@mui/material/IconButton"; import useWebSocket, { ReadyState } from "react-use-websocket"; +import { Session } from "./GlobalContext"; import WebRTCStatus from "./WebRTCStatus"; import Moveable from "react-moveable"; import { flushSync } from "react-dom"; @@ -17,15 +18,6 @@ const debug = true; // When true, do not send host candidates to the signaling server. Keeps TURN relays preferred. const FILTER_HOST_CANDIDATES = false; // Temporarily disabled to test direct connections -export type Session = { - session_id: string; - peer_name: string; - has_media?: boolean; // Whether this user provides audio/video streams - attributes?: Record; - name: string; - id: string; -}; - /* ---------- Synthetic Tracks Helpers ---------- */ // Helper to hash a string to a color @@ -1130,13 +1122,12 @@ const MediaAgent = (props: MediaAgentProps) => { // Join lobby when media is ready useEffect(() => { - if (!session) return; if (media && joinStatus.status === "Not joined" && readyState === ReadyState.OPEN) { console.log(`media-agent - Initiating media join for ${session.name}`); setJoinStatus({ status: "Joining" }); sendJsonMessage({ type: "join", data: {} }); } - }, [media, joinStatus.status, sendJsonMessage, readyState, session]); + }, [media, joinStatus.status, sendJsonMessage, readyState, session.name]); // Update local peer in peers list useEffect(() => { @@ -1190,7 +1181,6 @@ const MediaAgent = (props: MediaAgentProps) => { console.log(`media-agent - Requesting access to local audio/video`); const attempt = { get_audio: true, get_video: true }; let media = null; - if (!session) { return new MediaStream(); } // Try to get user media with fallback while (attempt.get_audio || attempt.get_video) { @@ -1271,7 +1261,7 @@ const MediaAgent = (props: MediaAgentProps) => { hasRealVideo, }); return finalMedia; - }, [session]); + }, [session.name]); // Initialize media once useEffect(() => {