create server list function
This commit is contained in:
parent
77a387ade4
commit
7e1ff9c38a
3 changed files with 27 additions and 7 deletions
|
@ -174,7 +174,9 @@ CServer::CServer ( const QString& strLoggingFileName,
|
|||
const QString& strCentralServer ) :
|
||||
Socket ( this, iPortNumber ),
|
||||
bWriteStatusHTMLFile ( false ),
|
||||
ServerListManager ( bServerListEnabled, bIsCentralServer )
|
||||
ServerListManager ( bServerListEnabled,
|
||||
bIsCentralServer,
|
||||
&ConnLessProtocol )
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -27,8 +27,10 @@
|
|||
|
||||
/* Implementation *************************************************************/
|
||||
CServerListManager::CServerListManager ( const bool NbEbld,
|
||||
const bool NbIsCentralServer )
|
||||
: bIsCentralServer ( NbIsCentralServer )
|
||||
const bool NbIsCentralServer,
|
||||
CProtocol* pNConLProt )
|
||||
: bIsCentralServer ( NbIsCentralServer ),
|
||||
pConnLessProtocol ( pNConLProt )
|
||||
{
|
||||
// per definition, the very first entry is this server and this entry will
|
||||
// never be deleted
|
||||
|
@ -163,12 +165,24 @@ void CServerListManager::QueryServerList ( const CHostAddress& InetAddr )
|
|||
|
||||
if ( bIsCentralServer && bEnabled )
|
||||
{
|
||||
const int iCurServerListSize = ServerList.size();
|
||||
|
||||
// TODO
|
||||
// allocate memory for the entire list
|
||||
CVector<CServerInfo> vecServerInfo ( iCurServerListSize );
|
||||
|
||||
// extract the list data in message or transmit directly?
|
||||
// copy the list (we have to copy it since the message requires
|
||||
// a vector but the list is actually stored in a QList object and
|
||||
// not in a vector object
|
||||
for ( int iIdx = 1; iIdx < iCurServerListSize; iIdx++ )
|
||||
{
|
||||
vecServerInfo[iIdx] = ServerList[iIdx];
|
||||
}
|
||||
|
||||
// create "send empty message" for all registered servers
|
||||
// send the server list to the client
|
||||
pConnLessProtocol->CreateCLServerListMes ( InetAddr, vecServerInfo );
|
||||
|
||||
|
||||
// TODO create "send empty message" for all registered servers
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ private network.
|
|||
#include <qmutex.h>
|
||||
#include "global.h"
|
||||
#include "util.h"
|
||||
#include "protocol.h"
|
||||
|
||||
|
||||
/* Classes ********************************************************************/
|
||||
|
@ -125,7 +126,8 @@ class CServerListManager : public QObject
|
|||
|
||||
public:
|
||||
CServerListManager ( const bool NbEbld,
|
||||
const bool NbIsCentralServer );
|
||||
const bool NbIsCentralServer,
|
||||
CProtocol* pNConLProt );
|
||||
|
||||
void SetEnabled ( const bool bState );
|
||||
|
||||
|
@ -141,6 +143,8 @@ protected:
|
|||
bool bEnabled;
|
||||
bool bIsCentralServer;
|
||||
|
||||
CProtocol* pConnLessProtocol;
|
||||
|
||||
public slots:
|
||||
void OnTimerPollList();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue