diff options
Diffstat (limited to 'src/Server/RequestHandlers/DaemonStatusRequestHandler.cpp')
-rw-r--r-- | src/Server/RequestHandlers/DaemonStatusRequestHandler.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/Server/RequestHandlers/DaemonStatusRequestHandler.cpp b/src/Server/RequestHandlers/DaemonStatusRequestHandler.cpp index 94df846..114260d 100644 --- a/src/Server/RequestHandlers/DaemonStatusRequestHandler.cpp +++ b/src/Server/RequestHandlers/DaemonStatusRequestHandler.cpp @@ -27,8 +27,8 @@ namespace Mad { namespace Server { namespace RequestHandlers { -void DaemonStatusRequestHandler::handlePacket(const Common::XmlPacket &packet) { - if(packet.getType() != "GetDaemonStatus") { +void DaemonStatusRequestHandler::handlePacket(boost::shared_ptr<const Common::XmlPacket> packet) { + if(packet->getType() != "GetDaemonStatus") { Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet."); Common::XmlPacket ret; @@ -43,12 +43,12 @@ void DaemonStatusRequestHandler::handlePacket(const Common::XmlPacket &packet) { // TODO Require authentication - std::string daemonName = packet["daemonName"]; - try { - boost::shared_ptr<Common::Connection> daemonCon = ConnectionManager::get()->getDaemonConnection(daemonName); - Common::RequestManager::get()->sendRequest0<Common::Requests::StatusRequest>(daemonCon.get(), - boost::bind(&DaemonStatusRequestHandler::requestFinished, this, _1)); + boost::shared_ptr<Common::Connection> daemonCon = ConnectionManager::get()->getDaemonConnection((*packet)["daemonName"]); + + boost::shared_ptr<Common::Requests::StatusRequest> request(new Common::Requests::StatusRequest); + request->connectSignalFinished(boost::bind(&DaemonStatusRequestHandler::requestFinished, this, _1, _2)); + Common::RequestManager::get()->sendRequest(daemonCon.get(), request); } catch(Net::Exception &e) { Common::XmlPacket ret; @@ -62,20 +62,20 @@ void DaemonStatusRequestHandler::handlePacket(const Common::XmlPacket &packet) { } } -void DaemonStatusRequestHandler::requestFinished(Common::Request &request) { - try { - sendPacket(request.getResult()); - } - catch(Net::Exception &e) { +void DaemonStatusRequestHandler::requestFinished(boost::shared_ptr<const Common::XmlPacket> packet, Net::Exception error) { + if(error) { Common::XmlPacket ret; ret.setType("Error"); - ret.add("ErrorCode", e.getErrorCode()); - ret.add("SubCode", e.getSubCode()); - ret.add("SubSubCode", e.getSubSubCode()); - ret.add("Where", e.getWhere()); + ret.add("ErrorCode", error.getErrorCode()); + ret.add("SubCode", error.getSubCode()); + ret.add("SubSubCode", error.getSubSubCode()); + ret.add("Where", error.getWhere()); sendPacket(ret); } + else { + sendPacket(*packet); + } signalFinished(); } |