mirror of
https://github.com/ShaYmez/P25Clients.git
synced 2024-12-23 02:15:35 -05:00
Simplify the networking code a little.
This commit is contained in:
parent
bfbdfea30b
commit
14da695e8e
@ -41,7 +41,6 @@ m_file(file),
|
||||
m_callsign(),
|
||||
m_rptAddress(),
|
||||
m_rptPort(0U),
|
||||
m_myAddress(),
|
||||
m_myPort(0U),
|
||||
m_debug(false),
|
||||
m_daemon(false),
|
||||
@ -143,8 +142,6 @@ bool CConf::read()
|
||||
m_rptAddress = value;
|
||||
else if (::strcmp(key, "RptPort") == 0)
|
||||
m_rptPort = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "LocalAddress") == 0)
|
||||
m_myAddress = value;
|
||||
else if (::strcmp(key, "LocalPort") == 0)
|
||||
m_myPort = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Debug") == 0)
|
||||
@ -232,11 +229,6 @@ unsigned int CConf::getRptPort() const
|
||||
return m_rptPort;
|
||||
}
|
||||
|
||||
std::string CConf::getMyAddress() const
|
||||
{
|
||||
return m_myAddress;
|
||||
}
|
||||
|
||||
unsigned int CConf::getMyPort() const
|
||||
{
|
||||
return m_myPort;
|
||||
|
@ -34,7 +34,6 @@ public:
|
||||
std::string getCallsign() const;
|
||||
std::string getRptAddress() const;
|
||||
unsigned int getRptPort() const;
|
||||
std::string getMyAddress() const;
|
||||
unsigned int getMyPort() const;
|
||||
bool getDebug() const;
|
||||
bool getDaemon() const;
|
||||
@ -78,7 +77,6 @@ private:
|
||||
std::string m_callsign;
|
||||
std::string m_rptAddress;
|
||||
unsigned int m_rptPort;
|
||||
std::string m_myAddress;
|
||||
unsigned int m_myPort;
|
||||
bool m_debug;
|
||||
bool m_daemon;
|
||||
|
@ -189,7 +189,7 @@ void CP25Gateway::run()
|
||||
return;
|
||||
}
|
||||
|
||||
CRptNetwork localNetwork(m_conf.getMyAddress(), m_conf.getMyPort(), rptAddr, rptAddrLen, m_conf.getCallsign(), m_conf.getDebug());
|
||||
CRptNetwork localNetwork(m_conf.getMyPort(), rptAddr, rptAddrLen, m_conf.getCallsign(), m_conf.getDebug());
|
||||
ret = localNetwork.open();
|
||||
if (!ret) {
|
||||
::LogFinalise();
|
||||
|
@ -2,7 +2,6 @@
|
||||
Callsign=G4KLX
|
||||
RptAddress=127.0.0.1
|
||||
RptPort=32010
|
||||
LocalAddress=127.0.0.1
|
||||
LocalPort=42020
|
||||
Debug=0
|
||||
Daemon=1
|
||||
|
@ -24,21 +24,17 @@
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
CRptNetwork::CRptNetwork(const std::string& myAddr, unsigned int myPort, const sockaddr_storage& rptAddr, unsigned int rptAddrLen, const std::string& callsign, bool debug) :
|
||||
m_myAddr(),
|
||||
m_myAddrLen(0U),
|
||||
CRptNetwork::CRptNetwork(unsigned int myPort, const sockaddr_storage& rptAddr, unsigned int rptAddrLen, const std::string& callsign, bool debug) :
|
||||
m_rptAddr(rptAddr),
|
||||
m_rptAddrLen(rptAddrLen),
|
||||
m_callsign(callsign),
|
||||
m_socket(myAddr, myPort),
|
||||
m_socket(myPort),
|
||||
m_debug(debug),
|
||||
m_timer(1000U, 5U)
|
||||
{
|
||||
assert(myPort > 0U);
|
||||
assert(rptAddrLen > 0U);
|
||||
|
||||
CUDPSocket::lookup(myAddr, myPort, m_myAddr, m_myAddrLen);
|
||||
|
||||
m_callsign.resize(10U, ' ');
|
||||
}
|
||||
|
||||
@ -48,14 +44,9 @@ CRptNetwork::~CRptNetwork()
|
||||
|
||||
bool CRptNetwork::open()
|
||||
{
|
||||
if (m_myAddrLen == 0U) {
|
||||
LogError("Unable to resolve the local address and port");
|
||||
return false;
|
||||
}
|
||||
|
||||
LogInfo("Opening Rpt network connection");
|
||||
|
||||
bool ret = m_socket.open(m_myAddr);
|
||||
bool ret = m_socket.open(m_rptAddr);
|
||||
|
||||
if (ret) {
|
||||
m_timer.start();
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
class CRptNetwork {
|
||||
public:
|
||||
CRptNetwork(const std::string& myAddr, unsigned int myPort, const sockaddr_storage& rptAddr, unsigned int rptAddrLen, const std::string& callsign, bool debug);
|
||||
CRptNetwork(unsigned int myPort, const sockaddr_storage& rptAddr, unsigned int rptAddrLen, const std::string& callsign, bool debug);
|
||||
~CRptNetwork();
|
||||
|
||||
bool open();
|
||||
@ -41,8 +41,6 @@ public:
|
||||
void close();
|
||||
|
||||
private:
|
||||
sockaddr_storage m_myAddr;
|
||||
unsigned int m_myAddrLen;
|
||||
sockaddr_storage m_rptAddr;
|
||||
unsigned int m_rptAddrLen;
|
||||
std::string m_callsign;
|
||||
|
Loading…
Reference in New Issue
Block a user