aboutsummaryrefslogtreecommitdiff
path: root/src/BootstrapConnection.cpp
diff options
context:
space:
mode:
authordec05eba <0xdec05eba@gmail.com>2018-10-16 05:23:12 +0200
committerdec05eba <0xdec05eba@gmail.com>2018-10-16 05:23:14 +0200
commite0511ecead4d98ed84e18960a2f23cfe707b5a28 (patch)
treeef07ffb6234c868f78a642ef29c724d9edeac0ec /src/BootstrapConnection.cpp
parenteda94456add9a65d1821302e343bef4021d2a773 (diff)
Add more state functions
Diffstat (limited to 'src/BootstrapConnection.cpp')
-rw-r--r--src/BootstrapConnection.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/BootstrapConnection.cpp b/src/BootstrapConnection.cpp
index 0237a90..995fdcd 100644
--- a/src/BootstrapConnection.cpp
+++ b/src/BootstrapConnection.cpp
@@ -160,8 +160,13 @@ namespace sibs
{
{
std::lock_guard<std::recursive_mutex> lock(listenerCallbackFuncMutex);
- if(listenCallbackFuncs.find(pubsubKey) != listenCallbackFuncs.end())
- throw PubsubKeyAlreadyListeningException("");
+ auto it = listenCallbackFuncs.find(pubsubKey);
+ if(it != listenCallbackFuncs.end())
+ {
+ Log::warn("BootstrapConnection::listen called on existing listener, overwriting callback function");
+ it->second = callbackFunc;
+ return { pubsubKey };
+ }
listenCallbackFuncs[pubsubKey] = callbackFunc;
}
@@ -246,6 +251,12 @@ namespace sibs
return true;
}
+ bool BootstrapConnection::areWeListeningOnKey(const PubsubKey &pubsubKey)
+ {
+ std::lock_guard<std::recursive_mutex> lock(listenerCallbackFuncMutex);
+ return listenCallbackFuncs.find(pubsubKey) != listenCallbackFuncs.end();
+ }
+
std::vector<std::shared_ptr<DirectConnectionPeer>> BootstrapConnection::getPeers()
{
return connections.getPeers();