Is it possible to implement Server Side Events in Hunchentoot?

177 views Asked by At

I would like to create a web application with Hunchentoot that works as follows; A client tells the server application that it is interested in a certain table in the database. When a change in the table occurs the server pushes this information. I have not looked into WebSockets yet because I am interested in HTML5's Server Side Events. Is it possible to write a Huncentoot acceptor that pushes data to the client through Server Side Events

1

There are 1 answers

0
Svante On

As far as I understand, it should just work by following the protocol:

  • send headers with content-type text/event-stream
  • send events as UTF-8 strings separated by double newlines

In Hunchentoot, see send-headers, which would send the headers set so far on the reply object and returns a binary stream that you'd write your events to (seems that you'd need to convert your strings to UTF-8 binary yourself).