Skip to content

Commit

Permalink
FEAT: 웹소켓 + stomp 채팅 기능
Browse files Browse the repository at this point in the history
  • Loading branch information
minnieming committed Apr 6, 2024
1 parent de03de6 commit e50abd2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,4 @@ public void message(ChatDto.ChatMessageDto message) {

messagingTemplate.convertAndSend("/sub/chat/room/" + message.getRoomId(), message);
}

@GetMapping("/chat/room/{roomId}/message")
public List<ChatDto.ChatMessageDto> loadMessage (@PathVariable Long roomId,
@AuthenticationPrincipal UserDetailsImpl userDetails) {
return chatMessageService.loadMessage(roomId, userDetails.getUser());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.nawabali.nawabali.controller;

import com.nawabali.nawabali.dto.ChatDto;
import com.nawabali.nawabali.repository.ChatMessageRepository;
import com.nawabali.nawabali.repository.ChatRoomRepository;
import com.nawabali.nawabali.service.ChatMessageService;
import com.nawabali.nawabali.service.ChatRoomService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
Expand All @@ -17,6 +19,7 @@ public class ChatRoomController {

private final ChatRoomService chatRoomService;
private final ChatRoomRepository chatRoomRepository;
private final ChatMessageService chatMessageService;

// 채팅 리스트 화면
@GetMapping("/room")
Expand Down Expand Up @@ -58,4 +61,10 @@ public List<ChatDto.ChatRoomDto> roomInfo(@RequestParam String name) {
return chatRoomService.roomInfo(name);
// return chatRoomRepository.findRoomById(roomId);
}

// ChatController는 웹소켓 endpoint를 담당해서 일반적인 http요청을 처리하지 않아 이곳으로 옮겨 놓음.
// @GetMapping("/room/{roomId}/message")
// public List<ChatDto.ChatMessageDto> loadMessage (@PathVariable Long roomId) {
// return chatMessageService.loadMessage(roomId);
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public class ChatMessageService {
private final ChatMessageRepository chatMessageRepository;
private final ChatRoomRepository chatRoomRepository;




// 대화 조회
public List<ChatDto.ChatMessageDto> loadMessage(Long roomId, User user) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public ResponseEntity<SignupDto.SignupResponseDto> signup(SignupDto.SignupReques
.build();
userRepository.save(user);
User responseUser = userRepository.findByEmail(user.getEmail())
.orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND));
.orElseThrow(()-> new CustomException(ErrorCode.MEMBER_NOT_FOUND));
return ResponseEntity.ok(new SignupDto.SignupResponseDto(responseUser.getId()));
}

Expand Down

0 comments on commit e50abd2

Please sign in to comment.