even more server list implementation

This commit is contained in:
Volker Fischer 2011-04-09 15:30:58 +00:00
parent fa76bbab4c
commit 8447c1ea32
3 changed files with 40 additions and 2 deletions

View file

@ -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 ); }

View file

@ -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] );
}
}

View file

@ -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<CServerListEntry> ServerList;
bool bEnabled;
@ -147,6 +150,7 @@ protected:
public slots:
void OnTimerPollList();
void OnTimerRegistering();
};
#endif /* !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ ) */