Forráskód Böngészése

fix socket health

herlanS_ 4 éve
szülő
commit
8987344fbf

+ 14 - 1
src/main/kotlin/co/id/datacomsolusindo/ipphonebridge/BridgeFIlter.kt

@@ -9,8 +9,11 @@ import org.springframework.core.annotation.Order
 import org.springframework.core.io.ResourceLoader
 import org.springframework.http.HttpMethod
 import org.springframework.http.HttpStatus
+import org.springframework.messaging.handler.annotation.MessageMapping
+import org.springframework.messaging.handler.annotation.SendTo
 import org.springframework.messaging.simp.SimpMessagingTemplate
 import org.springframework.stereotype.Component
+import org.springframework.stereotype.Controller
 import org.springframework.web.bind.annotation.GetMapping
 import org.springframework.web.bind.annotation.PathVariable
 import org.springframework.web.bind.annotation.PostMapping
@@ -136,7 +139,6 @@ class BridgeFilter(private val template: SimpMessagingTemplate, val resourceLoad
         val f = File("web")
         if (splPath.size >= itr && f.isDirectory) {
             val search = splPath.joinToString("/")
-//            println("search $search")
             return f.listFiles()?.filter { it.isDirectory }?.map { it.name }?.map {
                 Pair(it, resourceLoader.getResource("file:web/$it/$search"))
             }?.filter { it.second.exists() && it.second.file.isFile }?.map { "${it.first}/$search" }?.firstOrNull()
@@ -172,6 +174,17 @@ object Singletons {
     val requestInstance: MutableMap<String, RequestQue> by lazy { mutableMapOf<String, RequestQue>() }
 }
 
+
+@Controller
+class SocketChecker {
+    @MessageMapping("/hi")
+    @SendTo("/topic/healthCheck")
+    @Throws(Exception::class)
+    fun greeting(message: MutableMap<*, *>): MutableMap<*, *> {
+        return mutableMapOf(Pair("Hi", "I'am Ok"))
+    }
+}
+
 @RestController
 class BridgeRestController {
     @PostMapping("/_response/{id}")

+ 0 - 2
src/main/kotlin/co/id/datacomsolusindo/ipphonebridge/WebSocketConfig.kt

@@ -10,7 +10,6 @@ import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerCo
 @Configuration
 @EnableWebSocketMessageBroker
 class WebSocketConfig : WebSocketMessageBrokerConfigurer {
-
     override fun configureMessageBroker(config: MessageBrokerRegistry) {
         config.enableSimpleBroker("/topic")
         config.setApplicationDestinationPrefixes("/app")
@@ -19,5 +18,4 @@ class WebSocketConfig : WebSocketMessageBrokerConfigurer {
     override fun registerStompEndpoints(registry: StompEndpointRegistry) {
         registry.addEndpoint("/_websocket").setAllowedOrigins("*")
     }
-
 }