Fri 11 Feb 2005

CL-ZEROCONF

It was pretty much as easy as I'd hoped. asdf-install the CL-ZEROCONF library (or do it manually — I use OpenMCL, for which the downloading part doesn't seem to work, so (asdf::operate 'asdf:compile-op :cl-zeroconf), then the same for 'asdf:load-op). All set!

Now, add the following to the iTunes listener (apologies for the <pre> formatting):
;;; Now we publish the service. We have to construct
;;; a txt-record, because we need to append a path.
(dns-sd:publish (make-instance 'dns-sd:service
:name "iTunes Controller"
:type "_http._tcp"
:txt-record
(dns-sd:build-txt-record
'(("path" . "/itunes/")))
:port 8000) nil)
(dns-sd:publish (make-instance 'dns-sd:service
:name "Shutdown iTunes"
:type "_http._tcp"
:txt-record
(dns-sd:build-txt-record
'(("path" . "/itunes-power/shutdown")))
:port 8000) nil)
(dns-sd:publish (make-instance 'dns-sd:service
:name "Start iTunes"
:type "_http._tcp"
:txt-record
(dns-sd:build-txt-record
'(("path" . "/itunes-power/startup")))
:port 8000) nil)
(dns-sd:process-dns-sd-events 3.0)
These assume that the URL has been set up — my machine is named redwood, so I had to add a listener for (araneida::parse-urlstring "http://redwood.local.:8000") to Araneida. Voila! Controls to start, stop, and open the controller appear in Safari:
If I get round to it, I'll post updated code.

Posted at 2005-02-11 13:22:31 by RichardLink to CL-ZEROCONF