X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/d3ea2ff01c51df0df95cd23157267048e2c2fdcd..f0ca04947cd23aa5f973f184941dc5af13b43744:/Server/src/controlserver.cpp diff --git a/Server/src/controlserver.cpp b/Server/src/controlserver.cpp index 144d236..133f36e 100644 --- a/Server/src/controlserver.cpp +++ b/Server/src/controlserver.cpp @@ -26,7 +26,8 @@ // #include "plaqui/server/controlserver.h" -#include "plaqui/server/httprequest.h" +#include "plaqui/server/command.h" +#include "plaqui/server/string.h" #include #include #ifdef DEBUG @@ -58,8 +59,22 @@ void ControlServer::real_run(void) { #endif // DEBUG //char buf[BUFSIZ]; while (!stop) { - HTTPRequest request; - socket >> request; + Command command; + try { + socket >> command; + } catch (const char* e) { + cerr << " (" << __LINE__ << ") Error: " << e << endl; + stop = true; + continue; + } catch (string e) { + cerr << " (" << __LINE__ << ") Error: " << e << endl; + stop = true; + continue; + } catch (...) { + cerr << " (" << __LINE__ << ") Error desconocido!" << endl; + stop = true; + continue; + } // TODO agregar las verificaciones de abajo a HTTPRequest y padres. /* // Primera línea no vacía (que debe ser el request). @@ -99,7 +114,10 @@ void ControlServer::real_run(void) { // Command command = parse_command(request.uri); //signal_command_received().emit(command); #ifdef DEBUG - cerr << "Request: " << request << endl; + cerr << "Comando: target = " << command.get_target() + << " | command = " << command.get_command() + << " | args = [" << String::join(command.get_args(), ", ") << "]" + << endl; //for (HTTPRequest::const_iterator i = request.begin(); // i != request.end(); i++) { // cerr << " " << i->first << ": " << i->second << endl; @@ -124,14 +142,27 @@ Accept-Ranges: bytes response_xml << " " << endl; response_xml << " " << endl; response_xml << "

PlaQui

" << endl; - response_xml << "

versión 0.2

" << endl; - response_xml << "

Pedido HTTP

" << endl; + response_xml << "

versión 0.4

" << endl; + response_xml << "

Comando

" << endl; response_xml << " " << endl; response_xml << "

Desarrollado por

" << endl; response_xml << "