the number of connected clients are now not managed with the server list but by the connection less ping time message

This commit is contained in:
Volker Fischer 2011-04-25 10:51:57 +00:00
parent c4e0e6e000
commit 23d79c5f85
13 changed files with 2878 additions and 2799 deletions

View File

@ -114,8 +114,9 @@ CClient::CClient ( const quint16 iPortNumber ) :
SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ), SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ),
SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ) ); SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ) );
QObject::connect ( &ConnLessProtocol, SIGNAL ( CLPingReceived ( CHostAddress, int ) ), QObject::connect ( &ConnLessProtocol,
this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) ); SIGNAL ( CLPingWithNumClientsReceived ( CHostAddress, int, int ) ),
this, SLOT ( OnCLPingWithNumClientsReceived ( CHostAddress, int, int ) ) );
QObject::connect ( &Sound, SIGNAL ( ReinitRequest() ), QObject::connect ( &Sound, SIGNAL ( ReinitRequest() ),
this, SLOT ( OnSndCrdReinitRequest() ) ); this, SLOT ( OnSndCrdReinitRequest() ) );
@ -162,13 +163,17 @@ void CClient::OnReceivePingMessage ( int iMs )
} }
} }
void CClient::OnCLPingReceived ( CHostAddress InetAddr, int iMs ) void CClient::OnCLPingWithNumClientsReceived ( CHostAddress InetAddr,
int iMs,
int iNumClients )
{ {
// take care of wrap arounds (if wrapping, do not use result) // take care of wrap arounds (if wrapping, do not use result)
const int iCurDiff = EvaluatePingMessage ( iMs ); const int iCurDiff = EvaluatePingMessage ( iMs );
if ( iCurDiff >= 0 ) if ( iCurDiff >= 0 )
{ {
emit CLPingTimeReceived ( InetAddr, iCurDiff ); emit CLPingTimeWithNumClientsReceived ( InetAddr,
iCurDiff,
iNumClients );
} }
} }

View File

@ -307,7 +307,9 @@ public slots:
void OnReceivePingMessage ( int iMs ); void OnReceivePingMessage ( int iMs );
void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage ); void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage );
void OnCLPingReceived ( CHostAddress InetAddr, int iMs ); void OnCLPingWithNumClientsReceived ( CHostAddress InetAddr,
int iMs,
int iNumClients );
void OnSndCrdReinitRequest(); void OnSndCrdReinitRequest();
@ -317,7 +319,9 @@ signals:
void PingTimeReceived ( int iPingTime ); void PingTimeReceived ( int iPingTime );
void CLServerListReceived ( CHostAddress InetAddr, void CLServerListReceived ( CHostAddress InetAddr,
CVector<CServerInfo> vecServerInfo ); CVector<CServerInfo> vecServerInfo );
void CLPingTimeReceived ( CHostAddress InetAddr, int iPingTime ); void CLPingTimeWithNumClientsReceived ( CHostAddress InetAddr,
int iPingTime,
int iNumClients );
void Disconnected(); void Disconnected();
void Stopped(); void Stopped();
}; };

View File

