Skip to content

Commit

Permalink
[BE] feat: WebSocketConfig 추가 (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
toychip committed Feb 4, 2025
1 parent cf18d8a commit 4586224
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/backend/chat-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,22 @@ dependencies {
implementation("org.springframework.cloud:spring-cloud-starter-netflix-eureka-client")
implementation("org.springframework.cloud:spring-cloud-starter-openfeign")

compileOnly("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")
implementation ("io.jsonwebtoken:jjwt-api:0.11.5")
runtimeOnly ("io.jsonwebtoken:jjwt-impl:0.11.5")
runtimeOnly ("io.jsonwebtoken:jjwt-jackson:0.11.5")

testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

// AWS
// AWS
implementation ("org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE")

implementation ("org.springframework.boot:spring-boot-starter-websocket")

implementation ("org.springframework.kafka:spring-kafka")

implementation ("org.springframework.boot:spring-boot-starter-data-mongodb")
}

dependencyManagement {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.asyncgate.chat_server.config

import com.asyncgate.chat_server.filter.FilterChannelInterceptor
import org.springframework.context.annotation.Configuration
import org.springframework.messaging.simp.config.ChannelRegistration
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
class WebSocketConfig(
private val filterChannelInterceptor: FilterChannelInterceptor
) : WebSocketMessageBrokerConfigurer {

override fun registerStompEndpoints(registry: StompEndpointRegistry) {
registry.addEndpoint("/asyncgate-chat")
.setAllowedOriginPatterns("*")
.withSockJS()
}

override fun configureMessageBroker(registry: MessageBrokerRegistry) {
registry.setApplicationDestinationPrefixes("/kafka")
registry.enableSimpleBroker("/topic/")
}

override fun configureClientInboundChannel(registration: ChannelRegistration) {
registration.interceptors(filterChannelInterceptor)
}
}

0 comments on commit 4586224

Please sign in to comment.