From f5aaf1b1cc94e28d4fa423a3d0b8ca286cf7f87d Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 21 May 2018 08:27:47 +0200 Subject: Implement online/offline users (pinging) --- include/Channel.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/Channel.hpp') diff --git a/include/Channel.hpp b/include/Channel.hpp index 16c2fb3..28d174b 100644 --- a/include/Channel.hpp +++ b/include/Channel.hpp @@ -6,10 +6,13 @@ #include "Channel.hpp" #include "types.hpp" #include +#include #include #include #include #include +#include +#include namespace odhtdb { @@ -58,8 +61,14 @@ namespace dchat void processEvent(const sf::Event &event, Cache &cache); void draw(sf::RenderWindow &window, Cache &cache); + void update(); + // Returns 0 if we are offline + u64 getSyncedTimestampUtcCombined(); + static void setCurrent(Channel *channel); static Channel* getCurrent(); + private: + void sendPing(u32 pingCounter, u64 pingTimestamp); protected: odhtdb::Database *database; odhtdb::DatabaseNode databaseNodeInfo; @@ -70,5 +79,8 @@ namespace dchat SystemUser systemUser; std::vector users; odhtdb::Signature::MapPublicKey publicKeyOnlineUsersMap; + dht::InfoHash pingKey; + std::future pingListener; + sf::Clock pingTimer; }; } -- cgit v1.2.3