Skip to content

Commit 14e7547

Browse files
added webrtc feature on client side too
1 parent fbdaa7f commit 14e7547

File tree

7 files changed

+443
-38
lines changed

7 files changed

+443
-38
lines changed

admin/src/components/AdminLive.jsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ import Message from "../shared/Message";
77
import TabMonitor from "./TabMonitor/TabMonitor";
88
import { useNavigate } from "react-router-dom";
99
import CallEndIcon from "@mui/icons-material/CallEnd";
10+
11+
// Room ID for consistent room joining
12+
const DEFAULT_ROOM_ID = "admin-classroom-live";
13+
1014
const AdminLive = () => {
1115
const [alertMsg, setAlertMsg] = useState("");
16+
const [roomId, setRoomId] = useState(DEFAULT_ROOM_ID);
17+
const [isConnected, setIsConnected] = useState(false);
1218
const navigate = useNavigate();
1319
const { socket } = useSocket();
1420
const {
@@ -476,6 +482,22 @@ const AdminLive = () => {
476482
}
477483
}, [peer, myStream, sendStream]);
478484

485+
useEffect(() => {
486+
if (socket && !isConnected) {
487+
console.log("Joining room:", roomId);
488+
socket.emit("join-room", { roomId });
489+
setIsConnected(true);
490+
}
491+
492+
return () => {
493+
if (socket && isConnected) {
494+
console.log("Leaving room:", roomId);
495+
socket.emit("leave-room", { roomId });
496+
setIsConnected(false);
497+
}
498+
};
499+
}, [socket, roomId, isConnected]);
500+
479501
return (
480502
<div className="video-call flex h-auto w-full bg-gray-900 text-white">
481503
{" "}

client/src/App.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import Notes from "./Student Dashboard/Notes/Notes.jsx";
4444
import TeachersNotes from "./Student Dashboard/Notes/TeachersNotes.jsx";
4545
import Payfees from "./Student Dashboard/Payment/Payfees.jsx";
4646
import Verify from "./Student Dashboard/Payment/Verify.jsx";
47+
import StudentLive from "./Student Dashboard/Live/StudentLive.jsx";
4748

4849
// import ModalComponent from "./Modal/ModalComponent.jsx";
4950

@@ -100,6 +101,10 @@ function App() {
100101
path="/StudentDashboard/teachersNotes"
101102
element={<ProtectedRoute element={<TeachersNotes />} />}
102103
/>
104+
<Route
105+
path="/live-class"
106+
element={<ProtectedRoute element={<StudentLive />} />}
107+
/>
103108
<Route path="*" element={<NotFound />} />
104109
</Routes>
105110
</PeerProvider>

0 commit comments

Comments
 (0)