diff options
Diffstat (limited to 'src/Core/RequestHandlers')
16 files changed, 66 insertions, 108 deletions
diff --git a/src/Core/RequestHandlers/DaemonCommandRequestHandler.cpp b/src/Core/RequestHandlers/DaemonCommandRequestHandler.cpp index 1bfe3e4..c9a4530 100644 --- a/src/Core/RequestHandlers/DaemonCommandRequestHandler.cpp +++ b/src/Core/RequestHandlers/DaemonCommandRequestHandler.cpp @@ -26,7 +26,7 @@ namespace Mad { namespace Core { namespace RequestHandlers { -void DaemonCommandRequestHandler::handlePacket(Net::Connection *connection, uint16_t rid, const Common::XmlPacket &packet) { +void DaemonCommandRequestHandler::handlePacket(const Common::XmlPacket &packet) { if(packet.getType() != "DaemonCommand") { Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet."); @@ -34,7 +34,7 @@ void DaemonCommandRequestHandler::handlePacket(Net::Connection *connection, uint ret.setType("Error"); ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); - connection->send(ret.encode(rid)); + sendPacket(ret); signalFinished().emit(); return; @@ -42,16 +42,12 @@ void DaemonCommandRequestHandler::handlePacket(Net::Connection *connection, uint // TODO Require authentication - con = connection; - requestId = rid; - std::string command = packet["command"]; try { Net::Connection *daemonCon = ConnectionManager::get()->getDaemonConnection(packet["daemon"]); - Common::RequestManager::get()->sendRequest(daemonCon, std::auto_ptr<Common::Request>( - new Requests::CommandRequest(command == "reboot", sigc::mem_fun(this, &DaemonCommandRequestHandler::requestFinished)) - )); + Common::RequestManager::get()->sendRequest<Requests::CommandRequest>(daemonCon, + sigc::mem_fun(this, &DaemonCommandRequestHandler::requestFinished), command == "reboot"); } catch(Common::Exception &e) { Common::XmlPacket ret; @@ -61,15 +57,13 @@ void DaemonCommandRequestHandler::handlePacket(Net::Connection *connection, uint ret.add("SubSubCode", e.getSubSubCode()); ret.add("Where", e.getWhere()); - con->send(ret.encode(requestId)); + sendPacket(ret); } } void DaemonCommandRequestHandler::requestFinished(const Common::Request &request) { try { - const Common::XmlPacket &packet = request.getResult(); - - con->send(packet.encode(requestId)); + sendPacket(request.getResult()); } catch(Common::Exception &e) { Common::XmlPacket ret; @@ -79,7 +73,7 @@ void DaemonCommandRequestHandler::requestFinished(const Common::Request &request ret.add("SubSubCode", e.getSubSubCode()); ret.add("Where", e.getWhere()); - con->send(ret.encode(requestId)); + sendPacket(ret); } signalFinished().emit(); diff --git a/src/Core/RequestHandlers/DaemonCommandRequestHandler.h b/src/Core/RequestHandlers/DaemonCommandRequestHandler.h index 4ab7a3f..9e089e3 100644 --- a/src/Core/RequestHandlers/DaemonCommandRequestHandler.h +++ b/src/Core/RequestHandlers/DaemonCommandRequestHandler.h @@ -30,16 +30,14 @@ namespace RequestHandlers { class DaemonCommandRequestHandler : public Common::RequestHandler { private: - Net::Connection *con; - uint16_t requestId; - void requestFinished(const Common::Request &request); protected: - virtual void handlePacket(Net::Connection *connection, uint16_t rid, const Common::XmlPacket &packet); + virtual void handlePacket(const Common::XmlPacket &packet); public: - DaemonCommandRequestHandler() {} + DaemonCommandRequestHandler(Net::Connection *connection, uint16_t requestId) + : RequestHandler(connection, requestId) {} }; } diff --git a/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp index b9dc030..ae12a8e 100644 --- a/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp +++ b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp @@ -27,7 +27,7 @@ namespace Mad { namespace Core { namespace RequestHandlers { -void DaemonFSInfoRequestHandler::handlePacket(Net::Connection *connection, uint16_t rid, const Common::XmlPacket &packet) { +void DaemonFSInfoRequestHandler::handlePacket(const Common::XmlPacket &packet) { if(packet.getType() != "DaemonFSInfo") { Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet."); @@ -35,7 +35,7 @@ void DaemonFSInfoRequestHandler::handlePacket(Net::Connection *connection, uint1 ret.setType("Error"); ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); - connection->send(ret.encode(rid)); + sendPacket(ret); signalFinished().emit(); return; @@ -43,12 +43,10 @@ void DaemonFSInfoRequestHandler::handlePacket(Net::Connection *connection, uint1 // TODO Require authentication - con = connection; - requestId = rid; - try { Net::Connection *daemonCon = ConnectionManager::get()->getDaemonConnection(packet["daemon"]); - Common::RequestManager::get()->sendRequest(daemonCon, std::auto_ptr<Common::Request>(new Common::Requests::FSInfoRequest(sigc::mem_fun(this, &DaemonFSInfoRequestHandler::requestFinished)))); + Common::RequestManager::get()->sendRequest<Common::Requests::FSInfoRequest>(daemonCon, + sigc::mem_fun(this, &DaemonFSInfoRequestHandler::requestFinished)); } catch(Common::Exception &e) { Common::XmlPacket ret; @@ -58,14 +56,13 @@ void DaemonFSInfoRequestHandler::handlePacket(Net::Connection *connection, uint1 ret.add("SubSubCode", e.getSubSubCode()); ret.add("Where", e.getWhere()); - con->send(ret.encode(requestId)); + sendPacket(ret); } } void DaemonFSInfoRequestHandler::requestFinished(const Common::Request &request) { try { - const Common::XmlPacket &packet = request.getResult(); - con->send(packet.encode(requestId)); + sendPacket(request.getResult()); } catch(Common::Exception &e) { Common::XmlPacket ret; @@ -75,7 +72,7 @@ void DaemonFSInfoRequestHandler::requestFinished(const Common::Request &request) ret.add("SubSubCode", e.getSubSubCode()); ret.add("Where", e.getWhere()); - con->send(ret.encode(requestId)); + sendPacket(ret); } signalFinished().emit(); diff --git a/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h index 820ef69..6a70c5e 100644 --- a/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h +++ b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h @@ -25,28 +25,19 @@ #include <stdint.h> namespace Mad { - -namespace Net { -namespace Packets { -class FSInfoPacket; -} -} - namespace Core { namespace RequestHandlers { class DaemonFSInfoRequestHandler : public Common::RequestHandler { private: - Net::Connection *con; - uint16_t requestId; - void requestFinished(const Common::Request &request); protected: - virtual void handlePacket(Net::Connection *connection, uint16_t rid, const Common::XmlPacket &packet); + virtual void handlePacket(const Common::XmlPacket &packet); public: - DaemonFSInfoRequestHandler() {} + DaemonFSInfoRequestHandler(Net::Connection *connection, uint16_t requestId) + : RequestHandler(connection, requestId) {} }; } diff --git a/src/Core/RequestHandlers/DaemonListRequestHandler.cpp b/src/Core/RequestHandlers/DaemonListRequestHandler.cpp index c20627f..84d3207 100644 --- a/src/Core/RequestHandlers/DaemonListRequestHandler.cpp +++ b/src/Core/RequestHandlers/DaemonListRequestHandler.cpp @@ -20,14 +20,12 @@ #include "DaemonListRequestHandler.h" #include "../ConnectionManager.h" #include <Common/Logger.h> -#include <Common/XmlPacket.h> -#include <Net/Connection.h> namespace Mad { namespace Core { namespace RequestHandlers { -void DaemonListRequestHandler::handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet) { +void DaemonListRequestHandler::handlePacket(const Common::XmlPacket &packet) { if(packet.getType() != "ListHosts") { Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet."); @@ -35,7 +33,7 @@ void DaemonListRequestHandler::handlePacket(Net::Connection *connection, uint16_ ret.setType("Error"); ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); - connection->send(ret.encode(requestId)); + sendPacket(ret); signalFinished().emit(); return; @@ -57,7 +55,7 @@ void DaemonListRequestHandler::handlePacket(Net::Connection *connection, uint16_ ret["hosts"].back().add("state", daemon->getState()); } - connection->send(ret.encode(requestId)); + sendPacket(ret); signalFinished().emit(); } diff --git a/src/Core/RequestHandlers/DaemonListRequestHandler.h b/src/Core/RequestHandlers/DaemonListRequestHandler.h index 26c46f8..07badae 100644 --- a/src/Core/RequestHandlers/DaemonListRequestHandler.h +++ b/src/Core/RequestHandlers/DaemonListRequestHandler.h @@ -28,10 +28,11 @@ namespace RequestHandlers { class DaemonListRequestHandler : public Common::RequestHandler { protected: - virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet); + virtual void handlePacket(const Common::XmlPacket &packet); public: - DaemonListRequestHandler() {} + DaemonListRequestHandler(Net::Connection *connection, uint16_t requestId) + : RequestHandler(connection, requestId) {} }; } diff --git a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp index 35daae4..66c3aa1 100644 --- a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp +++ b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp @@ -27,7 +27,7 @@ namespace Mad { namespace Core { namespace RequestHandlers { -void DaemonStatusRequestHandler::handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet) { +void DaemonStatusRequestHandler::handlePacket(const Common::XmlPacket &packet) { if(packet.getType() != "GetDaemonStatus") { Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet."); @@ -35,7 +35,7 @@ void DaemonStatusRequestHandler::handlePacket(Net::Connection *connection, uint1 ret.setType("Error"); ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); - con->send(ret.encode(requestId)); + sendPacket(ret); signalFinished().emit(); return; @@ -43,14 +43,12 @@ void DaemonStatusRequestHandler::handlePacket(Net::Connection *connection, uint1 // TODO Require authentication - con = connection; - rid = requestId; - std::string daemonName = packet["daemonName"]; try { Net::Connection *daemonCon = ConnectionManager::get()->getDaemonConnection(daemonName); - Common::RequestManager::get()->sendRequest(daemonCon, std::auto_ptr<Common::Request>(new Common::Requests::StatusRequest(sigc::mem_fun(this, &DaemonStatusRequestHandler::requestFinished)))); + Common::RequestManager::get()->sendRequest<Common::Requests::StatusRequest>(daemonCon, + sigc::mem_fun(this, &DaemonStatusRequestHandler::requestFinished)); } catch(Common::Exception &e) { Common::XmlPacket ret; @@ -60,14 +58,13 @@ void DaemonStatusRequestHandler::handlePacket(Net::Connection *connection, uint1 ret.add("SubSubCode", e.getSubSubCode()); ret.add("Where", e.getWhere()); - con->send(ret.encode(rid)); + sendPacket(ret); } } void DaemonStatusRequestHandler::requestFinished(const Common::Request &request) { try { - const Common::XmlPacket &packet = request.getResult(); - con->send(packet.encode(rid)); + sendPacket(request.getResult()); } catch(Common::Exception &e) { Common::XmlPacket ret; @@ -77,7 +74,7 @@ void DaemonStatusRequestHandler::requestFinished(const Common::Request &request) ret.add("SubSubCode", e.getSubSubCode()); ret.add("Where", e.getWhere()); - con->send(ret.encode(rid)); + sendPacket(ret); } signalFinished().emit(); diff --git a/src/Core/RequestHandlers/DaemonStatusRequestHandler.h b/src/Core/RequestHandlers/DaemonStatusRequestHandler.h index 92dac2f..f232649 100644 --- a/src/Core/RequestHandlers/DaemonStatusRequestHandler.h +++ b/src/Core/RequestHandlers/DaemonStatusRequestHandler.h @@ -25,28 +25,19 @@ #include <stdint.h> namespace Mad { - -namespace Net { -namespace Packets { -class HostStatusPacket; -} -} - namespace Core { namespace RequestHandlers { class DaemonStatusRequestHandler : public Common::RequestHandler { private: - Net::Connection *con; - uint16_t rid; - void requestFinished(const Common::Request &request); protected: - virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet); + virtual void handlePacket(const Common::XmlPacket &packet); public: - DaemonStatusRequestHandler() {} + DaemonStatusRequestHandler(Net::Connection *connection, uint16_t requestId) + : RequestHandler(connection, requestId) {} }; } diff --git a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp index d9694c8..ad0a293 100644 --- a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp +++ b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp @@ -20,7 +20,6 @@ #include "GSSAPIAuthRequestHandler.h" #include <Common/Exception.h> #include <Common/Logger.h> -#include <Common/XmlPacket.h> #include <Net/Connection.h> #include <cstring> @@ -31,7 +30,7 @@ namespace RequestHandlers { // TODO Error handling -void GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet) { +void GSSAPIAuthRequestHandler::handlePacket(const Common::XmlPacket &packet) { if(packet.getType() != "AuthGSSAPI") { Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet."); @@ -39,7 +38,7 @@ void GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, uint16_ ret.setType("Error"); ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); - connection->send(ret.encode(requestId)); + sendPacket(ret); signalFinished().emit(); return; @@ -74,7 +73,7 @@ void GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, uint16_ ret.setType("AuthGSSAPI"); ret.addBinary("authToken", sendBuffer.value, sendBuffer.length); - if(!connection->send(ret.encode(requestId))) { + if(!sendPacket(ret)) { gss_release_buffer(&minStat, &sendBuffer); return; } @@ -85,7 +84,7 @@ void GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, uint16_ if(!packet["binary"].isEmpty()) return; - const gnutls_datum_t *cert = connection->getCertificate(); + const gnutls_datum_t *cert = getConnection()->getCertificate(); recvBuffer.length = cert->size; recvBuffer.value = cert->data; @@ -101,7 +100,7 @@ void GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, uint16_ ret.setType("AuthGSSAPI"); ret.addBinary("certMic", sendBuffer.value, sendBuffer.length); - if(!connection->send(ret.encode(requestId))) { + if(!sendPacket(ret)) { gss_release_buffer(&minStat, &sendBuffer); return; } diff --git a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h index 7f29804..06c1886 100644 --- a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h +++ b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h @@ -34,10 +34,11 @@ class GSSAPIAuthRequestHandler : public Common::RequestHandler { bool gssContinue, sentSignature; protected: - virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet); + virtual void handlePacket(const Common::XmlPacket &packet); public: - GSSAPIAuthRequestHandler() : gssContext(GSS_C_NO_CONTEXT), gssContinue(true), sentSignature(false) {} + GSSAPIAuthRequestHandler(Net::Connection *connection, uint16_t requestId) + : RequestHandler(connection, requestId), gssContext(GSS_C_NO_CONTEXT), gssContinue(true), sentSignature(false) {} }; } diff --git a/src/Core/RequestHandlers/IdentifyRequestHandler.cpp b/src/Core/RequestHandlers/IdentifyRequestHandler.cpp index 4bf921e..235569c 100644 --- a/src/Core/RequestHandlers/IdentifyRequestHandler.cpp +++ b/src/Core/RequestHandlers/IdentifyRequestHandler.cpp @@ -20,15 +20,13 @@ #include "IdentifyRequestHandler.h" #include "../ConnectionManager.h" #include <Common/Logger.h> -#include <Common/XmlPacket.h> -#include <Net/Connection.h> namespace Mad { namespace Core { namespace RequestHandlers { -void IdentifyRequestHandler::handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet) { +void IdentifyRequestHandler::handlePacket(const Common::XmlPacket &packet) { if(packet.getType() != "Identify") { Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet."); @@ -36,7 +34,7 @@ void IdentifyRequestHandler::handlePacket(Net::Connection *connection, uint16_t ret.setType("Error"); ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); - connection->send(ret.encode(requestId)); + sendPacket(ret); signalFinished().emit(); return; @@ -44,11 +42,11 @@ void IdentifyRequestHandler::handlePacket(Net::Connection *connection, uint16_t // TODO Require authentication try { - ConnectionManager::get()->identifyDaemonConnection(connection, packet["hostname"]); + ConnectionManager::get()->identifyDaemonConnection(getConnection(), packet["hostname"]); Common::XmlPacket ret; ret.setType("OK"); - connection->send(ret.encode(requestId)); + sendPacket(ret); } catch(Common::Exception &e) { Common::XmlPacket ret; @@ -58,7 +56,7 @@ void IdentifyRequestHandler::handlePacket(Net::Connection *connection, uint16_t ret.add("SubSubCode", e.getSubSubCode()); ret.add("Where", e.getWhere()); - connection->send(ret.encode(requestId)); + sendPacket(ret); } signalFinished().emit(); diff --git a/src/Core/RequestHandlers/IdentifyRequestHandler.h b/src/Core/RequestHandlers/IdentifyRequestHandler.h index 7bc5d7c..37aa74b 100644 --- a/src/Core/RequestHandlers/IdentifyRequestHandler.h +++ b/src/Core/RequestHandlers/IdentifyRequestHandler.h @@ -28,10 +28,11 @@ namespace RequestHandlers { class IdentifyRequestHandler : public Common::RequestHandler { protected: - virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet); + virtual void handlePacket(const Common::XmlPacket &packet); public: - IdentifyRequestHandler() {} + IdentifyRequestHandler(Net::Connection *connection, uint16_t requestId) + : RequestHandler(connection, requestId) {} }; } diff --git a/src/Core/RequestHandlers/LogRequestHandler.cpp b/src/Core/RequestHandlers/LogRequestHandler.cpp index 77be876..aeec7da 100644 --- a/src/Core/RequestHandlers/LogRequestHandler.cpp +++ b/src/Core/RequestHandlers/LogRequestHandler.cpp @@ -20,15 +20,13 @@ #include "LogRequestHandler.h" #include <Common/Logger.h> #include <Common/LogManager.h> -#include <Common/XmlPacket.h> #include "../ConnectionManager.h" -#include <Net/Connection.h> namespace Mad { namespace Core { namespace RequestHandlers { -void LogRequestHandler::handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet) { +void LogRequestHandler::handlePacket(const Common::XmlPacket &packet) { if(packet.getType() != "Log") { Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet."); @@ -36,7 +34,7 @@ void LogRequestHandler::handlePacket(Net::Connection *connection, uint16_t reque ret.setType("Error"); ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); - connection->send(ret.encode(requestId)); + sendPacket(ret); signalFinished().emit(); return; @@ -46,7 +44,7 @@ void LogRequestHandler::handlePacket(Net::Connection *connection, uint16_t reque try { Common::LogManager::get()->log(packet["category"], packet["level"], packet["timestamp"], packet["message"], - ConnectionManager::get()->getDaemonName(connection)); + ConnectionManager::get()->getDaemonName(getConnection())); } catch(Common::Exception &e) { Common::Logger::logf(Common::Logger::ERROR, "Can't determine daemon name: %s", e.strerror().c_str()); @@ -55,7 +53,7 @@ void LogRequestHandler::handlePacket(Net::Connection *connection, uint16_t reque Common::XmlPacket ret; ret.setType("OK"); - connection->send(ret.encode(requestId)); + sendPacket(ret); signalFinished().emit(); } diff --git a/src/Core/RequestHandlers/LogRequestHandler.h b/src/Core/RequestHandlers/LogRequestHandler.h index 4a0f9cb..9cf63ec 100644 --- a/src/Core/RequestHandlers/LogRequestHandler.h +++ b/src/Core/RequestHandlers/LogRequestHandler.h @@ -28,10 +28,11 @@ namespace RequestHandlers { class LogRequestHandler : public Common::RequestHandler { protected: - virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet); + virtual void handlePacket(const Common::XmlPacket &packet); public: - LogRequestHandler() {} + LogRequestHandler(Net::Connection *connection, uint16_t requestId) + : RequestHandler(connection, requestId) {} }; } diff --git a/src/Core/RequestHandlers/UserListRequestHandler.cpp b/src/Core/RequestHandlers/UserListRequestHandler.cpp index 176fde9..bb67df9 100644 --- a/src/Core/RequestHandlers/UserListRequestHandler.cpp +++ b/src/Core/RequestHandlers/UserListRequestHandler.cpp @@ -21,14 +21,12 @@ #include "../UserBackend.h" #include <Common/Exception.h> #include <Common/Logger.h> -#include <Common/XmlPacket.h> -#include <Net/Connection.h> namespace Mad { namespace Core { namespace RequestHandlers { -void UserListRequestHandler::handlePacket(Net::Connection *con, uint16_t requestId, const Common::XmlPacket &packet) { +void UserListRequestHandler::handlePacket(const Common::XmlPacket &packet) { if(packet.getType() != "ListUsers") { Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet."); @@ -36,7 +34,7 @@ void UserListRequestHandler::handlePacket(Net::Connection *con, uint16_t request ret.setType("Error"); ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); - con->send(ret.encode(requestId)); + sendPacket(ret); signalFinished().emit(); return; @@ -44,15 +42,12 @@ void UserListRequestHandler::handlePacket(Net::Connection *con, uint16_t request // TODO Require authentication - connection = con; - rid = requestId; - if(!UserBackend::getUserList(sigc::mem_fun(this, &UserListRequestHandler::userListHandler))) { Common::XmlPacket ret; ret.setType("Error"); ret.add("ErrorCode", Common::Exception::NOT_IMPLEMENTED); - con->send(ret.encode(requestId)); + sendPacket(ret); signalFinished().emit(); } } @@ -72,7 +67,7 @@ void UserListRequestHandler::userListHandler(const std::map<unsigned long, Commo entry.add("fullName", user->second.getFullName()); } - connection->send(ret.encode(rid)); + sendPacket(ret); signalFinished().emit(); } diff --git a/src/Core/RequestHandlers/UserListRequestHandler.h b/src/Core/RequestHandlers/UserListRequestHandler.h index a9c8ac6..8eae11e 100644 --- a/src/Core/RequestHandlers/UserListRequestHandler.h +++ b/src/Core/RequestHandlers/UserListRequestHandler.h @@ -32,16 +32,14 @@ namespace RequestHandlers { class UserListRequestHandler : public Common::RequestHandler { private: - Net::Connection *connection; - uint16_t rid; - void userListHandler(const std::map<unsigned long, Common::UserInfo> &info); protected: - virtual void handlePacket(Net::Connection *con, uint16_t requestId, const Common::XmlPacket &packet); + virtual void handlePacket(const Common::XmlPacket &packet); public: - UserListRequestHandler() {} + UserListRequestHandler(Net::Connection *connection, uint16_t requestId) + : RequestHandler(connection, requestId) {} }; } |