@ -234,13 +234,16 @@ void CConnectDlg::SetServerList ( const CHostAddress& InetAddr,
CurPingTimeFont.setBold ( true ); CurPingTimeFont.setBold ( true );
pNewListViewItem->setFont ( 1, CurPingTimeFont ); pNewListViewItem->setFont ( 1, CurPingTimeFont );
// number of clients // server location (city and country)
pNewListViewItem->setText ( 2, QString strLocation = vecServerInfo[iIdx].strCity;
QString().setNum ( vecServerInfo[iIdx].iNumClients ) ); if ( !strLocation.isEmpty() )
{
strLocation += ", ";
}
strLocation +=
QLocale::countryToString ( vecServerInfo[iIdx].eCountry );
// server country pNewListViewItem->setText ( 3, strLocation );
pNewListViewItem->setText ( 3,
QLocale::countryToString ( vecServerInfo[iIdx].eCountry ) );
// store host address // store host address
pNewListViewItem->setData ( 0, Qt::UserRole, pNewListViewItem->setData ( 0, Qt::UserRole,
@ -294,9 +297,10 @@ void CConnectDlg::OnTimerPing()
} }
} }
void CConnectDlg::SetPingTimeResult ( CHostAddress& InetAddr, void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr,
const int iPingTime, const int iPingTime,
const int iPingTimeLEDColor ) const int iPingTimeLEDColor,
const int iNumClients )
{ {
// apply the received ping time to the correct server list entry // apply the received ping time to the correct server list entry
const int iServerListLen = ListViewServers->topLevelItemCount(); const int iServerListLen = ListViewServers->topLevelItemCount();
@ -332,6 +336,10 @@ void CConnectDlg::SetPingTimeResult ( CHostAddress& InetAddr,
ListViewServers->topLevelItem ( iIdx )-> ListViewServers->topLevelItem ( iIdx )->
setText ( 1, QString().setNum ( iPingTime ) + " ms" ); setText ( 1, QString().setNum ( iPingTime ) + " ms" );
// update number of clients text
ListViewServers->topLevelItem ( iIdx )->
setText ( 2, QString().setNum ( iNumClients ) );
// a ping time was received, set item to visible // a ping time was received, set item to visible
ListViewServers->topLevelItem ( iIdx )->setHidden ( false ); ListViewServers->topLevelItem ( iIdx )->setHidden ( false );
} }

View File

@ -61,9 +61,10 @@ public:
void LoadStoredServers ( const CVector<QString>& vstrNewIPAddresses ); void LoadStoredServers ( const CVector<QString>& vstrNewIPAddresses );
void SetPingTimeResult ( CHostAddress& InetAddr, void SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr,
const int iPingTime, const int iPingTime,
const int iPingTimeLEDColor ); const int iPingTimeLEDColor,
const int iNumClients );
bool GetStateOK() const { return bStateOK; } bool GetStateOK() const { return bStateOK; }
bool GetServerListItemWasChosen() const { return bServerListItemWasChosen; } bool GetServerListItemWasChosen() const { return bServerListItemWasChosen; }

View File

@ -389,8 +389,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ), SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ),
this, SLOT ( OnCLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ) ); this, SLOT ( OnCLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ) );
QObject::connect ( pClient, SIGNAL ( CLPingTimeReceived ( CHostAddress, int ) ), QObject::connect ( pClient,
this, SLOT ( OnCLPingTimeResult ( CHostAddress, int ) ) ); SIGNAL ( CLPingTimeWithNumClientsReceived ( CHostAddress, int, int ) ),
this, SLOT ( OnCLPingTimeWithNumClientsReceived ( CHostAddress, int, int ) ) );
QObject::connect ( &ClientSettingsDlg, SIGNAL ( GUIDesignChanged() ), QObject::connect ( &ClientSettingsDlg, SIGNAL ( GUIDesignChanged() ),
this, SLOT ( OnGUIDesignChanged() ) ); this, SLOT ( OnGUIDesignChanged() ) );
@ -698,8 +699,9 @@ void CLlconClientDlg::OnPingTimeResult ( int iPingTime )
LEDDelay->SetLight ( iOverallDelayLEDColor ); LEDDelay->SetLight ( iOverallDelayLEDColor );
} }
void CLlconClientDlg::OnCLPingTimeResult ( CHostAddress InetAddr, void CLlconClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr,
int iPingTime ) int iPingTime,
int iNumClients )
{ {
// color definition: <= 25 ms green, <= 50 ms yellow, otherwise red // color definition: <= 25 ms green, <= 50 ms yellow, otherwise red
int iPingTimeLEDColor; int iPingTimeLEDColor;
@ -720,9 +722,10 @@ void CLlconClientDlg::OnCLPingTimeResult ( CHostAddress InetAddr,
} }
// update connection dialog server list // update connection dialog server list
ConnectDlg.SetPingTimeResult ( InetAddr, ConnectDlg.SetPingTimeAndNumClientsResult ( InetAddr,
iPingTime, iPingTime,
iPingTimeLEDColor ); iPingTimeLEDColor,
iNumClients );
} }
void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart ) void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart )

View File

@ -115,7 +115,9 @@ public slots:
void OnTimerPing(); void OnTimerPing();
void OnPingTimeResult ( int iPingTime ); void OnPingTimeResult ( int iPingTime );
void OnCLPingTimeResult ( CHostAddress InetAddr, int iPingTime ); void OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr,
int iPingTime,
int iNumClients );
void OnOpenGeneralSettings(); void OnOpenGeneralSettings();
void OnOpenChatDialog() void OnOpenChatDialog()

