diff --git a/src/server.h b/src/server.h index b037bca7..ad302a53 100755 --- a/src/server.h +++ b/src/server.h @@ -194,7 +194,15 @@ public slots: { ConnLessProtocol.CreateCLPingMes ( InetAddr, iMs ); } void OnCLSendEmptyMes ( CHostAddress TargetInetAddr ) - { ConnLessProtocol.CreateCLEmptyMes ( TargetInetAddr ); } + { + // only send empty message if server list is enabled and this is not + // the central server + if ( ServerListManager.GetEnabled() && + !ServerListManager.GetIsCentralServer() ) + { + ConnLessProtocol.CreateCLEmptyMes ( TargetInetAddr ); + } + } void OnCLReqServerList ( CHostAddress InetAddr ) { ServerListManager.QueryServerList ( InetAddr ); } diff --git a/src/serverlist.cpp b/src/serverlist.cpp index 85b86582..bd127c66 100755 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -54,6 +54,9 @@ ServerList.append ( CServerListEntry ( QObject::connect ( &TimerPollList, SIGNAL ( timeout() ), this, SLOT ( OnTimerPollList() ) ); + QObject::connect ( &TimerRegistering, SIGNAL ( timeout() ), + this, SLOT ( OnTimerRegistering() ) ); + // call set enable function after the connection of the timer since in this // function the timer gets started @@ -74,14 +77,24 @@ void CServerListManager::SetEnabled ( const bool bState ) // 1 minute = 60 * 1000 ms TimerPollList.start ( SERVLIST_POLL_TIME_MINUTES * 60000 ); } + else + { + // start timer for registering this server at the central server + // 1 minute = 60 * 1000 ms + TimerRegistering.start ( SERVLIST_REGIST_INTERV_MINUTES * 60000 ); + } } else { + // disable service -> stop timer if ( bIsCentralServer ) { - // disable service -> stop timer TimerPollList.stop(); } + else + { + TimerRegistering.stop(); + } } } @@ -196,5 +209,18 @@ void CServerListManager::QueryServerList ( const CHostAddress& InetAddr ) /* Slave server functionality *************************************************/ +void CServerListManager::OnTimerRegistering() +{ + QMutexLocker locker ( &Mutex ); + + if ( !bIsCentralServer && bEnabled ) + { + // for the slave server, the slave server properties are store in the + // very first item in the server list (which is actually no server list + // but just one item long for the slave server) // TODO + +// pConnLessProtocol->CreateCLRegisterServerMes (, ServerList[0] ); + } +} diff --git a/src/serverlist.h b/src/serverlist.h index 36660aae..ea5585c0 100755 --- a/src/serverlist.h +++ b/src/serverlist.h @@ -130,6 +130,8 @@ public: CProtocol* pNConLProt ); void SetEnabled ( const bool bState ); + bool GetEnabled() const { return bEnabled; } + bool GetIsCentralServer() const { return bIsCentralServer; } void RegisterServer ( const CHostAddress& InetAddr, const CServerCoreInfo& ServerInfo ); @@ -138,6 +140,7 @@ public: protected: QTimer TimerPollList; + QTimer TimerRegistering; QMutex Mutex; QList ServerList; bool bEnabled; @@ -147,6 +150,7 @@ protected: public slots: void OnTimerPollList(); + void OnTimerRegistering(); }; #endif /* !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ ) */