7
server = dbus.Interface(bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER)
9
def new_service(interface, protocol, name, type, domain, flags):
10
interface, protocol, name, type, domain, host, aprotocol, address, port, txt, flags = server.ResolveService(interface, protocol, name, type, domain, avahi.PROTO_UNSPEC, dbus.UInt32(0))
11
print "Found service '%s' of type '%s' in domain '%s' at address '%s:%s'" % (name, type, domain, address, port)
13
def remove_service(interface, protocol, name, type, domain):
14
print "Service '%s' of type '%s' in domain '%s' disappeared." % (name, type, domain)
18
browser = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.ServiceBrowserNew(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, stype, domain, dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_BROWSER)
20
browser.connect_to_signal('ItemNew', new_service)
21
browser.connect_to_signal('ItemRemove', remove_service)
22
gobject.MainLoop().run()