1
0
Fork 0

Simplify the link reversion logic.

ycs232-kbc
Jonathan Naylor 8 years ago committed by GitHub
parent d6c3f0fe32
commit e3827bbd1b

@ -346,41 +346,26 @@ int CYSFGateway::run()
inactivityTimer.clock(ms); inactivityTimer.clock(ms);
if (inactivityTimer.isRunning() && inactivityTimer.hasExpired()) { if (inactivityTimer.isRunning() && inactivityTimer.hasExpired()) {
if (m_linked) { if (m_linked) {
if (revert) { CYSFReflector* reflector = NULL;
CYSFReflector* reflector = m_wiresX->getReflector(startup); if (revert && !startup.empty() && m_wiresX != NULL)
if (reflector != NULL) { reflector = m_wiresX->getReflector(startup);
LogMessage("Reverting connection to %s", reflector->m_id.c_str());
if (m_wiresX != NULL) if (reflector != NULL) {
m_wiresX->processConnect(reflector); LogMessage("Reverting connection to %5.5s", reflector->m_id.c_str());
m_netNetwork->writeUnlink(); m_wiresX->processConnect(reflector);
m_netNetwork->writeUnlink();
m_netNetwork->writeUnlink();
m_netNetwork->setDestination(reflector->m_address, reflector->m_port);
m_netNetwork->writePoll();
m_netNetwork->writePoll();
m_netNetwork->writePoll();
lostTimer.start();
pollTimer.start();
} else {
LogMessage("Disconnecting due to inactivity");
if (m_wiresX != NULL) m_netNetwork->writeUnlink();
m_wiresX->processDisconnect(); m_netNetwork->writeUnlink();
m_netNetwork->writeUnlink();
m_netNetwork->writeUnlink();
m_netNetwork->writeUnlink();
m_netNetwork->writeUnlink();
m_netNetwork->clearDestination();
lostTimer.stop(); m_netNetwork->setDestination(reflector->m_address, reflector->m_port);
pollTimer.stop(); m_netNetwork->writePoll();
m_netNetwork->writePoll();
m_netNetwork->writePoll();
m_linked = false; lostTimer.start();
} pollTimer.start();
} else { } else {
LogMessage("Disconnecting due to inactivity"); LogMessage("Disconnecting due to inactivity");

Loading…
Cancel
Save