feat : rabbitmq 추가
This commit is contained in:
parent
d94a09eea6
commit
ec0331e263
@ -22,6 +22,9 @@ dependencies {
|
|||||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||||
implementation 'mysql:mysql-connector-java:8.0.33'
|
implementation 'mysql:mysql-connector-java:8.0.33'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-websocket'
|
implementation 'org.springframework.boot:spring-boot-starter-websocket'
|
||||||
|
implementation 'org.springframework.boot:spring-boot-starter-amqp'
|
||||||
|
implementation 'org.springframework.boot:spring-boot-starter-reactor-netty'
|
||||||
|
testImplementation 'org.springframework.amqp:spring-rabbit-test'
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
implementation group: 'io.livekit', name: 'livekit-server', version: '0.6.1'
|
implementation group: 'io.livekit', name: 'livekit-server', version: '0.6.1'
|
||||||
implementation 'org.projectlombok:lombok'
|
implementation 'org.projectlombok:lombok'
|
||||||
|
@ -38,6 +38,9 @@ public class BoardController {
|
|||||||
){
|
){
|
||||||
List<ResponseBoardSummaryDto> boardSummaries = boardService.findBoards(pageNo, category, lectureId);
|
List<ResponseBoardSummaryDto> boardSummaries = boardService.findBoards(pageNo, category, lectureId);
|
||||||
|
|
||||||
|
if(boardSummaries.isEmpty())
|
||||||
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
|
|
||||||
return new ResponseEntity<>(boardSummaries, HttpStatus.OK);
|
return new ResponseEntity<>(boardSummaries, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,35 +14,39 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
public class WebConfiguration implements WebMvcConfigurer {
|
public class WebConfiguration implements WebMvcConfigurer {
|
||||||
|
|
||||||
private JWTInterceptor jwtInterceptor;
|
// private JWTInterceptor jwtInterceptor;
|
||||||
|
//
|
||||||
public WebConfiguration(JWTInterceptor jwtInterceptor) {
|
// public WebConfiguration(JWTInterceptor jwtInterceptor) {
|
||||||
super();
|
// super();
|
||||||
this.jwtInterceptor = jwtInterceptor;
|
//
|
||||||
}
|
// this.jwtInterceptor = jwtInterceptor;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
// @Override
|
||||||
registry
|
// public void addCorsMappings(CorsRegistry registry) {
|
||||||
.addMapping("/**")
|
// registry
|
||||||
.allowedOrigins("http://i11a701.p.ssafy.io/", "http://localhost:5173", "http://localhost:4173")
|
// .addMapping("/**")
|
||||||
.allowedMethods(HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PUT.name(),
|
// .allowedOrigins("http://i11a701.p.ssafy.io/", "http://localhost:5173", "http://localhost:4173")
|
||||||
HttpMethod.DELETE.name(), HttpMethod.HEAD.name(), HttpMethod.OPTIONS.name(),
|
// .allowedMethods(HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PUT.name(),
|
||||||
HttpMethod.PATCH.name())
|
// HttpMethod.DELETE.name(), HttpMethod.HEAD.name(), HttpMethod.OPTIONS.name(),
|
||||||
.allowCredentials(true)
|
// HttpMethod.PATCH.name())
|
||||||
.allowedHeaders("*")
|
// .allowCredentials(true)
|
||||||
.maxAge(1800); // Pre-flight Caching
|
// .allowedHeaders("*")
|
||||||
}
|
// .maxAge(1800); // Pre-flight Caching
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
// @Override
|
||||||
registry.addResourceHandler("/img/**").addResourceLocations("classpath:/static/assets/img/");
|
// public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
registry.addResourceHandler("/*.html**").addResourceLocations("classpath:/static/");
|
// registry.addResourceHandler("/img/**").addResourceLocations("classpath:/static/assets/img/");
|
||||||
}
|
// registry.addResourceHandler("/*.html**").addResourceLocations("classpath:/static/");
|
||||||
@Override
|
// }
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
// @Override
|
||||||
registry.addInterceptor(jwtInterceptor)
|
// public void addInterceptors(InterceptorRegistry registry) {
|
||||||
.addPathPatterns("/**") // 모든 경로에 대해 인터셉터 적용
|
// registry.addInterceptor(jwtInterceptor)
|
||||||
.excludePathPatterns("/auth/**", "/board/**", "/user/**","/lecture/**","/qna/**"); // 인증 없이 접근 가능한 경로 설정
|
//
|
||||||
}
|
// .addPathPatterns("/**") // 모든 경로에 대해 인터셉터 적용
|
||||||
|
// .excludePathPatterns("/v3/api-docs/**","/swagger-resources/**","/webjars/**","/swagger-ui/**","/auth/**", "/board/**", "/user/**","/lecture/**","/qna/**", "/quiz/**"); // 인증 없이 접근 가능한 경로 설정
|
||||||
|
//
|
||||||
|
// ///v3/api-docs/**, /swagger-resources/**, /webjars/**
|
||||||
|
// }
|
||||||
}
|
}
|
@ -12,8 +12,13 @@ public class WebSocketConfigurer implements WebSocketMessageBrokerConfigurer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureMessageBroker(MessageBrokerRegistry registry) {
|
public void configureMessageBroker(MessageBrokerRegistry registry) {
|
||||||
registry.enableSimpleBroker("/sub");
|
registry.setApplicationDestinationPrefixes("/pub")
|
||||||
registry.setApplicationDestinationPrefixes("/pub");
|
.enableStompBrokerRelay("/topic")
|
||||||
|
.setRelayHost("localhost")
|
||||||
|
.setVirtualHost("/")
|
||||||
|
.setRelayPort(61613)
|
||||||
|
.setClientLogin("guest")
|
||||||
|
.setClientPasscode("guest");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,10 +16,14 @@ import org.springframework.messaging.handler.annotation.SendTo;
|
|||||||
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
|
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
|
||||||
import org.springframework.messaging.simp.SimpMessageSendingOperations;
|
import org.springframework.messaging.simp.SimpMessageSendingOperations;
|
||||||
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
|
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.socket.messaging.SessionConnectedEvent;
|
||||||
import org.springframework.web.socket.messaging.SessionDisconnectEvent;
|
import org.springframework.web.socket.messaging.SessionDisconnectEvent;
|
||||||
|
import org.springframework.web.socket.messaging.SessionSubscribeEvent;
|
||||||
|
import org.springframework.web.socket.messaging.SessionUnsubscribeEvent;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -38,34 +42,36 @@ public class ChatController {
|
|||||||
this.jwtUtil = jwtUtil;
|
this.jwtUtil = jwtUtil;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @GetMapping("/chat/enter/{lectureId}")
|
@GetMapping("/chat/enter/{lectureId}")
|
||||||
// public ResponseEntity<?> enter(@PathVariable long lectureId){
|
public ResponseEntity<?> enter(@PathVariable long lectureId){
|
||||||
// List<ChatUserDto> chatUsers = chatService.findChatUsers(lectureId);
|
List<ChatUserDto> chatUsers = chatService.findChatUsers(lectureId);
|
||||||
//
|
|
||||||
// return new ResponseEntity<>(chatUsers, HttpStatus.OK);
|
return new ResponseEntity<>(chatUsers, HttpStatus.OK);
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
// @MessageMapping("/hello/{channelId}")
|
@MessageMapping("/hello/{channelId}")
|
||||||
// @SendTo("/sub/channel/{channelId}")
|
@SendTo("/topic/{channelId}")
|
||||||
// public ChatUserDto hello(@DestinationVariable long channelId, SimpMessageHeaderAccessor simpMessageHeaderAccessor, @Header("Authorization") String token){
|
public ChatUserDto hello(@DestinationVariable long channelId, SimpMessageHeaderAccessor simpMessageHeaderAccessor, @Header("Authorization") String token){
|
||||||
// String sessionId = simpMessageHeaderAccessor.getSessionId();
|
String sessionId = simpMessageHeaderAccessor.getSessionId();
|
||||||
//
|
|
||||||
// System.out.println("session" + sessionId);
|
System.out.println("session" + sessionId);
|
||||||
//
|
|
||||||
// long userId = Long.parseLong(jwtUtil.getUserId(token));
|
System.out.println("가냐?????"+token);
|
||||||
//
|
|
||||||
// chatService.saveChatUserInfo(userId, channelId, sessionId);
|
long userId = Long.parseLong(jwtUtil.getUserId(token));
|
||||||
//
|
|
||||||
// return chatService.getChatUserInfo(userId);
|
chatService.saveChatUserInfo(userId, channelId, sessionId);
|
||||||
// }
|
|
||||||
|
return chatService.getChatUserInfo(userId);
|
||||||
|
}
|
||||||
|
|
||||||
@MessageMapping("/message/{lectureId}")
|
@MessageMapping("/message/{lectureId}")
|
||||||
@SendTo("/sub/channel/{lectureId}")
|
@SendTo("/topic/{lectureId}")
|
||||||
public MessageDto sendMessage(@DestinationVariable long lectureId, MessageDto messageDto){return messageDto;}
|
public MessageDto sendMessage(@DestinationVariable long lectureId, MessageDto messageDto){return messageDto;}
|
||||||
|
|
||||||
@MessageMapping("/quiz/{lectureId}")
|
@MessageMapping("/quiz/{lectureId}")
|
||||||
@SendTo("/sub/channel/{lectureId}")
|
@SendTo("/topic/{lectureId}")
|
||||||
public QuizDto quizStart(@DestinationVariable long lectureId, QuizDto quizDto){
|
public QuizDto quizStart(@DestinationVariable long lectureId, QuizDto quizDto){
|
||||||
return quizDto;
|
return quizDto;
|
||||||
}
|
}
|
||||||
@ -88,5 +94,6 @@ public class ChatController {
|
|||||||
// chatService.deleteChatUserInfo(chatUserDto.getUserId());
|
// chatService.deleteChatUserInfo(chatUserDto.getUserId());
|
||||||
// simpMessageSendingOperations.convertAndSend("/sub/channel/" + chatUserDto.getLectureId(), chatUserDto);
|
// simpMessageSendingOperations.convertAndSend("/sub/channel/" + chatUserDto.getLectureId(), chatUserDto);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user