[avahi] DBUS Integration and Browsing Services

Glenn Martin lifewarped at yahoo.com
Tue Sep 1 11:28:22 PDT 2015


My team and i are trying to integrate Avahi via DBUS in Go (golang.org). I have read through the documentation and i have worked with the python bindings as a guide, we have basic browsing working, however we seem to be running in to a few unexpected issues.

The browser (http://avahi.org/download/ServiceBrowser.introspect.xml) only seems to signal back on its first run. This makes sense for efficiencies sake, however in cases of things such as unit tests, this means that the code that tests various lookups fail on subsequent runs. Given that we are following a light form of TDD this is becomming a real issue. 
Is there anyway to clear the Browser's cache or make it repeat values? Or perhaps have some way to know when a session is over and the next request will require a full update, not just a differential? Code example at EOF.
Thanks!
Glenn Martin

// The following is a messy excerpt from the code we are presently using to test. Many of the constants are stolen from the python bindings found here: http://git.0pointer.net/avahi.git/tree/avahi-python/avahi/__init__.py sysbus, err := dbus.SystemBusPrivate() if err != nil { return err }
 defer sysbus.Close()
 if err = sysbus.Auth(nil); err != nil { return err } if err = sysbus.Hello(); err != nil { return err }
 logs.Infof("SysBus => %+ v", sysbus)
 /* Lets get our Service object */ avahiObject := sysbus.Object(DBUS_NAME, DBUS_PATH_SERVER)
 logs.Infof("Avahi Object => %+v", avahiObject)
 /* Were gonna need this for resolution later. */ var items []serviceBrowserRecord = []serviceBrowserRecord{}
 /* Now lets listen to our ServiceBrowser and Listen in to its wisdom */ c := avahiObject.Call("ServiceBrowserNew", 0, IF_UNSPEC, PROTO_UNSPEC, service, "local", uint32(0)) if c.Err != nil { panic(c.Err) } logs.Infof("Browser Object Response => %+v", c)
 browserObject := sysbus.Object(DBUS_INTERFACE_SERVICE_BROWSER, c.Body[0].(dbus.ObjectPath))
 defer browserObject.Call("Free", 0)
 logs.Infof("Browser Object => %+v", browserObject)
 browserMatchingRule := fmt.Sprintf("type='signal',path='%s',interface='%s',sender='%s'", c.Body[0].(dbus.ObjectPath), DBUS_INTERFACE_SERVICE_BROWSER, DBUS_INTERFACE_SERVICE_BROWSER)
 sysbus.BusObject().Call(DBUS_OFD_ADD_MATCH, 0, browserMatchingRule)
 ch := make(chan *dbus.Signal, 10)
 sysbus.Signal(ch)
 breakIt := false for v := range ch { logs.Infof("SIG => %+v",v)}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/avahi/attachments/20150901/eb885ccd/attachment.html>


More information about the avahi mailing list