summaryrefslogtreecommitdiffstats
path: root/src/Common/Request
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-09-10 03:26:49 +0200
committerMatthias Schiffer <matthias@gamezock.de>2008-09-10 03:26:49 +0200
commit707344b4d161cb5a11e7f78d7622cb7cd1a791f6 (patch)
tree8879f226c610e25fc532d64f40f2fe382e6d8371 /src/Common/Request
parent8dd9bc2815347435c8f92bb329a0209b50660618 (diff)
downloadmad-707344b4d161cb5a11e7f78d7622cb7cd1a791f6.tar
mad-707344b4d161cb5a11e7f78d7622cb7cd1a791f6.zip
Client erweitert; Status-Befehl angefangen
Diffstat (limited to 'src/Common/Request')
-rw-r--r--src/Common/Request/CoreStatusRequest.h82
-rw-r--r--src/Common/Request/DisconnectRequest.h10
-rw-r--r--src/Common/Request/Makefile.am2
-rw-r--r--src/Common/Request/Makefile.in2
4 files changed, 93 insertions, 3 deletions
diff --git a/src/Common/Request/CoreStatusRequest.h b/src/Common/Request/CoreStatusRequest.h
new file mode 100644
index 0000000..97f8318
--- /dev/null
+++ b/src/Common/Request/CoreStatusRequest.h
@@ -0,0 +1,82 @@
+/*
+ * CoreStatusRequest.h
+ *
+ * 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/>.
+ */
+
+#ifndef MAD_COMMON_REQUEST_CORESTATUSREQUEST_H_
+#define MAD_COMMON_REQUEST_CORESTATUSREQUEST_H_
+
+#include "Request.h"
+#include "../RequestManager.h"
+#include <Net/Connection.h>
+#include <Net/Packet.h>
+
+#include <sigc++/signal.h>
+
+namespace Mad {
+namespace Common {
+namespace Request {
+
+class CoreStatusRequest: public Request {
+ private:
+ sigc::signal<void> finished;
+
+ CoreStatusRequest() {}
+
+ public:
+ static bool send(Net::Connection *connection, RequestManager &requestManager, const sigc::slot<void> &callback) {
+ CoreStatusRequest *request = new CoreStatusRequest();
+
+ request->finished.connect(callback);
+
+ if(requestManager.sendRequest(connection, request))
+ return true;
+
+ delete request;
+ return false;
+ }
+
+ virtual bool sendRequest(Net::Connection *connection, unsigned short requestId) {
+ if(isSent())
+ return false;
+
+ if(!connection->send(Net::Packet(Net::Packet::TYPE_CORE_STATUS, requestId)))
+ return false;
+
+ setSent();
+ return true;
+ }
+
+ virtual bool handlePacket(Net::Connection*, const Net::Packet &packet) {
+ if(isFinished())
+ return false;
+
+ if(packet.getType() != Net::Packet::TYPE_OK)
+ return false; // TODO Logging
+
+ finished();
+
+ setFinished();
+ return true;
+ }
+};
+
+}
+}
+}
+
+#endif /* MAD_COMMON_REQUEST_CORESTATUSREQUEST_H_ */
diff --git a/src/Common/Request/DisconnectRequest.h b/src/Common/Request/DisconnectRequest.h
index 48256a7..c20a3d0 100644
--- a/src/Common/Request/DisconnectRequest.h
+++ b/src/Common/Request/DisconnectRequest.h
@@ -25,18 +25,24 @@
#include <Net/Connection.h>
#include <Net/Packet.h>
+#include <sigc++/signal.h>
+
namespace Mad {
namespace Common {
namespace Request {
class DisconnectRequest: public Request {
private:
+ sigc::signal<void> finished;
+
DisconnectRequest() {}
public:
- static bool send(Net::Connection *connection, RequestManager &requestManager) {
+ static bool send(Net::Connection *connection, RequestManager &requestManager, const sigc::slot<void> &callback) {
DisconnectRequest *request = new DisconnectRequest();
+ request->finished.connect(callback);
+
if(requestManager.sendRequest(connection, request))
return true;
@@ -64,6 +70,8 @@ class DisconnectRequest: public Request {
connection->disconnect();
+ finished();
+
setFinished();
return true;
}
diff --git a/src/Common/Request/Makefile.am b/src/Common/Request/Makefile.am
index 64c5078..4c6ffd5 100644
--- a/src/Common/Request/Makefile.am
+++ b/src/Common/Request/Makefile.am
@@ -1 +1 @@
-noinst_HEADERS = DisconnectRequest.h GSSAPIAuthRequest.h IdentifyRequest.h Request.h
+noinst_HEADERS = CoreStatusRequest.h DisconnectRequest.h GSSAPIAuthRequest.h IdentifyRequest.h Request.h
diff --git a/src/Common/Request/Makefile.in b/src/Common/Request/Makefile.in
index bf7652c..8d53cc0 100644
--- a/src/Common/Request/Makefile.in
+++ b/src/Common/Request/Makefile.in
@@ -162,7 +162,7 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-noinst_HEADERS = DisconnectRequest.h GSSAPIAuthRequest.h IdentifyRequest.h Request.h
+noinst_HEADERS = CoreStatusRequest.h DisconnectRequest.h GSSAPIAuthRequest.h IdentifyRequest.h Request.h
all: all-am
.SUFFIXES: