Use a "x-dom-event-stream" stream in javascript ?
- by rnaud
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 ?