ruby dbus and avahi zeroconf

i was playing with ruby-dbus this afternoon. the 'rbus' gem wasn't working for me.

require 'dbus' bus = DBus::SystemBus.instance p=bus.introspect("org.freedesktop.Avahi","/") server = p["org.freedesktop.Avahi.Server"]

sb = server.ServiceBrowserNew(-1,-1,"_presence._tcp","",0) puts sb.inspect

register for signals

mr = DBus::MatchRule.new mr.type = "signal" mr.interface = "org.freedesktop.Avahi.ServiceBrowser" mr.path = sb.first bus.add_match(mr) do |msg, first_param|

puts msg.params.inspect

puts msg.member + " " +msg.params[2].to_s end

Main loop

main = DBus::Main.new main << bus main.run /typo:code

With pidgin running, a zeroconf presence is established and the ruby script picks up on that.

ruby-dbus-0.2.1$ ruby -I lib /home/donp/src/ruby/avahi.ruby.dbus.rb
["/Client31/ServiceBrowser1"]
ItemNew Don park@sparky
CacheExhausted 
AllForNow 

the idea is to add opengl bits to make a group of spheres that represent people/laptops in the cafe. (inspired by gl_tail)

tags: