Created
September 11, 2011 21:48
-
-
Save julesbou/1210174 to your computer and use it in GitHub Desktop.
Is it a good idea ? (not tested)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Alternative to the long polling system used in lichess (github.com/ornicar/lichess) | |
// - We could use an ajax request on a php script with an infinite loop until version has changed. | |
$userVersion = $_GET['version'] | |
$version = $db->stack->find($_GET['player_id'])->getVersion(); | |
while ($userVersion <= $version) { | |
usleep(10000); | |
$version = $db->stack->find($_GET['player_id'])->getVersion(); | |
if ($version !== $userVersion) { | |
return json_encode(array( | |
'events' => $stack->getEventsSince($userVersion))), | |
'version' => $version, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment