Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. private val (chatSink, chatSource) = {
  2. val source = MergeHub.source[WSMessage]
  3. .log("source")
  4. .map { msg =>
  5. try {
  6. val json = Json.parse(msg)
  7. inputSanitizer.sanText((json "msg").as[String])
  8. } catch {
  9. case e: Exception => println(">>" + msg)
  10. "Malfunction client"
  11. }
  12. }
  13. .recoverWithRetries(-1, { case _: Exception ⇒ Source.empty })
  14.  
  15. val sink = BroadcastHub.sink[WSMessage]
  16. source.toMat(sink)(Keep.both).run()
  17. }
  18.  
  19. private val userFlow: Flow[WSMessage, WSMessage, _] = {
  20. Flow.fromSinkAndSource(chatSink, chatSource)
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement