[avahi] Mono apps don't get notified of ClientState.Running

Celso Pinto cpinto at yimports.com
Sun Apr 30 20:47:38 PDT 2006

Hi again guys,

the Connect() method doesn't work because the Client.OnClientCallback 
method is invoked while avahi_client_new, which means that the Client 
object still has an invalid Handle and Avahi.EntryGroup barfs on it.

I'm attaching the patch if you care to take a look (it prints a couple 
of debug messages to stdout).

You'll see that the output "OnClientCallback invoked for state Running" 
is printed before the "Got handle" message.

Any ideas?


Celso Pinto wrote:
> Hi everyone,
> I'm programming an application that uses Avahi's Mono bindings and I 
> think I found an ugly problem: when a Mono app creates an instance of 
> Avahi.Client, the constructor of this class invokes the native 
> avahi_client_new method, which receives a parameter for the client_state 
> callback.
> While still in construction, the Avahi.Client class gets notified that 
> the ClientState is now Running, so the Client.OnClientCallback method is 
> invoked but the StateChanged event still doesn't contain any Handlers 
> because this is all happening during construction of the Avahi.Client 
> object.
> This means that applications, like my own, that are waiting on the 
> StateChanged event with a ClientState.Running value to start publishing 
> their services never get notified, therefore never get to publish anything.
> The only way to fix this problem is to create a Client.Connect() method. 
> This allows us to first create an instance of Avahi.Client, then add a 
> delegate to the StateChanged event and finally call the 
> Avahi.Client.Connect() method. Only then our callbacks get notified of 
> the running state.
> The big question is: because this will break the current behaviour of 
> the Avahi.Client class (meaning that the client connects to the daemon 
> during construction), will you guys make the necessary changes?
> Cheers,
> Celso
> _______________________________________________
> avahi mailing list
> avahi at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/avahi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: client.diff
Type: text/x-patch
Size: 1869 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/avahi/attachments/20060501/c299d0c2/client.bin

More information about the avahi mailing list