Thank you so much guys! You definitely rock :) I think Björn link was excatly what I was loooking for. Is there to influence the demanded chunk-size dynamically?
Regards, Thomas On Tuesday, January 27, 2015 at 1:42:15 PM UTC+1, drewhk wrote: > > > > On Tue, Jan 27, 2015 at 1:35 PM, Björn Antonsson <[email protected] > <javascript:>> wrote: > >> Hi Thomas, >> >> There is a recipe for chunking up bytestrings in the stream docs >> http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-M2/scala/stream-cookbook.html#Chunking_up_a_stream_of_ByteStrings_into_limited_size_ByteStrings >> > > Aaaand of course there is one recipe for parsing frames with a terminator > sequence (for example text lines): > http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-M2/scala/stream-cookbook.html#Parsing_lines_from_a_stream_of_ByteStrings > > -Endre > > >> >> Maybe you could use that as a starting point to chunk up the bytestring >> into the header bytestring and payload bytestring. >> >> B/ >> >> On 26 January 2015 at 12:09:57, Thomas Zimmer ( >> [email protected] <javascript:>) wrote: >> >> Hi, >> >> i have a question regarding TCP Streams and request strategies. Lets say >> i have a TCPStream build upon the ReactiveStream Framework. I have a >> Subscriber to consume the incoming data as a Sink using the >> ActorSubscriber. Now my problem is that i have a binary network protocol >> that looks like this: >> >> <protocol> = <header><body> >> <header> = LengthField (4 bytes), Type(4 bytes), .... >> <body> = Length and content is dynamic >> >> So my approach was creating a own request - strategy like this: >> >> class IncomingDataActor extends ActorSubscriber with RequestStrategy { >> >> >> val HEADER_SIZE: Int = 8 >> var expectedBodyLength: Int = 0 >> >> >> override def requestDemand(remainingRequested : scala.Int) : Int = { >> if (parsingBody) { >> expectedBodyLength >> } else { >> HEADER_SIZE >> } >> } >> >> >> override def receive: Actor.Receive = { >> case OnNext(data: ByteString) => >> expectedBodyLength = readHeaderSize(data) >> parsingBody = true >> context.become(parseBody, false) >> } >> >> >> def parseBody: Actor.Receive = { >> case OnNext(data: ByteString) => >> parseBodyAndProcessData(); >> parsingBody = false >> context.unbecome() >> } >> } >> >> >> >> The problem that i receive all available data in the "non parse body" >> state. Is there a way to deal with that or do i have to implement some >> "buffer" mechanism on my own? >> >> Regards, >> Thomas >> -- >> >>>>>>>>>> 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] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at http://groups.google.com/group/akka-user. >> For more options, visit https://groups.google.com/d/optout. >> >> >> -- >> Björn Antonsson >> Typesafe <http://typesafe.com/> – Reactive Apps on the JVM >> twitter: @bantonsson <http://twitter.com/#!/bantonsson> >> >> -- >> >>>>>>>>>> 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] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at http://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 http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
