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

[FE] feat: 코드 실행 기능 추가 #161

Merged
merged 7 commits into from
Nov 29, 2023

Conversation

HBSPS
Copy link
Collaborator

@HBSPS HBSPS commented Nov 29, 2023

PR 설명

✅ 완료한 기능 명세

  • 코드 실행 기능 추가.

📸 스크린샷

image image

고민과 해결과정

  • socket의 id를 가져오는 과정에서 문제가 발생
    const handleExecCode = async () => {
      executionSocket = io(VITE_CODE_RUNNING_SOCKET_URL);
    
      console.log(VITE_CODE_RUNNING_SOCKET_URL);
    
      executionSocket.on('done', (response: RunCodeResponse) => {
        setExecResult(`${response.result}\n\n실행시간: ${dateFormatter(response.timestamp)}`);
        executionSocket.disconnect();
      });
    
      postRunCode(executionSocket.id, plainCode, languageName);
    };
    • 위의 코드에서 postRunCode 시점에 소켓 연결이 완료되지 않아 소켓 id가 undefined가 되는 문제 발생
    • 이를 해결하기 위해 소켓 연결이 완료되었을 때 해당 함수가 실행되어야 했음
    • 소켓의 이벤트 중 connect 이벤트를 활용
    const handleExecCode = async () => {
      executionSocket = io(VITE_CODE_RUNNING_SOCKET_URL);
    
      console.log(VITE_CODE_RUNNING_SOCKET_URL);
    
      executionSocket.on('done', (response: RunCodeResponse) => {
        setExecResult(`${response.result}\n\n실행시간: ${dateFormatter(response.timestamp)}`);
        executionSocket.disconnect();
      });
    
      executionSocket.on('connect', () => postRunCode(executionSocket.id, plainCode, languageName));
    };
    • 연결이 완료되었을 때 해당 함수를 실행하도록 하여, 소켓 연결에 오랜 시간이 걸리더라도 순차적으로 post 요청을 보낼 수 있도록 함

@HBSPS HBSPS added feature 기능 구현 FrontEnd 프론트엔드 관련 labels Nov 29, 2023
@HBSPS HBSPS requested a review from d0422 November 29, 2023 08:07
@HBSPS HBSPS self-assigned this Nov 29, 2023
Copy link
Collaborator

@d0422 d0422 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!
코드 리뷰 완료했습니다!

frontEnd/src/components/room/EditorSection.tsx Outdated Show resolved Hide resolved
frontEnd/src/components/room/EditorSection.tsx Outdated Show resolved Hide resolved
frontEnd/src/components/room/EditorSection.tsx Outdated Show resolved Hide resolved
@HBSPS HBSPS requested a review from d0422 November 29, 2023 08:15
Copy link
Collaborator

@d0422 d0422 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

@HBSPS HBSPS merged commit d09666a into boostcampwm2023:dev Nov 29, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 기능 구현 FrontEnd 프론트엔드 관련
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FE] 에디터 세부 기능 구현
2 participants