X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fnet%2FClient.hpp;h=ee848c0d74729db9976cf382ccfe8ad1d83b512d;hb=ee77b8cf96525f0db007b170b6e96f055cba4d33;hp=63c3fdd5e9f7d1aa7ae020fe4d22ef19b0031ce4;hpb=9ebe2c320fd9f94266ab93fa2f9d9908a0a284d3;p=blank.git diff --git a/src/net/Client.hpp b/src/net/Client.hpp index 63c3fdd..ee848c0 100644 --- a/src/net/Client.hpp +++ b/src/net/Client.hpp @@ -2,6 +2,7 @@ #define BLANK_NET_CLIENT_HPP_ #include "Connection.hpp" +#include "../app/IntervalTimer.hpp" #include #include @@ -20,23 +21,30 @@ public: }; public: - Client(const Config &, World &); + explicit Client(const Config &); ~Client(); void Handle(); void Update(int dt); - bool TimedOut() { return conn.TimedOut(); } + Connection &GetConnection() noexcept { return conn; } + const Connection &GetConnection() const noexcept { return conn; } + + std::uint16_t SendPing(); + std::uint16_t SendLogin(const std::string &); + std::uint16_t SendPart(); + // this may not send the update at all, in which case it returns -1 + int SendPlayerUpdate(const Entity &); private: void HandlePacket(const UDPpacket &); private: - World &world; Connection conn; UDPsocket client_sock; UDPpacket client_pack; + IntervalTimer update_timer; };