make upnp take asio context
Change-Id: Ie039a084d04dee1a1bfcda5865b6482f272ccfe3
diff --git a/include/upnp/upnp_context.h b/include/upnp/upnp_context.h
index a85db51..b9a5d26 100644
--- a/include/upnp/upnp_context.h
+++ b/include/upnp/upnp_context.h
@@ -37,6 +37,7 @@
#include "upnp/mapping.h"
#include <opendht/rng.h>
+#include <opendht/logger.h>
#include <asio/steady_timer.hpp>
#include <set>
@@ -110,11 +111,11 @@
};
public:
- UPnPContext();
+ UPnPContext(std::shared_ptr<asio::io_context> ctx, std::shared_ptr<dht::log::Logger> logger);
~UPnPContext();
// Retrieve the UPnPContext singleton.
- static std::shared_ptr<UPnPContext> getUPnPContext();
+ // static std::shared_ptr<UPnPContext> getUPnPContext();
// Terminate the instance.
void shutdown();
diff --git a/include/upnp/upnp_control.h b/include/upnp/upnp_control.h
index 10e44e3..e68cada 100644
--- a/include/upnp/upnp_control.h
+++ b/include/upnp/upnp_control.h
@@ -40,7 +40,7 @@
class Controller
{
public:
- Controller();
+ Controller(const std::shared_ptr<UPnPContext>& ctx);
~Controller();
// Set known public address
diff --git a/include/upnp/upnp_thread_util.h b/include/upnp/upnp_thread_util.h
index 6c7f97b..6bc5271 100644
--- a/include/upnp/upnp_thread_util.h
+++ b/include/upnp/upnp_thread_util.h
@@ -3,12 +3,13 @@
#include <thread>
#include <memory>
#include <asio/io_context.hpp>
+#include <fmt/format.h>
// This macro is used to validate that a code is executed from the expected
// thread. It's useful to detect unexpected race on data members.
#define CHECK_VALID_THREAD() \
if (not isValidThread()) \
- printf("The calling thread %d is not the expected thread: %d", getCurrentThread(), threadId_);
+ fmt::print("The calling thread {} is not the expected thread: {}\n", getCurrentThread(), threadId_);
/*JAMI_ERR() << "The calling thread " << getCurrentThread() \
<< " is not the expected thread: " << threadId_;*/