1
0
Fork 0

Add periodic repeater/gateway list dumping to the reflector.

ycs232-kbc
Jonathan Naylor 9 years ago
parent 6231cf2a3e
commit 94e3347d72

@ -25,6 +25,9 @@
#if defined(_WIN32) || defined(_WIN64)
#include <Windows.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
@ -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<CYSFRepeater*>::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);
}
}

@ -64,10 +64,10 @@ public:
private:
CConf m_conf;
std::string m_file;
std::vector<CYSFRepeater*> m_repeaters;
CYSFRepeater* findRepeater(const std::string& callsign) const;
void dumpRepeaters() const;
};
#endif

Loading…
Cancel
Save