summaryrefslogtreecommitdiffstats
path: root/src/Net
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/Net
parentfbe26b0e48e6f3714900833174fcf42196e86fc8 (diff)
downloadmad-30bec92571ba23f1f2aa6b12149f6545a4ef0d7e.tar
mad-30bec92571ba23f1f2aa6b12149f6545a4ef0d7e.zip
Hosts k?nnen jetzt aufgelistet werden
Diffstat (limited to 'src/Net')
-rw-r--r--src/Net/Packet.h3
-rw-r--r--src/Net/Packets/HostStatusPacket.h1
-rw-r--r--src/Net/Packets/Makefile.am4
-rw-r--r--src/Net/Packets/Makefile.in7
-rw-r--r--src/Net/Packets/NameListPacket.cpp56
-rw-r--r--src/Net/Packets/NameListPacket.h65
6 files changed, 129 insertions, 7 deletions
diff --git a/src/Net/Packet.h b/src/Net/Packet.h
index e94f2ff..59e794d 100644
--- a/src/Net/Packet.h
+++ b/src/Net/Packet.h
@@ -33,7 +33,8 @@ class Packet {
enum Type {
OK = 0x0000, ERROR = 0x0001, DISCONNECT = 0x0002,
GSSAPI_AUTH = 0x0010, IDENTIFY = 0x0011,
- CORE_STATUS = 0x0020, DAEMON_STATUS = 0x0021
+ LIST_DAEMONS = 0x0020,
+ CORE_STATUS = 0x0030, DAEMON_STATUS = 0x0031
};
struct Data {
diff --git a/src/Net/Packets/HostStatusPacket.h b/src/Net/Packets/HostStatusPacket.h
index f023917..0de63de 100644
--- a/src/Net/Packets/HostStatusPacket.h
+++ b/src/Net/Packets/HostStatusPacket.h
@@ -50,7 +50,6 @@ class HostStatusPacket : public Packet {
}
HostStatusPacket(const HostStatusPacket &p) : Packet(p) {
- setLength(sizeof(CoreStatusData));
coreStatusData = (CoreStatusData*)&rawData->data;
}
diff --git a/src/Net/Packets/Makefile.am b/src/Net/Packets/Makefile.am
index e65e543..9e1f589 100644
--- a/src/Net/Packets/Makefile.am
+++ b/src/Net/Packets/Makefile.am
@@ -1,4 +1,4 @@
noinst_LTLIBRARIES = libpackets.la
-libpackets_la_SOURCES = HostStatusPacket.cpp
+libpackets_la_SOURCES = HostStatusPacket.cpp NameListPacket.cpp
-noinst_HEADERS = HostStatusPacket.h
+noinst_HEADERS = HostStatusPacket.h NameListPacket.h
diff --git a/src/Net/Packets/Makefile.in b/src/Net/Packets/Makefile.in
index b6a7338..6a7e39f 100644
--- a/src/Net/Packets/Makefile.in
+++ b/src/Net/Packets/Makefile.in
@@ -45,7 +45,7 @@ CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libpackets_la_LIBADD =
-am_libpackets_la_OBJECTS = HostStatusPacket.lo
+am_libpackets_la_OBJECTS = HostStatusPacket.lo NameListPacket.lo
libpackets_la_OBJECTS = $(am_libpackets_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -184,8 +184,8 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = libpackets.la
-libpackets_la_SOURCES = HostStatusPacket.cpp
-noinst_HEADERS = HostStatusPacket.h
+libpackets_la_SOURCES = HostStatusPacket.cpp NameListPacket.cpp
+noinst_HEADERS = HostStatusPacket.h NameListPacket.h
all: all-am
.SUFFIXES:
@@ -238,6 +238,7 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HostStatusPacket.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NameListPacket.Plo@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
diff --git a/src/Net/Packets/NameListPacket.cpp b/src/Net/Packets/NameListPacket.cpp
new file mode 100644
index 0000000..19f588a
--- /dev/null
+++ b/src/Net/Packets/NameListPacket.cpp
@@ -0,0 +1,56 @@
+/*
+ * NameListPacket.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 "NameListPacket.h"
+#include <cstring>
+#include <sstream>
+
+namespace Mad {
+namespace Net {
+namespace Packets {
+
+void NameListPacket::assemblePacket() {
+ std::ostringstream stream;
+
+ for(std::vector<std::string>::iterator name = nameList.begin(); name != nameList.end(); ++name)
+ stream << *name << std::endl;
+
+ std::string str = stream.str();
+
+ setLength(str.length());
+ std::memcpy(rawData->data, str.c_str(), str.length());
+}
+
+void NameListPacket::parsePacket() {
+ nameList.clear();
+
+ std::istringstream stream(std::string((char*)getData(), getLength()));
+
+ while(!stream.eof()) {
+ std::string str;
+ std::getline(stream, str);
+
+ if(!str.empty())
+ nameList.push_back(str);
+ }
+}
+
+}
+}
+}
diff --git a/src/Net/Packets/NameListPacket.h b/src/Net/Packets/NameListPacket.h
new file mode 100644
index 0000000..89cc040
--- /dev/null
+++ b/src/Net/Packets/NameListPacket.h
@@ -0,0 +1,65 @@
+/*
+ * NameListPacket.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_NET_PACKETS_NAMELISTPACKET_H_
+#define MAD_NET_PACKETS_NAMELISTPACKET_H_
+
+#include "../Packet.h"
+
+#include <vector>
+#include <string>
+
+
+namespace Mad {
+namespace Net {
+namespace Packets {
+
+class NameListPacket : public Packet {
+ protected:
+ std::vector<std::string> nameList;
+
+ void assemblePacket();
+ void parsePacket();
+
+ public:
+ NameListPacket(Type type, uint16_t requestId, const std::vector<std::string> &nameList0) : Packet(type, requestId), nameList(nameList0) {
+ assemblePacket();
+ }
+
+ NameListPacket(const Packet &p) : Packet(p) {
+ parsePacket();
+ }
+
+ NameListPacket& operator=(const Packet &p) {
+ Packet::operator=(p);
+ parsePacket();
+
+ return *this;
+ }
+
+ const std::vector<std::string>& getNameList() const {
+ return nameList;
+ }
+};
+
+}
+}
+}
+
+#endif /* MAD_NET_PACKETS_NAMELISTPACKET_H_ */