Hi there,
EventSource looks like a much nicer alternative to WebSockets in all the cases where the connection doesn't really need to be bi-directional (ajax request to push to the server, Event Source to push to the client). It doesn't require a new protocol and should be trivial to pass through HTTP aware load balancers, cache proxies and so on.
Have been trying to get either Snap or Warp to serve up an EventSource endpoint, but so far I'm stuck at not being able to get any of them to actually write to the response body before the request is all over.
Here's some example code:
The code is mostly the same apart from the glue to the web server. In both cases I'm trying a silly enumerator that gets messages from the keyboard and pass them to the iterator.
It all compiles and kinda works, but nothing gets written to the response before I end the enumeration with "q".
Any hints on what I'm doing wrong? Or any example code for controlling writes to the response body during a long request?
Cheers,
Mathias