[prev in list] [next in list] [prev in thread] [next in thread]
List: freedesktop-dbus
Subject: Re: DBUS service using glib: question
From: Thiago Macieira <thiago.macieira () trolltech ! com>
Date: 2006-06-25 13:13:49
Message-ID: 200606251513.49924.thiago.macieira () trolltech ! com
[Download RAW message or body]
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
[Attachment #3 (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic