mirror of
https://github.com/ShaYmez/P25Clients.git
synced 2025-08-12 02:32:28 -04:00
Change relinking logic.
This commit is contained in:
parent
7f1abc00dc
commit
7e0cd5a9d4
@ -206,11 +206,11 @@ void CP25Gateway::run()
|
|||||||
in_addr currentAddr;
|
in_addr currentAddr;
|
||||||
unsigned int currentPort = 0U;
|
unsigned int currentPort = 0U;
|
||||||
|
|
||||||
unsigned int id = m_conf.getNetworkStartup();
|
unsigned int startupId = m_conf.getNetworkStartup();
|
||||||
if (id != 9999U) {
|
if (startupId != 9999U) {
|
||||||
CP25Reflector* reflector = reflectors.find(id);
|
CP25Reflector* reflector = reflectors.find(startupId);
|
||||||
if (reflector != NULL) {
|
if (reflector != NULL) {
|
||||||
currentId = id;
|
currentId = startupId;
|
||||||
currentAddr = reflector->m_address;
|
currentAddr = reflector->m_address;
|
||||||
currentPort = reflector->m_port;
|
currentPort = reflector->m_port;
|
||||||
|
|
||||||
@ -343,8 +343,7 @@ void CP25Gateway::run()
|
|||||||
|
|
||||||
inactivityTimer.clock(ms);
|
inactivityTimer.clock(ms);
|
||||||
if (inactivityTimer.isRunning() && inactivityTimer.hasExpired()) {
|
if (inactivityTimer.isRunning() && inactivityTimer.hasExpired()) {
|
||||||
unsigned int startId = m_conf.getNetworkStartup();
|
if (currentId != 9999U && startupId == 9999U) {
|
||||||
if (currentId != startId) {
|
|
||||||
LogMessage("Unlinking from %u due to inactivity", currentId);
|
LogMessage("Unlinking from %u due to inactivity", currentId);
|
||||||
|
|
||||||
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
||||||
@ -358,26 +357,38 @@ void CP25Gateway::run()
|
|||||||
pollTimer.stop();
|
pollTimer.stop();
|
||||||
lostTimer.stop();
|
lostTimer.stop();
|
||||||
inactivityTimer.stop();
|
inactivityTimer.stop();
|
||||||
|
} else if (currentId != startupId) {
|
||||||
|
if (currentId != 9999U) {
|
||||||
|
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
||||||
|
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
||||||
|
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
||||||
|
}
|
||||||
|
|
||||||
//Connecting to default startup reflector
|
CP25Reflector* reflector = reflectors.find(startupId);
|
||||||
|
if (reflector != NULL) {
|
||||||
CP25Reflector* reflector = reflectors.find(startId);
|
currentId = startupId;
|
||||||
currentAddr = reflector->m_address;
|
currentAddr = reflector->m_address;
|
||||||
currentPort = reflector->m_port;
|
currentPort = reflector->m_port;
|
||||||
|
|
||||||
remoteNetwork.writePoll(currentAddr, currentPort);
|
|
||||||
remoteNetwork.writePoll(currentAddr, currentPort);
|
|
||||||
remoteNetwork.writePoll(currentAddr, currentPort);
|
|
||||||
|
|
||||||
LogMessage("Linked to startup %u due to inactivity", startId);
|
|
||||||
|
|
||||||
inactivityTimer.start();
|
inactivityTimer.start();
|
||||||
pollTimer.start();
|
pollTimer.start();
|
||||||
lostTimer.start();
|
lostTimer.start();
|
||||||
currentId = startId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
LogMessage("Linked to reflector %u due to inactivity", currentId);
|
||||||
|
|
||||||
|
if (speech != NULL)
|
||||||
|
speech->announce(currentId);
|
||||||
|
|
||||||
|
remoteNetwork.writePoll(currentAddr, currentPort);
|
||||||
|
remoteNetwork.writePoll(currentAddr, currentPort);
|
||||||
|
remoteNetwork.writePoll(currentAddr, currentPort);
|
||||||
|
} else {
|
||||||
|
startupId = 9999U;
|
||||||
inactivityTimer.stop();
|
inactivityTimer.stop();
|
||||||
|
pollTimer.stop();
|
||||||
|
lostTimer.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pollTimer.clock(ms);
|
pollTimer.clock(ms);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user