Introduction
Web API provide an interface to receive server-sent events. It would connect to a server over HTTP and receives events in text/event format without closing the connection.
var eventSource = new EventSource("");
Once message is received from the server, the follow-up action would be triggered.
eventSource.onmessage = function(event){ // the data of the event can be found on event.data };
Not all browser support Server Sent Event API
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
Basic support | 9 | 6.0 | ? | 11 | 5 |