Hello,
HTML5 draft contains an API called EventSource to stream data (notifications) trough javascript using only one server call.
Looking it up, I found an exemple on Opera Labs of the javascript part :
document.getElementsByTagName("event-source")[0]
.addEventListener("server-time", eventHandler, false);
function eventHandler(event)
{
// Alert time sent by the server
alert(event.data);
}
and the server side part :
<?php
header("Content-Type: application/x-dom-event-stream");
while(true) {
echo "Event: server-time\n";
$time = time();
echo "data: $time\n";
echo "\n";
flush();
sleep(3);
}
?>
But as of today, it seems only Opera has implemented the API, neither Chrome nor Safari have a working version (Am I wrong here ?)
So my question is, is there any other way in javascript, maybe more complex, to use this one stream to get data ?
EDIT : I'm looking at Comet stuff right now, but I'm not sure how to reuse that :) EDIT 2 : Apparentry, "x-dom-event-stream" has now been renamed "text/event-stream" EDIT 3 : Got to understand way more of it with this recent article from javanet