Refactor: websocket 도메인 리팩토링 (#214) #219
Merged
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.
📌 개요
WebSocket의 보안, 성능, 구조를 개선하는 전반적인 리팩토링을 진행했습니다.
🔨 작업 내용
인증된 Principal 사용 : 메시지 핸들러(WebSocketMessageController)에서 클라이언트가 전송한 userId 대신, 서버에서 인증된 Principal 객체를 사용하도록 변경하여 보안을 강화했습니다.
온라인 유저 수 조회 성능 개선 : Redis KEYS 명령어를 사용하는 기존 로직을 제거하고, O(1) 복잡도의 카운터 방식으로 전체 온라인 유저 수를 조회하도록 최적화하여 서버 부하를 크게 줄였습니다.
예외 처리 중앙화 : WebSocketMessageController 내 반복적인 try-catch 구문을 @MessageExceptionHandler로 통합하여 코드 중복을 제거하고 가독성 및 유지보수성을 향상시켰습니다.
🔗 관련 이슈
Closes #214
✅ 체크리스트