cl-sse is an partial implementation of the Server Side Events protocol as per https://www.w3.org/TR/eventsource/. It is a toolkit for Common Lisp service implementations that want to send or receive events according to the protocol. There is a small demo you can try with a browser (instructions below).
With appreciation to https://gist.github.com/jareware/aae9748a1873ef8a91e5 for a browser eventsource example.
The server.lisp module is for the push piece of the protocol.
You could probably make do with
format, but this piece ensures that
protocols are observed if you aren't familiar with SSE, though it does differ
in that it requires an event name/type where the spec consider this optional.
I was tempted to have the event properties be nil, instead of empty strings, when they weren't in the event, however I opted instead to follow the spec a bit more closely, for no particularly good reason. As there are no users of this code it's something of a moot point, it was mostly for example purposes.
Shows SSE in action in a browser. Use as follows:
- (ql:quickload :sse-demo)
- (sse:demo/start-server) ; starts a hunchentoot server (in demo::http-server)
- Connect a browser to localhost:8080/sse and watch the demo unfold.
- When you're done, kill your browser tab, and (sse:demo/stop-server) to kill
the web service.