diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-02-24 23:08:23 +0100 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-02-24 23:08:23 +0100 |
commit | 8f85624a76934b14e0ba0f49413f471f8f4aa4f1 (patch) | |
tree | 9fc387bb5523a56d1b4c1d45e3cbccb90c0584b2 /src/Daemon | |
parent | 35ab037e7e6ac08e214b053de8ed87e3f35586fc (diff) | |
download | mad-8f85624a76934b14e0ba0f49413f471f8f4aa4f1.tar mad-8f85624a76934b14e0ba0f49413f471f8f4aa4f1.zip |
LogRequest ist jetzt ein XmlRequest
Diffstat (limited to 'src/Daemon')
-rw-r--r-- | src/Daemon/Backends/NetworkLogger.h | 2 | ||||
-rw-r--r-- | src/Daemon/Requests/LogRequest.cpp | 18 | ||||
-rw-r--r-- | src/Daemon/Requests/LogRequest.h | 8 |
3 files changed, 18 insertions, 10 deletions
diff --git a/src/Daemon/Backends/NetworkLogger.h b/src/Daemon/Backends/NetworkLogger.h index b33f180..a07fd59 100644 --- a/src/Daemon/Backends/NetworkLogger.h +++ b/src/Daemon/Backends/NetworkLogger.h @@ -37,7 +37,7 @@ class NetworkLogger : public Common::Logger { protected: virtual void logMessage(Common::Logger::MessageCategory category, Common::Logger::MessageLevel level, time_t messageTimestamp, const std::string &message) { Common::RequestManager::get()->sendRequest(connection, - std::auto_ptr<Common::RequestBase>(new Requests::LogRequest(category, level, messageTimestamp, message, Requests::LogRequest::slot_type())) + std::auto_ptr<Common::XmlRequest>(new Requests::LogRequest(category, level, messageTimestamp, message, Requests::LogRequest::slot_type())) ); } diff --git a/src/Daemon/Requests/LogRequest.cpp b/src/Daemon/Requests/LogRequest.cpp index 3a04284..f7a498d 100644 --- a/src/Daemon/Requests/LogRequest.cpp +++ b/src/Daemon/Requests/LogRequest.cpp @@ -19,23 +19,31 @@ #include "LogRequest.h" #include <Net/Connection.h> -#include <Net/Packets/LogPacket.h> namespace Mad { namespace Daemon { namespace Requests { void LogRequest::sendRequest(Net::Connection *connection, uint16_t requestId) { - connection->send(Net::Packets::LogPacket(Net::Packet::LOG, requestId, category, level, messageTimestamp, message)); + Common::XmlPacket packet; + + packet.setType("Log"); + + packet.add("category", category); + packet.add("level", level); + packet.add("timestamp", messageTimestamp); + packet.add("message", message); + + connection->send(packet.encode(requestId)); } -void LogRequest::handlePacket(Net::Connection*, const Net::Packet &packet) { - if(packet.getType() != Net::Packet::OK) { +void LogRequest::handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet) { + if(packet.getType() != "OK") { finishWithError(Common::Exception(Common::Exception::UNEXPECTED_PACKET)); return; // TODO Logging } - finish(); + finish(packet); } } diff --git a/src/Daemon/Requests/LogRequest.h b/src/Daemon/Requests/LogRequest.h index 8d3798a..2a03ce3 100644 --- a/src/Daemon/Requests/LogRequest.h +++ b/src/Daemon/Requests/LogRequest.h @@ -20,7 +20,7 @@ #ifndef MAD_DAEMON_REQUESTS_LOGREQUEST_H_ #define MAD_DAEMON_REQUESTS_LOGREQUEST_H_ -#include <Common/Request.h> +#include <Common/XmlRequest.h> #include <Common/Logger.h> #include <ctime> @@ -28,7 +28,7 @@ namespace Mad { namespace Daemon { namespace Requests { -class LogRequest : public Common::Request<> { +class LogRequest : public Common::XmlRequest { private: Common::Logger::MessageCategory category; Common::Logger::MessageLevel level; @@ -37,11 +37,11 @@ class LogRequest : public Common::Request<> { protected: virtual void sendRequest(Net::Connection *connection, uint16_t requestId); - virtual void handlePacket(Net::Connection*, const Net::Packet &packet); + virtual void handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet); public: LogRequest(Common::Logger::MessageCategory category0, Common::Logger::MessageLevel level0, time_t messageTimestamp0, const std::string &message0, slot_type slot) - : Common::Request<>(slot), category(category0), level(level0), messageTimestamp(messageTimestamp0), message(message0) {} + : Common::XmlRequest(slot), category(category0), level(level0), messageTimestamp(messageTimestamp0), message(message0) {} }; } |