[Cppcms-users] comet question
Brought to you by:
artyom-beilis
From: Frank E. <fra...@an...> - 2010-07-13 13:19:49
|
hi, i try to build the example from the blogpost http://art-blog.no-ip.info/cppcms/blog/post/47 and i'm kind of stuck. the example seems not to be really compatible with the current cppcms version. i adapted the source as follows: class lpTest : public cppcms::application { public: lpTest(cppcms::service &srv) : cppcms::application(srv) { dispatcher().assign("^/postMessage$", &lpTest::postMessage, this); dispatcher().assign("^/consumeMessage/(\\d+)$", &lpTest::consumeMessage, this, 1); } void postMessage() { if(request().request_method() == "POST") { if(request().post().find("message") != request().post().end()) { messages.push_back(request().post().find("message")->second); broadcast(); } } release_context()->async_complete_response(); } void consumeMessage(std::string id) { unsigned pos = atoi(id.c_str()); if(pos < messages.size()) { response().set_plain_text_header(); response().out() << messages[pos]; release_context()->async_complete_response(); } else if(pos == messages.size()) { waiters.push_back(release_context()); } else { response().status(404); release_context()->async_complete_response(); } } void broadcast() { // send the message to all waiters for(unsigned i=0; i<waiters.size(); i++) { waiters[i]->response().set_plain_text_header(); waiters[i]->response().out() << messages.back(); waiters[i]->async_complete_response(); } waiters.clear(); } private: std::vector<std::string> messages; std::vector<booster::shared_ptr<cppcms::http::context> > waiters; }; and for main: cppcms::service srv(argc, argv); booster::intrusive_ptr<lpTest> app = new lpTest(srv); srv.applications_pool().mount(app); srv.run(); as far as i understand this should work. my problem is that if i start the application and do a request it gives me the following exception: Catched excepion [Access to unassigned context] (.../http_context.cpp:144) it seems like the framework tries to do something with the context though it has been released by release_context() - what am i missing? frank |