Skip to content

Commit

Permalink
mod #121: 방 입장 / 퇴장 시 해당 유저의 닉네임 value에 반환되도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoguoo committed Mar 18, 2024
1 parent 2c4fd39 commit 4a1b565
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ public class MessageResponse {
private final String value;
private final String timestamp = LocalDateTime.now().toString();

public static MessageResponse enterRoom(Long memberId) {
public static MessageResponse enterRoom(Long memberId, String nickname) {
return new MessageResponse(
memberId,
MessageType.ENTER_ROOM,
null
nickname
);
}

public static MessageResponse quitRoom(Long memberId) {
public static MessageResponse quitRoom(Long memberId, String nickname) {
return new MessageResponse(
memberId,
MessageType.QUIT_ROOM,
null
nickname
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,30 @@ public class ChatServiceImpl implements ChatService {
public void enterRoom(String roomShortUuid, Long memberId) {
Member member = memberService.getMemberById(memberId);
roomMemberService.joinRoomByRoomShortUuid(roomShortUuid, member);
messageService.sendMessage(roomShortUuid, MessageResponse.enterRoom(memberId));
messageService.sendMessage(
roomShortUuid,
MessageResponse.enterRoom(
memberId,
member.getNickname()
)
);
}

@Override
public void quitRoom(String roomShortUuid, Long memberId) {
Member member = memberService.getMemberById(memberId);
RoomExitResponse roomExitResponse = roomMemberService.exitRoomByMemberId(memberId);
if (roomExitResponse.isHostChanged()) {
messageService.sendMessage(roomShortUuid,
MessageResponse.changeHost(roomExitResponse.getNewHostId()));
}
messageService.sendMessage(roomShortUuid, MessageResponse.quitRoom(memberId));
messageService.sendMessage(
roomShortUuid,
MessageResponse.quitRoom(
memberId,
member.getNickname()
)
);
}

@Override
Expand Down

0 comments on commit 4a1b565

Please sign in to comment.