Boost:Signals and Bind question
Hi Everyone, I have a question on using Signals with a COM server and a client. Is it possible to have a signal on a COM server and a method ConnectSlot(clientMethod) that can be called from a client? I want to have a COM server that when some update is done, notifies all of the slots(subscribers), so that from the clients I can do: helloService->ConnectSlot(boost::bind(&Callback)); where callback is a method in the client. On the server side I have: STDMETHODIMP CHelloService::ConnectSlot(VARIANT aSubscriber) { connect(aSubscriber); //connect(boost::bind(aSubscriber)); return S_OK; } CHelloService::connection_t CHelloService::connect(signal_t::slot_function_type subscriber) { return m_sig.connect(subscriber); } Don't know how to receive the result of Boost::bind from the client. I read Bind supports COM by adding #define BOOST_MEM_FN_ENABLE_STDCALL before the include of bind.hpp. What would you recommend for this approach? Any examples? Thanks in advance, Marcos -- View this message in context: http://www.nabble.com/Boost%3ASignals-and-Bind-question-tp21800004p21800004.... Sent from the Boost - Users mailing list archive at Nabble.com.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 02 February 2009 18:45 pm, mararual wrote:
CHelloService::connection_t CHelloService::connect(signal_t::slot_function_type subscriber) { return m_sig.connect(subscriber); }
You should forward slots with signal_t::slot_type, not signal_t::slot_function_type. I believe the type erasure that occurs when assigning something to slot_function_type will prevent visit_each from finding any boost::trackable objects for automatic connection management purposes. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFJh4zp5vihyNWuA4URAvS8AKCtWS20G/driWGZmLEaXh3bsz1dIQCfU4Cv asnslZ58hbrCPgmEbkL6Kzw= =U6/1 -----END PGP SIGNATURE-----
STDMETHODIMP CHelloService::ConnectSlot(VARIANT aSubscriber) { connect(aSubscriber); //connect(boost::bind(aSubscriber)); return S_OK; }
CHelloService::connection_t CHelloService::connect(signal_t::slot_function_type subscriber) { return m_sig.connect(subscriber); }
How would you make singal slot out of "VARIANT aSubscriber" (which probably wraps some IDispatch* pointing to the stub that communicates with the proxy residing in the Client appartment) ? What boost::signal does after is just a call of a function/functor provided by the subscriber. Certainly, you can't call this way any client code from within the server. In the COM environment callbacks are usually implemented as so-called "connection points", and that's what you need: http://msdn.microsoft.com/en-us/library/h7kad5hw(VS.80).aspx
participants (3)
-
Frank Mori Hess
-
Igor R
-
mararual