From 0e9e9c4d233a331e10dfb2db889fe437d0911ba2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roman=20Smr=C5=BE?= <roman.smrz@seznam.cz>
Date: Sun, 16 Feb 2020 20:18:32 +0100
Subject: Peer list in public API

---
 include/erebos/identity.h |  1 +
 include/erebos/network.h  | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

(limited to 'include/erebos')

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;
+};
+
+}
-- 
cgit v1.2.3