Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix: 참여자 페이지 게스트 토큰 임시 추가 #267

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { useNavigate, useLocation } from "react-router-dom";
import axios from "axios";

import VolumeMeter from "./VolumeMeter";
import useAuth from "@/hooks/useAuth";

import PlayIcon from "@/assets/svgs/play.svg?react";
import StopIcon from "@/assets/svgs/stop.svg?react";
import MicOnIcon from "@/assets/svgs/micOn.svg?react";
Expand All @@ -15,7 +17,6 @@ import Modal from "@/components/Modal/Modal";
import { useToast } from "@/components/Toast/useToast";
import { ICanvasData, saveCanvasData } from "@/utils/fabricCanvasUtil";
import { convertMsTohhmm } from "@/utils/convertMsToTimeString";
import useAuth from "@/hooks/useAuth";
import calcNormalizedVolume from "@/utils/calcNormalizedVolume";

import selectedMicrophoneState from "@/stores/stateSelectedMicrophone";
Expand All @@ -30,9 +31,6 @@ interface HeaderInstructorControlsProps {
}

const HeaderInstructorControls = ({ setLectureCode, setLectureTitle }: HeaderInstructorControlsProps) => {
const { checkAuth } = useAuth();
const isLectureStartRef = useRef<boolean>(false);

const [isMicOn, setIsMicOn] = useState(true);
const [isStartModalOpen, setIsStartModalOpen] = useState(false);
const [isCloseModalOpen, setIsCloseModalOpen] = useState(false);
Expand All @@ -46,7 +44,9 @@ const HeaderInstructorControls = ({ setLectureCode, setLectureTitle }: HeaderIns
const setInstructorSocket = useSetRecoilState(instructorSocketState);
const navigate = useNavigate();
const showToast = useToast();
const { checkAuth } = useAuth();

const isLectureStartRef = useRef<boolean>(false);
const timerIdRef = useRef<number | null>(null); // 경과 시간 표시 타이머 id
const onFrameIdRef = useRef<number | null>(null); // 마이크 볼륨 측정 타이머 id
const managerRef = useRef<Manager>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { useNavigate, useLocation } from "react-router-dom";
import axios from "axios";

import VolumeMeter from "./VolumeMeter";
import useAuth from "@/hooks/useAuth";

import StopIcon from "@/assets/svgs/stop.svg?react";
import MicOnIcon from "@/assets/svgs/micOn.svg?react";
import MicOffIcon from "@/assets/svgs/micOff.svg?react";
Expand Down Expand Up @@ -54,10 +56,11 @@ const HeaderParticipantControls = ({ setLectureCode, setLectureTitle }: HeaderPa

const navigate = useNavigate();
const showToast = useToast();
const { checkAuth } = useAuth();

const roomid = new URLSearchParams(useLocation().search).get("roomid") || "999999";
const sampleAccessToken =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InBsYXRpbm91c3MwMkBnbWFpbC5jb20iLCJpYXQiOjE3MDE2ODUyMDYsImV4cCI6MTcwMjcyMjAwNn0.gNXyIPGyaBKX5KjBVB6USNWGEc3k9ZruCTglCGeLo3Y";
const guestAccessToken =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InBsYXRpbm91c3MxNEBnbWFpbC5jb20iLCJpYXQiOjE3MDIzNjA4OTMsImV4cCI6MTcwMzM5NzY5M30.nSbiGLp03Zmz0xNdlmAKDWEAuPXJfZu4MBwVW9JW6Yk";
const pc_config = {
iceServers: [
{
Expand All @@ -67,6 +70,7 @@ const HeaderParticipantControls = ({ setLectureCode, setLectureTitle }: HeaderPa
};

useEffect(() => {
checkAuth();
setDidMount(true);
const backToMain = () => {
leaveLecture({ isLectureEnd: false });
Expand Down Expand Up @@ -158,10 +162,11 @@ const HeaderParticipantControls = ({ setLectureCode, setLectureTitle }: HeaderPa
// guest 판별 로직 추가 예정
socketRef.current = managerRef.current.socket("/enter-room", {
auth: {
accessToken: sampleAccessToken,
accessToken: guestAccessToken,
refreshToken: "test"
}
});
// accessToken: localStorage.getItem("token") ? localStorage.getItem("token") : "",

if (!socketRef.current) return;
socketRef.current.on(`serverAnswer`, (data) => handleServerAnswer(data));
Expand Down Expand Up @@ -293,10 +298,11 @@ const HeaderParticipantControls = ({ setLectureCode, setLectureTitle }: HeaderPa
if (!managerRef.current) return;
lectureSocketRef.current = managerRef.current.socket("/lecture", {
auth: {
accessToken: sampleAccessToken,
accessToken: guestAccessToken,
refreshToken: "sample"
}
});
// accessToken: localStorage.getItem("token") ? localStorage.getItem("token") : "",
setParticipantSocket(lectureSocketRef.current);
lectureSocketRef.current.on("ended", () => handleLectureEnd());
lectureSocketRef.current.on("update", (data) => handleWhiteboardUpdate(data));
Expand Down