Flow.fromSinkAndSource(sink, source) allows you to have decoupled incoming and outgoing messages. Maybe this sample can be helpful: https://markatta.com/codemonkey/blog/2016/10/02/chat-with-akka-http-websockets/
Please don't ask a new question in an only somewhat related old thread, start a new thread instead, thanks! -- Johan Akka Team On Sun, Jan 28, 2018 at 12:48 PM, Thai <[email protected]> wrote: > Hi Mathieu, > > Sorry to re-open a quite old topic. I'm looking for an example exactly > like this one "*a websocket server for which there is no 1-1 relation > between incoming and outgoing messages. The client can send messages at any > time which may or not have a reply from the server. The server can push > messages at any time which may or not have a reply from the client*". > It's really easy in non-Akka world (e.g. spring websocket, jetty websocket > ...). Do you have any example (scala version is fine too) for me to follow? > > Regards. > > On Tuesday, May 2, 2017 at 6:35:33 AM UTC-4, Mathieu Bruyen wrote: >> >> Hello, >> >> (this is more related to akka-http but there seem to be no dedicated >> group) >> >> I am trying to setup a websocket server for which there is no 1-1 >> relation between incoming and outgoing messages. The client can send >> messages at any time which may or not have a reply from the server. The >> server can push messages at any time which may or not have a reply from the >> client. I wanted to let actors handle and produce these messages. Following >> the doc >> <http://doc.akka.io/docs/akka-http/current/java/http/server-side/websocket-support.html#handling-messages> >> I am using Sink#actorRefWithAck to push incoming messages to the >> entrypoint/router actor and let it do it's job. For outgoing messages in >> the options suggested by the doc >> <http://doc.akka.io/docs/akka/current/scala/stream/stream-integrations.html#Integrating_with_Actors> >> I was planning to use Source#queue and give this queue to all the actors >> which might need to push to the queue. I targeted this solution because it >> allows for backpressure management. >> >> -- > >>>>>>>>>> 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- >>>>>>>>>> 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
