From: Andreas V. <li...@br...> - 2010-12-05 22:10:16
|
Am Wed, 20 Oct 2010 15:10:37 -0700 schrieb Jason, Jamie: > Apologies if this has been discussed before, but I couldn't find what > I needed in a quick search of the archives. If it is there, simply > pointing me to the relevant discussion thread would be great. > > I have a class that implements the adaptor and I would like to do the > following: > - detect when a client disconnects from my session bus (either by > cleanly shutting down or even if it crashes) > - obtain the client that is sending a message (i.e., calling one of > my exported methods) > > The reason I would like to do this is that when a client calls some > of my exposed methods, I allocate some resources on the client's > behalf. When the client calls one of these methods, I need to > determine the unique client that is requesting it. I need to know > when the client disconnects (or dies) so that I can look at my held > resources and clean up the ones that have been created on behalf of > the client. > > A quick perusal of the header files and mapping out the inheritance > hierarchy for the classes, I don't see how I can get from my class > that derives from *_adaptor and DBus::ObjectAdaptor to a class that > can give me this information. I see that the DBus::Server class has > an on_new_connection callback, but that doesn't appear to be what I > want. > > Can someone point me in the right direction? Hello, sorry for the late answer. I also don't know such a feature in DBus. I would also call this a intelligent logic that shouldn't belong into the DBus protocol. But maybe you could ask on the C list and come back with the C way for it to ask for wrapping it in C++. But for your solution I know similar logic from other systems. I would design an interface function to your client that is named heartbeat() or similar and specify your system to call it e.g. twice a minute. If you doesn't receive a call after e.g. a minute you could consider the other side dead. But please aware of the danger of such heartbeat logic on real live productive systems! So be sure what heartbeat time you choose! Systems sometimes look dead in heavy load situations and come back later. regards Andreas |