Skip to content

Conversation

@sunninz
Copy link
Contributor

@sunninz sunninz commented Sep 15, 2025

👀 관련 이슈

#304

✨ 작업한 내용

로직 흐름
handshake

  1. 클라이언트가 /ws-connect로 web socket 연결 요청
  2. WebSocketConfig를 통해 STOMP 프로토콜로 업그레이드 및 Handshake 수행
  3. 이후 클라이언트는 /pub으로 메시지를 발행하고, /sub을 통해 메시지 수신 가능

메시지 송수신과정

  1. 클라이언트에서 /pub/lecture/{lectureId}로 메시지 전송
  2. 서버에서 수신 후, Redis Pub/Sub으로 모든 구독자에게 브로드캐스트 & redis list에 채팅 내용 저장
  3. Redis → RedisMessageSubscriber를 통해 메시지를 다시 브로드캐스트
  4. STOMP를 통해 /sub/lecture/{lectureId}로 메시지가 전달되어 클라이언트에서 수신

주요 파일 설명

  1. WebSocketConfig: WebSocket 및 STOMP 기본 설정 (엔드포인트 등록, 브로커 경로 지정)
  2. StompChannelInterceptor: STOMP 연결 시 인터셉트하여 JWT 인증 및 사용자 정보 추출
  3. StompPrincipal: 인증된 사용자 정보를 WebSocket 세션에 저장하기 위한 커스텀 Principal 객체
  4. ChatController: /pub/lecture/{lectureId}로 전달된 메시지를 수신
  5. ChatService: 수신된 메시지를 Redis에 저장하고 Redis 채널로 발행하는 로직 처리
  6. RedisMessageSubscriber: Redis로부터 발행된 메시지를 수신 → STOMP를 통해 해당 채널 구독자에게 메시지 전파

🌀 PR Point

🍰 참고사항

추후 이슈에서 이전 내용 불러오기와 종료 이후에 RDB에 저장하는 로직 구현하겠습니다.

📷 스크린샷 또는 GIF

X

@sunninz sunninz self-assigned this Sep 15, 2025
@sunninz sunninz added the ✨ Feat 새 기능 개발 label Sep 15, 2025
@sunninz sunninz linked an issue Sep 15, 2025 that may be closed by this pull request
10 tasks
@sunninz sunninz merged commit f123729 into dev Sep 21, 2025
1 check passed
@sunninz sunninz deleted the Feat/#304/chatting branch September 21, 2025 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feat 새 기능 개발

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ 실시간 채팅 기능 구현

4 participants