From 1169a73ef72e296cc79da746b5d6d916714633c2 Mon Sep 17 00:00:00 2001 From: dec05eba <0xdec05eba@gmail.com> Date: Tue, 16 Oct 2018 05:23:57 +0200 Subject: Listen on key when sending custom message --- depends/sibs-pubsub | 2 +- src/Database.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/depends/sibs-pubsub b/depends/sibs-pubsub index eda9445..e0511ec 160000 --- a/depends/sibs-pubsub +++ b/depends/sibs-pubsub @@ -1 +1 @@ -Subproject commit eda94456add9a65d1821302e343bef4021d2a773 +Subproject commit e0511ecead4d98ed84e18960a2f23cfe707b5a28 diff --git a/src/Database.cpp b/src/Database.cpp index 2a7a510..5ff3460 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -661,6 +661,11 @@ namespace odhtdb void Database::sendCustomMessage(const InfoHash &requestKey, const void *data, const usize size) { + if(!bootstrapConnection.areWeListeningOnKey(requestKey.getKey())) + { + bootstrapConnection.listen(requestKey.getKey(), nullptr); + std::this_thread::sleep_for(std::chrono::seconds(3)); + } bootstrapConnection.put(requestKey.getKey(), data, size); } @@ -674,7 +679,7 @@ namespace odhtdb return callbackFunc(true, data, size); }); - bootstrapConnection.put(requestKey.getKey(), data, size); + sendCustomMessage(requestKey, data, size); return listener; } -- cgit v1.2.3