Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 상세 내용
언마운트 시 웹소켓 연결 해제를 하기 위해 코드를 보니 중복 구독 문제가 있었습니다. stomp client를 chat page 내에 여러 useEffect 훅 내에서 선언하여 구독, 연결, 해제 로직을 쓰다 보니, stomp client의 현재 상태가 제대로 반영되지 않는 문제가 있었습니다.
그래서 코드의 구조를 전체 수정했습니다. 하나의 stomp client 객체로 관리하고, 이와 구독 로직들을 함수로 만들어 ws instance로 분리하였습니다. 이로 인해 stomp client 객체 하나만 관리돼서 문제 없이 연결, 해제가 가능합니다.
ws instance로 웹소켓 함수들을 분리하는 과정에서 소켓에서 구독하는 roomUserList, userList 들이 subscribeToRoom 콜백 내부에 있어서 채팅방의 채팅 메세지가 도착할 때만 실행되는 문제가 있어서 콜백 밖으로 분리하여서, 이제 /topic/users와 /topic/room-users 토픽으로 메세지가 올 때마다 실시간으로 전체 사용자 목록, 방 사용자 목록이 반영되도록 수정했습니다.
#️⃣ 이슈 번호
💬 리뷰 요구사항
⏰ 현재 버그
📷 스크린샷(선택)
🔗 참고 자료(선택)