[scalaz-stream] How to implement an ask then wait for reply pattern

82 views
Skip to first unread message

jilen nil

unread,
Jan 18, 2015, 9:29:05 PM1/18/15
to sca...@googlegroups.com

StackOverFlow link

I want to implement an client app that first send an request to server then wait for its reply(similar to http)

My client process may be

val topic = async.topic[ByteVector]
val client
= topic.subscribe

Here is the Client 
trait Client {
  val topic
= async.topic[ByteVector]
  val client
= topic.subscribe
  val incoming
= tcp.connect(...)(client)
  val reqBus
= topic.pubsh()
 
def ask(req: ByteVector): Task[Throwable \/ ByteVector] = {
     
(tcp.writes(req).flatMap(_ => tcp.reads(1024))).to(reqBus)
     
???
 
}
}


How to implement the remaining part

Reply all
Reply to author
Forward
0 new messages