]> git.localhorst.tv Git - blank.git/blob - src/client/Client.hpp
(shabby) client side handling of messages
[blank.git] / src / client / Client.hpp
1 #ifndef BLANK_CLIENT_CLIENT_HPP_
2 #define BLANK_CLIENT_CLIENT_HPP_
3
4 #include "../app/Config.hpp"
5 #include "../net/Connection.hpp"
6
7 #include <string>
8 #include <SDL_net.h>
9
10
11 namespace blank {
12
13 class World;
14
15 namespace client {
16
17 class Client {
18
19 public:
20         explicit Client(const Config::Network &);
21         ~Client();
22
23         void Handle();
24
25         void Update(int dt);
26
27         Connection &GetConnection() noexcept { return conn; }
28         const Connection &GetConnection() const noexcept { return conn; }
29
30         std::uint16_t SendPing();
31         std::uint16_t SendLogin(const std::string &);
32         std::uint16_t SendPart();
33         std::uint16_t SendPlayerUpdate(
34                 const EntityState &prediction,
35                 const glm::vec3 &movement,
36                 float pitch,
37                 float yaw,
38                 std::uint8_t actions,
39                 std::uint8_t slot);
40         std::uint16_t SendMessage(
41                 std::uint8_t type,
42                 std::uint32_t ref,
43                 const std::string &msg);
44
45 private:
46         void HandlePacket(const UDPpacket &);
47
48 private:
49         Connection conn;
50         UDPsocket client_sock;
51         UDPpacket client_pack;
52
53 };
54
55 }
56 }
57
58 #endif