2024-08-16 10:50:57 +02:00
|
|
|
package at.eisibaer.jbear2.config
|
|
|
|
|
|
|
|
|
|
import org.springframework.context.annotation.Configuration
|
|
|
|
|
import org.springframework.messaging.simp.config.MessageBrokerRegistry
|
2026-03-15 17:38:23 +01:00
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling
|
|
|
|
|
import org.springframework.session.Session
|
|
|
|
|
import org.springframework.session.web.socket.config.annotation.AbstractSessionWebSocketMessageBrokerConfigurer
|
2024-08-16 10:50:57 +02:00
|
|
|
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker
|
|
|
|
|
import org.springframework.web.socket.config.annotation.StompEndpointRegistry
|
2026-03-15 17:38:23 +01:00
|
|
|
|
2024-08-16 10:50:57 +02:00
|
|
|
|
|
|
|
|
@Configuration
|
2026-03-15 17:38:23 +01:00
|
|
|
@EnableScheduling
|
2024-08-16 10:50:57 +02:00
|
|
|
@EnableWebSocketMessageBroker
|
2026-03-15 17:38:23 +01:00
|
|
|
class WebSocketConfig(
|
|
|
|
|
val applicationProperties: ApplicationProperties,
|
|
|
|
|
) : AbstractSessionWebSocketMessageBrokerConfigurer<Session>() {
|
2024-08-16 10:50:57 +02:00
|
|
|
|
|
|
|
|
override fun configureMessageBroker(registry: MessageBrokerRegistry) {
|
|
|
|
|
registry.setApplicationDestinationPrefixes("/app");
|
2026-03-15 17:38:23 +01:00
|
|
|
registry.enableSimpleBroker("/topic");
|
2024-08-16 10:50:57 +02:00
|
|
|
}
|
|
|
|
|
|
2026-03-15 17:38:23 +01:00
|
|
|
override fun configureStompEndpoints(registry: StompEndpointRegistry) {
|
|
|
|
|
registry
|
|
|
|
|
.addEndpoint("/ws")
|
|
|
|
|
.setAllowedOrigins(applicationProperties.corsAllowedOrigins.joinToString(","))
|
2024-08-16 10:50:57 +02:00
|
|
|
}
|
|
|
|
|
}
|