-
Notifications
You must be signed in to change notification settings - Fork 3
[feat] 게임방 퇴장 및 삭제 구현 #33
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
Conversation
# Conflicts: # backend/src/main/java/io/f1/backend/domain/game/app/RoomService.java
| } | ||
|
|
||
| @Transactional(readOnly = true) | ||
| public Long getQuizMinId() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[L4-변경제안]
quizRepository.findAll().stream().findFirst(); 이런 형식으로 해당 메서드를 대체할 수 있을 것 같습니다 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[L4-변경제안]
quizRepository.findAll().stream().findFirst(); 이런 형식으로 해당 메서드를 대체할 수 있을 것 같습니다 !
인덱스로 제일 작은 id값 가져오는게 더 빠르지않나요 ?.?
findAll()하면 모든 값을 가져오고 stream 돌리는거라서 id만 필요한 상황이라 findAll()은 과하지않나(?)라는 생각이 듭니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
최소인 id 값을 가지는 행을 찾아야하기 때문에 테이블 전체를 도는 것은 똑같다고 생각합니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
최소인 id 값을 가지는 행을 찾아야하기 때문에 테이블 전체를 도는 것은 똑같다고 생각합니다
id값은 pk값으로 인덱스가있기 때문에 모든 테이블을 돌지 않는다고 알고있는데 ,, 잘못 알고있는걸까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ORDER BY절을 명시를 안해주면 순서가 보장되지 않는다고 알고 있습니다 ! PK를 지정하면 테이블 데이터 자체는 PK 기준으로 클러스터링되어 저장되지만, 쿼리에서 ORDER BY pk를 명시하지 않으면 반환 결과의 순서는 보장되지 않는다고 알고 있습니다 !
[참고링크] https://hudi.blog/mysql-no-order-by-no-sorting-guarantee/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ORDER BY절을 명시를 안해주면 순서가 보장되지 않는다고 알고 있습니다 ! PK를 지정하면 테이블 데이터 자체는 PK 기준으로 클러스터링되어 저장되지만, 쿼리에서 ORDER BY pk를 명시하지 않으면 반환 결과의 순서는 보장되지 않는다고 알고 있습니다 ! [참고링크] https://hudi.blog/mysql-no-order-by-no-sorting-guarantee/
MIN(id)와 같은 쿼리를 처리할 때, 데이터베이스 옵티마이저는 전체 인덱스(또는 테이블)를 스캔하는 대신, B-Tree 인덱스의 루트에서부터 가장 왼쪽의 리프 노드로 직접 이동하여 최솟값을 매우 빠르게 찾아낸다고합니다 !
+) 별개로 orderby 명시 안하면 순서 보장 안되는건 얻어갑니다.. 홍홍
https://dev.mysql.com/doc/refman/8.4/en/mysql-indexes.html
https://mangkyu.tistory.com/286
| playerListResponse); | ||
| } | ||
|
|
||
| public RoomExitData exitRoom(Long roomId, String sessionId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[L4-변경제안]
메서드로 분리할 수 있는 로직들은 분리하는 것이 가독성이 좋아보입니다 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안그래도 private static 으로 몇개는 분리해놨는데, 요 부분은 동시성 진행하면서 더 분리해보도록 하겠습니다! 감사합니다
|
|
||
| if (playerSessionMap.size() == 1 && playerSessionMap.get(sessionId) != null) { | ||
| roomRepository.removeRoom(roomId); | ||
| return new RoomExitData(destination, null, null, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[L4-변경제안]
생성자 형식으로 null을 삽입하는 것 보다 값이 들어갈 필드에 대해서만 Builder를 열어두는 것도 좋다고 생각합니다 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
헉쓰! record로 만들어서 생각 못했는데 그 부분이 더 좋아보이네요. 반영하겠습니다. 감사합니다!
|
[L5-참고의견] |
헐! 게임중에는 사용자리스트를 유지해야하기때문에 있는 필드군요! 이해완료입니다. 감사합니다 |
backend/src/main/java/io/f1/backend/domain/game/app/RoomService.java
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| SystemNoticeResponse systemNoticeResponse = | ||
| new SystemNoticeResponse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[L4-변경제안]
메시지 생성 로직은 매퍼 클래스로 분리하면 좋을것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 객체에서 변환(?) 하는 개념이라고 생각못했는데 듣고보니 옮기는게 맞겠군요. 감사합니다!
|
|
||
| // todo security | ||
| Player player = new Player(1L, "빵야빵야"); | ||
| Player player = createPlayer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[L3-중요질문]
새 플레이어가 방에 입장했을 때, SYSTEM NOTICE타입의 입장메시지가 브로드캐스팅되지 않는것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
웹소켓 명세에 빠져있는 부분이라 놓쳤군요..! 감사합니다. 추가하겠습니다. 😇
# Conflicts: # backend/src/main/java/io/f1/backend/domain/quiz/app/QuizService.java # backend/src/main/java/io/f1/backend/domain/quiz/dao/QuizRepository.java
# Conflicts: # backend/src/main/java/io/f1/backend/domain/game/app/RoomService.java # backend/src/main/java/io/f1/backend/domain/game/dto/RoomExitData.java # backend/src/main/java/io/f1/backend/domain/game/websocket/GameSocketController.java # backend/src/main/java/io/f1/backend/domain/quiz/app/QuizService.java # backend/src/main/java/io/f1/backend/domain/quiz/dao/QuizRepository.java
| public RoomCreateResponse saveRoom(RoomCreateRequest request, Map<String, Object> loginUser) { | ||
| public RoomCreateResponse saveRoom(RoomCreateRequest request) { | ||
|
|
||
| Long minQuizId = quizService.getQuizMinId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[L4-변경제안]
변수에서는 minQuizId고, 메서드명은 QuizMinId인데, 이걸 하나로 통일하는 것이 좋지 않을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[L4-변경제안] 변수에서는
minQuizId고, 메서드명은QuizMinId인데, 이걸 하나로 통일하는 것이 좋지 않을까요?
분명.. 통일했다고 생각했는데!! 요런 디테일... 감사합니다.
jiwon1217
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다 !
|
|
||
| PlayerListResponse playerListResponse = toPlayerListResponse(room); | ||
|
|
||
| return new RoomExitData(destination, playerListResponse, systemNoticeResponse, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removedRoom이라는 필드가 방이 삭제되었을 때 true로 사용되고 있지 않은 것 같은데 이 필드의 용도는 뭔지 궁금합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removedRoom이라는 필드가 방이 삭제되었을 때true로 사용되고 있지 않은 것 같은데 이 필드의 용도는 뭔지 궁금합니다.
방이 삭제되었을때는 따로 응답 값을 보내주지 보내주지 않아도되고, 삭제가 안되었을때만 응답값을 보내줘야하기에 구분 필드를 넣었습니다. 원래 record로 사용시에는 true로 생성했는데, 빌더로 바꾸면서 true가 빠진 것 같습니다! 알려주셔서.. 감사합니다 ^_^
|
|
||
| String destination = roomExitData.getDestination(); | ||
|
|
||
| if (!roomExitData.isRemovedRoom()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아, 여기서 사용되는군요!! 확인했습니다.
silver-eunjoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다 ! 굉장하십니다.
🛰️ Issue Number
🪐 작업 내용
pub/room/exit/{roomId} 요청으로 방 퇴장 구현
security, 퀴즈 api 적용
그 외
논의사항
재연결 처리 시 세션 id가 다르게 들어오는데 현재 playerSessionMap 은 <sessionId, Player> 로 설계되어있고,
player안에 userId가 들어있으므로 재연결 시 확인로직이 비효율적이라고 생각합니다.
그래서 <UserId, SessionId> Map 이런 세션 관리 맵을 추가로 하나 더 만들고싶은데 어떻게 생각하시나요?
그리고 Player안에 있는 ConnectionState 의 용도를 잘 모르겠습니다.
현재는 룸 입장시 RoomMap에 넣어주고 퇴장 시 roomMap에서 제거를 해주는데 . 이 상태값이 왜 필요한건지 설명해주실 분 괌 🏝️
📚 Reference
✅ Check List