Skip to content

Commit

Permalink
feat: socket config 추가(#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
acceptor-gyu committed May 18, 2024
1 parent 509764b commit f390f42
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions be/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-websocket'
implementation 'org.webjars:stomp-websocket:2.3.3-1'
implementation 'org.webjars:sockjs-client:1.1.2'

// redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
}

tasks.named('bootBuildImage') {
Expand Down
30 changes: 30 additions & 0 deletions be/src/main/java/yeonba/be/config/WebSocketConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package yeonba.be.config;

import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
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
@EnableWebSocket
@RequiredArgsConstructor
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

@Override
public void configureMessageBroker(MessageBrokerRegistry config) {

config.enableSimpleBroker("/chat/sub");
config.setApplicationDestinationPrefixes("/chat/pub");
}

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {

registry.addEndpoint("/chat")
.withSockJS();
}
}

0 comments on commit f390f42

Please sign in to comment.