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);
if (inactivityTimer.isRunning() && inactivityTimer.hasExpired()) {
if (m_linked) {
if (revert) {
CYSFReflector* reflector = m_wiresX->getReflector(startup);
if (reflector != NULL) {
LogMessage("Reverting connection to %s", reflector->m_id.c_str());
CYSFReflector* reflector = NULL;
if (revert && !startup.empty() && m_wiresX != NULL)
reflector = m_wiresX->getReflector(startup);
if (m_wiresX != NULL)
m_wiresX->processConnect(reflector);
if (reflector != NULL) {
LogMessage("Reverting connection to %5.5s", reflector->m_id.c_str());
m_netNetwork->writeUnlink();
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");
m_wiresX->processConnect(reflector);
if (m_wiresX != NULL)
m_wiresX->processDisconnect();
m_netNetwork->writeUnlink();
m_netNetwork->writeUnlink();
m_netNetwork->writeUnlink();
m_netNetwork->clearDestination();
m_netNetwork->writeUnlink();
m_netNetwork->writeUnlink();
m_netNetwork->writeUnlink();
lostTimer.stop();
pollTimer.stop();
m_netNetwork->setDestination(reflector->m_address, reflector->m_port);
m_netNetwork->writePoll();
m_netNetwork->writePoll();
m_netNetwork->writePoll();
m_linked = false;
}
lostTimer.start();
pollTimer.start();
} else {
LogMessage("Disconnecting due to inactivity");

Loading…
Cancel
Save