mirror of
https://github.com/ShaYmez/P25Clients.git
synced 2024-11-24 13:18:37 -05:00
Add an inactivity timer to the gateway.
This commit is contained in:
parent
411173efdc
commit
1225e0bc87
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -52,6 +52,7 @@ m_networkReloadTime(0U),
|
||||
m_networkParrotAddress("127.0.0.1"),
|
||||
m_networkParrotPort(0U),
|
||||
m_networkStartup(9999U),
|
||||
m_networkInactivityTimeout(0U),
|
||||
m_networkDebug(false)
|
||||
{
|
||||
}
|
||||
@ -134,6 +135,8 @@ bool CConf::read()
|
||||
m_networkParrotPort = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Startup") == 0)
|
||||
m_networkStartup = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "InactivityTimeout") == 0)
|
||||
m_networkInactivityTimeout = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Debug") == 0)
|
||||
m_networkDebug = ::atoi(value) == 1;
|
||||
}
|
||||
@ -224,6 +227,11 @@ unsigned int CConf::getNetworkStartup() const
|
||||
return m_networkStartup;
|
||||
}
|
||||
|
||||
unsigned int CConf::getNetworkInactivityTimeout() const
|
||||
{
|
||||
return m_networkInactivityTimeout;
|
||||
}
|
||||
|
||||
bool CConf::getNetworkDebug() const
|
||||
{
|
||||
return m_networkDebug;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -53,6 +53,7 @@ public:
|
||||
std::string getNetworkParrotAddress() const;
|
||||
unsigned int getNetworkParrotPort() const;
|
||||
unsigned int getNetworkStartup() const;
|
||||
unsigned int getNetworkInactivityTimeout() const;
|
||||
bool getNetworkDebug() const;
|
||||
|
||||
private:
|
||||
@ -76,6 +77,7 @@ private:
|
||||
std::string m_networkParrotAddress;
|
||||
unsigned int m_networkParrotPort;
|
||||
unsigned int m_networkStartup;
|
||||
unsigned int m_networkInactivityTimeout;
|
||||
bool m_networkDebug;
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2016 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -24,6 +24,7 @@
|
||||
#include "Version.h"
|
||||
#include "Thread.h"
|
||||
#include "Speech.h"
|
||||
#include "Timer.h"
|
||||
#include "Log.h"
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
@ -185,6 +186,7 @@ void CP25Gateway::run()
|
||||
CDMRLookup* lookup = new CDMRLookup(m_conf.getLookupName(), m_conf.getLookupTime());
|
||||
lookup->read();
|
||||
|
||||
CTimer inactivityTimer(1000U, m_conf.getNetworkInactivityTimeout());
|
||||
CTimer lostTimer(1000U, 120U);
|
||||
CTimer pollTimer(1000U, 5U);
|
||||
|
||||
@ -324,6 +326,7 @@ void CP25Gateway::run()
|
||||
}
|
||||
|
||||
remoteNetwork.writeData(buffer, len, currentAddr, currentPort);
|
||||
inactivityTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
@ -335,6 +338,26 @@ void CP25Gateway::run()
|
||||
if (speech != NULL)
|
||||
speech->clock(ms);
|
||||
|
||||
inactivityTimer.clock(ms);
|
||||
if (inactivityTimer.isRunning() && inactivityTimer.hasExpired()) {
|
||||
if (currentId != 9999U) {
|
||||
LogMessage("Unlinking from %u due to inactivity", currentId);
|
||||
|
||||
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
||||
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
||||
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
||||
|
||||
if (speech != NULL)
|
||||
speech->announce(currentId);
|
||||
currentId = 9999U;
|
||||
|
||||
pollTimer.stop();
|
||||
lostTimer.stop();
|
||||
}
|
||||
|
||||
inactivityTimer.stop();
|
||||
}
|
||||
|
||||
pollTimer.clock(ms);
|
||||
if (pollTimer.isRunning() && pollTimer.hasExpired()) {
|
||||
if (currentId != 9999U)
|
||||
|
@ -1,5 +1,5 @@
|
||||
[General]
|
||||
Callsign=G9BF
|
||||
Callsign=G4KLX
|
||||
RptAddress=127.0.0.1
|
||||
RptPort=32010
|
||||
LocalPort=42020
|
||||
@ -20,5 +20,6 @@ Hosts=P25Hosts.txt
|
||||
ReloadTime=60
|
||||
ParrotAddress=127.0.0.1
|
||||
ParrotPort=42011
|
||||
Startup=10100
|
||||
# Startup=10100
|
||||
InactivityTimeout=10
|
||||
Debug=0
|
||||
|
Loading…
Reference in New Issue
Block a user