Skip to content

Commit

Permalink
feat:[#28] WebSocketConfig 구성
Browse files Browse the repository at this point in the history
  • Loading branch information
pjhcsols committed Nov 4, 2024
1 parent a200558 commit 6033bd2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ dependencies {
testImplementation 'org.testcontainers:junit-jupiter:1.20.2'
testImplementation 'org.testcontainers:mysql:1.20.2'

//chat
implementation 'org.springframework.boot:spring-boot-starter-websocket'

}

tasks.named('test') {
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/helpmeCookies/global/config/WebSocketConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.helpmeCookies.global.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/api/sub");
config.setApplicationDestinationPrefixes("/api/pub");
}

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws").setAllowedOriginPatterns("*");
//.withSockJS();
}
}

0 comments on commit 6033bd2

Please sign in to comment.