diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-09-15 06:26:15 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-09-15 06:26:15 +0200 |
commit | 9ca70bbfa460fe1c6c31b8e685be6df24935ab73 (patch) | |
tree | 8fe0a6e164d7d2f4e5f23e073c0a80a0b29daf94 /src/Common/RequestHandlers/StatusRequestHandler.cpp | |
parent | 30bec92571ba23f1f2aa6b12149f6545a4ef0d7e (diff) | |
download | mad-9ca70bbfa460fe1c6c31b8e685be6df24935ab73.tar mad-9ca70bbfa460fe1c6c31b8e685be6df24935ab73.zip |
Kann jetzt Status von Daemons abfragen
Diffstat (limited to 'src/Common/RequestHandlers/StatusRequestHandler.cpp')
-rw-r--r-- | src/Common/RequestHandlers/StatusRequestHandler.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/Common/RequestHandlers/StatusRequestHandler.cpp b/src/Common/RequestHandlers/StatusRequestHandler.cpp new file mode 100644 index 0000000..0a437fa --- /dev/null +++ b/src/Common/RequestHandlers/StatusRequestHandler.cpp @@ -0,0 +1,49 @@ +/* + * StatusRequestHandler.cpp + * + * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "StatusRequestHandler.h" +#include "../SystemBackend.h" +#include <Net/Connection.h> +#include <Net/Packets/HostStatusPacket.h> + +namespace Mad { +namespace Common { +namespace RequestHandlers { + +bool StatusRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) { + if(packet.getType() != Net::Packet::STATUS) + return false; // TODO Logging + + // TODO Require authentication + + SystemBackend::UptimeInfo uptimeInfo = SystemBackend::getBackend()->getUptimeInfo(); + SystemBackend::MemoryInfo memInfo = SystemBackend::getBackend()->getMemoryInfo(); + + if(!connection->send(Net::Packets::HostStatusPacket(Net::Packet::OK, packet.getRequestId(), uptimeInfo.uptime, uptimeInfo.idleTime, + memInfo.totalMem, memInfo.freeMem, memInfo.totalSwap, memInfo.freeSwap))) + return false; + + signalFinished().emit(); + + return true; +} + +} +} +} |