Skip to content

Commit

Permalink
fix: remove ping-pong check
Browse files Browse the repository at this point in the history
  • Loading branch information
DongGeon0908 committed Aug 11, 2024
1 parent fd561f8 commit d566583
Showing 1 changed file with 3 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ import org.springframework.stereotype.Component
import org.springframework.web.reactive.socket.WebSocketHandler
import org.springframework.web.reactive.socket.WebSocketMessage
import org.springframework.web.reactive.socket.WebSocketSession
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
import reactor.core.publisher.SynchronousSink
import java.time.Duration
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentMap

Expand All @@ -39,17 +36,6 @@ class ReactiveConcurrentUserWebSocketHandler(
*/
private val concurrentUserByMap: ConcurrentMap<Long, ConcurrentMap<Long, WebSocketSession>> = ConcurrentHashMap()

/** ping-pong check */
private val eventFlux: Flux<String> = Flux.generate { sink: SynchronousSink<String> ->
runCatching {
mapper.writeValueAsString("ping pong")
}.onSuccess { json ->
sink.next(json)
}.onFailure { e ->
sink.error(e)
}
}

override fun handle(session: WebSocketSession): Mono<Void> {
val authUserToken = session.handshakeInfo.headers.resolve()

Expand Down Expand Up @@ -86,11 +72,9 @@ class ReactiveConcurrentUserWebSocketHandler(
}
}

return session.send(
Flux.interval(Duration.ofMillis(1000L))
.zipWith(eventFlux) { _, event -> event }
.map(session::textMessage)
).and(session.receive().map(WebSocketMessage::getPayloadAsText).log())
return session.receive()
.map(WebSocketMessage::getPayloadAsText)
.log()
.doFinally { handleSessionTermination(session, user.uid) }
.then()
}
Expand Down

0 comments on commit d566583

Please sign in to comment.