diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-05-21 08:27:47 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-05-21 08:27:50 +0200 |
commit | f5aaf1b1cc94e28d4fa423a3d0b8ca286cf7f87d (patch) | |
tree | 839418cbb8a8f5ee4bbabc79c3ca915babab8302 /include/Channel.hpp | |
parent | e1322b06148b633df365d8916404a2748945de65 (diff) |
Implement online/offline users (pinging)
Diffstat (limited to 'include/Channel.hpp')
-rw-r--r-- | include/Channel.hpp | 12 |
1 files changed, 12 insertions, 0 deletions
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 <vector> +#include <SFML/System/Clock.hpp> #include <odhtdb/DatabaseNode.hpp> #include <odhtdb/Signature.hpp> #include <odhtdb/Group.hpp> #include <odhtdb/Hash.hpp> +#include <odhtdb/DhtKey.hpp> +#include <future> 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<User*> users; odhtdb::Signature::MapPublicKey<OnlineUser*> publicKeyOnlineUsersMap; + dht::InfoHash pingKey; + std::future<size_t> pingListener; + sf::Clock pingTimer; }; } |