we need more server list classes with slightly different properties

This commit is contained in:
Volker Fischer 2011-04-02 18:25:13 +00:00
parent 5ca224af19
commit 53e8cabdbe
4 changed files with 96 additions and 58 deletions

View File

@ -555,16 +555,8 @@ bool CProtocol::ParseConnectionLessMessage ( const CVector<uint8_t>& vecbyData,
// TODO // TODO
break; break;
case PROTMESSID_CLM_EMPTY_MESSAGE:
// TODO
break;
case PROTMESSID_CLM_REGISTER_SERVER: case PROTMESSID_CLM_REGISTER_SERVER:
// TODO bRet = EvaluateCLRegisterServerMes ( InetAddr, vecData );
break;
case PROTMESSID_CLM_UNREGISTER_SERVER:
// TODO
break; break;
} }
} }
@ -1129,8 +1121,8 @@ bool CProtocol::EvaluateCLServerFullMes()
return false; // no error return false; // no error
} }
void CProtocol::CreateCLRegisterServerMes ( const CHostAddress& InetAddr, void CProtocol::CreateCLRegisterServerMes ( const CHostAddress& InetAddr,
const CServerInfo& ServerInfo ) const CServerCoreInfo& ServerInfo )
{ {
int iPos = 0; // init position pointer int iPos = 0; // init position pointer
@ -1185,9 +1177,9 @@ void CProtocol::CreateCLRegisterServerMes ( const CHostAddress& InetAddr,
bool CProtocol::EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr, bool CProtocol::EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr,
const CVector<uint8_t>& vecData ) const CVector<uint8_t>& vecData )
{ {
int iPos = 0; // init position pointer int iPos = 0; // init position pointer
const int iDataLen = vecData.Size(); const int iDataLen = vecData.Size();
CServerInfo RecServerInfo; CServerCoreInfo RecServerInfo;
// check size (the first 5 bytes) // check size (the first 5 bytes)
if ( iDataLen < 5 ) if ( iDataLen < 5 )
@ -1250,6 +1242,21 @@ bool CProtocol::EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr,
} }
void CProtocol::CreateCLServerListMes ( const CHostAddress& InetAddr,
const CVector<CServerInfo> vecServerInfo )
{
// TODO
}
/*
bool CProtocol::EvaluateCLServerListMes ( const CHostAddress& InetAddr,
const CVector<uint8_t>& vecData )
{
// TODO
}
*/
/******************************************************************************\ /******************************************************************************\
* Message generation and parsing * * Message generation and parsing *
\******************************************************************************/ \******************************************************************************/

View File

@ -62,7 +62,7 @@
#define PROTMESSID_CLM_SEND_EMPTY_MESSAGE 1005 // an empty message shall be send #define PROTMESSID_CLM_SEND_EMPTY_MESSAGE 1005 // an empty message shall be send
#define PROTMESSID_CLM_EMPTY_MESSAGE 1006 // empty message #define PROTMESSID_CLM_EMPTY_MESSAGE 1006 // empty message
#define PROTMESSID_CLM_REGISTER_SERVER 1007 // register server #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 // lengths of message as defined in protocol.cpp file
@ -97,8 +97,10 @@ public:
void CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs ); void CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs );
void CreateCLServerFullMes ( const CHostAddress& InetAddr ); void CreateCLServerFullMes ( const CHostAddress& InetAddr );
void CreateCLRegisterServerMes ( const CHostAddress& InetAddr, void CreateCLRegisterServerMes ( const CHostAddress& InetAddr,
const CServerInfo& ServerInfo ); const CServerCoreInfo& ServerInfo );
void CreateCLServerListMes ( const CHostAddress& InetAddr,
const CVector<CServerInfo> vecServerInfo );
void CreateAndImmSendDisconnectionMes(); void CreateAndImmSendDisconnectionMes();
void CreateAndImmSendAcknMess ( const int& iID, void CreateAndImmSendAcknMess ( const int& iID,
@ -238,7 +240,8 @@ signals:
void Disconnection(); void Disconnection();
void CLPingReceived ( CHostAddress InetAddr, int iMs ); 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_ ) */ #endif /* !defined ( PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_ ) */

View File

@ -70,47 +70,41 @@ private network.
/* Classes ********************************************************************/ /* Classes ********************************************************************/
class CServerListProperties class CServerListEntry : public CServerInfo
{ {
public: public:
CServerListProperties() : CServerListEntry() :
ServerInfo ( "", CServerInfo ( CHostAddress(),
"", "",
QLocale::AnyCountry, "",
"", QLocale::AnyCountry,
0, "",
0, 0,
false ) { RegisterTime.start(); } 0,
false ) { RegisterTime.start(); }
CServerListProperties ( const CHostAddress& NIAddr, CServerListEntry ( const CHostAddress& NIAddr,
const QString& NsName, const QString& NsName,
const QString& NsTopic, const QString& NsTopic,
const QLocale::Country& NeCountry, const QLocale::Country& NeCountry,
const QString& NsCity, const QString& NsCity,
const int NiNumClients, const int NiNumClients,
const int NiMaxNumClients, const int NiMaxNumClients,
const bool NbPermOnline) const bool NbPermOnline)
: InetAddr ( NIAddr ), ServerInfo ( NsName, : CServerInfo ( NIAddr,
NsTopic, NsName,
NeCountry, NsTopic,
NsCity, NeCountry,
NiNumClients, NsCity,
NiMaxNumClients, NiNumClients,
NbPermOnline ) NiMaxNumClients,
{ RegisterTime.start(); } NbPermOnline ) { RegisterTime.start(); }
public: public:
// time on which the entry was registered // time on which the entry was registered
QTime RegisterTime; QTime RegisterTime;
// internet address of the server
CHostAddress InetAddr;
// infos of the server
CServerInfo ServerInfo;
}; };
class CServerListManager : public QObject class CServerListManager : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -119,10 +113,10 @@ public:
CServerListManager ( const bool NbEbld ); CServerListManager ( const bool NbEbld );
protected: protected:
QTimer TimerPollList; QTimer TimerPollList;
QMutex Mutex; QMutex Mutex;
QList<CServerListProperties> ServerList; QList<CServerListEntry> ServerList;
bool bEnabled; bool bEnabled;
public slots: public slots:
void OnTimerPollList(); void OnTimerPollList();

View File

@ -452,10 +452,10 @@ public:
// Server info ----------------------------------------------------------------- // Server info -----------------------------------------------------------------
class CServerInfo class CServerCoreInfo
{ {
public: public:
CServerInfo() : CServerCoreInfo() :
strName ( "" ), strName ( "" ),
strTopic ( "" ), strTopic ( "" ),
eCountry ( QLocale::AnyCountry ), eCountry ( QLocale::AnyCountry ),
@ -464,7 +464,7 @@ public:
iMaxNumClients ( 0 ), iMaxNumClients ( 0 ),
bPermanentOnline ( false ) {} bPermanentOnline ( false ) {}
CServerInfo ( CServerCoreInfo (
const QString& NsName, const QString& NsName,
const QString& NsTopic, const QString& NsTopic,
const QLocale::Country& NeCountry, const QLocale::Country& NeCountry,
@ -504,6 +504,40 @@ public:
bool bPermanentOnline; 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 ------------------------------------------------- // Audio compression type enum -------------------------------------------------
enum EAudComprType enum EAudComprType