Re: [Cppcms-users] "endless" stream of data
Brought to you by:
artyom-beilis
From: Artyom B. <art...@ya...> - 2011-12-27 14:52:00
|
Please, read carefully the chat example and see how callbacks are used. It is all about event handling. Remember the you run inside event loop. and operations are done via callbacks. It is not like in PHP where "comet" event holds entire thread. Read 3 articles under "Concepts" there: http://art-blog.no-ip.info/wikipp/en/page/cppcms_1x You probably looking for something like this. myservice : public cppcms::application { void main(std::string) { context_=release_context(); // now we can handle new connection - note it is very simplistic // we store only one connection, there may be more } void handle_some_external_event() { context_->out() << "event!" << std::endl; context_->async_flush_output(boost::bind(&my_service::on_complete,this,_1); } void on_complete(completion_type c) { if(c!=operation_completed) { // error - disconnect context_.reset(); // delete context } // done we can wait for next event ... } booster::shared_ptr<cppcms::http::context> context_; }; Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.sf.net/ CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/ >________________________________ > From: Marcel Hellwig <ke...@co...> >To: Artyom Beilis <art...@ya...>; cpp...@li... >Sent: Tuesday, December 27, 2011 4:15 PM >Subject: Re: [Cppcms-users] "endless" stream of data > >could you give me a simple example? Just writing something stupid. I don't get the async flush output method. Don't know what the handler is and does. > > > |