Hi Brandon,

I guess you are using the following method to respond WebSocket handshake:

UpgradeToWebSocket.handleMessagesWith(handlerFlow: Graph 
<http://doc.akka.io/api/akka/2.4.2/akka/stream/Graph.html>[FlowShape 
<http://doc.akka.io/api/akka/2.4.2/akka/stream/FlowShape.html>[Message 
<http://doc.akka.io/api/akka/2.4.2/akka/http/javadsl/model/ws/Message.html>
, Message 
<http://doc.akka.io/api/akka/2.4.2/akka/http/javadsl/model/ws/Message.html>], 
_]): HttpResponse 
<http://doc.akka.io/api/akka/2.4.2/akka/http/javadsl/model/HttpResponse.html>

In this case, the flow is indeed one-to-one. For each incoming message only 
a single outgoing message is produced. However there other over variants 
that take a pair of streams:

UpgradeToWebSocket.handleMessagesWith(inSink: Graph 
<http://doc.akka.io/api/akka/2.4.2/akka/stream/Graph.html>[SinkShape 
<http://doc.akka.io/api/akka/2.4.2/akka/stream/SinkShape.html>[Message 
<http://doc.akka.io/api/akka/2.4.2/akka/http/javadsl/model/ws/Message.html>], 
_], outSource: Graph 
<http://doc.akka.io/api/akka/2.4.2/akka/stream/Graph.html>[SourceShape 
<http://doc.akka.io/api/akka/2.4.2/akka/stream/SourceShape.html>[Message 
<http://doc.akka.io/api/akka/2.4.2/akka/http/javadsl/model/ws/Message.html>], 
_]): HttpResponse 
<http://doc.akka.io/api/akka/2.4.2/akka/http/javadsl/model/HttpResponse.html>

This allows you to implement a many-to-one, one-to-many, unidirectional 
reader / writer or any arbitrary communication scheme you can think of. You 
could implement the logic in an Actor and then use a pair of ActorSubcriber 
+ ActorPublisher helpers to complete the required plumbing.

Here's an example of WebSocket usage in my toy 
project 
https://github.com/rkrzewski/akka-cluster-etcd/tree/master/examples/cluster-monitor/src/main/scala/pl/caltha/akka/cluster/monitor/frontend
 
(here the input and output channels serve different purposes and are 
independent of one another)

Cheers,
Rafał 

W dniu sobota, 5 marca 2016 18:24:43 UTC+1 użytkownik Brandon Bradley 
napisał:
>
> Hello,
>
> I have a websockets connection that continuously sends messages after I 
> send a particular message. I've followed the websockets client example. 
> But, I only get one message back. I believe this is because streams are 
> one-to-one. Is there a way to process messages received after sending an 
> initial message with akka-http? Or is this the wrong tool for the job.
>
> Cheers!
> Brandon Bradley
>

-- 
>>>>>>>>>>      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.

Reply via email to