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

[BE] FEAT: 채팅 서버 - WebSocket 붙이기 #174 #181

Merged
merged 19 commits into from
Feb 17, 2025

Conversation

dahyun24
Copy link
Collaborator

@dahyun24 dahyun24 commented Feb 15, 2025

해당 사항 (중복 선택)

  • FEAT : 새로운 기능 추가 및 개선
  • FIX : 기존 기능 수정 및 정상 동작을 위한 간단한 추가, 수정사항
  • BUG : 버그 수정
  • REFACTOR : 결과의 변경 없이 코드의 구조를 재조정
  • TEST : 테스트 코드 추가
  • DOCS : 코드가 아닌 문서를 수정한 경우
  • REMOVE : 파일을 삭제하는 작업만 수행
  • RENAME : 파일 또는 폴더명을 수정하거나 위치(경로)를 변경
  • ETC : 이외에 다른 경우 - 어떠한 사항인지 작성해주세요.

설명

✅ Kickzo 팀원들 숙지 필수!!

[pub]

  • /app/connect
  • /app/send-message
  • /app/play-time

[sub]

user가 받는 정보

  • /topic/user/${userId}/friend-state
  • /topic/user/${userId}/notification

room에서 받는 정보

  • /topic/room/${roomId}/user-info
  • /topic/room/${roomId}/room-update
  • /topic/room/${roomId}/role-change
  • /topic/room/${roomId}/playlist-update
  • /topic/room/${roomId}/play-time
  • /topic/room/${roomId}/chat

🔗 관련 이슈

해결한 이슈: closed #174

📝 작업 내용

현재 userId = 4인 유저가 connect 된 상태 (4는 1,5와 친구)

  • 친구인 5가 online이 되면 친구인 4가 친구의 접속 상태 수신
<<< MESSAGE
destination:/topic/user/4/friend-state
content-type:text/plain;charset=UTF-8
subscription:sub-0
message-id:imlmepa2-0
content-length:30

{"userId":5,"status":"online"}
  • 친구가 offline이 되었을 경우
<<< MESSAGE
destination:/topic/user/4/friend-state
content-type:text/plain;charset=UTF-8
subscription:sub-0
message-id:imlmepa2-10
content-length:31

{"userId":1,"status":"offline"}

roomId = 1 에 join 하고 있는 유저

  • 채팅
<<< MESSAGE
destination:/topic/room/1/chat
content-type:application/json
subscription:sub-8
message-id:imlmepa2-6
content-length:58

{"roomId":1,"userId":1,"nickname":"User1","role":2,"profileImageUrl":null,"content":null,"message":"sfdsfsf"}
  • 방에 새로운 유저 입장
<<< MESSAGE
destination:/topic/room/1/user-info
content-type:text/plain;charset=UTF-8
subscription:sub-3
message-id:imlmepa2-12
content-length:91

{"roomId":1,"userInfo":{"userId":9,"role":2,"nickname":"kickickkk","profileImageUrl":null}}
  • 방 정보 update
<<< MESSAGE
destination:/topic/room/1/room-update
content-type:text/plain;charset=UTF-8
subscription:sub-4
message-id:imlmepa2-15
content-length:85

{"roomId":1,"title":null,"description":"방 설명을 바꿔보자.","isPublic":null}
  • playlist update
<<< MESSAGE
destination:/topic/room/1/playlist-update
content-type:text/plain;charset=UTF-8
subscription:sub-6
message-id:imlmepa2-17
content-length:121

{"roomId":1,"playlist":[{"url":"https://example.com/song1","order":0},{"url":"https://example.com/song2","order":1}]}
  • role 변경
<<< MESSAGE
destination:/topic/room/1/role-change
content-type:text/plain;charset=UTF-8
subscription:sub-5
message-id:imlmepa2-19
content-length:41

{"roomId":1,"targetUserId":9,"newRole":1}
  • play-time 변경
<<< MESSAGE
destination:/topic/room/1/play-time
content-type:text/plain;charset=UTF-8
subscription:sub-7
message-id:nrhhkaod-0
content-length:30

{"roomId":1,"playTime":12,"playerState":"playing"}

현재 파일 구조 (추후 dto 쪽 리팩토링 예정)

📂 config
├── JacksonConfig
├── KafkaConsumerConfig
├── KafkaProducerConfig
└── WebSocketConfig

📂 controller
└── WebSocketController

📂 dto
├── RoomEvent
📂 room
├── ChatMessage
├── NewUserJoinEvent
├── RoleChangeEvent
├── RoomData
└── UserInfoDto
📂 playlist
├── PlaylistItem
├── PlaylistUpdateEvent
└── PlayTime
📂 user
├── ConnectionEvent
├── FriendNotification
├── InvitationData
└── UserStatusEvent

📂 enums
└── EventType

📂 event
└── WebSocketEventListener

📂 repository
└── KafkaRepository

📂 service
├── KafkaConsumerService
├── MessagingService
├── PlaylistEventHandler
├── RoomEventHandler
└── WebSocketRoomService

📸 스크린샷(optional)

@dahyun24 dahyun24 added FEAT 새로운 기능 추가 및 개선 FIX 기존 기능을 수정할 경우(주로 안 좋았던 것에서 좋은 것으로) 🕹️BE 백엔드 작업 labels Feb 15, 2025
@dahyun24 dahyun24 added this to the 킥튜브 마일스톤 1 milestone Feb 15, 2025
@dahyun24 dahyun24 self-assigned this Feb 15, 2025
Copy link
Collaborator

@42inshin 42inshin left a comment

Choose a reason for hiding this comment

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

늦은 밤까지 작업하시느라 고생많으셨어요 다현님!

두 가지 건의드릴게 있습니다.ㅎㅎ

  1. sendMessage만 엔드포인트가 카멜케이스라 일관성있게 변경하면 좋을 것 같아요
  2. play-time의 JSON 값에도 playlistTime 대신 엔드포인트와 동일한 명칭이나 더 명확한 명칭으로 변경하면 좋을 것 같습니다. dto/의 파일명과 class 명도요.

바쁜 시점에서 넘어갈 수도 있을 부분이지만, 이런 부분들이 가독성, 유지보수성, 협업 효율성에 직결되는 부분이라 말씀드려요!

@juwon5272
Copy link
Collaborator

고생하셨습니다!! 문서화가 잘 되어 있어서 확인하기 편했습니다

저도 네이밍 관련해서 말씀드리자면

{"roomId":1,"userInfo":{"userId":9,"role":2,"nickname":"kickickkk","profileImageUrl":null}}
는 userInfo인데

{"roomId":1,"playlistJson":[{"url":"https://example.com/song1","order":0},{"url":"https://example.com/song2","order":1}]}
는 playlistJson이라 Json은 떼어도 좋을듯 합니다

- playlistJson에서 playlist로 변경
- playlistTime 변수를 playTime으로 변경
- endpoint send-message로 변경
@dahyun24
Copy link
Collaborator Author

수정하였습니다!

Copy link
Collaborator

@42inshin 42inshin left a comment

Choose a reason for hiding this comment

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

다시 확인했습니다! 고생많으셨어요!

Copy link
Collaborator

@KSK9820 KSK9820 left a comment

Choose a reason for hiding this comment

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

확인했습니다!!👍

@dahyun24 dahyun24 merged commit 09a96aa into dev Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕹️BE 백엔드 작업 FEAT 새로운 기능 추가 및 개선 FIX 기존 기능을 수정할 경우(주로 안 좋았던 것에서 좋은 것으로)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BE] FEAT: 채팅 서버 - ws 연결하기
4 participants