]> git.localhorst.tv Git - blank.git/blob - src/client/Client.hpp
68b2f7fc65e5de8434484178d4d537a98a998937
[blank.git] / src / client / Client.hpp
1 #ifndef BLANK_CLIENT_CLIENT_HPP_
2 #define BLANK_CLIENT_CLIENT_HPP_
3
4 #include "../net/Connection.hpp"
5
6 #include <string>
7 #include <SDL_net.h>
8
9
10 namespace blank {
11
12 class World;
13
14 namespace client {
15
16 class Client {
17
18 public:
19         struct Config {
20                 std::string host = "localhost";
21                 Uint16 port = 12354;
22         };
23
24 public:
25         explicit Client(const Config &);
26         ~Client();
27
28         void Handle();
29
30         void Update(int dt);
31
32         Connection &GetConnection() noexcept { return conn; }
33         const Connection &GetConnection() const noexcept { return conn; }
34
35         std::uint16_t SendPing();
36         std::uint16_t SendLogin(const std::string &);
37         std::uint16_t SendPart();
38         std::uint16_t SendPlayerUpdate(const Entity &);
39
40 private:
41         void HandlePacket(const UDPpacket &);
42
43 private:
44         Connection conn;
45         UDPsocket client_sock;
46         UDPpacket client_pack;
47
48 };
49
50 }
51 }
52
53 #endif