diff --git a/src/protocol.cpp b/src/protocol.cpp index b9bd38d7..0bde0dc0 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -555,16 +555,8 @@ bool CProtocol::ParseConnectionLessMessage ( const CVector& vecbyData, // TODO break; - case PROTMESSID_CLM_EMPTY_MESSAGE: -// TODO - break; - case PROTMESSID_CLM_REGISTER_SERVER: -// TODO - break; - - case PROTMESSID_CLM_UNREGISTER_SERVER: -// TODO + bRet = EvaluateCLRegisterServerMes ( InetAddr, vecData ); break; } } @@ -1129,8 +1121,8 @@ bool CProtocol::EvaluateCLServerFullMes() return false; // no error } -void CProtocol::CreateCLRegisterServerMes ( const CHostAddress& InetAddr, - const CServerInfo& ServerInfo ) +void CProtocol::CreateCLRegisterServerMes ( const CHostAddress& InetAddr, + const CServerCoreInfo& ServerInfo ) { int iPos = 0; // init position pointer @@ -1185,9 +1177,9 @@ void CProtocol::CreateCLRegisterServerMes ( const CHostAddress& InetAddr, bool CProtocol::EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr, const CVector& vecData ) { - int iPos = 0; // init position pointer - const int iDataLen = vecData.Size(); - CServerInfo RecServerInfo; + int iPos = 0; // init position pointer + const int iDataLen = vecData.Size(); + CServerCoreInfo RecServerInfo; // check size (the first 5 bytes) if ( iDataLen < 5 ) @@ -1250,6 +1242,21 @@ bool CProtocol::EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr, } +void CProtocol::CreateCLServerListMes ( const CHostAddress& InetAddr, + const CVector vecServerInfo ) +{ + // TODO +} + +/* +bool CProtocol::EvaluateCLServerListMes ( const CHostAddress& InetAddr, + const CVector& vecData ) +{ + // TODO +} +*/ + + /******************************************************************************\ * Message generation and parsing * \******************************************************************************/ diff --git a/src/protocol.h b/src/protocol.h index d6b90591..2deb1aba 100755 --- a/src/protocol.h +++ b/src/protocol.h @@ -62,7 +62,7 @@ #define PROTMESSID_CLM_SEND_EMPTY_MESSAGE 1005 // an empty message shall be send #define PROTMESSID_CLM_EMPTY_MESSAGE 1006 // empty message #define PROTMESSID_CLM_REGISTER_SERVER 1007 // register server -#define PROTMESSID_CLM_UNREGISTER_SERVER 1008 // unregister server +#define PROTMESSID_CLM_UNREGISTER_SERVER 1008 // unregister server -> TODO // lengths of message as defined in protocol.cpp file @@ -97,8 +97,10 @@ public: void CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs ); void CreateCLServerFullMes ( const CHostAddress& InetAddr ); - void CreateCLRegisterServerMes ( const CHostAddress& InetAddr, - const CServerInfo& ServerInfo ); + void CreateCLRegisterServerMes ( const CHostAddress& InetAddr, + const CServerCoreInfo& ServerInfo ); + void CreateCLServerListMes ( const CHostAddress& InetAddr, + const CVector vecServerInfo ); void CreateAndImmSendDisconnectionMes(); void CreateAndImmSendAcknMess ( const int& iID, @@ -238,7 +240,8 @@ signals: void Disconnection(); void CLPingReceived ( CHostAddress InetAddr, int iMs ); - void CLRegisterServerReceived ( CHostAddress InetAddr, CServerInfo ServerInfo ); + void CLRegisterServerReceived ( CHostAddress InetAddr, + CServerCoreInfo ServerInfo ); }; #endif /* !defined ( PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_ ) */ diff --git a/src/serverlist.h b/src/serverlist.h index e4de5b0d..11065dcb 100755 --- a/src/serverlist.h +++ b/src/serverlist.h @@ -70,47 +70,41 @@ private network. /* Classes ********************************************************************/ -class CServerListProperties +class CServerListEntry : public CServerInfo { public: - CServerListProperties() : - ServerInfo ( "", - "", - QLocale::AnyCountry, - "", - 0, - 0, - false ) { RegisterTime.start(); } + CServerListEntry() : + CServerInfo ( CHostAddress(), + "", + "", + QLocale::AnyCountry, + "", + 0, + 0, + false ) { RegisterTime.start(); } - CServerListProperties ( const CHostAddress& NIAddr, - const QString& NsName, - const QString& NsTopic, - const QLocale::Country& NeCountry, - const QString& NsCity, - const int NiNumClients, - const int NiMaxNumClients, - const bool NbPermOnline) - : InetAddr ( NIAddr ), ServerInfo ( NsName, - NsTopic, - NeCountry, - NsCity, - NiNumClients, - NiMaxNumClients, - NbPermOnline ) - { RegisterTime.start(); } + CServerListEntry ( const CHostAddress& NIAddr, + const QString& NsName, + const QString& NsTopic, + const QLocale::Country& NeCountry, + const QString& NsCity, + const int NiNumClients, + const int NiMaxNumClients, + const bool NbPermOnline) + : CServerInfo ( NIAddr, + NsName, + NsTopic, + NeCountry, + NsCity, + NiNumClients, + NiMaxNumClients, + NbPermOnline ) { RegisterTime.start(); } public: // time on which the entry was registered - QTime RegisterTime; - - // internet address of the server - CHostAddress InetAddr; - - // infos of the server - CServerInfo ServerInfo; + QTime RegisterTime; }; - class CServerListManager : public QObject { Q_OBJECT @@ -119,10 +113,10 @@ public: CServerListManager ( const bool NbEbld ); protected: - QTimer TimerPollList; - QMutex Mutex; - QList ServerList; - bool bEnabled; + QTimer TimerPollList; + QMutex Mutex; + QList ServerList; + bool bEnabled; public slots: void OnTimerPollList(); diff --git a/src/util.h b/src/util.h index 23bd498a..d701953b 100755 --- a/src/util.h +++ b/src/util.h @@ -452,10 +452,10 @@ public: // Server info ----------------------------------------------------------------- -class CServerInfo +class CServerCoreInfo { public: - CServerInfo() : + CServerCoreInfo() : strName ( "" ), strTopic ( "" ), eCountry ( QLocale::AnyCountry ), @@ -464,7 +464,7 @@ public: iMaxNumClients ( 0 ), bPermanentOnline ( false ) {} - CServerInfo ( + CServerCoreInfo ( const QString& NsName, const QString& NsTopic, const QLocale::Country& NeCountry, @@ -504,6 +504,40 @@ public: bool bPermanentOnline; }; +class CServerInfo : public CServerCoreInfo +{ +public: + CServerInfo() : + CServerCoreInfo ( "", + "", + QLocale::AnyCountry, + "", + 0, + 0, + false ), InetAddr ( CHostAddress() ) {} + + CServerInfo ( + const CHostAddress& NIAddr, + const QString& NsName, + const QString& NsTopic, + const QLocale::Country& NeCountry, + const QString& NsCity, + const int NiNumClients, + const int NiMaxNumClients, + const bool NbPermOnline) : + CServerCoreInfo ( NsName, + NsTopic, + NeCountry, + NsCity, + NiNumClients, + NiMaxNumClients, + NbPermOnline ), InetAddr ( NIAddr ) {} + +public: + // internet address of the server + CHostAddress InetAddr; +}; + // Audio compression type enum ------------------------------------------------- enum EAudComprType