View File

@ -155,6 +155,17 @@ CONNECTION LESS MESSAGES
note: same definition as PROTMESSID_PING_MS note: same definition as PROTMESSID_PING_MS
- PROTMESSID_CLM_PING_MS_WITHNUMCLIENTS: Connection less ping message (for
measuring the ping time) with the
info about the current number of
connected clients
+-----------------------------+---------------------------------+
| 4 bytes transmit time in ms | 1 byte number connected clients |
+-----------------------------+---------------------------------+
- PROTMESSID_SERVER_FULL: Connection less server full message - PROTMESSID_SERVER_FULL: Connection less server full message
note: does not have any data -> n = 0 note: does not have any data -> n = 0
@ -163,30 +174,29 @@ CONNECTION LESS MESSAGES
- PROTMESSID_CLM_REGISTER_SERVER: Register a server, providing server - PROTMESSID_CLM_REGISTER_SERVER: Register a server, providing server
information information
+-----------------+---------------------------------+ ... +-----------------+----------------------------------+ ...
| 2 bytes country | 1 byte number connected clients | ... | 2 bytes country | 1 byte maximum connected clients | ...
+-----------------+---------------------------------+ ... +-----------------+----------------------------------+ ...
... ---------------------------------+---------------------+ ... ... ---------------------+------------------+ ...
... 1 byte maximum connected clients | 1 byte is permanent | ... ... 1 byte is permanent | 2 bytes number n | ...
... ---------------------------------+---------------------+ ... ... ---------------------+------------------+ ...
... -----------------+----------------------------------+ ... ... ----------------------------------+ ...
... 2 bytes number n | n bytes UTF-8 string server name | ... ... n bytes UTF-8 string server name | ...
... -----------------+----------------------------------+ ... ... ----------------------------------+ ...
... -----------------+----------------------------+ ... ... ------------------+----------------------------+ ...
... 2 bytes number n | n bytes UTF-8 string topic | ... ... 2 bytes number n | n bytes UTF-8 string topic | ...
... -----------------+----------------------------+ ... ... ------------------+----------------------------+ ...
... -----------------+---------------------------+ ... ------------------+---------------------------+
... 2 bytes number n | n bytes UTF-8 string city | ... 2 bytes number n | n bytes UTF-8 string city |
... -----------------+---------------------------+ ... ------------------+---------------------------+
- "country" is according to "Common Locale Data Repository" which is used in
the QLocale class
- "connected clients" is the current number of connected clients
- "maximum connected clients" is the maximum number of clients which can - "maximum connected clients" is the maximum number of clients which can
be connected to the server at the same time be connected to the server at the same time
- "is permanent" is a flag which indicates if the server is permanent - "is permanent" is a flag which indicates if the server is permanent
online or not. If this value is any value <> 0 indicates that the server online or not. If this value is any value <> 0 indicates that the server
is permanent online. is permanent online.
- "country" is according to "Common Locale Data Repository" which is used in
the QLocale class
- PROTMESSID_CLM_SERVER_LIST: Server list message - PROTMESSID_CLM_SERVER_LIST: Server list message
@ -564,6 +574,10 @@ bool CProtocol::ParseConnectionLessMessage ( const CVector<uint8_t>& vecbyData,
bRet = EvaluateCLPingMes ( InetAddr, vecData ); bRet = EvaluateCLPingMes ( InetAddr, vecData );
break; break;
case PROTMESSID_CLM_PING_MS_WITHNUMCLIENTS:
bRet = EvaluateCLPingWithNumClientsMes ( InetAddr, vecData );
break;
case PROTMESSID_CLM_SERVER_FULL: case PROTMESSID_CLM_SERVER_FULL:
bRet = EvaluateCLServerFullMes(); bRet = EvaluateCLServerFullMes();
break; break;
@ -1133,6 +1147,51 @@ bool CProtocol::EvaluateCLPingMes ( const CHostAddress& InetAddr,
return false; // no error return false; // no error
} }
void CProtocol::CreateCLPingWithNumClientsMes ( const CHostAddress& InetAddr,
const int iMs,
const int iNumClients )
{
int iPos = 0; // init position pointer
// build data vector (5 bytes long)
CVector<uint8_t> vecData ( 5 );
// transmit time (4 bytes)
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iMs ), 4 );
// current number of connected clients (1 byte)
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iNumClients ), 1 );
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_PING_MS_WITHNUMCLIENTS,
vecData,
InetAddr );
}
bool CProtocol::EvaluateCLPingWithNumClientsMes ( const CHostAddress& InetAddr,
const CVector<uint8_t>& vecData )
{
int iPos = 0; // init position pointer
// check size
if ( vecData.Size() != 5 )
{
return true; // return error code
}
// transmit time
const int iCurMs =
static_cast<int> ( GetValFromStream ( vecData, iPos, 4 ) );
// current number of connected clients
const int iCurNumClients =
static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
// invoke message action
emit CLPingWithNumClientsReceived ( InetAddr, iCurMs, iCurNumClients );
return false; // no error
}
void CProtocol::CreateCLServerFullMes ( const CHostAddress& InetAddr ) void CProtocol::CreateCLServerFullMes ( const CHostAddress& InetAddr )
{ {
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_SERVER_FULL, CreateAndImmSendConLessMessage ( PROTMESSID_CLM_SERVER_FULL,
@ -1156,7 +1215,6 @@ void CProtocol::CreateCLRegisterServerMes ( const CHostAddress& InetAddr,
// size of current message body // size of current message body
const int iEntrLen = const int iEntrLen =
2 /* country */ + 2 /* country */ +
1 /* number of connected clients */ +
1 /* maximum number of connected clients */ + 1 /* maximum number of connected clients */ +
1 /* is permanent flag */ + 1 /* is permanent flag */ +
2 /* name string size */ + ServerInfo.strName.size() + 2 /* name string size */ + ServerInfo.strName.size() +
@ -1170,10 +1228,6 @@ void CProtocol::CreateCLRegisterServerMes ( const CHostAddress& InetAddr,
PutValOnStream ( vecData, iPos, PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( ServerInfo.eCountry ), 2 ); static_cast<uint32_t> ( ServerInfo.eCountry ), 2 );
// number of connected clients (1 byte)
PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( ServerInfo.iNumClients ), 1 );
// maximum number of connected clients (1 byte) // maximum number of connected clients (1 byte)
PutValOnStream ( vecData, iPos, PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( ServerInfo.iMaxNumClients ), 1 ); static_cast<uint32_t> ( ServerInfo.iMaxNumClients ), 1 );
@ -1203,8 +1257,8 @@ bool CProtocol::EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr,
const int iDataLen = vecData.Size(); const int iDataLen = vecData.Size();
CServerCoreInfo RecServerInfo; CServerCoreInfo RecServerInfo;
// check size (the first 5 bytes) // check size (the first 4 bytes)
if ( iDataLen < 5 ) if ( iDataLen < 4 )
{ {
return true; // return error code return true; // return error code
} }
@ -1213,10 +1267,6 @@ bool CProtocol::EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr,
RecServerInfo.eCountry = RecServerInfo.eCountry =
static_cast<QLocale::Country> ( GetValFromStream ( vecData, iPos, 2 ) ); static_cast<QLocale::Country> ( GetValFromStream ( vecData, iPos, 2 ) );
// number of connected clients (1 byte)
RecServerInfo.iNumClients =
static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
// maximum number of connected clients (1 byte) // maximum number of connected clients (1 byte)
RecServerInfo.iMaxNumClients = RecServerInfo.iMaxNumClients =
static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) ); static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
@ -1281,7 +1331,6 @@ void CProtocol::CreateCLServerListMes ( const CHostAddress& InetAddr,
4 /* IP address */ + 4 /* IP address */ +
2 /* port number */ + 2 /* port number */ +
2 /* country */ + 2 /* country */ +
1 /* number of connected clients */ +
1 /* maximum number of connected clients */ + 1 /* maximum number of connected clients */ +
1 /* is permanent flag */ + 1 /* is permanent flag */ +
2 /* name string size */ + vecServerInfo[i].strName.size() + 2 /* name string size */ + vecServerInfo[i].strName.size() +
@ -1303,10 +1352,6 @@ void CProtocol::CreateCLServerListMes ( const CHostAddress& InetAddr,
PutValOnStream ( vecData, iPos, PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( vecServerInfo[i].eCountry ), 2 ); static_cast<uint32_t> ( vecServerInfo[i].eCountry ), 2 );
// number of connected clients (1 byte)
PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( vecServerInfo[i].iNumClients ), 1 );
// maximum number of connected clients (1 byte) // maximum number of connected clients (1 byte)
PutValOnStream ( vecData, iPos, PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( vecServerInfo[i].iMaxNumClients ), 1 ); static_cast<uint32_t> ( vecServerInfo[i].iMaxNumClients ), 1 );
@ -1339,8 +1384,8 @@ bool CProtocol::EvaluateCLServerListMes ( const CHostAddress& InetAddr,
while ( iPos < iDataLen ) while ( iPos < iDataLen )
{ {
// check size (the next 11 bytes) // check size (the next 10 bytes)
if ( ( iDataLen - iPos ) < 11 ) if ( ( iDataLen - iPos ) < 10 )
{ {
return true; // return error code return true; // return error code
} }
@ -1357,10 +1402,6 @@ bool CProtocol::EvaluateCLServerListMes ( const CHostAddress& InetAddr,
const QLocale::Country eCountry = const QLocale::Country eCountry =
static_cast<QLocale::Country> ( GetValFromStream ( vecData, iPos, 2 ) ); static_cast<QLocale::Country> ( GetValFromStream ( vecData, iPos, 2 ) );
// number of connected clients (1 byte)
const int iNumClients =
static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
// maximum number of connected clients (1 byte) // maximum number of connected clients (1 byte)
const int iMaxNumClients = const int iMaxNumClients =
static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) ); static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
@ -1406,7 +1447,6 @@ bool CProtocol::EvaluateCLServerListMes ( const CHostAddress& InetAddr,
strTopic, strTopic,
eCountry, eCountry,
strCity, strCity,
iNumClients,
iMaxNumClients, iMaxNumClients,
bPermanentOnline ) ); bPermanentOnline ) );
} }

