]> git.localhorst.tv Git - blank.git/blob - src/net/Client.hpp
client-side implementation of login packet
[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         void SendPing();
33         void SendLogin(const std::string &);
34
35 private:
36         void HandlePacket(const UDPpacket &);
37
38 private:
39         World &world;
40         Connection conn;
41         UDPsocket client_sock;
42         UDPpacket client_pack;
43
44 };
45
46 }
47
48 #endif