]> git.localhorst.tv Git - blank.git/blob - src/net/Client.hpp
first draft for client/server architecture
[blank.git] / src / net / Client.hpp
1 #ifndef BLANK_NET_CLIENT_HPP_
2 #define BLANK_NET_CLIENT_HPP_
3
4 #include "Connection.hpp"
5
6 #include <string>
7 #include <SDL_net.h>
8
9
10 namespace blank {
11
12 class World;
13
14 class Client {
15
16 public:
17         struct Config {
18                 std::string host = "localhost";
19                 Uint16 port = 12354;
20         };
21
22 public:
23         Client(const Config &, World &);
24         ~Client();
25
26         void Handle();
27
28         void Update(int dt);
29
30         bool TimedOut() { return conn.TimedOut(); }
31
32 private:
33         void HandlePacket(const UDPpacket &);
34
35 private:
36         World &world;
37         Connection conn;
38         UDPsocket client_sock;
39         UDPpacket client_pack;
40
41 };
42
43 }
44
45 #endif