|
@@ -29,11 +29,8 @@ import java.util.concurrent.ConcurrentHashMap
|
|
|
import java.util.concurrent.ConcurrentMap
|
|
|
|
|
|
class GatewayClient(
|
|
|
- val socketHost: String,
|
|
|
- val clientName: String,
|
|
|
- val currentLocalPort: Int,
|
|
|
- val socketPort: Int,
|
|
|
- val srvTemplate: SimpMessagingTemplate
|
|
|
+ val socketUrl: String,
|
|
|
+ private val srvTemplate: SimpMessagingTemplate
|
|
|
) {
|
|
|
enum class State { INITIALIZED, CONNECTING, FAILED, CONNECT }
|
|
|
|
|
@@ -49,8 +46,8 @@ class GatewayClient(
|
|
|
val sessionHandler =
|
|
|
BridgeStompSessionHandler(srvTemplate)
|
|
|
|
|
|
- AppLog.write(this.javaClass).info("Try connect to : ws://$socketHost:$socketPort/_websocket")
|
|
|
- val cn = stompClient.connect("ws://$socketHost:$socketPort/_websocket", sessionHandler)
|
|
|
+ AppLog.write(this.javaClass).info("Try connect to : $socketUrl")
|
|
|
+ val cn = stompClient.connect(socketUrl, sessionHandler)
|
|
|
|
|
|
cn.addCallback({ s ->
|
|
|
session = s
|
|
@@ -73,7 +70,7 @@ class GatewayClient(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-class BridgeStompSessionHandler(val srvTemplate: SimpMessagingTemplate) : StompSessionHandler {
|
|
|
+class BridgeStompSessionHandler(private val srvTemplate: SimpMessagingTemplate) : StompSessionHandler {
|
|
|
var session: StompSession? = null
|
|
|
|
|
|
// val partialDataMap: ConcurrentMap<String, MutableList<PartialData>> = ConcurrentHashMap()
|
|
@@ -101,8 +98,10 @@ class BridgeStompSessionHandler(val srvTemplate: SimpMessagingTemplate) : StompS
|
|
|
|
|
|
override fun afterConnected(ss: StompSession, sh: StompHeaders) {
|
|
|
AppLog.write(this.javaClass).info("Connected to gateway socket server")
|
|
|
-// ss.subscribe("/topic/partial/$clientName", this)
|
|
|
-// ss.subscribe("/topic/healthCheck", this)
|
|
|
+ ClientHolder.setOnPut { ClientHolder.addSubs(it, ss.subscribe("/topic/partial/$it", this)) }
|
|
|
+ ClientHolder.setOnRemove { ClientHolder.removeSubs(it) }
|
|
|
+ ClientHolder.subsAll(ss, this)
|
|
|
+ ss.subscribe("/topic/healthCheck", this)
|
|
|
this.session = ss
|
|
|
}
|
|
|
|
|
@@ -122,7 +121,7 @@ class BridgeStompSessionHandler(val srvTemplate: SimpMessagingTemplate) : StompS
|
|
|
)
|
|
|
}
|
|
|
"/topic/response/$reqId" -> {
|
|
|
- SocketChecker().collectChunk(payload as SocketChunkData,reqId)
|
|
|
+ SocketChecker().collectChunk(payload as SocketChunkData, reqId)
|
|
|
}
|
|
|
}
|
|
|
}
|