diff options
Diffstat (limited to 'rotord/rotord.cpp')
| -rwxr-xr-x | rotord/rotord.cpp | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/rotord/rotord.cpp b/rotord/rotord.cpp index 21ce639..fe860a6 100755 --- a/rotord/rotord.cpp +++ b/rotord/rotord.cpp @@ -144,73 +144,73 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS if (command.size()) { if (command[0]=="new") { - string sID=idGen.createOne().toString(); //create() seems to cause problems - //Creates a new time-based UUID, using the MAC address of one of the system's ethernet adapters. - //Throws a SystemException if no MAC address can be obtained. - // - //seems to hang, to me + string sID=idGen.createOne().toString(); //create() seems to cause problems + //Creates a new time-based UUID, using the MAC address of one of the system's ethernet adapters. + //Throws a SystemException if no MAC address can be obtained. + // + //seems to hang, to me printf("Rotor: starting thread\n"); manager.start(new Rotor::Render_context(sID)); content="<sID>"+sID+"</sID>\n"; } else if (command[0]=="list") { - //std::list < Poco::AutoPtr < Poco::Task > >::iterator it; - //it=manager.taskList().begin(); - //for (it=manager.taskList().begin();it !=manager.taskList().end();++it) { - //content+="<sID>"+(*it)->name()+"</sID>\n"; - //} - - //massive problems making an iterator for the tasklist, the above crashes - //solution: auto type range-based for-loop - //this is c++11 specific but works - - for (auto& task: manager.taskList()) - { - content+="<sID>"+task->name()+" </sID>\n"; - } - } - else { - bool found=false; + //std::list < Poco::AutoPtr < Poco::Task > >::iterator it; + //it=manager.taskList().begin(); + //for (it=manager.taskList().begin();it !=manager.taskList().end();++it) { + //content+="<sID>"+(*it)->name()+"</sID>\n"; + //} + + //massive problems making an iterator for the tasklist, the above crashes + //solution: auto type range-based for-loop + //this is c++11 specific but works + for (auto& task: manager.taskList()) //c++11 - { - if(task->name()==command[0]) { - //valid session command - found=true; - if (command.size()==1) { - //just invoking sID - if (request.getMethod()=="DELETE") { - task->cancel(); - content="<status>1</status>\n"; - } - else { - status=HTTPResponse::HTTP_BAD_REQUEST; - content="<status>Rotor: render context invoked with no command</status>\n"; - } - } - else { //session modifier command- to be passed to render context - //some commands need to return error codes - //ie where the audio file isn't found - //on the other hand, some commands need to know state of the renderer? - std::string s; - std::ostringstream os; - os<<request.stream().rdbuf(); - s=os.str(); - - vector<string> sc; //method,id,command1,{command2,}{body} - sc.push_back(request.getMethod()); - for (auto& i: command){ - sc.push_back(i); - } - sc.push_back(s); - - Rotor::Command_response response=((Poco::AutoPtr<Rotor::Render_context>)task)->session_command(sc); - - content=response.description; - status=response.status; - - } - } - } + { + content+="<sID>"+task->name()+" </sID>\n"; + } + } + else { + bool found=false; + for (auto& task: manager.taskList()) //c++11 + { + if(task->name()==command[0]) { + //valid session command + found=true; + if (command.size()==1) { + //just invoking sID + if (request.getMethod()=="DELETE") { + task->cancel(); + content="<status>1</status>\n"; + } + else { + status=HTTPResponse::HTTP_BAD_REQUEST; + content="<status>Rotor: render context invoked with no command</status>\n"; + } + } + else { //session modifier command- to be passed to render context + //some commands need to return error codes + //ie where the audio file isn't found + //on the other hand, some commands need to know state of the renderer? + std::string s; + std::ostringstream os; + os<<request.stream().rdbuf(); + s=os.str(); + + vector<string> sc; //method,id,command1,{command2,}{body} + sc.push_back(request.getMethod()); + for (auto& i: command){ + sc.push_back(i); + } + sc.push_back(s); + + Rotor::Command_response response=((Poco::AutoPtr<Rotor::Render_context>)task)->session_command(sc); + + content=response.description; + status=response.status; + + } + } + } if (!found) { status=HTTPResponse::HTTP_NOT_FOUND; content="<status>Rotor: render context not found</status>\n"; |
