summaryrefslogtreecommitdiff
path: root/sw-server
diff options
context:
space:
mode:
Diffstat (limited to 'sw-server')
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt11
1 files changed, 10 insertions, 1 deletions
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt
index dd4c4b15..1911f5b9 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt
@@ -5,6 +5,7 @@ import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.messaging.simp.config.ChannelRegistration
import org.springframework.messaging.simp.config.MessageBrokerRegistry
+import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker
import org.springframework.web.socket.config.annotation.StompEndpointRegistry
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
@@ -18,13 +19,21 @@ class WebSocketConfig(
override fun configureMessageBroker(config: MessageBrokerRegistry) {
// prefixes for all subscriptions
- config.enableSimpleBroker("/queue", "/topic")
+ config.enableSimpleBroker("/queue", "/topic").apply {
+ setTaskScheduler(createTaskScheduler()) // to support heart beats
+ }
config.setUserDestinationPrefix("/user")
// /app for normal calls, /topic for subscription events
config.setApplicationDestinationPrefixes("/app", "/topic")
}
+ private fun createTaskScheduler() = ThreadPoolTaskScheduler().apply {
+ poolSize = 1
+ threadNamePrefix = "stomp-heartbeat-thread-"
+ initialize()
+ }
+
override fun registerStompEndpoints(registry: StompEndpointRegistry) {
registry.addEndpoint(SEVEN_WONDERS_WS_ENDPOINT)
.setHandshakeHandler(handshakeHandler())
bgstack15