Skip to content

Commit

Permalink
FE: [fix] 불필요한 state 삭제 및 api 추가 #53
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeona01 committed Dec 8, 2024
1 parent aecb6eb commit 43e41f4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
18 changes: 18 additions & 0 deletions src/frontend/eyesee-user/src/apis/video.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { api } from ".";

export const videoPost = async (
userId: number,
startTime: string,
endTime: string,
video: File
) => {
const formData = new FormData();

formData.append("userId", userId.toString());
formData.append("startOffset", new Date(startTime).toISOString());
formData.append("endOffset", new Date(endTime).toISOString());
formData.append("video", video);

const response = await api.post(`/cheatings/video`, formData);
return response.data;
};
9 changes: 3 additions & 6 deletions src/frontend/eyesee-user/src/app/exam-room/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@ import { useStore } from "@/store/useStore";
const RealTimeVideoPage = () => {
// 수험자 실시간 화면이 담기는 공간
const videoRef = useRef<HTMLVideoElement>(null);

// 캠버스에서 프레임을 캡쳐
const canvasRef = useRef<HTMLCanvasElement>(null);

// 웹소켓 연결 관리
const socketRef = useRef<WebSocket | null>(null);

// 실시간 비디오 녹화
const mediaRecorderRef = useRef<MediaRecorder | null>(null);

// 미디어 스트림을 저장
const streamRef = useRef<MediaStream | null>(null);

// 녹화된 비디오 데이터를 청크 단위로 저장
const recordedChunksRef = useRef<Blob[]>([]);
const captureIntervalRef = useRef<number | null>(null);

const [isProcessing, setIsProcessing] = useState(false);

const userId = useStore(useUserStore, (state) => state.userId);
const examId = useStore(useUserStore, (state) => state.examId);

Expand Down Expand Up @@ -120,8 +121,6 @@ const RealTimeVideoPage = () => {

const startRecordingForCheating = async () => {
try {
setIsProcessing(true);

// 이미 녹화 중이면 기존 녹화 중지
if (mediaRecorderRef.current) {
mediaRecorderRef.current.stop();
Expand All @@ -138,11 +137,9 @@ const RealTimeVideoPage = () => {
if (mediaRecorderRef.current) {
mediaRecorderRef.current.stop();
}
setIsProcessing(false);
}, 5000);
} catch (error) {
console.error("부정행위 이벤트 처리 중 오류", error);
setIsProcessing(false);
}
};

Expand Down

0 comments on commit 43e41f4

Please sign in to comment.