Is it possible that a service object gets a notification when a client closes dbus connection?
phuang at redhat.com
Mon Mar 31 07:15:41 PDT 2008
Thanks. I write some code to test your idea. It works well. :)
But I still have a little problem. You said we can use argyment matching
to avoid unnecessay wakeups. How to get the client's Name (arg0)? Can I
get the name of the caller in any functions of my service? Or I must
provide a function in my service and let client call it with the
client's name as a argument?
BTW, I am using dbus-python.
在 2008-03-31一的 12:07 +0100，Simon McVittie写道：
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> On Mon, 31 Mar 2008 at 18:21:08 +0800, Huang Peng wrote:
> > I want to develop a service object in the SessionBus. This object wants
> > to track which clients are reference it. Is it possible that the service
> > object get a notification when a client's connection is closed.
> Yes. Keep track of the unique names of clients who are referencing the
> service (unique names look like ":1.42"); you can get these from the
> method call message when they call any of your methods. If you're using
> this pattern, you might have to require that all clients call some sort
> of IAmInterested() method on your service).
> When the client falls off the bus for any reason (deliberate disconnection,
> segfault, kill -9, whatever) you will receive a signal like this:
> org.freedesktop.DBus.NameOwnerChanged(":1.42", ":1.42", "")
> from the bus daemon. The empty string as the "new owner" argument
> indicates that the unique name is now unowned (the process has
> disconnected from the bus).
> You'll need to register with the bus daemon as being interested in that
> signal - ideally, use argument-matching (e.g. 'arg0=":1.42"') to avoid
> unnecessary wakeups.
> -----BEGIN PGP SIGNATURE-----
> -----END PGP SIGNATURE-----
> dbus mailing list
> dbus at lists.freedesktop.org
More information about the dbus