diff --git a/src/server.cpp b/src/server.cpp index c51baae2..f53823a4 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -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; diff --git a/src/serverlist.cpp b/src/serverlist.cpp index bb5304ca..35703d67 100755 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -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 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 } } diff --git a/src/serverlist.h b/src/serverlist.h index b4f041aa..36660aae 100755 --- a/src/serverlist.h +++ b/src/serverlist.h @@ -67,6 +67,7 @@ private network. #include #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(); };