[traffic] API to reconfigure a running HttpTrafficSource

Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
mvglasow
2025-07-23 21:34:11 +03:00
parent be3792b93a
commit 3b1fca01e3
6 changed files with 80 additions and 0 deletions

View File

@@ -923,6 +923,27 @@ bool TrafficManager::IsEnabled() const
return m_state != TrafficState::Disabled;
}
void TrafficManager::SetHttpTraffSource(bool enabled, std::string url)
{
if (IsTestMode())
return;
{
std::lock_guard<std::mutex> lock(m_trafficSourceMutex);
for (auto it = m_trafficSources.begin(); it != m_trafficSources.end(); )
if (traffxml::HttpTraffSource* httpSource = dynamic_cast<traffxml::HttpTraffSource*>(it->get()))
{
httpSource->Close();
m_trafficSources.erase(it);
}
else
++it;
}
if (enabled)
traffxml::HttpTraffSource::Create(*this, url);
}
bool TrafficManager::IsInvalidState() const
{
return m_state == TrafficState::NetworkError;