View File

@ -56,13 +56,14 @@
// message IDs of connection less messages (CLM) // message IDs of connection less messages (CLM)
// DEFINITION -> start at 1000, end at 1999, see IsConnectionLessMessageID // DEFINITION -> start at 1000, end at 1999, see IsConnectionLessMessageID
#define PROTMESSID_CLM_PING_MS 1001 // for measuring ping time #define PROTMESSID_CLM_PING_MS 1001 // for measuring ping time
#define PROTMESSID_CLM_SERVER_FULL 1002 // server full message #define PROTMESSID_CLM_PING_MS_WITHNUMCLIENTS 1002 // for ping time and num. of clients info
#define PROTMESSID_CLM_REGISTER_SERVER 1003 // register server #define PROTMESSID_CLM_SERVER_FULL 1003 // server full message
#define PROTMESSID_CLM_UNREGISTER_SERVER 1004 // unregister server -> TODO #define PROTMESSID_CLM_REGISTER_SERVER 1004 // register server
#define PROTMESSID_CLM_SERVER_LIST 1005 // server list #define PROTMESSID_CLM_UNREGISTER_SERVER 1005 // unregister server -> TODO
#define PROTMESSID_CLM_REQ_SERVER_LIST 1006 // request server list #define PROTMESSID_CLM_SERVER_LIST 1006 // server list
#define PROTMESSID_CLM_SEND_EMPTY_MESSAGE 1007 // an empty message shall be send #define PROTMESSID_CLM_REQ_SERVER_LIST 1007 // request server list
#define PROTMESSID_CLM_EMPTY_MESSAGE 1008 // empty message #define PROTMESSID_CLM_SEND_EMPTY_MESSAGE 1008 // an empty message shall be send
#define PROTMESSID_CLM_EMPTY_MESSAGE 1009 // empty message
// lengths of message as defined in protocol.cpp file // lengths of message as defined in protocol.cpp file
@ -96,6 +97,9 @@ public:
void CreateReqNetwTranspPropsMes(); void CreateReqNetwTranspPropsMes();
void CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs ); void CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs );
void CreateCLPingWithNumClientsMes ( const CHostAddress& InetAddr,
const int iMs,
const int iNumClients );
void CreateCLServerFullMes ( const CHostAddress& InetAddr ); void CreateCLServerFullMes ( const CHostAddress& InetAddr );
void CreateCLRegisterServerMes ( const CHostAddress& InetAddr, void CreateCLRegisterServerMes ( const CHostAddress& InetAddr,
const CServerCoreInfo& ServerInfo ); const CServerCoreInfo& ServerInfo );
@ -204,6 +208,8 @@ protected:
bool EvaluateCLPingMes ( const CHostAddress& InetAddr, bool EvaluateCLPingMes ( const CHostAddress& InetAddr,
const CVector<uint8_t>& vecData ); const CVector<uint8_t>& vecData );
bool EvaluateCLPingWithNumClientsMes ( const CHostAddress& InetAddr,
const CVector<uint8_t>& vecData );
bool EvaluateCLServerFullMes(); bool EvaluateCLServerFullMes();
bool EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr, bool EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr,
const CVector<uint8_t>& vecData ); const CVector<uint8_t>& vecData );
@ -248,6 +254,9 @@ signals:
void Disconnection(); void Disconnection();
void CLPingReceived ( CHostAddress InetAddr, int iMs ); void CLPingReceived ( CHostAddress InetAddr, int iMs );
void CLPingWithNumClientsReceived ( CHostAddress InetAddr,
int iMs,
int iNumClients );
void CLRegisterServerReceived ( CHostAddress InetAddr, void CLRegisterServerReceived ( CHostAddress InetAddr,
CServerCoreInfo ServerInfo ); CServerCoreInfo ServerInfo );
void CLServerListReceived ( CHostAddress InetAddr, void CLServerListReceived ( CHostAddress InetAddr,

View File

@ -870,6 +870,23 @@ int CServer::GetFreeChan()
return INVALID_CHANNEL_ID; return INVALID_CHANNEL_ID;
} }
int CServer::GetNumberOfConnectedClients()
{
int iNumConnClients = 0;
// check all possible channels for connection status
for ( int i = 0; i < USED_NUM_CHANNELS; i++ )
{
if ( vecChannels[i].IsConnected() )
{
// this channel is connected, increment counter
iNumConnClients += 1;
}
}
return iNumConnClients;
}
int CServer::CheckAddr ( const CHostAddress& Addr ) int CServer::CheckAddr ( const CHostAddress& Addr )
{ {
CHostAddress InetAddr; CHostAddress InetAddr;

View File

@ -135,6 +135,7 @@ protected:
int CheckAddr ( const CHostAddress& Addr ); int CheckAddr ( const CHostAddress& Addr );
int GetFreeChan(); int GetFreeChan();
int GetNumberOfConnectedClients();
CVector<CChannelShortInfo> CreateChannelList(); CVector<CChannelShortInfo> CreateChannelList();
void CreateAndSendChanListForAllConChannels(); void CreateAndSendChanListForAllConChannels();
void CreateAndSendChanListForThisChan ( const int iCurChanID ); void CreateAndSendChanListForThisChan ( const int iCurChanID );
@ -189,7 +190,11 @@ public slots:
void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage ); void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage );
void OnCLPingReceived ( CHostAddress InetAddr, int iMs ) void OnCLPingReceived ( CHostAddress InetAddr, int iMs )
{ ConnLessProtocol.CreateCLPingMes ( InetAddr, iMs ); } {
ConnLessProtocol.CreateCLPingWithNumClientsMes ( InetAddr,
iMs,
GetNumberOfConnectedClients() );
}
void OnCLSendEmptyMes ( CHostAddress TargetInetAddr ) void OnCLSendEmptyMes ( CHostAddress TargetInetAddr )
{ {

View File

@ -62,7 +62,6 @@ ServerList.append ( CServerListEntry (
"", "",
QLocale::Germany, // TEST QLocale::Germany, // TEST
"Munich", // TEST "Munich", // TEST
0, // will be updated later
USED_NUM_CHANNELS, USED_NUM_CHANNELS,
true ) ); // TEST true ) ); // TEST
@ -187,7 +186,6 @@ void CServerListManager::RegisterServer ( const CHostAddress& InetAddr,
ServerList[iSelIdx].strTopic = ServerInfo.strTopic; ServerList[iSelIdx].strTopic = ServerInfo.strTopic;
ServerList[iSelIdx].eCountry = ServerInfo.eCountry; ServerList[iSelIdx].eCountry = ServerInfo.eCountry;
ServerList[iSelIdx].strCity = ServerInfo.strCity; ServerList[iSelIdx].strCity = ServerInfo.strCity;
ServerList[iSelIdx].iNumClients = ServerInfo.iNumClients;
ServerList[iSelIdx].iMaxNumClients = ServerInfo.iMaxNumClients; ServerList[iSelIdx].iMaxNumClients = ServerInfo.iMaxNumClients;
ServerList[iSelIdx].bPermanentOnline = ServerInfo.bPermanentOnline; ServerList[iSelIdx].bPermanentOnline = ServerInfo.bPermanentOnline;
ServerList[iSelIdx].UpdateRegistration(); ServerList[iSelIdx].UpdateRegistration();

View File

@ -81,7 +81,6 @@ public:
QLocale::AnyCountry, QLocale::AnyCountry,
"", "",
0, 0,
0,
false ) { UpdateRegistration(); } false ) { UpdateRegistration(); }
CServerListEntry ( const CHostAddress& NHAddr, CServerListEntry ( const CHostAddress& NHAddr,
@ -89,7 +88,6 @@ public:
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 NiMaxNumClients, const int NiMaxNumClients,
const bool NbPermOnline) const bool NbPermOnline)
: CServerInfo ( NHAddr, : CServerInfo ( NHAddr,
@ -97,7 +95,6 @@ public:
NsTopic, NsTopic,
NeCountry, NeCountry,
NsCity, NsCity,
NiNumClients,
NiMaxNumClients, NiMaxNumClients,
NbPermOnline ) { UpdateRegistration(); } NbPermOnline ) { UpdateRegistration(); }
@ -108,7 +105,6 @@ public:
NewCoreServerInfo.strTopic, NewCoreServerInfo.strTopic,
NewCoreServerInfo.eCountry, NewCoreServerInfo.eCountry,
NewCoreServerInfo.strCity, NewCoreServerInfo.strCity,
NewCoreServerInfo.iNumClients,
NewCoreServerInfo.iMaxNumClients, NewCoreServerInfo.iMaxNumClients,
NewCoreServerInfo.bPermanentOnline ) NewCoreServerInfo.bPermanentOnline )
{ UpdateRegistration(); } { UpdateRegistration(); }

