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

feat : room 종료 코드 수정 #46

Merged
merged 3 commits into from
Dec 7, 2024
Merged

feat : room 종료 코드 수정 #46

merged 3 commits into from
Dec 7, 2024

Conversation

minseok1015
Copy link
Collaborator

hostUser가 혼자 남았고 나갈 시에 방을 종료한다

public void setHostUserId() {
if (!userWriter.isEmpty()) {
this.hostUserId = userWriter.keySet().iterator().next();
} else {
this.roomThread.stopThread();
}
}

지금 roomThread는 껍데기 뿐일뿐, roomManger에서 관리하는 rooms 의 해당 room을 삭제해줘야 한다
그래서 다음과 같은 deleteRoom을 사용해서 room을 지우면서 Thread도 종료한다

public synchronized void deleteRoom(int roomId) {
Room room = rooms.remove(roomId);
if (room != null) {
room.stopThread(); // 방 쓰레드 중지
System.out.println("방 ID " + roomId + "가 삭제되었습니다.");
} else {
System.out.println("방 ID " + roomId + "를 찾을 수 없습니다.");
}
}

Copy link
Contributor

@ckkim817 ckkim817 left a comment

Choose a reason for hiding this comment

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

확인했습니다 고생하셨습니다 ~!

@minseok1015 minseok1015 merged commit a075f33 into main Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants