]> git.localhorst.tv Git - blank.git/blob - src/net/ClientConnection.hpp
acbee6ec98ce47a7ee15979e4f296f1efc4e36b1
[blank.git] / src / net / ClientConnection.hpp
1 #ifndef BLANK_NET_CLIENTCONNECTION_HPP_
2 #define BLANK_NET_CLIENTCONNECTION_HPP_
3
4 #include "Connection.hpp"
5 #include "ConnectionHandler.hpp"
6
7 #include <SDL_net.h>
8
9
10 namespace blank {
11
12 class Entity;
13 class Server;
14
15 class ClientConnection
16 : public ConnectionHandler {
17
18 public:
19         explicit ClientConnection(Server &, const IPaddress &);
20         ~ClientConnection();
21
22         bool Matches(const IPaddress &addr) const noexcept { return conn.Matches(addr); }
23
24         void Update(int dt);
25
26         Connection &GetConnection() noexcept { return conn; }
27         bool Disconnected() const noexcept { return conn.Closed(); }
28
29         void AttachPlayer(Entity &);
30         void DetachPlayer();
31
32         void On(const Packet::Login &) override;
33         void On(const Packet::Part &) override;
34
35 private:
36         Server &server;
37         Connection conn;
38         Entity *player;
39
40 };
41
42 }
43
44 #endif