From 9de16e3435b0e6fd14af991db278717387d676d3 Mon Sep 17 00:00:00 2001 From: Comment Date: Sun, 24 Feb 2013 19:24:40 +0000 Subject: working threading --- rotord/rotord.cpp | 108 +++++++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 53 deletions(-) (limited to 'rotord/rotord.cpp') diff --git a/rotord/rotord.cpp b/rotord/rotord.cpp index c9fbbf5..1843c9c 100755 --- a/rotord/rotord.cpp +++ b/rotord/rotord.cpp @@ -21,6 +21,8 @@ Output is: "segmentation" Done ./rotord: symbol lookup error: /usr/local/lib/vamp/qm-vamp-plugins.so: undefined symbol: clapack_dgetrf +http://www.codeproject.com/Articles/252827/Learning-Poco-A-simple-HTTP-server + next: load a movie and retreive frames save a movie @@ -50,8 +52,6 @@ void RotorRequestHandler::handleRequest(HTTPServerRequest& request,HTTPServerRes ostr << "

"; } -RotorRequestHandlerFactory::RotorRequestHandlerFactory(const std::string& format):_format(format){ -} AudioAnalyserHandler::AudioAnalyserHandler(const vampHost::Settings& _settings): settings(_settings){ } @@ -73,7 +73,9 @@ void AudioAnalyserHandler::handleRequest(HTTPServerRequest& request,HTTPServerRe ostr << "

"; } -RenderContextHandler::RenderContextHandler(const std::vector _command): command(_command){ +RenderContextHandler::RenderContextHandler(const std::string _content,const HTTPServerResponse::HTTPStatus _status){ + content=_content; + status=_status; } @@ -81,47 +83,11 @@ void RenderContextHandler::handleRequest(HTTPServerRequest& request,HTTPServerRe response.setChunkedTransferEncoding(true); response.setContentType("text/html"); + response.setStatus(status); std::ostream& ostr = response.send(); - string content; - if (command.size()) { - if (command[0]=="new") { - Poco:UUID sID=idGen.create(); - context[sID]=new Rotor::Render_context(); - context[sID].run(); - content=""+sID.toString()+""; - } - else { - Poco:UUID sID; - if (sID.tryParse(command[0]) { - iterator iter = context.find(sID); - if (iter!=context.end()) { - //successfully located context - if (command.size()==1) { - //just invoking sID - if (request.getMethod()=="DELETE") { - - } - } - else { - - } - } - else { - resp.setStatus(HTTPResponse::HTTP_NOT_FOUND); - content="Rotor: render context not found"; - } - } - else resp.setStatus(HTTPResponse::HTTP_BAD_REQUEST); - content="Rotor: command not found"; - } - } - else { - content="Rotor: empty request"; - } - - ostr << ""; + ostr << ""; ostr << content; } @@ -131,19 +97,14 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS Application& app = Application::instance(); Poco::URI theuri=Poco::URI(request.getURI()); - std::vector segments; - theuri.getPathSegments(segments); + std::vector command; + theuri.getPathSegments(command); - std::ostringstream ostr; - ostr << segments.size(); + app.logger().information(request.clientAddress().toString()+" "+request.getMethod()); - std::string out; - for (uint i=0;i\n"; + } + else if (command[0]=="list") { + for (std::unordered_map::iterator it = context.begin(); it != context.end(); ++it) { + content+=""+it->first+"\n"; + } + } + else { + std::unordered_map::iterator iter = context.find(command[0]); + if (iter!=context.end()) { + //successfully located context + if (command.size()==1) { + //just invoking sID + if (request.getMethod()=="DELETE") { + + } + } + else { + + } + } + else { + status=HTTPResponse::HTTP_NOT_FOUND; + content="Rotor: render context not found\n"; + } + } + } + else { + content="Rotor: empty request"; + } + return new RenderContextHandler(content, status); } @@ -223,7 +225,7 @@ int RotorServer::main(const std::vector& args){ unsigned short port = (unsigned short) config().getInt("port", 9980); std::string format(config().getString("format", DateTimeFormat::SORTABLE_FORMAT)); ServerSocket svs(port); - HTTPServer srv(new RotorRequestHandlerFactory(format),svs, new HTTPServerParams); + HTTPServer srv(new RotorRequestHandlerFactory(),svs, new HTTPServerParams); srv.start(); waitForTerminationRequest(); srv.stop(); -- cgit v1.2.3