I'm using the Long Polling technique for my notification system (a facebook like notification for my single page app with ajax).
I used the sleep(2000) function for every database checking for new notifications:
Controller : notificationsController
Action: indexAction
<?php
//.......
while(count($notifications)==0){
//sleep for 2 secs
sleep(2000);
$notifications = Notifications::find('for_user_id = '.$this->userSession->id);
}
//some notifications found!
return $notifications
It works well, but the problem is that all my scripts that uses the Phalcon framework are stopped by this sleep(2000), I mean not only my current Phalcon app, all the phalcon apps that are located in different folders and wait for the boucle to end.
I think this is a problem from Phalcon ?
Using: WampServer Version 2.2 64bits on Windows 8.1 64bits