Created
September 1, 2011 13:12
-
-
Save Integralist/1186135 to your computer and use it in GitHub Desktop.
Example PHP code for setting up server-sent events
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 | |
header("Content-Type: text/event-stream"); | |
while(true) { | |
echo "Event: server-time\n"; | |
$time = time(); | |
echo "data: $time\n"; | |
echo "\n"; | |
flush(); | |
sleep(3); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment