[avahi] DBUS Integration and Browsing Services

Jonathan Bagg jbagg at lenbrook.com
Tue Sep 1 12:10:12 PDT 2015


Glenn,

What do you mean by "The browser only seems to signal back on its first 
run"?  signal back what, new services?  I use Avahi-client (c api) in 
Qt.  Avahi-client talks to the daemon over d-bus.  My callback fires 
whenever a service is added or removed long after startup.

On 15-09-01 02:28 PM, Glenn Martin wrote:
> 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)
> }
>
>
> _______________________________________________
> avahi mailing list
> avahi at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/avahi


-- 
Jonathan Bagg
Embedded Systems Developer
NAD Electronics | Lenbrook Industries Limited
633 Granite Court, Pickering, Ontario, Canada L1W 3K1 | 905-831-0799 ext 4478 | http://www.nadelectronics.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/avahi/attachments/20150901/cf1cd973/attachment.html>


More information about the avahi mailing list