[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

www(omega) event



In article <gjh-1801951803190001@dugong.hpl.hp.com> gjh@hpl.hp.com (Graham Higgins) writes:

   I'd like to send a WWW(Omega)sdoc event to MCL. 

   Before I sink into the morass of AppleEvents and interprocess
   communication documentation, has anyone been this way before? 

   Thanks in anticipation.

Here is an excerpt from an experiment I did a while ago (and then
moved on to other things). It should show what the basics of setting
up the appleevent receiver look like. The sketch is
 1) install #'respond-to-http-request as the handler for the appleevent
 2) respond-to-http-request takes out the string argument, calls a
    routine which tries to respond, and passes something back to
    the http server.
 3) maybe-handle-framer-query did a look up in a database. If it found
    an entry it generated an html description of it. If not it returns nil.

Someone mentioned that this is slow. It is. But I found the delay to
be on the order of seconds, not minutes. 

Hope that this helps. 
-alan 

The key :|WWW| needs a (unprintable here) omega.

(require 'appleevent-toolkit)

(ccl::install-appleevent-handler :|WWW| :|srch| #'respond-to-hhtp-request)

(defmethod respond-to-hhtp-request ((a application) 
				    theAppleEvent 
				    reply
				    handlerRefcon)
  (declare (ignore handlerRefcon))
  (let ((query (ccl::ae-get-parameter-char theAppleEvent #$keyDirectObject t)))
    (ccl::ae-put-parameter-char reply #$keyDirectObject
                           (or (maybe-handle-framer-query query)
                               "Lisp didn't understand what you wanted") t)))

(defun maybe-handle-framer-query (query)
  (when  (and (char= (char query 0) #\#)
                            (char= (char query 1) #\/))
    (with-output-to-string (s)
      (describe-frame-in-html (eval (read-from-string query)) s)
      (return-from maybe-handle-framer-query (get-output-stream-string s)))))