]> git.localhorst.tv Git - blank.git/blobdiff - src/net/Client.hpp
first draft for client/server architecture
[blank.git] / src / net / Client.hpp
diff --git a/src/net/Client.hpp b/src/net/Client.hpp
new file mode 100644 (file)
index 0000000..63c3fdd
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef BLANK_NET_CLIENT_HPP_
+#define BLANK_NET_CLIENT_HPP_
+
+#include "Connection.hpp"
+
+#include <string>
+#include <SDL_net.h>
+
+
+namespace blank {
+
+class World;
+
+class Client {
+
+public:
+       struct Config {
+               std::string host = "localhost";
+               Uint16 port = 12354;
+       };
+
+public:
+       Client(const Config &, World &);
+       ~Client();
+
+       void Handle();
+
+       void Update(int dt);
+
+       bool TimedOut() { return conn.TimedOut(); }
+
+private:
+       void HandlePacket(const UDPpacket &);
+
+private:
+       World &world;
+       Connection conn;
+       UDPsocket client_sock;
+       UDPpacket client_pack;
+
+};
+
+}
+
+#endif