From 8f85624a76934b14e0ba0f49413f471f8f4aa4f1 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 24 Feb 2009 23:08:23 +0100 Subject: LogRequest ist jetzt ein XmlRequest --- src/Daemon/Backends/NetworkLogger.h | 2 +- src/Daemon/Requests/LogRequest.cpp | 18 +++++++++++++----- src/Daemon/Requests/LogRequest.h | 8 ++++---- 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'src/Daemon') 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(new Requests::LogRequest(category, level, messageTimestamp, message, Requests::LogRequest::slot_type())) + std::auto_ptr(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 -#include 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 +#include #include #include @@ -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) {} }; } -- cgit v1.2.3