]> git.localhorst.tv Git - blank.git/blobdiff - src/server/Server.hpp
move server and client stuff around
[blank.git] / src / server / Server.hpp
diff --git a/src/server/Server.hpp b/src/server/Server.hpp
new file mode 100644 (file)
index 0000000..8bbb778
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef BLANK_SERVER_SERVER_HPP
+#define BLANK_SERVER_SERVER_HPP
+
+#include <list>
+#include <SDL_net.h>
+
+
+namespace blank {
+
+class World;
+
+namespace server {
+
+class ClientConnection;
+
+class Server {
+
+public:
+       struct Config {
+               Uint16 port = 12354;
+       };
+
+public:
+       Server(const Config &, World &);
+       ~Server();
+
+       void Handle();
+
+       void Update(int dt);
+
+       UDPsocket &GetSocket() noexcept { return serv_sock; }
+       UDPpacket &GetPacket() noexcept { return serv_pack; }
+
+       World &GetWorld() noexcept { return world; }
+
+private:
+       void HandlePacket(const UDPpacket &);
+
+       ClientConnection &GetClient(const IPaddress &);
+
+private:
+       UDPsocket serv_sock;
+       UDPpacket serv_pack;
+       std::list<ClientConnection> clients;
+
+       World &world;
+
+};
+
+}
+}
+
+#endif