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