mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-08 13:27:57 +00:00
[traffic] API to reconfigure a running HttpTrafficSource
Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
@@ -136,6 +136,27 @@ HttpTraffSource::HttpTraffSource(TraffSourceManager & manager, std::string const
|
||||
, m_url(url)
|
||||
{}
|
||||
|
||||
void HttpTraffSource::Close()
|
||||
{
|
||||
std::string data;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
if (m_subscriptionId.empty())
|
||||
return;
|
||||
data = "<request operation=\"UNSUBSCRIBE\" subscription_id=\"" + m_subscriptionId + "\"/>";
|
||||
m_subscriptionId.clear();
|
||||
}
|
||||
|
||||
LOG(LDEBUG, ("Sending request:\n", data));
|
||||
|
||||
threads::SimpleThread thread([this, data]() {
|
||||
TraffResponse response = HttpPost(m_url, data);
|
||||
return;
|
||||
});
|
||||
thread.detach();
|
||||
}
|
||||
|
||||
void HttpTraffSource::Subscribe(std::set<MwmSet::MwmId> & mwms)
|
||||
{
|
||||
std::string data = "<request operation=\"SUBSCRIBE\">\n<filter_list>\n"
|
||||
|
||||
@@ -441,6 +441,15 @@ public:
|
||||
*/
|
||||
static void Create(TraffSourceManager & manager, std::string const & url);
|
||||
|
||||
/**
|
||||
* @brief Prepares the HTTP traffic source for unloading.
|
||||
*
|
||||
* If there is still an active subscription, it unsubscribes, but without processing the result
|
||||
* received from the service. Otherwise, teardown is a no-op.
|
||||
*/
|
||||
// TODO move this to the parent class and override it here?
|
||||
void Close();
|
||||
|
||||
/**
|
||||
* @brief Subscribes to a traffic service.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user