Skip to content

Commit

Permalink
Merge pull request #35 from catchroom/develop
Browse files Browse the repository at this point in the history
Fix : ๋ฉ”์„ธ์ง€ ๋ฆฌ์ŠคํŠธ ์ตœ์‹ ์ˆœ ์ •๋ ฌ ๋กœ์ง fix
  • Loading branch information
HyemIin authored Jan 20, 2024
2 parents 8898371 + 003b543 commit 3a83f06
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/main/java/com/catchroom/chat/global/pubsub/RedisSubscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,17 @@ public void sendRoomList(String publishMessage) {
ChatMessageDto chatMessage = objectMapper.readValue(publishMessage, MessageSubDto.class).getChatMessageDto();
List<ChatRoomListGetResponse> chatRoomListGetResponseList = objectMapper.readValue(publishMessage, MessageSubDto.class)
.getList();

Collections.sort(chatRoomListGetResponseList, new ChatRoomListGetResponseComparator());
Comparator<ChatRoomListGetResponse> comparator = new Comparator<ChatRoomListGetResponse>() {
@Override
public int compare(ChatRoomListGetResponse o1, ChatRoomListGetResponse o2) {
if (o1.getChatMessageDto() != null && o2.getChatMessageDto() != null) {
return LocalDateTime.parse(o1.getChatMessageDto().getTime()).withNano(0).compareTo(LocalDateTime.parse(o2.getChatMessageDto().getTime()).withNano(0));
} else {
return 0;
}
}
};
Collections.sort(chatRoomListGetResponseList,comparator);
// ๋กœ๊ทธ์ธ ์œ ์ € ์ฑ„ํŒ…๋ฐฉ ๋ฆฌ์ŠคํŠธ ์ตœ์‹ ํ™”
messagingTemplate.convertAndSend("/sub/chat/roomlist/" + chatMessage.getUserId(), chatRoomListGetResponseList);
} catch (Exception e) {
Expand All @@ -59,12 +68,3 @@ public void sendRoomList(String publishMessage) {

}

class ChatRoomListGetResponseComparator implements Comparator<ChatRoomListGetResponse> {
@Override
public int compare(ChatRoomListGetResponse response1, ChatRoomListGetResponse response2) {
LocalDateTime time1 = LocalDateTime.parse(response1.getChatMessageDto().getTime());
LocalDateTime time2 = LocalDateTime.parse(response2.getChatMessageDto().getTime());
return time1.compareTo(time2);
}
}

0 comments on commit 3a83f06

Please sign in to comment.