Skip to content

Instantly share code, notes, and snippets.

@icewind1991
Created November 19, 2012 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icewind1991/4114368 to your computer and use it in GitHub Desktop.
Save icewind1991/4114368 to your computer and use it in GitHub Desktop.
<?php
if(isset($_GET['run'])){
$eventSource = new OC_EventSource();
for($i=0;$i<100;$i++){
$eventSource->send('tick',$i);
sleep(1);
}
$eventSource->close();
}
?>
<html>
<head>
<script>
var eventSource = new OC.EventSource('es.php',{run:true});
eventSource.listen('tick', function(i){
console.log(i);
});
</script>
</head>
</html>
@DeepDiver1975
Copy link

Cool! THX a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment