]> git.localhorst.tv Git - blank.git/blob - src/net/Client.hpp
send player updates from client to server
[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         std::uint16_t SendPing();
34         std::uint16_t SendLogin(const std::string &);
35         std::uint16_t SendPlayerUpdate(const Entity &);
36
37 private:
38         void HandlePacket(const UDPpacket &);
39
40 private:
41         Connection conn;
42         UDPsocket client_sock;
43         UDPpacket client_pack;
44
45 };
46
47 }
48
49 #endif