From dc55c78ec00af25cd7f550307d2b10acee442834 Mon Sep 17 00:00:00 2001 From: DongGeon0908 Date: Wed, 21 Aug 2024 09:05:37 +0900 Subject: [PATCH] =?UTF-8?q?imp:=20ws=EC=97=90=20ping-pong=20check=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReactiveConcurrentUserWebSocketHandler.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/hero/alignlab/ws/handler/ReactiveConcurrentUserWebSocketHandler.kt b/src/main/kotlin/com/hero/alignlab/ws/handler/ReactiveConcurrentUserWebSocketHandler.kt index 97a00b7..5fc6a27 100644 --- a/src/main/kotlin/com/hero/alignlab/ws/handler/ReactiveConcurrentUserWebSocketHandler.kt +++ b/src/main/kotlin/com/hero/alignlab/ws/handler/ReactiveConcurrentUserWebSocketHandler.kt @@ -40,8 +40,6 @@ class ReactiveConcurrentUserWebSocketHandler( private val concurrentUserByMap: ConcurrentMap> = ConcurrentHashMap() override fun handle(session: WebSocketSession): Mono { - println(">> 접속함") - val groupId = session.handshakeInfo.uri.path .split("/") .lastOrNull { it.matches(Regex("\\d+")) } @@ -59,8 +57,6 @@ class ReactiveConcurrentUserWebSocketHandler( val user = authFacade.resolveAuthUser(authUserToken) - println("concurrent user : ${user.uid}") - val groupUsers = groupUserService.findAllByUidSync(user.uid) groupUsers.forEach { groupUser -> @@ -95,6 +91,18 @@ class ReactiveConcurrentUserWebSocketHandler( return session.receive() .map(WebSocketMessage::getPayloadAsText) + .flatMap { payload -> + when { + payload.contains("ping") -> { + session.send(Mono.just(session.textMessage("pong"))) + } + + else -> { + logger.warn { "UNDEFINED WS MESSAGE : $payload" } + Mono.empty() + } + } + } .log() .doFinally { handleSessionTermination(session, user.uid) } .then()