fix some issues with not clocking timers for peer list and aff list; fix issue with logging system not redirecting to a std::ostream;

pull/72/head
Bryan Biedenkapp 1 year ago
parent bc5e49e80a
commit ac6518abe5

@ -149,11 +149,15 @@ int HostWS::run()
StopWatch stopWatch; StopWatch stopWatch;
stopWatch.start(); stopWatch.start();
g_logDisplayLevel = 0U;
std::ostringstream logOutput; std::ostringstream logOutput;
__InternalOutputStream(logOutput); __InternalOutputStream(logOutput);
Timer peerListUpdate(1000U, 10U); Timer peerListUpdate(1000U, 10U);
peerListUpdate.start();
Timer affListUpdate(1000U, 10U); Timer affListUpdate(1000U, 10U);
affListUpdate.start();
// main execution loop // main execution loop
while (!g_killed) { while (!g_killed) {
@ -163,17 +167,10 @@ int HostWS::run()
stopWatch.start(); stopWatch.start();
if (m_wsConList.size() > 0U) { if (m_wsConList.size() > 0U) {
if (!peerListUpdate.isRunning()) {
peerListUpdate.start();
}
if (!affListUpdate.isRunning()) {
affListUpdate.start();
}
// send log messages // send log messages
if (!logOutput.str().empty()) { if (!logOutput.str().empty()) {
std::string str = logOutput.str(); std::string str = std::string(logOutput.str());
logOutput.str("");
json::object wsObj = json::object(); json::object wsObj = json::object();
std::string type = "log"; std::string type = "log";
@ -196,6 +193,7 @@ int HostWS::run()
} }
// update peer list data // update peer list data
peerListUpdate.clock(ms);
if (peerListUpdate.isRunning() && peerListUpdate.hasExpired()) { if (peerListUpdate.isRunning() && peerListUpdate.hasExpired()) {
peerListUpdate.start(); peerListUpdate.start();
// callback REST API to get status of the channel we represent // callback REST API to get status of the channel we represent
@ -222,6 +220,7 @@ int HostWS::run()
} }
// update affiliation list data // update affiliation list data
affListUpdate.clock(ms);
if (affListUpdate.isRunning() && affListUpdate.hasExpired()) { if (affListUpdate.isRunning() && affListUpdate.hasExpired()) {
affListUpdate.start(); affListUpdate.start();
// callback REST API to get status of the channel we represent // callback REST API to get status of the channel we represent
@ -247,14 +246,16 @@ int HostWS::run()
} }
} }
} else { } else {
peerListUpdate.stop(); // clear ostream
affListUpdate.stop(); logOutput.str("");
} }
if (ms < 2U) if (ms < 2U)
Thread::sleep(1U); Thread::sleep(1U);
} }
g_logDisplayLevel = 1U;
if (g_killed) if (g_killed)
m_wsServer.stop(); m_wsServer.stop();

Loading…
Cancel
Save

Powered by TurnKey Linux.