]> git.pond.sub.org Git - eow/blob - Notes
Ignore data messages in init mode. Handle simple-stream-error.
[eow] / Notes
1 On COMET w/ hunchentoot: http://common-lisp.net/pipermail/tbnl-devel/2009-February/004620.html
2
3 I have a working comet system using Hunchentoot.
4
5 The basic way I'm operating is to have the browser contact the hunchentoot
6 server and the server thread waits on a semaphore. Any other thread can then
7 release the semaphore and cause a reply back to the browser.
8
9 Hope this helps. I am only using this for development purposes, as I have
10 been having problems with certain browsers, and this will also occupy one of
11 the available browser requests, where many browsers have a very small number
12 available.
13
14 (defun kill-comet-thread (thread)
15   (warn "KILLING COMET THREAD: ~a" thread)
16   (ignore-errors
17     (destroy-thread thread)))
18
19 (defun handle-comet ()
20   (awhen (session-value 'comet-thread) (kill-comet-thread it))
21   (setf (session-value 'comet-thread) *current-thread*)
22   (wait-on-semaphore (session-value 'comet-semaphore))
23   (setf (session-value 'comet-thread) nil)
24   (aif (session-value 'comet-fn) (funcall it)))
25
26 (defun comet (fn &optional (session *working-session*))
27   (setf (session-value 'comet-fn session) fn)
28   (signal-semaphore (session-value 'comet-semaphore session)))