I have an empty Controller with the Following Code:
public function streamAction() {
$this->view->disable();
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
header("Connection: keep-alive");
for ($i = 1; $i <= 10; $i++) {
echo "data: {".date('r')."}\n\n";
ob_flush();
flush();
sleep(2);
}
}
When I request this with my browser, it takes about 20 Seconds ( 2 Second wait per loop-iteration ) and after that I get all the Results at once. Which is not the expected behaviour of an event-stream.
When I use the same code in "native" PHP, I get a result "send" to my browser ever 2 Seconds. Which is how its supposed to be.
Any Ideas on how I could implemet this into my Phalcon Project?