|
From: Schmottlach, G. <gle...@ha...> - 2009-06-10 14:02:59
|
It may be better for you to exam this fork of the D-Bus C++ binding where both asynchronous client/server mechanisms are supported: git://zub.lamer.la/dbus-c++-async.git I don't believe the "original" C++ binding really supported this. Also, don't use the C++ binding from different threads because the underlying library (D-Bus Lib) really isn't thread-safe when making asynchronous requests. (See: http://lists.freedesktop.org/archives/dbus/2009-March/011031.html) for more details). It exhibits several race conditions. The example programs in the above GIT repository are pretty much broken. They compile but won't work so don't use them as a guide. The underlying binding there, however, will work in the asynchronous fashion you desire. Good luck . . . -----Original Message----- From: Freyensee, James P [mailto:jam...@in...] Sent: Tuesday, June 09, 2009 7:12 PM To: dbu...@li... Cc: Ahmed, Suhail; Benis, Robertino Subject: [dbus-cplusplus-devel] Setting the callback function and data in dbus-c++ for async calls Hello: I am struggling to understand how I could do an asynchronous call using dbus-c++ and was wondering if anyone has any currently working example code, explanation, or a tutorial to help me out. This is what I know (I believe at least). For asynchronous calls I need to call the dbus function dbus_bool_t dbus_pending_call_set_notify ( DBusPendingCall * pending, DBusPendingCallNotifyFunction function, void * user_data, DBusFreeFunction free_user_data ) This happens when the constructor PendingCall::PendingCall(PendingCall::Private *p) : _pvt(p) {} is called. I believe this PendingCall::PendingCall() constructor called when the function in Connection.cpp: PendingCall Connection::send_async(Message &msg, int timeout) is called. Now I was thinking that a new, unwritten function in object.cpp needs be written as follows that would call send_async(): PendingCall ObjectProxy::_invoke_method_async(CallMessage &call) { if (call.path() == NULL) call.path(path().c_str()); if (call.destination() == NULL) call.destination(service().c_str()); return conn().send_async(call); } This is actually pretty similar to Message ObjectProxy::_invoke_method(CallMessage &call) {} in Object.cpp. The big question is how do I use this dbus-c++ framework to set the (DBusPendingCallNotifyFunction function, void * user_data) parameters of the dbus_pending_call_set_notify() function? I figure I need to set some parameters in the CallMessage object in ObjectProxy::_invoke_method_async() and/or the Message object in the Connection::send_async(). However, I don't know what to do and how to do it. Second question- is there anything else I am missing that I would need to do to make the callback operation work right in this dbus-c++ framework? Thank you for the help! Regards, Jay Freyensee ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ dbus-cplusplus-devel mailing list dbu...@li... https://lists.sourceforge.net/lists/listinfo/dbus-cplusplus-devel |