diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-10-21 13:49:34 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-18 22:56:48 +0200 |
commit | f96ed2f3195166485875e801cd0d923023a2dd4e (patch) | |
tree | 1720e76558c3b92ca127f05502b42fe9f4890ba8 /include | |
parent | 4f84a5d325686202bd623ee530d197596ff3f411 (diff) |
Async bootstrap connect
Diffstat (limited to 'include')
-rw-r--r-- | include/sibs/BootstrapConnection.hpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/include/sibs/BootstrapConnection.hpp b/include/sibs/BootstrapConnection.hpp index 8156bd7..790b7ee 100644 --- a/include/sibs/BootstrapConnection.hpp +++ b/include/sibs/BootstrapConnection.hpp @@ -5,6 +5,7 @@ #include "PubsubKey.hpp" #include <mutex> #include <atomic> +#include <future> namespace sibs { @@ -41,7 +42,7 @@ namespace sibs DISABLE_COPY(BootstrapConnection) public: // Throws BootstrapConnectionException on error - BootstrapConnection(const Ipv4 &bootstrapAddress); + static std::future<std::unique_ptr<BootstrapConnection>> create(const Ipv4 &bootstrapAddress); ~BootstrapConnection(); // If we are already listening on the key @pubsubKey then the callback function is overwritten @@ -55,6 +56,9 @@ namespace sibs std::vector<std::shared_ptr<DirectConnectionPeer>> getPeers(); private: + // Throws BootstrapConnectionException on error + BootstrapConnection(const Ipv4 &bootstrapAddress); + ListenHandle listen(const PubsubKey &pubsubKey, BoostrapConnectionListenCallbackFunc callbackFunc, bool registerCallbackFunc); void receiveDataFromServer(std::shared_ptr<DirectConnectionPeer> peer, MessageType messageType, const void *data, const usize size); void receiveDataFromPeer(std::shared_ptr<DirectConnectionPeer> peer, MessageType messageType, const void *data, const usize size); |