]> git.pond.sub.org Git - eow/blobdiff - web.lisp
Forward prompt to browser
[eow] / web.lisp
index 763b6f3a46621d7698aa0daa576fcb3b961060bf..20e27510d2a67c37764967dd29b271b141479ee6 100644 (file)
--- a/web.lisp
+++ b/web.lisp
          (fullname (concatenate 'string +static-files-root+ fname)))
     (handle-static-file fullname)))
 
+(defvar *update-queue* (locked-queue:create))
+
+(defun update ()
+  "Send stream of updates to client"
+  (locked-queue:dequeue *update-queue*))
+
+(defun send (string)
+  "Push a javascript update fragment to the client."
+  (locked-queue:enqueue *update-queue* string))
+
+(defun prompt (minutes btus)
+  (send (format nil "prompt(~a,~a);~%" minutes btus)))
+
 (defun dispatch (request)
   (let ((script-name (script-name request)))
     (cond
       ((not (string-starts-with script-name +web-root+)) nil) ; do not handle this request
+      ((string= script-name "/eow/update") 'update)
       ((or (string-equal script-name +web-root-base+)
            (string-equal script-name +web-root+)) (redirect +root-url+)) ; go to the start page
       ((string-starts-with script-name +static-web-root+) 'serve-static)))) ; serve static file