Skip to content

Commit

Permalink
Chore: 웹소켓 연결 관련 로그 구체화 (#28)
Browse files Browse the repository at this point in the history
* chore: 웹소켓 연결 종료 시 발생하는 상태 코드 로그 추가

* chore: 웹소켓 관련 로그 구체화

* refactor: 연결 후 문제를 전송하는 메서드 명 변경
  • Loading branch information
Youthhing authored Jun 22, 2024
1 parent c7db38b commit 1d226fe
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public void afterConnectionEstablished(WebSocketSession session) {
addMemberToSession(memberId, session);

if (MemberRoleGroup.hasRole(MemberRoleGroup.CLIENTS, memberRole)) {
sendQuiz(educationId, session);
sendCurrentOpenQuiz(educationId, session);
}

log.info("[세션 연결] {}", memberId);
log.info("[세션 연결] {}, 연결된 세션: {}", memberId, session.getId());
}

private void sendQuiz(Long educationId, WebSocketSession session) {
private void sendCurrentOpenQuiz(Long educationId, WebSocketSession session) {
Optional<Quiz> maybeQuiz = quizRepository.findByStatusAndEducationId(QuizStatus.QUIZ_ON,
educationId);

Expand All @@ -84,8 +84,7 @@ public void afterConnectionClosed(WebSocketSession session, CloseStatus status)
} else {
MANAGERS.remove(memberId);
}

log.info("[세션 종료] {}", memberId);
log.info("[세션 종료] {}, 종료 코드: {}", memberId, status);
}

public void accessQuiz(Long quizId) {
Expand Down Expand Up @@ -115,7 +114,7 @@ public void startQuiz(Long quizId) {
for (WebSocketSession clientSession : CLIENTS.values()) {
sendMessage(clientSession, response);
}
log.info("[전구 전송 후 사용자 : {}]", CLIENTS.keySet());
log.info("[풀이 신호 전송 후 사용자 : {}]", CLIENTS.keySet());
}

public void stopQuiz(Quiz quiz) {
Expand Down Expand Up @@ -154,10 +153,10 @@ private void addMemberToSession(String memberId, WebSocketSession session) {

if (MemberRoleGroup.hasRole(MemberRoleGroup.CLIENTS, role)) {
CLIENTS.put(memberId, session);
log.info("{} connect with Session {} in CLIENTS", memberId, session);
log.info("[부원 연결] : {} , 세션 ID : {}" , memberId, session.getId());
} else {
MANAGERS.put(memberId, session);
log.info("{} connect with Session {} in MANAGER", memberId, session);
log.info("[관리자 연결] : {} , 세션 ID : {}" , memberId, session.getId());
}
}

Expand Down

0 comments on commit 1d226fe

Please sign in to comment.