I had taken code from the Akka Documentation about handling WebSocket 
connections server-side with Akka Streams; 
and was able to take the essentials of that to connect to a simple 
Javascript Client to send data to the Server, augment it on Server, then 
echo it back to the Client.

However, I still had the following specific questions about parts of that 
code (see TODO comments 4, 5, 6); THANKS in advance for any insight!

// TODO 4:  find out how to choose between  bind, bindAndHandleSync, or 
bindAndHandleAsync for most REACTIVE/RESPONSIVE processing
//          i.e. ALL methods wrap internal AKKA support for TCP backpressure;
//               but Async permits concurrent requests on a single connection 
without waiting for a response first
// TODO 5:  what are the most important failure handling scenarios to handle; 
or can this be handled internally with
//          any specific higher-level API that propagates errors through Try 
// - Handling HTTP Server failures in the Low-Level API
// - routing-level exceptions
val bindingFuture =
  Http().bindAndHandleSync(requestHandler, interface = "localhost", port = 8080)

println(s"Server online at http://localhost:8080/\nPress RETURN to stop...")

// TODO 6: Is it good practice to keep WebSocket connection open, monitoring 
for data on either Client or Server side;
//         i.e. is it OK to just wait until Server is shutdown instead of 
explicitly closing Websocket prior to that shutdown?
//         If not, how do you close that WebSocket explicitly, and outside of 
the request handlers?
import system.dispatcher // for the future transformations
  .flatMap(_.unbind()) // trigger unbinding from the port
  .onComplete(_ => system.terminate()) // and shutdown when done

>>>>>>>>>>      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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to