summaryrefslogtreecommitdiff
path: root/include/erebos
diff options
context:
space:
mode:
Diffstat (limited to 'include/erebos')
-rw-r--r--include/erebos/message.h10
-rw-r--r--include/erebos/network.h11
2 files changed, 18 insertions, 3 deletions
diff --git a/include/erebos/message.h b/include/erebos/message.h
index c94e8c3..66d221c 100644
--- a/include/erebos/message.h
+++ b/include/erebos/message.h
@@ -4,11 +4,14 @@
#include <chrono>
#include <functional>
+#include <memory>
#include <optional>
#include <string>
namespace erebos {
+using std::unique_ptr;
+
class Identity;
class DirectMessage
@@ -78,13 +81,14 @@ public:
void handle(Context &) const override;
typedef std::function<void(const DirectMessageThread &, ssize_t, ssize_t)> ThreadWatcher;
- static void onUpdate(ThreadWatcher);
- static DirectMessageThread thread(const Identity &);
+ void onUpdate(ThreadWatcher);
+ DirectMessageThread thread(const Identity &);
- static DirectMessage send(const Identity &, const Peer &, const std::string &);
+ DirectMessage send(const Identity &, const Peer &, const std::string &);
private:
struct Priv;
+ unique_ptr<Priv> p;
};
}
diff --git a/include/erebos/network.h b/include/erebos/network.h
index d730fb5..a2f989e 100644
--- a/include/erebos/network.h
+++ b/include/erebos/network.h
@@ -4,6 +4,7 @@
#include <erebos/service.h>
#include <functional>
+#include <typeinfo>
namespace erebos {
@@ -13,14 +14,24 @@ public:
Server(const Identity &, std::vector<std::unique_ptr<Service>> &&);
~Server();
+ template<class S> S & svc();
+
class PeerList & peerList() const;
struct Peer;
private:
+ Service & svcHelper(const std::type_info &);
+
struct Priv;
const std::shared_ptr<Priv> p;
};
+template<class S>
+S & Server::svc()
+{
+ return dynamic_cast<S&>(svcHelper(typeid(S)));
+}
+
class Peer
{
public: