introduce command line argument for enabling the ping of the slave servers in the list to keep the NAT port open (central server functionality only)

This commit is contained in:
Volker Fischer 2012-07-14 16:18:09 +00:00
parent 046cb18253
commit aada1a912f
5 changed files with 67 additions and 37 deletions

View file

@ -59,6 +59,7 @@ int main ( int argc, char** argv )
bool bConnectOnStartup = false;
bool bDisalbeLEDs = false;
bool bShowComplRegConnList = false;
bool bCentServPingServerInList = false;
int iNumServerChannels = DEFAULT_USED_NUM_CHANNELS;
quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER;
QString strIniFileName = "";
@ -143,6 +144,18 @@ int main ( int argc, char** argv )
}
// Ping servers in list for central server -----------------------------
if ( GetFlagArgument ( argv,
i,
"-g",
"--pingservers" ) )
{
bCentServPingServerInList = true;
tsConsole << "- ping servers in slave server list" << endl;
continue;
}
// Show all registered servers in the server list ----------------------
// Undocumented debugging command line argument: Show all registered
// servers in the server list regardless if a ping to the server is
@ -391,7 +404,8 @@ int main ( int argc, char** argv )
strHistoryFileName,
strServerName,
strCentralServer,
strServerInfo );
strServerInfo,
bCentServPingServerInList );
if ( bUseGUI )
{
@ -469,30 +483,32 @@ QString UsageArguments ( char **argv )
return
"Usage: " + QString ( argv[0] ) + " [option] [argument]\n"
"\nRecognized options:\n"
" -s, --server start server\n"
" -n, --nogui disable GUI (server only)\n"
" -u, --numchannels maximum number of channels (server only)\n"
" -z, --startminimized start minimizied (server only)\n"
" -l, --log enable logging, set file name\n"
" -i, --inifile initialization file name (client only)\n"
" -p, --port local port number (server only)\n"
" -m, --htmlstatus enable HTML status file, set file name (server\n"
" only)\n"
" -a, --servername server name, required for HTML status (server\n"
" only)\n"
" -y, --history enable connection history and set file\n"
" name (server only)\n"
" -c, --connect connect to last server on startup (client\n"
" only)\n"
" -d, --disableleds disable LEDs in main window (client only)\n"
" -e, --centralserver address of the central server (server only)\n"
" -g, --pingservers ping servers in list to keep NAT port open\n"
" (central server only)\n"
" -h, -?, --help this help text\n"
" -i, --inifile initialization file name (client only)\n"
" -l, --log enable logging, set file name\n"
" -m, --htmlstatus enable HTML status file, set file name (server\n"
" only)\n"
" -n, --nogui disable GUI (server only)\n"
" -o, --serverinfo infos of the server(s) in the format:\n"
" [name];[city];[country as QLocale ID]; ...\n"
" [server1 address];[server1 name]; ...\n"
" [server1 city]; ...\n"
" [server1 country as QLocale ID]; ...\n"
" [server2 address]; ... (server only)\n"
" -c, --connect connect to last server on startup (client\n"
" only)\n"
" -d, --disableleds disable LEDs in main window (client only)\n"
" -h, -?, --help this help text\n"
" -p, --port local port number (server only)\n"
" -s, --server start server\n"
" -u, --numchannels maximum number of channels (server only)\n"
" -y, --history enable connection history and set file\n"
" name (server only)\n"
" -z, --startminimized start minimizied (server only)\n"
"\nExample: " + QString ( argv[0] ) + " -l -inifile myinifile.ini\n";
}

View file

@ -171,7 +171,8 @@ CServer::CServer ( const int iNewNumChan,
const QString& strHistoryFileName,
const QString& strServerNameForHTMLStatusFile,
const QString& strCentralServer,
const QString& strServerInfo ) :
const QString& strServerInfo,
const bool bNCentServPingServerInList ) :
iNumChannels ( iNewNumChan ),
Socket ( this, iPortNumber ),
bWriteStatusHTMLFile ( false ),
@ -179,6 +180,7 @@ CServer::CServer ( const int iNewNumChan,
strCentralServer,
strServerInfo,
iNewNumChan,
bNCentServPingServerInList,
&ConnLessProtocol ),
bAutoRunMinimized ( false )
{

View file

@ -110,7 +110,8 @@ public:
const QString& strHistoryFileName,
const QString& strServerNameForHTMLStatusFile,
const QString& strCentralServer,
const QString& strServerInfo );
const QString& strServerInfo,
const bool bNCentServPingServerInList );
void Start();
void Stop();

View file

@ -30,11 +30,13 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum,
const QString& sNCentServAddr,
const QString& strServerInfo,
const int iNumChannels,
const bool bNCentServPingServerInList,
CProtocol* pNConLProt )
: iPortNumber ( iNPortNum ),
iNumPredefinedServers ( 0 ),
bUseDefaultCentralServerAddress ( false ),
pConnLessProtocol ( pNConLProt )
pConnLessProtocol ( pNConLProt ),
bCentServPingServerInList ( bNCentServPingServerInList )
{
// set the central server address
SetCentralServerAddress ( sNCentServAddr );
@ -200,9 +202,12 @@ void CServerListManager::Update()
// 1 minute = 60 * 1000 ms
TimerPollList.start ( SERVLIST_POLL_TIME_MINUTES * 60000 );
if ( bCentServPingServerInList )
{
// start timer for sending ping messages to servers in the list
TimerPingServerInList.start ( SERVLIST_UPDATE_PING_SERVERS_MS );
}
}
else
{
// initiate registration right away so that we do not have to wait
@ -235,8 +240,12 @@ void CServerListManager::Update()
if ( bIsCentralServer )
{
TimerPollList.stop();
if ( bCentServPingServerInList )
{
TimerPingServerInList.stop();
}
}
else
{
TimerRegistering.stop();

View file

@ -129,6 +129,7 @@ public:
const QString& sNCentServAddr,
const QString& strServerInfo,
const int iNumChannels,
const bool bNCentServPingServerInList,
CProtocol* pNConLProt );
// the update has to be called if any change to the server list
@ -194,6 +195,7 @@ protected:
bool bEnabled;
bool bIsCentralServer;
bool bUseDefaultCentralServerAddress;
bool bCentServPingServerInList;
CHostAddress SlaveCurCentServerHostAddress;