even more server list implementation
This commit is contained in:
parent
fa76bbab4c
commit
8447c1ea32
3 changed files with 40 additions and 2 deletions
10
src/server.h
10
src/server.h
|
@ -194,7 +194,15 @@ public slots:
|
||||||
{ ConnLessProtocol.CreateCLPingMes ( InetAddr, iMs ); }
|
{ ConnLessProtocol.CreateCLPingMes ( InetAddr, iMs ); }
|
||||||
|
|
||||||
void OnCLSendEmptyMes ( CHostAddress TargetInetAddr )
|
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 )
|
void OnCLReqServerList ( CHostAddress InetAddr )
|
||||||
{ ServerListManager.QueryServerList ( InetAddr ); }
|
{ ServerListManager.QueryServerList ( InetAddr ); }
|
||||||
|
|
|
@ -54,6 +54,9 @@ ServerList.append ( CServerListEntry (
|
||||||
QObject::connect ( &TimerPollList, SIGNAL ( timeout() ),
|
QObject::connect ( &TimerPollList, SIGNAL ( timeout() ),
|
||||||
this, SLOT ( OnTimerPollList() ) );
|
this, SLOT ( OnTimerPollList() ) );
|
||||||
|
|
||||||
|
QObject::connect ( &TimerRegistering, SIGNAL ( timeout() ),
|
||||||
|
this, SLOT ( OnTimerRegistering() ) );
|
||||||
|
|
||||||
|
|
||||||
// call set enable function after the connection of the timer since in this
|
// call set enable function after the connection of the timer since in this
|
||||||
// function the timer gets started
|
// function the timer gets started
|
||||||
|
@ -74,14 +77,24 @@ void CServerListManager::SetEnabled ( const bool bState )
|
||||||
// 1 minute = 60 * 1000 ms
|
// 1 minute = 60 * 1000 ms
|
||||||
TimerPollList.start ( SERVLIST_POLL_TIME_MINUTES * 60000 );
|
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
|
else
|
||||||
{
|
{
|
||||||
|
// disable service -> stop timer
|
||||||
if ( bIsCentralServer )
|
if ( bIsCentralServer )
|
||||||
{
|
{
|
||||||
// disable service -> stop timer
|
|
||||||
TimerPollList.stop();
|
TimerPollList.stop();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TimerRegistering.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,5 +209,18 @@ void CServerListManager::QueryServerList ( const CHostAddress& InetAddr )
|
||||||
|
|
||||||
|
|
||||||
/* Slave server functionality *************************************************/
|
/* 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
|
// TODO
|
||||||
|
|
||||||
|
// pConnLessProtocol->CreateCLRegisterServerMes (, ServerList[0] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -130,6 +130,8 @@ public:
|
||||||
CProtocol* pNConLProt );
|
CProtocol* pNConLProt );
|
||||||
|
|
||||||
void SetEnabled ( const bool bState );
|
void SetEnabled ( const bool bState );
|
||||||
|
bool GetEnabled() const { return bEnabled; }
|
||||||
|
bool GetIsCentralServer() const { return bIsCentralServer; }
|
||||||
|
|
||||||
void RegisterServer ( const CHostAddress& InetAddr,
|
void RegisterServer ( const CHostAddress& InetAddr,
|
||||||
const CServerCoreInfo& ServerInfo );
|
const CServerCoreInfo& ServerInfo );
|
||||||
|
@ -138,6 +140,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QTimer TimerPollList;
|
QTimer TimerPollList;
|
||||||
|
QTimer TimerRegistering;
|
||||||
QMutex Mutex;
|
QMutex Mutex;
|
||||||
QList<CServerListEntry> ServerList;
|
QList<CServerListEntry> ServerList;
|
||||||
bool bEnabled;
|
bool bEnabled;
|
||||||
|
@ -147,6 +150,7 @@ protected:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnTimerPollList();
|
void OnTimerPollList();
|
||||||
|
void OnTimerRegistering();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ ) */
|
#endif /* !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ ) */
|
||||||
|
|
Loading…
Reference in a new issue