From 0e9e9c4d233a331e10dfb2db889fe437d0911ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 16 Feb 2020 20:18:32 +0100 Subject: Peer list in public API --- include/erebos/network.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'include/erebos/network.h') 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 +#include + 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 p; }; +class Peer +{ +public: + struct Priv; + Peer(const std::shared_ptr & p); + ~Peer(); + + std::string name() const; + std::optional identity() const; + +private: + std::shared_ptr p; }; + +class PeerList +{ +public: + struct Priv; + PeerList(); + PeerList(const std::shared_ptr & p); + ~PeerList(); + + size_t size() const; + Peer at(size_t n) const; + + void onUpdate(std::function); + +private: + friend Server; + const std::shared_ptr p; +}; + +} -- cgit v1.2.3