summaryrefslogtreecommitdiffstats
path: root/src/Client/Requests/DaemonListRequest.cpp
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-09-15 04:46:28 +0200
committerMatthias Schiffer <matthias@gamezock.de>2008-09-15 04:46:28 +0200
commit30bec92571ba23f1f2aa6b12149f6545a4ef0d7e (patch)
treee823812fc05dfa81a103f386df6be81745e2928e /src/Client/Requests/DaemonListRequest.cpp
parentfbe26b0e48e6f3714900833174fcf42196e86fc8 (diff)
downloadmad-30bec92571ba23f1f2aa6b12149f6545a4ef0d7e.tar
mad-30bec92571ba23f1f2aa6b12149f6545a4ef0d7e.zip
Hosts k?nnen jetzt aufgelistet werden
Diffstat (limited to 'src/Client/Requests/DaemonListRequest.cpp')
-rw-r--r--src/Client/Requests/DaemonListRequest.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/Client/Requests/DaemonListRequest.cpp b/src/Client/Requests/DaemonListRequest.cpp
new file mode 100644
index 0000000..a0e4cf1
--- /dev/null
+++ b/src/Client/Requests/DaemonListRequest.cpp
@@ -0,0 +1,66 @@
+/*
+ * DaemonListRequest.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 "DaemonListRequest.h"
+#include <Common/RequestManager.h>
+#include <Net/Packets/NameListPacket.h>
+
+namespace Mad {
+namespace Client {
+namespace Requests {
+
+bool DaemonListRequest::send(Net::Connection *connection, const sigc::slot<void,const Net::Packets::NameListPacket&> &callback) {
+ DaemonListRequest *request = new DaemonListRequest();
+
+ request->finished.connect(callback);
+
+ if(Mad::Common::RequestManager::getRequestManager()->sendRequest(connection, request))
+ return true;
+
+ delete request;
+ return false;
+}
+
+bool DaemonListRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
+ if(isSent())
+ return false;
+
+ if(!connection->send(Net::Packet(Net::Packet::LIST_DAEMONS, requestId)))
+ return false;
+
+ setSent();
+ return true;
+}
+
+bool DaemonListRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
+ if(isFinished())
+ return false;
+
+ if(packet.getType() != Net::Packet::OK)
+ return false; // TODO Logging
+
+ finished(Net::Packets::NameListPacket(packet));
+
+ setFinished();
+ return true;
+}
+
+}
+}
+}