Re: [Cppcms-users] Server
Brought to you by:
artyom-beilis
From: Artyom B. <art...@gm...> - 2016-01-02 17:01:39
|
Hi, You have two issues: 1st of all your code does not compile because sig.connect tries to copy the ticker class which isn't something you actually want. And in general if you already using boost::signals2 you should also use its automatic disconnection handling. So first change would be boost::signals2::scoped_connection conn; void connectSlot() { conn = std::move(sig.connect([this](double v) { this->on_new_value(v); })); } Now the second issue is that you should be aware of the fact that the robot thread and application thread are different so what you need to do is to use service().post(handler) to post code execution to the main event loop of the cppcms: void on_new_value(double v) { service().post([=]() { // post for execution in relevant thread this->handle(v); }); } // now actual work void handle(double new_one) { cout << "SLOT CALLED" << endl; counter_++; price_ = new_one; for(auto waiter : waiters_) { async_send(waiter); } waiters_.clear(); } Regards, Artyom On Sat, Jan 2, 2016 at 1:32 PM, eric middelkoop <mid...@gm...> wrote: > Hi, > > I'm developing a robot that is controlled via the browser by issuing > commands. > > Apart from the cppcms applications that are started from main, the server > has an additional thread for controlling the motors: robotThread > > While the robotThread is acting on a command I like it to report progress > back to the browser so that I can follow what exactly it is doing. > > The idea is to use ticker-example http://blog.cppcms.com/post/107 and > replace the timed updates by something like a boost::signals2 slot so that > progress in the robotThread can be reported to the cppcms comet application > that can report it to the browser. > > Enclosed is the sourcecode of a small testprogram based on the ticker > example. It does not compile because of an error: use of deleted function > ‘ticker::ticker(const ticker&). I can't find a way to connect the cppcms > comet application to the signal. > > Do you have any idea how to do this or any other way to use the cppcms comet > application as a proxy between server and webclient? > > Kind regards, > Eric > > ------------------------------------------------------------------------------ > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |