Detecting connection to service
Roman I Khimov
roman at khimov.ru
Fri Jun 9 12:16:46 PDT 2006
9 июня 2006 21:12 | John (J5) Palmieri:
> You don't connect to a service, you connect and disconnect to a bus.
> Disconnect only gets sent to the service which disconnects. The bus
> handles connections so there is no corresponding signal. You can listen
> to NameOwnerChanged.
> So the question is how do I detect incoming connections to a service?
> Well when you get a message you've got an incoming connection. What I
> suspect you want to do is create a lookup table and populate it with
> unique names from the clients that send messages to you. You then want
> to listen for NameOwnerChanged on the unique names in your lookup (if
> the name is already in the table you don't want to add another
> listener). When you handle a NameOwnerChanged signal and the name drops
> off the bus (new_name == NULL) you want to take it out of your lookup
Thanks a lot, I'm beginning to understand better the whole thing.
Actually the real question for me is how to make service (well, it's called
services still) unloading. Services can be autostarted by D-Bus and that is
really a great thing, but there is no way for automatic unloading of them
when they're not needed anymore.
For example, we might have something sort of a shared library available as a
set D-Bus objects and want to load it with first app using it (and that is
possible today), but unload it when last application using it will close
it's D-Bus connection (so it doesn't waste precious memory).
But NameOwnerChanged watching might actually be solution, although it will
require more "intellectual" and even "spying" :) services.
Again, thanks a lot!
mailto: roman at khimov.ru ..o
gpg --recv-keys 0xE5E055C3 --keyserver hkp://subkeys.pgp.net ooo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20060609/b7887165/attachment.pgp
More information about the dbus