[avahi] Client Browser questions
Nathanael D. Noblet
nathanael at gnat.ca
Tue Apr 12 23:09:19 PDT 2011
On 04/12/2011 11:44 PM, Rajesh Sai T wrote:
> Hi Nathan,
>
> Even im looking out for a potential possibility to know if any
> device publishing the service has been removed from LAN and all rest of
> devices get a REMOVE notification so that respective devices can update
> their cache. If any new device comes up, we get BROWSER_NEW event in
> browser_callback but there isnt any event for REMOVE. Could you please
> just share your idea how could we achieve this?
Well there are two callbacks, one for browse, which gets events like
AVAHI_BROWSER_NEW and AVAHI_BROWSER_REMOVE.
when you get BROWSER_NEW you get a new resolver which takes the new
event and resolves it to a hostname etc. and that gets returned in a
browser_resolve_callback.
So from looking at how avahi-discover does it, I added to my app 'global
object' that gets passed to all callbacks a GList services;
the avahi-discover has a Hashtable of servicetypes & services, but I
don't need all service types, just the one, so all I have is a GList.
in the browse_resolve_callback, I create a structure, with the service
name, domain, host and interface and protocol and append it to my list
of services.
Then I have a function that given the list of the services checks for a
duplicate. It does this with
s->interface == interface && s->protocol == protocol &&
avahi_domain_equal(s->service, service_name) &&
avahi_domain_equal(s->domain, domain_name)
which was learnt from looking at avahi-discover similar test.
From there in the browse_callback, when I get a AVAHI_BROWSER_REMOVE
event I call this getService function that loops over the GList and
returns the matching record, then do what I need to remove it from my app...
--
Nathanael d. Noblet
t 403.875.4613
More information about the avahi
mailing list