From: Rafal D. <r....@ke...> - 2010-12-07 10:00:12
|
Here is a snippet of code from my application, This code is for periodic check if connection is alive You need to install DBus::DefaultTimeout (dt is pointer to this object) with DBus::BusDispatcher (dispatcher object) BTW framework is responsible for releasing dt memory (see internals of DBus::Callback_Base) bool const repeat=true; unsigned const timeout_ms = 3 * DEFAULT_TIMEOUT_MS;//DSP uses 10000 for Ping->Pong messages DBus::DefaultTimeout*const dt = new DBus::DefaultTimeout(timeout_ms, repeat, &dispatcher); dt->expired=new periodic(); periodic is a class which does processing on timeout: class periodic: public DBus::Callback_Base<void, DBus::DefaultTimeout &> { public: void call(DBus::DefaultTimeout & param) const { if( not ping_was_called.read_reset() ) { LWAR_ << "TIMEOUT: CLOSING THE CONNECTION " << blackfin << " last Ping received long time ago"; ::close( blackfin ); g_devices->invalidate();//Reset DBus collections - no connection with devices g_blocks->invalidate(); } } }; -----Original Message----- From: Theodore A. Roth [mailto:ta...@gm...] Sent: Fri 12/3/2010 11:23 PM To: dbu...@li... Subject: [dbus-cplusplus-devel] dispatcher timeout I've been trying to figure out how to register a timeout callback with the dispatcher so that my callback function will be invoked periodically by the dispatcher main loop. The BusDispatcher::add_timeout() method seems to take an internal timeout object as an argument which leads me to believe that I can't use that. I'm still in the learning dbus-c++ phase and my app is a rather simple server based on the echo demo, but I've stripped it down to only a Hello method and a single signal. My goal is to invoked the signal in the timeout. None of the examples in the source repo show how to do what I what, and google hasn't been too helpful. If someone has a link to an example of this, I would be most appreciative. Thanks. Ted Roth ------------------------------------------------------------------------------ Oracle to DB2 Conversion Guide: New IBM DB2 features make compatibility easy. Learn about native support for PL/SQL, new data types, scalar functions, improved concurrency, built-in packages, OCI, SQL*Plus, data movement tools, best practices and more - all designed to run applications on both DB2 and Oracle platforms. http://p.sf.net/sfu/oracle-sfdev2dev _______________________________________________ dbus-cplusplus-devel mailing list dbu...@li... https://lists.sourceforge.net/lists/listinfo/dbus-cplusplus-devel -- Asylia ExchangeDefender Message Security: Click below to verify authenticity http://www.exchangedefender.com/verify.asp?id=oB79TrMa012804&from=r....@ke... |