<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Mar 1, 2014, at 2:01 PM, Ben Hyde <<a href="mailto:bhyde@pobox.com">bhyde@pobox.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Mar 1, 2014, at 3:04 PM, Ron Garret <<a href="mailto:ron@flownet.com">ron@flownet.com</a>> wrote:</div><blockquote type="cite"><span style="font-family: 'Helvetica Neue'; font-size: inherit; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">server-side events</span></blockquote></div><br><div>I assume, you cobbled together your own Hunchentoot compatible implementation?  Or, is there one kicking about I've not noticed?  - ben</div></div></blockquote></div><br><div>Here’s a self-contained SSE demo:</div><div><br></div><div><div><br></div><div>(require :hunchentoot)</div><div><br></div><div>(rename-package :hunchentoot :hunchentoot '(:tbnl :ht))</div><div><br></div><div>(defvar $server (make-instance 'ht::easy-acceptor :port 1234 :access-log-destination nil))</div><div><br></div><div>(ht:start $server)</div><div><br></div><div>(ht:define-easy-handler (sse-test :uri "/sse-test") ()</div><div>  "<script></div><div>var source=new EventSource('sse-stream');</div><div>source.onmessage=function(event) {</div><div>document.getElementById('result').innerHTML=event.data + '<br>';</div><div>};</div><div></script></div><div>Server-side event demo<br></div><div><div id=result></div></div><div>")</div><div><br></div><div>(defun set-header (name value) (setf (ht:header-out name) value))</div><div><br></div><div>(ht:define-easy-handler (sse-stream :uri "/sse-stream") ()</div><div>  (set-header "content-type" "text/event-stream")</div><div>  (set-header "cache-control" "no-cache")</div><div>  (let ((stream (ht:send-headers)))</div><div>    (dotimes (i 10)</div><div>      (write-sequence (encode-string-to-octets</div><div>                       (format nil "data: test ~A~A~A" i #\newline #\newline))</div><div>                      stream)</div><div>      (force-output stream)</div><div>      (sleep 0.5))))</div></div><div><br></div></body></html>