hunchentoot serving manifest files, ie. .appcache files.

Ron Garret ron at flownet.com
Sat Mar 1 22:25:27 UTC 2014


On Mar 1, 2014, at 2:01 PM, Ben Hyde <bhyde at pobox.com> wrote:

> On Mar 1, 2014, at 3:04 PM, Ron Garret <ron at flownet.com> wrote:
>> server-side events
> 
> I assume, you cobbled together your own Hunchentoot compatible implementation?  Or, is there one kicking about I've not noticed?  - ben

Here’s a self-contained SSE demo:


(require :hunchentoot)

(rename-package :hunchentoot :hunchentoot '(:tbnl :ht))

(defvar $server (make-instance 'ht::easy-acceptor :port 1234 :access-log-destination nil))

(ht:start $server)

(ht:define-easy-handler (sse-test :uri "/sse-test") ()
  "<script>
var source=new EventSource('sse-stream');
source.onmessage=function(event) {
document.getElementById('result').innerHTML=event.data + '<br>';
};
</script>
Server-side event demo<br>
<div id=result></div>
")

(defun set-header (name value) (setf (ht:header-out name) value))

(ht:define-easy-handler (sse-stream :uri "/sse-stream") ()
  (set-header "content-type" "text/event-stream")
  (set-header "cache-control" "no-cache")
  (let ((stream (ht:send-headers)))
    (dotimes (i 10)
      (write-sequence (encode-string-to-octets
                       (format nil "data: test ~A~A~A" i #\newline #\newline))
                      stream)
      (force-output stream)
      (sleep 0.5))))

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/tbnl-devel/attachments/20140301/026d6b10/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://mailman.common-lisp.net/pipermail/tbnl-devel/attachments/20140301/026d6b10/attachment.sig>


More information about the Tbnl-devel mailing list