Hey !
Just try your EventSource project ! It's pretty cool !
First loading of the page is fast but if i refresh the page the page take the normal loading time + the sleep value (defined in the while loop) to load .
Is this normal ?
Here is my code (on symfony1.4)
$(function() {
var stream = new EventSource("<?php echo url_for('@messages_poll'); ?>");
stream.addEventListener('message', function (event) {
console.log(event.data);
});
});
<?php
public function executePoll(sfWebRequest $request)
{
set_time_limit(0);
ini_set('memory_limit', '512M');
foreach (Stream::getHeaders() as $name => $value) {
header("$name: $value");
}
$stream = new Stream();
while (true) {
$stream
->event()
->setData('Hello')
->end()
->flush();
sleep(2);
}
return sfView::NONE;
}
Hey !
Just try your EventSource project ! It's pretty cool !
First loading of the page is fast but if i refresh the page the page take the normal loading time + the sleep value (defined in the while loop) to load .
Is this normal ?
Here is my code (on symfony1.4)