From 94e3347d7218fbbfed3bfc2797f764efae2ae0fe Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 16 Jun 2016 17:54:43 +0100 Subject: [PATCH] Add periodic repeater/gateway list dumping to the reflector. --- YSFReflector/YSFReflector.cpp | 31 +++++++++++++++++++++++++++++++ YSFReflector/YSFReflector.h | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/YSFReflector/YSFReflector.cpp b/YSFReflector/YSFReflector.cpp index 7b14f09..092654f 100644 --- a/YSFReflector/YSFReflector.cpp +++ b/YSFReflector/YSFReflector.cpp @@ -25,6 +25,9 @@ #if defined(_WIN32) || defined(_WIN64) #include #else +#include +#include +#include #include #include #include @@ -164,6 +167,9 @@ void CYSFReflector::run() CStopWatch stopWatch; stopWatch.start(); + CTimer dumpTimer(1000U, 120U); + dumpTimer.start(); + CTimer pollTimer(1000U, 5U); pollTimer.start(); @@ -287,6 +293,12 @@ void CYSFReflector::run() watchdogTimer.stop(); } + dumpTimer.clock(ms); + if (dumpTimer.hasExpired()) { + dumpRepeaters(); + dumpTimer.start(); + } + if (ms < 5U) { #if defined(_WIN32) || defined(_WIN64) ::Sleep(5UL); // 5ms @@ -310,3 +322,22 @@ CYSFRepeater* CYSFReflector::findRepeater(const std::string& callsign) const return NULL; } + +void CYSFReflector::dumpRepeaters() const +{ + if (m_repeaters.size() == 0U) { + LogMessage("No repeaters/gateways linked"); + return; + } + + LogMessage("Currently linked repeaters/gateways:"); + + for (std::vector::const_iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) { + std::string callsign = (*it)->m_callsign; + in_addr address = (*it)->m_address; + unsigned int port = (*it)->m_port; + unsigned int timer = (*it)->m_timer.getTimer(); + unsigned int timeout = (*it)->m_timer.getTimeout(); + LogMessage(" %s: %s:%u %u/%u", callsign.c_str(), ::inet_ntoa(address), port, timer, timeout); + } +} diff --git a/YSFReflector/YSFReflector.h b/YSFReflector/YSFReflector.h index 80ec081..7b0df4c 100644 --- a/YSFReflector/YSFReflector.h +++ b/YSFReflector/YSFReflector.h @@ -64,10 +64,10 @@ public: private: CConf m_conf; - std::string m_file; std::vector m_repeaters; CYSFRepeater* findRepeater(const std::string& callsign) const; + void dumpRepeaters() const; }; #endif