My application has background threads that communicate with our weather radar hardware and need to notify all web sessions of status changes (e.g. the position of the antenna, the status of the transmitter).
I have tried using both WServer::post() as well as signal/slot - each has their advantages and disadvantages. Using WServer::post I've been using WServer::post(), but the callback function doesn't take any arguments, so the notified session has to retrieve the status, and then decode it. Note if I want to send multiple arguments, I have to encode them into a StatusEvent, and the session needs to decode the StatusEvent. (This technique was shamelessly borrowed from the Wt simplechat example). =========================== Using signal and slots I have some older code that is using Wt signals and slots. I liked that I could send multiple parameters to a slot, but the UpdateLock caused me problems - I needed to run one copy of the hardware polling thread per session, rather than a single instance. =========================== Questions: 1) Is there any way to send multiple parameters using WServer::post()? 2) How should I use signal/slot from a background boost thread to notify multiple sessions? My current code looks like: app = Wt::WApplication::Instance() Wt::WApplication::UpdateLock lock app->getUpdateLock(); logSignal_.emit(text); app->triggerUpdate(); // push the changes to the browser Do I need to call logSignal_.emit(text) multiple times, once for each session that needs to be notified? Or do I need to lock all sessions, before calling logSignal_.emit(text) ? 3) Is there any other mechanism I should use to send notifications with multiple parameters from a polling thread to multiple sessions? =========================== FYI, using WServer::post() the sequence of calls is: <Session> statusServer_.registerCallback( this, wApp->bind( boost::bind( &SystemStatus_UI::statusEventCallback, this)), ids) <background thread>: StatusServer::postStatusEvent(const StatusEvent &event) WServer:post(sessionId, callback) <Session> SystemStatus_UI::statusEventCallback() // called from WServer::post() event = statusServer_.getEvent(this) processStatusEvent(event) ------------------------------------------------------------------------------ Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk _______________________________________________ witty-interest mailing list witty-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/witty-interest