EvenSource Sample Published
I published a simple example on how to use EventSource/Server-Sent Events on GitHub (marschall/event-source-sample). Unlike other (mostly PHP) examples this does not require a server thread per connection.
Compared to WebSockets EvenSource is much simpler and more «lightweight». Server-Sent Events are only unidirectional (server → client
) but since all the reconnection logic in implemented in the browser you can use them without CometD or Socket.IO. The example doesn’t use any JavaScript library at all. However EvenSource does not support binary data.
Server Support
The example is implemented using jetty-eventsource-servlet with uses Jetty Continuations which are supported by any Jetty version starting with 6 or any Servlet 3 container.
Browser Support
EvenSource is supported by any modern browser any browser except IE.