From: Andreas V. <li...@br...> - 2011-03-10 12:40:08
|
Am Wed, 22 Dec 2010 10:09:35 -0500 (EST) schrieb Pierre-Luc Bacon: > We need to keep track of how many clients are currently connected to > our server application via DBus, and exit when no one is using it. > > Using NameOwnerChanged from org.freedesktop.DBus on the session bus > would allow to detect for client that disappeared because of a crash, > and release the allocation made for it in the server. > > To implement this logic, the unique name given to the client should > be known. > > The only way I see this can be done is through Message::sender() (in > the server). However, the Message object does not seem to be easily > available from the method being called in the bound object (in the > server). > > I could maybe hack my way into the glue file ... but then any change > in it would have to be maintained manually. > > Has anybody dealt with that issue ? Hello, I never had this use case. My applications were always not depending on such logic. But I could imagine such situations. Not sure how to solve this. The easiest idea I've is to add some signal connect() and deconnect() to your interface. Each time a client starts it calls the connect() method and if it stops it calls the deconnect() method. Then the server counts the number of connected clients and could exit if the last one disconnected. Should work and you don't have to hack something into the glue. regards Andreas -- Technical Blog <http://andreasvolz.wordpress.com/> |