]> git.localhorst.tv Git - blank.git/blobdiff - src/net/Server.hpp
first draft for client/server architecture
[blank.git] / src / net / Server.hpp
diff --git a/src/net/Server.hpp b/src/net/Server.hpp
new file mode 100644 (file)
index 0000000..b6a72a9
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef BLANK_NET_SERVER_HPP
+#define BLANK_NET_SERVER_HPP
+
+#include <list>
+#include <SDL_net.h>
+
+
+namespace blank {
+
+class Connection;
+class World;
+
+class Server {
+
+public:
+       struct Config {
+               Uint16 port = 12354;
+       };
+
+public:
+       Server(const Config &, World &);
+       ~Server();
+
+       void Handle();
+
+       void Update(int dt);
+
+private:
+       void HandlePacket(const UDPpacket &);
+
+       Connection &GetClient(const IPaddress &);
+
+       void OnConnect(Connection &);
+       void OnDisconnect(Connection &);
+
+private:
+       UDPsocket serv_sock;
+       UDPpacket serv_pack;
+       std::list<Connection> clients;
+
+       World &world;
+
+};
+
+}
+
+#endif