DBUS service using glib: question
Thiago Macieira
thiago.macieira at trolltech.com
Sun Jun 25 06:13:49 PDT 2006
Xavier Claessens wrote:
>I'm writing a simple dbus service using GLIB interface. My problem is
>that I have to keep some information about each client. For example how
>can I emit a signal on the object only for one specific client, or with
>different data for each client ?
You can't. A signal is emitted to whoever wants to listen to it.
If you want to talk to a specific destination, you should use a method
call.
>Another problem I have is how to know when a client connect/disconnect ?
Use the NameOwnerChanged signal from the org.freedesktop.DBus interface
(object /, service org.freedesktop.DBus).
>Because I keep some data in a hash table, I want to know when a client
>disconnect to delete corresponding data.
>
>How can I make that properly with dbus ?!?
The NameOwnerChanged is emitted for the unique-connection-name when the
client goes away. The new_owner string (the third string) will be empty.
> - 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.
--
Thiago José Macieira - thiago.macieira AT trolltech.com
Trolltech AS - Sandakerveien 116, NO-0402 Oslo, Norway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20060625/56549da4/attachment.pgp
More information about the dbus
mailing list