diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2020-02-16 20:18:32 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2020-02-16 20:18:32 +0100 |
commit | 0e9e9c4d233a331e10dfb2db889fe437d0911ba2 (patch) | |
tree | 450b78801436d007efd5eaaf2b52f3e7dfe95a96 /include/erebos | |
parent | 69e4c826a34eb84c36bb07338a9a292a520f5970 (diff) |
Peer list in public API
Diffstat (limited to 'include/erebos')
-rw-r--r-- | include/erebos/identity.h | 1 | ||||
-rw-r--r-- | include/erebos/network.h | 36 |
2 files changed, 37 insertions, 0 deletions
diff --git a/include/erebos/identity.h b/include/erebos/identity.h index 9ed170a..dce6093 100644 --- a/include/erebos/identity.h +++ b/include/erebos/identity.h @@ -12,6 +12,7 @@ public: std::optional<std::string> name() const; std::optional<Identity> owner() const; + const Identity & finalOwner() const; Stored<class PublicKey> keyMessage() const; diff --git a/include/erebos/network.h b/include/erebos/network.h index 47c7e7a..90c85a6 100644 --- a/include/erebos/network.h +++ b/include/erebos/network.h @@ -2,6 +2,8 @@ #include <erebos/identity.h> +#include <functional> + namespace erebos { class Server @@ -10,10 +12,44 @@ public: Server(const Identity &); ~Server(); + class PeerList & peerList() const; + struct Peer; private: struct Priv; const std::shared_ptr<Priv> p; }; +class Peer +{ +public: + struct Priv; + Peer(const std::shared_ptr<Priv> & p); + ~Peer(); + + std::string name() const; + std::optional<Identity> identity() const; + +private: + std::shared_ptr<Priv> p; }; + +class PeerList +{ +public: + struct Priv; + PeerList(); + PeerList(const std::shared_ptr<Priv> & p); + ~PeerList(); + + size_t size() const; + Peer at(size_t n) const; + + void onUpdate(std::function<void(size_t, const Peer *)>); + +private: + friend Server; + const std::shared_ptr<Priv> p; +}; + +} |