diff --git a/ChangeLog b/ChangeLog index 675ca6ab..e7226a47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,7 @@ 3.3.12 -TODO: +TODO: (close Ticket on Sourceforge if finished!) - on request show the names of the connected clients in the server list diff --git a/src/client.cpp b/src/client.cpp index d6505921..f96e60fc 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -204,6 +204,10 @@ QObject::connect ( &Channel, SIGNAL ( OpusSupported() ), SIGNAL ( CLServerListReceived ( CHostAddress, CVector ) ), SIGNAL ( CLServerListReceived ( CHostAddress, CVector ) ) ); + QObject::connect ( &ConnLessProtocol, + SIGNAL ( CLConnClientsListMesReceived ( CHostAddress, CVector ) ), + SIGNAL ( CLConnClientsListMesReceived ( CHostAddress, CVector ) ) ); + QObject::connect ( &ConnLessProtocol, SIGNAL ( CLPingReceived ( CHostAddress, int ) ), this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) ); diff --git a/src/client.h b/src/client.h index baa11d68..8f73cff4 100755 --- a/src/client.h +++ b/src/client.h @@ -267,9 +267,10 @@ public: } void CreateCLServerListReqVerAndOSMes ( const CHostAddress& InetAddr ) - { - ConnLessProtocol.CreateCLReqVersionAndOSMes ( InetAddr ); - } + { ConnLessProtocol.CreateCLReqVersionAndOSMes ( InetAddr ); } + + void CreateCLServerListReqConnClientsListMes ( const CHostAddress& InetAddr ) + { ConnLessProtocol.CreateCLReqConnClientsListMes ( InetAddr ); } void CreateCLReqServerListMes ( const CHostAddress& InetAddr ) { ConnLessProtocol.CreateCLReqServerListMes ( InetAddr ); } @@ -428,6 +429,9 @@ signals: void CLServerListReceived ( CHostAddress InetAddr, CVector vecServerInfo ); + void CLConnClientsListMesReceived ( CHostAddress InetAddr, + CVector vecChanInfo ); + void CLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, int iPingTime, int iNumClients ); diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index dac2dfb3..6f772579 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -474,6 +474,10 @@ CClientDlg::CClientDlg ( CClient* pNCliP, SIGNAL ( CLServerListReceived ( CHostAddress, CVector ) ), this, SLOT ( OnCLServerListReceived ( CHostAddress, CVector ) ) ); + QObject::connect ( pClient, + SIGNAL ( CLConnClientsListMesReceived ( CHostAddress, CVector ) ), + this, SLOT ( OnCLConnClientsListMesReceived ( CHostAddress, CVector ) ) ); + QObject::connect ( pClient, SIGNAL ( CLPingTimeWithNumClientsReceived ( CHostAddress, int, int ) ), this, SLOT ( OnCLPingTimeWithNumClientsReceived ( CHostAddress, int, int ) ) ); @@ -520,6 +524,9 @@ CClientDlg::CClientDlg ( CClient* pNCliP, QObject::connect ( &ConnectDlg, SIGNAL ( CreateCLServerListReqVerAndOSMes ( CHostAddress ) ), this, SLOT ( OnCreateCLServerListReqVerAndOSMes ( CHostAddress ) ) ); + QObject::connect ( &ConnectDlg, SIGNAL ( CreateCLServerListReqConnClientsListMes ( CHostAddress ) ), + this, SLOT ( OnCreateCLServerListReqConnClientsListMes ( CHostAddress ) ) ); + QObject::connect ( &ConnectDlg, SIGNAL ( accepted() ), this, SLOT ( OnConnectDlgAccepted() ) ); diff --git a/src/clientdlg.h b/src/clientdlg.h index 0a6dd556..199a03ff 100755 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -176,10 +176,17 @@ public slots: void OnCreateCLServerListReqVerAndOSMes ( CHostAddress InetAddr ) { pClient->CreateCLServerListReqVerAndOSMes ( InetAddr ); } + void OnCreateCLServerListReqConnClientsListMes ( CHostAddress InetAddr ) + { pClient->CreateCLServerListReqConnClientsListMes ( InetAddr ); } + void OnCLServerListReceived ( CHostAddress InetAddr, CVector vecServerInfo ) { ConnectDlg.SetServerList ( InetAddr, vecServerInfo ); } + void OnCLConnClientsListMesReceived ( CHostAddress InetAddr, + CVector vecChanInfo ) + { ConnectDlg.SetConnClientsList ( InetAddr, vecChanInfo ); } + void OnConnectDlgAccepted(); void OnDisconnected(); diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index 726d5095..fbdcb177 100755 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -93,6 +93,17 @@ CConnectDlg::CConnectDlg ( const bool bNewShowCompleteRegList, lvwServers->setColumnCount ( 5 ); lvwServers->hideColumn ( 4 ); + // setup the server list context menu + lvwServers->setContextMenuPolicy ( Qt::CustomContextMenu ); + + // per default the root shall not be decorated (to save space) + lvwServers->setRootIsDecorated ( false ); + + pServerListContextMenu = new QMenu ( this ); + + pServerListContextMenu->addAction ( tr ( "&Query Names" ), this, + SLOT ( OnServerListContextMenuNames() ) ); + // make sure the connect button has the focus butConnect->setFocus(); @@ -116,6 +127,10 @@ CConnectDlg::CConnectDlg ( const bool bNewShowCompleteRegList, SIGNAL ( activated ( QModelIndex ) ), this, SLOT ( OnConnectClicked() ) ); + QObject::connect ( lvwServers, + SIGNAL ( customContextMenuRequested ( const QPoint& ) ), + this, SLOT ( OnCustomContextMenuRequested ( const QPoint& ) ) ); + // combo boxes QObject::connect ( cbxServerAddr, SIGNAL ( editTextChanged ( const QString& ) ), this, SLOT ( OnServerAddrEditTextChanged ( const QString& ) ) ); @@ -305,6 +320,43 @@ strLocation += ", " + vecServerInfo[iIdx].HostAddr.InetAddr.toString() + TimerPing.start ( PING_UPDATE_TIME_SERVER_LIST_MS ); } +void CConnectDlg::SetConnClientsList ( const CHostAddress& InetAddr, + const CVector& vecChanInfo ) +{ + // find the server with the correct address + QTreeWidgetItem* pCurListViewItem = FindListViewItem ( InetAddr ); + + if ( pCurListViewItem ) + { + // first remove any existing childs + DeleteAllListViewItemChilds ( pCurListViewItem ); + + // get number of connected clients + const int iNumConnectedClients = vecChanInfo.Size(); + + for ( int i = 0; i < iNumConnectedClients; i++ ) + { + // create new list view item + QTreeWidgetItem* pNewChildListViewItem = + new QTreeWidgetItem ( pCurListViewItem ); + + // child items shall use only one column + pNewChildListViewItem->setFirstColumnSpanned ( true ); + + // set the clients name + pNewChildListViewItem->setText ( 0, vecChanInfo[i].strName ); + + // add the new child to the corresponding server item + pCurListViewItem->addChild ( pNewChildListViewItem ); + + // at least one server has childs now, show decoration to be able + // to show the childs and also expand to see the new childs + lvwServers->setRootIsDecorated ( true ); + lvwServers->expandItem ( pCurListViewItem ); + } + } +} + void CConnectDlg::OnServerListItemSelectionChanged() { // get current selected item (we are only interested in the first selcted @@ -317,7 +369,8 @@ void CConnectDlg::OnServerListItemSelectionChanged() // make sure no signals are send when we change the text cbxServerAddr->blockSignals ( true ); { - cbxServerAddr->setEditText ( CurSelListItemList[0]->text ( 0 ) ); + cbxServerAddr->setEditText ( + GetParentListViewItem ( CurSelListItemList[0] )->text ( 0 ) ); } cbxServerAddr->blockSignals ( false ); } @@ -334,6 +387,24 @@ void CConnectDlg::OnServerListItemDoubleClicked ( QTreeWidgetItem* Item, } } +void CConnectDlg::OnCustomContextMenuRequested ( const QPoint& Position ) +{ + // get the item to which the context menu is assigned to based on the given + // mouse position + QTreeWidgetItem* Item = lvwServers->itemAt ( Position ); + + // first check if the item is valid + if ( Item != 0 ) + { + // only show the context menu if there is at least von conntected client + if ( Item->text ( 2 ).toInt() > 0 ) + { + // use the given position for the position of the context menu + pServerListContextMenu->exec ( lvwServers->mapToGlobal ( Position ) ); + } + } +} + void CConnectDlg::OnServerAddrEditTextChanged ( const QString& ) { // in the server address combo box, a text was changed, remove selection @@ -350,12 +421,16 @@ void CConnectDlg::OnConnectClicked() if ( CurSelListItemList.count() > 0 ) { + // get the parent list view item + QTreeWidgetItem* pCurSelTopListItem = + GetParentListViewItem ( CurSelListItemList[0] ); + // get host address from selected list view item as a string strSelectedAddress = - CurSelListItemList[0]->data ( 0, Qt::UserRole ).toString(); + pCurSelTopListItem->data ( 0, Qt::UserRole ).toString(); // store selected server name - strSelectedServerName = CurSelListItemList[0]->text ( 0 ); + strSelectedServerName = pCurSelTopListItem->text ( 0 ); // set flag that a server list item was chosen to connect bServerListItemWasChosen = true; @@ -369,6 +444,28 @@ void CConnectDlg::OnConnectClicked() done ( QDialog::Accepted ); } +void CConnectDlg::OnServerListContextMenuNames() +{ + // get the current selected item(s) + QList CurSelListItemList = lvwServers->selectedItems(); + + if ( CurSelListItemList.count() > 0 ) + { + CHostAddress CurServerAddress; + + // try to parse host address string which is stored as user data + // in the server list item GUI control element + if ( NetworkUtil().ParseNetworkAddress ( + CurSelListItemList[0]-> + data ( 0, Qt::UserRole ).toString(), + CurServerAddress ) ) + { + // if address is valid, send connected clients list request + emit CreateCLServerListReqConnClientsListMes ( CurServerAddress ); + } + } +} + void CConnectDlg::OnTimerPing() { // send ping messages to the servers in the list @@ -401,6 +498,96 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& const int iNumClients ) { // apply the received ping time to the correct server list entry + QTreeWidgetItem* pCurListViewItem = FindListViewItem ( InetAddr ); + + if ( pCurListViewItem ) + { + // update the color of the ping time font + switch ( ePingTimeLEDColor ) + { + case CMultiColorLED::RL_GREEN: + pCurListViewItem->setTextColor ( 1, Qt::darkGreen ); + break; + + case CMultiColorLED::RL_YELLOW: + pCurListViewItem->setTextColor ( 1, Qt::darkYellow ); + break; + + default: // including "CMultiColorLED::RL_RED" + pCurListViewItem->setTextColor ( 1, Qt::red ); + break; + } + + // update ping text, take special care if ping time exceeds a + // certain value + if ( iPingTime > 500 ) + { + pCurListViewItem->setText ( 1, ">500 ms" ); + } + else + { + pCurListViewItem-> + setText ( 1, QString().setNum ( iPingTime ) + " ms" ); + } + + // update number of clients text + pCurListViewItem-> + setText ( 2, QString().setNum ( iNumClients ) ); + + // a ping time was received, set item to visible (note that we have + // to check if the item is hidden, otherwise we get a lot of CPU + // usage by calling "setHidden(false)" even if the item was already + // visible) + if ( pCurListViewItem->isHidden() ) + { + pCurListViewItem->setHidden ( false ); + } + + // update minimum ping time column (invisible, used for sorting) if + // the new value is smaller than the old value + if ( pCurListViewItem->text ( 4 ).toInt() > iPingTime ) + { + // we pad to a total of 8 characters with zeros to make sure the + // sorting is done correctly + pCurListViewItem->setText ( 4, QString ( "%1" ).arg ( + iPingTime, 8, 10, QLatin1Char ( '0' ) ) ); + + // Update the sorting (lowest number on top). + // Note that the sorting must be the last action for the current + // item since the topLevelItem ( iIdx ) is then no longer valid. + lvwServers->sortByColumn ( 4, Qt::AscendingOrder ); + } + + // check if the current number of clients is the same as the number + // of child items, if not, we remove all child items + if ( iNumClients != pCurListViewItem->childCount() ) + { + // delete all childs + DeleteAllListViewItemChilds ( pCurListViewItem ); + } + } + + // if no server item has childs, do not show decoration + bool bAnyListItemHasChilds = false; + const int iServerListLen = lvwServers->topLevelItemCount(); + + for ( int iIdx = 0; iIdx < iServerListLen; iIdx++ ) + { + // check if the current list item has childs + if ( lvwServers->topLevelItem ( iIdx )->childCount() > 0 ) + { + bAnyListItemHasChilds = true; + } + } + + if ( !bAnyListItemHasChilds ) + { + lvwServers->setRootIsDecorated ( false ); + } +} + +QTreeWidgetItem* CConnectDlg::FindListViewItem ( const CHostAddress& InetAddr ) +{ const int iServerListLen = lvwServers->topLevelItemCount(); for ( int iIdx = 0; iIdx < iServerListLen; iIdx++ ) @@ -411,67 +598,44 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& data ( 0, Qt::UserRole ).toString(). compare ( InetAddr.toString() ) ) { - // update the color of the ping time font - switch ( ePingTimeLEDColor ) - { - case CMultiColorLED::RL_GREEN: - lvwServers-> - topLevelItem ( iIdx )->setTextColor ( 1, Qt::darkGreen ); - break; - - case CMultiColorLED::RL_YELLOW: - lvwServers-> - topLevelItem ( iIdx )->setTextColor ( 1, Qt::darkYellow ); - break; - - default: // including "CMultiColorLED::RL_RED" - lvwServers-> - topLevelItem ( iIdx )->setTextColor ( 1, Qt::red ); - break; - } - - // update ping text, take special care if ping time exceeds a - // certain value - if ( iPingTime > 500 ) - { - lvwServers->topLevelItem ( iIdx )->setText ( 1, ">500 ms" ); - } - else - { - lvwServers->topLevelItem ( iIdx )-> - setText ( 1, QString().setNum ( iPingTime ) + " ms" ); - } - - // update number of clients text - lvwServers->topLevelItem ( iIdx )-> - setText ( 2, QString().setNum ( iNumClients ) ); - - // a ping time was received, set item to visible (note that we have - // to check if the item is hidden, otherwise we get a lot of CPU - // usage by calling "setHidden(false)" even if the item was already - // visible) - if ( lvwServers->topLevelItem ( iIdx )->isHidden() ) - { - lvwServers->topLevelItem ( iIdx )->setHidden ( false ); - } - - // update minimum ping time column (invisible, used for sorting) if - // the new value is smaller than the old value - if ( lvwServers->topLevelItem ( iIdx )->text ( 4 ).toInt() > iPingTime ) - { - // we pad to a total of 8 characters with zeros to make sure the - // sorting is done correctly - lvwServers->topLevelItem ( iIdx )-> - setText ( 4, QString ( "%1" ).arg ( - iPingTime, 8, 10, QLatin1Char ( '0' ) ) ); - - // Update the sorting (lowest number on top). - // Note that the sorting must be the last action for the current - // item since the topLevelItem ( iIdx ) is then no longer valid. - lvwServers->sortByColumn ( 4, Qt::AscendingOrder ); - } + return lvwServers->topLevelItem ( iIdx ); } } + + return NULL; +} + +QTreeWidgetItem* CConnectDlg::GetParentListViewItem ( QTreeWidgetItem* pItem ) +{ + // check if the current item is already the top item, i.e. the parent + // query fails and returns null + if ( pItem->parent() ) + { + // we only have maximum one level, i.e. if we call the parent function + // we are at the top item + return pItem->parent(); + } + else + { + // this item is already the top item + return pItem; + } +} + +void CConnectDlg::DeleteAllListViewItemChilds ( QTreeWidgetItem* pItem ) +{ + // loop over all childs + while ( pItem->childCount() > 0 ) + { + // get the first child in the list + QTreeWidgetItem* pCurChildItem = pItem->child ( 0 ); + + // remove it from the item (note that the object is not deleted) + pItem->removeChild ( pCurChildItem ); + + // delete the object to avoid a memory leak + delete pCurChildItem; + } } #ifdef ENABLE_CLIENT_VERSION_AND_OS_DEBUGGING @@ -480,28 +644,21 @@ void CConnectDlg::SetVersionAndOSType ( CHostAddress InetAddr, QString strVersion ) { // apply the received version and OS type to the correct server list entry - const int iServerListLen = lvwServers->topLevelItemCount(); + QTreeWidgetItem* pCurListViewItem = FindListViewItem ( InetAddr ); - for ( int iIdx = 0; iIdx < iServerListLen; iIdx++ ) + if ( pCurListViewItem ) { - // compare the received address with the user data string of the - // host address by a string compare - if ( !lvwServers->topLevelItem ( iIdx )-> - data ( 0, Qt::UserRole ).toString(). - compare ( InetAddr.toString() ) ) - { // TEST since this is just a debug info, we just reuse the ping column (note // the we have to replace the ping message emit with the version and OS request // so that this works, see above code) -lvwServers->topLevelItem ( iIdx )-> +pCurListViewItem-> setText ( 1, strVersion + "/" + COSUtil::GetOperatingSystemString ( eOSType ) ); // a version and OS type was received, set item to visible -if ( lvwServers->topLevelItem ( iIdx )->isHidden() ) +if ( pCurListViewItem->isHidden() ) { - lvwServers->topLevelItem ( iIdx )->setHidden ( false ); + pCurListViewItem->setHidden ( false ); } - } } } #endif diff --git a/src/connectdlg.h b/src/connectdlg.h index 55d97a25..46213910 100755 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -29,6 +29,7 @@ #include #include #include +#include #include "global.h" #include "client.h" #include "multicolorled.h" @@ -57,6 +58,9 @@ public: void SetServerList ( const CHostAddress& InetAddr, const CVector& vecServerInfo ); + void SetConnClientsList ( const CHostAddress& InetAddr, + const CVector& vecChanInfo ); + void SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr, const int iPingTime, const CMultiColorLED::ELightColor ePingTimeLEDColor, @@ -76,6 +80,11 @@ protected: virtual void showEvent ( QShowEvent* ); virtual void hideEvent ( QHideEvent* ); + QTreeWidgetItem* FindListViewItem ( const CHostAddress& InetAddr ); + QTreeWidgetItem* GetParentListViewItem ( QTreeWidgetItem* pItem ); + void DeleteAllListViewItemChilds ( QTreeWidgetItem* pItem ); + + QMenu* pServerListContextMenu; QTimer TimerPing; QTimer TimerReRequestServList; QString strCentralServerAddress; @@ -90,6 +99,8 @@ protected: public slots: void OnServerListItemSelectionChanged(); void OnServerListItemDoubleClicked ( QTreeWidgetItem* Item, int ); + void OnCustomContextMenuRequested ( const QPoint& Position ); + void OnServerListContextMenuNames(); void OnServerAddrEditTextChanged ( const QString& ); void OnConnectClicked(); void OnTimerPing(); @@ -99,4 +110,5 @@ signals: void ReqServerListQuery ( CHostAddress InetAddr ); void CreateCLServerListPingMes ( CHostAddress InetAddr ); void CreateCLServerListReqVerAndOSMes ( CHostAddress InetAddr ); + void CreateCLServerListReqConnClientsListMes ( CHostAddress InetAddr ); }; diff --git a/src/connectdlgbase.ui b/src/connectdlgbase.ui index 3a0277bd..bc48acfd 100755 --- a/src/connectdlgbase.ui +++ b/src/connectdlgbase.ui @@ -1,7 +1,8 @@ - + + CConnectDlgBase - - + + 0 0 @@ -9,70 +10,65 @@ 294 - + Connection Setup - - :/png/main/res/mainicon.png + + + :/png/main/res/mainicon.png:/png/main/res/mainicon.png - + - + true - + - - + + QAbstractItemView::NoEditTriggers - + true - - false - - - false - - + Server Name - + Ping Time - + Musicians - + Location - + - - + + Server Name/Address - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + true @@ -80,13 +76,13 @@ - + - + Qt::Horizontal - + 351 25 @@ -95,18 +91,18 @@ - - + + C&ancel - - + + &Connect - + true @@ -116,7 +112,7 @@ - + diff --git a/src/protocol.cpp b/src/protocol.cpp index 13847434..49a8de13 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -286,19 +286,14 @@ CONNECTION LESS MESSAGES for each connected client append the PROTMESSID_CONN_CLIENTS_LIST: - +--------------------+------------------------------+ ... - | 4 bytes request ID | PROTMESSID_CONN_CLIENTS_LIST | ... - +--------------------+------------------------------+ ... - +------------------------------+ ... - | PROTMESSID_CONN_CLIENTS_LIST | ... - +------------------------------+ ... + +------------------------------+------------------------------+ ... + | PROTMESSID_CONN_CLIENTS_LIST | PROTMESSID_CONN_CLIENTS_LIST | ... + +------------------------------+------------------------------+ ... - PROTMESSID_CLM_REQ_CONN_CLIENTS_LIST: Request the connected clients list - +--------------------+ - | 4 bytes request ID | - +--------------------+ + note: does not have any data -> n = 0 ****************************************************************************** @@ -673,7 +668,7 @@ if ( rand() < ( RAND_MAX / 2 ) ) return false; break; case PROTMESSID_CLM_REQ_CONN_CLIENTS_LIST: - bRet = EvaluateCLReqConnClientsListMes ( InetAddr, vecbyMesBodyData ); + bRet = EvaluateCLReqConnClientsListMes ( InetAddr ); break; } } @@ -1968,18 +1963,14 @@ bool CProtocol::EvaluateCLReqVersionAndOSMes ( const CHostAddress& InetAddr ) } void CProtocol::CreateCLConnClientsListMes ( const CHostAddress& InetAddr, - const int iRequestID, const CVector& vecChanInfo ) { const int iNumClients = vecChanInfo.Size(); // build data vector - CVector vecData ( 4 ); // 4 bytes of data for request ID + CVector vecData ( 0 ); int iPos = 0; // init position pointer - // request ID (4 bytes) - PutValOnStream ( vecData, iPos, static_cast ( iRequestID ), 4 ); - for ( int i = 0; i < iNumClients; i++ ) { // convert strings to utf-8 @@ -2036,16 +2027,6 @@ bool CProtocol::EvaluateCLConnClientsListMes ( const CHostAddress& InetAddr, const int iDataLen = vecData.Size(); CVector vecChanInfo ( 0 ); - // check size (the first 4 bytes) - if ( iDataLen < 4 ) - { - return true; // return error code - } - - // request ID (4 bytes) - const int iRequestID = - static_cast ( GetValFromStream ( vecData, iPos, 4 ) ); - while ( iPos < iDataLen ) { // check size (the next 12 bytes) @@ -2111,44 +2092,22 @@ bool CProtocol::EvaluateCLConnClientsListMes ( const CHostAddress& InetAddr, } // invoke message action - emit CLConnClientsListMesReceived ( InetAddr, iRequestID, vecChanInfo ); + emit CLConnClientsListMesReceived ( InetAddr, vecChanInfo ); return false; // no error } -void CProtocol::CreateCLReqConnClientsListMes ( const CHostAddress& InetAddr, - const int iRequestID ) +void CProtocol::CreateCLReqConnClientsListMes ( const CHostAddress& InetAddr ) { - int iPos = 0; // init position pointer - - // build data vector (4 bytes long) - CVector vecData ( 4 ); - - // request ID (4 bytes) - PutValOnStream ( vecData, iPos, static_cast ( iRequestID ), 4 ); - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REQ_CONN_CLIENTS_LIST, - vecData, + CVector ( 0 ), InetAddr ); } -bool CProtocol::EvaluateCLReqConnClientsListMes ( const CHostAddress& InetAddr, - const CVector& vecData ) +bool CProtocol::EvaluateCLReqConnClientsListMes ( const CHostAddress& InetAddr ) { - int iPos = 0; // init position pointer - - // check size - if ( vecData.Size() != 4 ) - { - return true; // return error code - } - - // request ID (4 bytes) - const int iRequestID = - static_cast ( GetValFromStream ( vecData, iPos, 4 ) ); - // invoke message action - emit CLReqConnClientsList ( InetAddr, iRequestID ); + emit CLReqConnClientsList ( InetAddr ); return false; // no error } diff --git a/src/protocol.h b/src/protocol.h index 62ad9e4b..13ac85fe 100755 --- a/src/protocol.h +++ b/src/protocol.h @@ -124,10 +124,8 @@ public: void CreateCLVersionAndOSMes ( const CHostAddress& InetAddr ); void CreateCLReqVersionAndOSMes ( const CHostAddress& InetAddr ); void CreateCLConnClientsListMes ( const CHostAddress& InetAddr, - const int iRequestID, const CVector& vecChanInfo ); - void CreateCLReqConnClientsListMes ( const CHostAddress& InetAddr, - const int iRequestID ); + void CreateCLReqConnClientsListMes ( const CHostAddress& InetAddr ); static bool ParseMessageFrame ( const CVector& vecbyData, const int iNumBytesIn, @@ -237,16 +235,15 @@ protected: bool EvaluateCLUnregisterServerMes ( const CHostAddress& InetAddr ); bool EvaluateCLServerListMes ( const CHostAddress& InetAddr, const CVector& vecData ); - bool EvaluateCLReqServerListMes ( const CHostAddress& InetAddr ); + bool EvaluateCLReqServerListMes ( const CHostAddress& InetAddr ); bool EvaluateCLSendEmptyMesMes ( const CVector& vecData ); - bool EvaluateCLDisconnectionMes ( const CHostAddress& InetAddr ); + bool EvaluateCLDisconnectionMes ( const CHostAddress& InetAddr ); bool EvaluateCLVersionAndOSMes ( const CHostAddress& InetAddr, const CVector& vecData ); - bool EvaluateCLReqVersionAndOSMes ( const CHostAddress& InetAddr ); + bool EvaluateCLReqVersionAndOSMes ( const CHostAddress& InetAddr ); bool EvaluateCLConnClientsListMes ( const CHostAddress& InetAddr, const CVector& vecData ); - bool EvaluateCLReqConnClientsListMes ( const CHostAddress& InetAddr, - const CVector& vecData ); + bool EvaluateCLReqConnClientsListMes ( const CHostAddress& InetAddr ); int iOldRecID; int iOldRecCnt; @@ -303,10 +300,8 @@ signals: QString strVersion ); void CLReqVersionAndOS ( CHostAddress InetAddr ); void CLConnClientsListMesReceived ( CHostAddress InetAddr, - int iRequestID, CVector vecChanInfo ); - void CLReqConnClientsList ( CHostAddress InetAddr, - int iRequestID ); + void CLReqConnClientsList ( CHostAddress InetAddr ); }; #endif /* !defined ( PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_ ) */ diff --git a/src/server.h b/src/server.h index 19ae34a1..2ecb6d0c 100755 --- a/src/server.h +++ b/src/server.h @@ -332,9 +332,8 @@ public slots: void OnCLReqVersionAndOS ( CHostAddress InetAddr ) { ConnLessProtocol.CreateCLVersionAndOSMes ( InetAddr ); } - void OnCLReqConnClientsList ( CHostAddress InetAddr, - int iRequestID ) - { ConnLessProtocol.CreateCLConnClientsListMes ( InetAddr, iRequestID, CreateChannelList() ); } + void OnCLReqConnClientsList ( CHostAddress InetAddr ) + { ConnLessProtocol.CreateCLConnClientsListMes ( InetAddr, CreateChannelList() ); } void OnCLRegisterServerReceived ( CHostAddress InetAddr, CServerCoreInfo ServerInfo )