is stream connection supported

Apr 5, 2013 at 2:37 PM
If the server continuously sends content to the client (keeping connection open) till it reaches max content-length - LightStreamer does that, can Casablanca properly sync the body() of the response?

So if I simply call read_line() in a loop will this work properly or is a callback missing in the SDK? It seems more reasonable if we can receive a callback when there is more data to read instead of doing the above in a loop.

while(!done)
{
response.body().read_line(data).get()
//process data here
}

One more questions:

will read_line() consume the body from the actually response so that as the data come I can keep consuming the new content or is there other things I need to do so body() is in sync with the the data being received? I know the SDK already handles WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE just not if it's properly synching the body() with a consumer provider buffer.

Thanks
Apr 5, 2013 at 4:09 PM
Yes, that should work, the http_client is pushing data through as soon as it arrives, but if the system is throttling or buffering data somewhere else in the system, we don't push it through until it's given. Our next release will allow you to set the size of the chunks the client asks for, too.

The callback you're looking for is what you get if instead of calling .get(), you call .then(). Asynchronous processing in a loop is hard, it requires that you radically rewrite your code. For an example, you may want to look at the implementation of read_line(), where we loop reading from a stream buffer until a newline character is found. Nasty-looking code, but completely unblocking.

Niklas