Skip to content

Commit

Permalink
imp: ws에 ping-pong check 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
DongGeon0908 committed Aug 21, 2024
1 parent 5c63d0c commit dc55c78
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class ReactiveConcurrentUserWebSocketHandler(
private val concurrentUserByMap: ConcurrentMap<Long, ConcurrentMap<Long, WebSocketSession>> = ConcurrentHashMap()

override fun handle(session: WebSocketSession): Mono<Void> {
println(">> 접속함")

val groupId = session.handshakeInfo.uri.path
.split("/")
.lastOrNull { it.matches(Regex("\\d+")) }
Expand All @@ -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 ->
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit dc55c78

Please sign in to comment.