summaryrefslogtreecommitdiffstats
path: root/src/Core/RequestHandlers/DaemonListRequestHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/RequestHandlers/DaemonListRequestHandler.cpp')
-rw-r--r--src/Core/RequestHandlers/DaemonListRequestHandler.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/Core/RequestHandlers/DaemonListRequestHandler.cpp b/src/Core/RequestHandlers/DaemonListRequestHandler.cpp
index 1f137ad..2bee423 100644
--- a/src/Core/RequestHandlers/DaemonListRequestHandler.cpp
+++ b/src/Core/RequestHandlers/DaemonListRequestHandler.cpp
@@ -20,15 +20,23 @@
#include "DaemonListRequestHandler.h"
#include "../ConnectionManager.h"
#include <Net/Connection.h>
+#include <Net/Packets/ErrorPacket.h>
#include <Net/Packets/NameListPacket.h>
+#include <iostream>
+
namespace Mad {
namespace Core {
namespace RequestHandlers {
-bool DaemonListRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(packet.getType() != Net::Packet::LIST_DAEMONS)
- return false; // TODO Logging
+void DaemonListRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
+ if(packet.getType() != Net::Packet::LIST_DAEMONS) {
+ std::cerr << "Received an unexpected packet." << std::endl;
+ connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Common::Exception(Common::Exception::UNEXPECTED_PACKET)));
+
+ signalFinished().emit();
+ return;
+ }
// TODO Require authentication
@@ -38,12 +46,9 @@ bool DaemonListRequestHandler::handlePacket(Net::Connection *connection, const N
for(std::map<std::string,DaemonInfo>::iterator daemon = daemons.begin(); daemon != daemons.end(); ++daemon)
names.push_back(daemon->first);
- if(!connection->send(Net::Packets::NameListPacket(Net::Packet::OK, packet.getRequestId(), names)))
- return false;
+ connection->send(Net::Packets::NameListPacket(Net::Packet::OK, packet.getRequestId(), names));
signalFinished().emit();
-
- return true;
}
}