X-Git-Url: http://git.pond.sub.org/?p=eow;a=blobdiff_plain;f=web.lisp;h=093769224ec938c3d91b3669e6250be4ec0959fc;hp=763b6f3a46621d7698aa0daa576fcb3b961060bf;hb=bbb4cc9f46ce5736c875623b542db5eddc58d773;hpb=26149be9cdf416550bd80f06b02e956bb1b0bf52 diff --git a/web.lisp b/web.lisp index 763b6f3..0937692 100644 --- a/web.lisp +++ b/web.lisp @@ -30,10 +30,21 @@ (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 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