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
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<uint8_t>& 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<CServerInfo> vecServerInfo )
{
// TODO
}
/*
bool CProtocol::EvaluateCLServerListMes ( const CHostAddress& InetAddr,
const CVector<uint8_t>& vecData )
{
// TODO
}
*/
/******************************************************************************\
* 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_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<CServerInfo> 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_ ) */

View file

@ -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<CServerListProperties> ServerList;
bool bEnabled;
QTimer TimerPollList;
QMutex Mutex;
QList<CServerListEntry> ServerList;
bool bEnabled;
public slots:
void OnTimerPollList();

View file

@ -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