View File

@ -487,7 +487,6 @@ public:
strTopic ( "" ), strTopic ( "" ),
eCountry ( QLocale::AnyCountry ), eCountry ( QLocale::AnyCountry ),
strCity ( "" ), strCity ( "" ),
iNumClients ( 0 ),
iMaxNumClients ( 0 ), iMaxNumClients ( 0 ),
bPermanentOnline ( false ) {} bPermanentOnline ( false ) {}
@ -496,14 +495,12 @@ public:
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 NiMaxNumClients, const int NiMaxNumClients,
const bool NbPermOnline) : const bool NbPermOnline) :
strName ( NsName ), strName ( NsName ),
strTopic ( NsTopic ), strTopic ( NsTopic ),
eCountry ( NeCountry ), eCountry ( NeCountry ),
strCity ( NsCity ), strCity ( NsCity ),
iNumClients ( NiNumClients ),
iMaxNumClients ( NiMaxNumClients ), iMaxNumClients ( NiMaxNumClients ),
bPermanentOnline ( NbPermOnline ) {} bPermanentOnline ( NbPermOnline ) {}
@ -520,9 +517,6 @@ public:
// city in which the server is located // city in which the server is located
QString strCity; QString strCity;
// current number of connected clients
int iNumClients;
// maximum number of clients which can connect to the server at the same // maximum number of clients which can connect to the server at the same
// time // time
int iMaxNumClients; int iMaxNumClients;
@ -540,7 +534,6 @@ public:
QLocale::AnyCountry, QLocale::AnyCountry,
"", "",
0, 0,
0,
false ), HostAddr ( CHostAddress() ) {} false ), HostAddr ( CHostAddress() ) {}
CServerInfo ( CServerInfo (
@ -549,14 +542,12 @@ public:
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 NiMaxNumClients, const int NiMaxNumClients,
const bool NbPermOnline) : const bool NbPermOnline) :
CServerCoreInfo ( NsName, CServerCoreInfo ( NsName,
NsTopic, NsTopic,
NeCountry, NeCountry,
NsCity, NsCity,
NiNumClients,
NiMaxNumClients, NiMaxNumClients,
NbPermOnline ), HostAddr ( NHAddr ) {} NbPermOnline ), HostAddr ( NHAddr ) {}