]> git.pond.sub.org Git - eow/commitdiff
Add notes on COMET
authorGerd Flaig <gefla@pond.sub.org>
Sun, 22 Mar 2009 14:42:50 +0000 (15:42 +0100)
committerGerd Flaig <gefla@pond.sub.org>
Sun, 22 Mar 2009 14:42:50 +0000 (15:42 +0100)
Notes [new file with mode: 0644]

diff --git a/Notes b/Notes
new file mode 100644 (file)
index 0000000..84450c8
--- /dev/null
+++ b/Notes
@@ -0,0 +1,28 @@
+On COMET w/ hunchentoot: http://common-lisp.net/pipermail/tbnl-devel/2009-February/004620.html
+
+I have a working comet system using Hunchentoot.
+
+The basic way I'm operating is to have the browser contact the hunchentoot
+server and the server thread waits on a semaphore. Any other thread can then
+release the semaphore and cause a reply back to the browser.
+
+Hope this helps. I am only using this for development purposes, as I have
+been having problems with certain browsers, and this will also occupy one of
+the available browser requests, where many browsers have a very small number
+available.
+
+(defun kill-comet-thread (thread)
+  (warn "KILLING COMET THREAD: ~a" thread)
+  (ignore-errors
+    (destroy-thread thread)))
+
+(defun handle-comet ()
+  (awhen (session-value 'comet-thread) (kill-comet-thread it))
+  (setf (session-value 'comet-thread) *current-thread*)
+  (wait-on-semaphore (session-value 'comet-semaphore))
+  (setf (session-value 'comet-thread) nil)
+  (aif (session-value 'comet-fn) (funcall it)))
+
+(defun comet (fn &optional (session *working-session*))
+  (setf (session-value 'comet-fn session) fn)
+  (signal-semaphore (session-value 'comet-semaphore session)))