Hi Stefan, > > I want to use a web socket connection > > 1. to push periodically results from the server to the browser > 2. to send requests from the browser to the server and return the > corresponding results to the browser (there might be many results, > therefore the results should be streamed into the web socket connection) >
Flow[Message] // Take message as text .collect { case tm: TextMessage => tm case _ => throw new UnsupportedOperationException("binary is not supported") } // Produce a MongoDB publisher somehow .map{msg.textStream. ... } // Make a Source from the publisher and feed into this stream .flatMapConcat(Source(_)) // Wrap in websocket Text message .map(TextMessage(_)) // merge it with server side pushes .merge(updates) You can have an actor in the server handling pushes, and it can look like this val updates = Source.actorRef[String](128, OverflowStrategy.fail) .mapMaterializedValue{ ref => updaterActor ! Register(ref) } Above will automatically send a Register message to a given actor, passing it an ActorRef to which it can send TextMessage events. If the client cannot keep up with the push frequency it will be kicked out due to OverflowStrategy.fail -Endre > > Cheers > > Stefan > > > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to akka-user+unsubscr...@googlegroups.com. > To post to this group, send email to akka-user@googlegroups.com. > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- Akka Team Typesafe - Reactive apps on the JVM Blog: letitcrash.com Twitter: @akkateam -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.