DBUS service using glib: question

Andre Magalhaes andrunko at gmail.com
Fri Jul 14 05:45:12 PDT 2006


On 7/14/06, Xavier Claessens <xclaesse at gmail.com> wrote:
> On dim, 2006-06-25 at 20:28 -0300, Andre Magalhaes wrote:
> > On 6/25/06, Xavier Claessens <xclaesse at gmail.com> wrote:
> > > Le dimanche 25 juin 2006 à 13:29 -0400, Havoc Pennington a écrit :
> > > > Thiago Macieira wrote:
> > > > >> - I register a main object with a connect method which returns an ID to
> > > > >> the client. The connect method also create and register a new object
> > > > >> just for this client which is stored in a list. The client, using the ID
> > > > >> can get the remote object and use it. Signals and method on this object
> > > > >> will have special effects depending on what the client does with it and
> > > > >> not interfering with what other clients does with other objects.
> > > > >> - The main object has also a disconnect method which takes the ID in
> > > > >> param and remove all data related to this client.
> > > > >>
> > > > >> Is that the good way ? Does someone knows if other projects does the
> > > > >> same thing, like that I can see how they do...
> > > > >
> > > > > Yes, that makes sense. In fact, this is what I recommend as a proper OOP
> > > > > approach.
> > > >
> > > > A couple details that might help:
> > > >   - of course you probably want to watch for the client's unique name
> > > > vanishing and automatically clean up after the client if it does
> > > >   - you probably don't need a custom ID thing, because you can use
> > > > a client's unique name, or you can generate an object path for unique
> > > > ids on the server side
> > >
> > > Thanks for answers. Maybe I didn't looked enough to documentation, but
> > > how can I get the client's unique name ? And how can I get notified when
> > > it disappear ? I can't find that in glib's API but it is maybe in lower
> > > level API ?
> > As Thiago said, you need to watch for the NameOwnerChanged signal to
> > know when a client disappear.
> > For an example, take a look at the file
> > http://svn.sourceforge.net/viewcvs.cgi/tapioca-voip/trunk/tapioca/daemon/main.c?view=markup&rev=298
> > and search for the name_owner_changed function.
>
> Thanks ! I can now know when a client connect/disconnect and I keep a
> hash table with information about all clients connected. Then only
> problem remaining: When a method is called on my object, how can I know
> which client called it ?
>
> My callback for the "NameOwnerChanged" signal is always called twice !
> Is is a bug ? For example, when a client connect the callback is called
> 2 times with the same args (name=:1.90 ; old_owner='\0' ;
> new_owner=:1.90). I have the same thing when client disconnect. Bug or
> feature ?
I can confirm this. I though it was a feature.

Andrunko


More information about the dbus mailing list