Skip to content

Commit

Permalink
#199 feat: 채팅 전송 API 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sojungpp committed Apr 12, 2023
1 parent c5599cd commit 58bca91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public void enter(ChatMessage message) throws BaseException {
chatService.enter(message);
}

// 채팅 전송
@MessageMapping(value = "/chats/message")
public void message(ChatMessage message) throws BaseException{
chatService.message(message);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ public void enter(ChatMessage message) throws BaseException {
message.setMessage(user.getNickname() + "님이 채팅방에 참여하였습니다.");
template.convertAndSend("/subscribe/rooms/" + message.getChatRoomId(), message.getMessage());
}

public void message(ChatMessage message) throws BaseException {
User user = userRepository.findByUserIdxAndStatusEquals(message.getUserIdx(), ACTIVE_STATUS).orElseThrow(() -> new BaseException(INVALID_USER_IDX));
template.convertAndSend("/sub/message/" + message.getChatRoomId(), message);
}
}

0 comments on commit 58bca91

Please sign in to comment.