From 35f5f0938c82e9aa9f0c704b1d43dff3209ad567 Mon Sep 17 00:00:00 2001 From: Comment Date: Sat, 23 Feb 2013 17:01:45 +0000 Subject: thread server architecture --- rotord/rotord.cpp | 72 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 8 deletions(-) mode change 100644 => 100755 rotord/rotord.cpp (limited to 'rotord/rotord.cpp') diff --git a/rotord/rotord.cpp b/rotord/rotord.cpp old mode 100644 new mode 100755 index f20b515..c9fbbf5 --- a/rotord/rotord.cpp +++ b/rotord/rotord.cpp @@ -73,6 +73,59 @@ void AudioAnalyserHandler::handleRequest(HTTPServerRequest& request,HTTPServerRe ostr << "

"; } +RenderContextHandler::RenderContextHandler(const std::vector _command): command(_command){ +} + + +void RenderContextHandler::handleRequest(HTTPServerRequest& request,HTTPServerResponse& response) { + + response.setChunkedTransferEncoding(true); + response.setContentType("text/html"); + + 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 << content; + +} + HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPServerRequest& request){ Application& app = Application::instance(); @@ -90,8 +143,9 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS out+=" "; } - app.logger().information("Request from "+ request.clientAddress().toString()+" "+ostr.str()+" segments: "+out); + app.logger().information(request.clientAddress().toString()+" "+request.getMethod()+": "+ostr.str()+" segments: "+out); + /* if (segments.size() == 0) { return new RotorRequestHandler(_format); } @@ -107,19 +161,21 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS return 0; } else if (segments[0]=="new") { - // website creating a new render context - + // create a new render context - //Settings(string _so="",string _filter="",string _id="",string _input=""); - return new AudioAnalyserHandler(vampHost::Settings(segments[1],segments[2],segments[3])); - //string audioData=runPlugin(string myname, string soname, string id, - // string output, int outputNo, string wavname, - // string outfilename, bool useFrames); return 0; } else { return 0; } + */ + return new RenderContextHandler(segments); + + //at this point we are within app + //making a new contexthandler? + //how will this have access to the thread that it refers to + //how will messages be passed + //we need to do testing etc here and } -- cgit v1.2.3