]> git.localhorst.tv Git - blank.git/blob - src/net/Client.hpp
reorganized client state
[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         explicit Client(const Config &);
24         ~Client();
25
26         void Handle();
27
28         void Update(int dt);
29
30         Connection &GetConnection() noexcept { return conn; }
31         const Connection &GetConnection() const noexcept { return conn; }
32
33         void SendPing();
34         void SendLogin(const std::string &);
35
36 private:
37         void HandlePacket(const UDPpacket &);
38
39 private:
40         Connection conn;
41         UDPsocket client_sock;
42         UDPpacket client_pack;
43
44 };
45
46 }
47
48 #endif