diff --git a/src/client.cpp b/src/client.cpp index 50e171c0..0e836ec8 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -117,6 +117,10 @@ CClient::CClient ( const quint16 iPortNumber ) : SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector ) ), this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector ) ) ); + QObject::connect ( &ConnLessProtocol, + SIGNAL ( CLServerListReceived ( CHostAddress, CVector ) ), + SIGNAL ( CLServerListReceived ( 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 3a51eafc..16937604 100755 --- a/src/client.h +++ b/src/client.h @@ -205,14 +205,17 @@ public: void SetRemoteName() { Channel.SetRemoteName ( strName ); } - void SendTextMess ( const QString& strChatText ) + void CreateChatTextMes ( const QString& strChatText ) { Channel.CreateChatTextMes ( strChatText ); } - void SendPingMess() - { Channel.CreatePingMes ( PreparePingMessage() ); }; + void CreatePingMes() + { Channel.CreatePingMes ( PreparePingMessage() ); } - void SendCLPingMess ( const CHostAddress& InetAddr ) - { ConnLessProtocol.CreateCLPingMes ( InetAddr, PreparePingMessage() ); }; + void CreateCLPingMes ( const CHostAddress& InetAddr ) + { ConnLessProtocol.CreateCLPingMes ( InetAddr, PreparePingMessage() ); } + + void CreateCLReqServerListMes ( const CHostAddress& InetAddr ) + { ConnLessProtocol.CreateCLReqServerListMes ( InetAddr ); } int EstimatedOverallDelay ( const int iPingTimeMs ); @@ -312,6 +315,8 @@ signals: void ConClientListMesReceived ( CVector vecChanInfo ); void ChatTextReceived ( QString strChatText ); void PingTimeReceived ( int iPingTime ); + void CLServerListReceived ( CHostAddress InetAddr, + CVector vecServerInfo ); void CLPingTimeReceived ( CHostAddress InetAddr, int iPingTime ); void Disconnected(); void Stopped(); diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index 92fc3869..dca0acbc 100755 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -26,9 +26,9 @@ /* Implementation *************************************************************/ -CConnectDlg::CConnectDlg ( CClient* pNCliP, QWidget* parent, - Qt::WindowFlags f ) - : QDialog ( parent, f ), pClient ( pNCliP ) +CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f ) + : QDialog ( parent, f ), + bServerListReceived ( false ) { setupUi ( this ); @@ -53,26 +53,69 @@ pListViewItem = new QTreeWidgetItem ( ListViewServers ); // timers QObject::connect ( &TimerPing, SIGNAL ( timeout() ), this, SLOT ( OnTimerPing() ) ); + + QObject::connect ( &TimerReRequestServList, SIGNAL ( timeout() ), + this, SLOT ( OnTimerReRequestServList() ) ); } void CConnectDlg::showEvent ( QShowEvent* ) { + // reset flag (on opening the connect dialg, we always want to request a new + // updated server list per definition) + bServerListReceived = false; -// TODO get the IP address of the Master Server when the connect dialog is -// opened -> this seems to be the correct time to do it, use the -// "CClient::SetServerAddr" functionality (extract it to another place...) +// TEST +QString strNAddr = "llcon.dyndns.org:22122"; - // only activate ping timer if window is actually shown - TimerPing.start ( PING_UPDATE_TIME_MS ); + // get the IP address of the central server (using the ParseNetworAddress + // function) when the connect dialog is opened, this seems to be the correct + // time to do it + if ( LlconNetwUtil().ParseNetworkAddress ( strNAddr, + CentralServerAddress ) ) + { + // send the request for the server list + emit ReqServerListQuery ( CentralServerAddress ); + + // start timer, if this message did not get any respond to retransmit + // the server list request message + TimerReRequestServList.start ( SERV_LIST_REQ_UPDATE_TIME_MS ); + } + + + +// TODO +// only activate ping timer if window is actually shown +//TimerPing.start ( PING_UPDATE_TIME_MS ); // UpdateDisplay(); } void CConnectDlg::hideEvent ( QHideEvent* ) { - // if window is closed, stop timer for ping + // if window is closed, stop timers TimerPing.stop(); + TimerReRequestServList.stop(); +} + +void CConnectDlg::OnTimerReRequestServList() +{ + // if the server list is not yet received, retransmit the request for the + // server list + if ( !bServerListReceived ) + { + emit ReqServerListQuery ( CentralServerAddress ); + } +} + +void CConnectDlg::SetServerList ( const CVector& vecServerInfo ) +{ + // set flag + bServerListReceived = true; + + +// TODO + } void CConnectDlg::OnTimerPing() @@ -81,7 +124,7 @@ void CConnectDlg::OnTimerPing() // TEST //QHostAddress test ( "127.0.0.1" ); -//pClient->SendCLPingMess ( CHostAddress ( test, 22124 ) ); +//emit CreateCLPingMes ( CHostAddress ( test, 22124 ) ); } diff --git a/src/connectdlg.h b/src/connectdlg.h index aafd7050..f4090617 100755 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -27,6 +27,7 @@ #include #include #include +#include #include "global.h" #include "client.h" #ifdef _WIN32 @@ -40,24 +41,31 @@ #endif +/* Definitions ****************************************************************/ +// defines the time interval at which the request server list message is re- +// transmitted until it is received +#define SERV_LIST_REQ_UPDATE_TIME_MS 2000 // ms + + /* Classes ********************************************************************/ class CConnectDlg : public QDialog, private Ui_CConnectDlgBase { Q_OBJECT public: - CConnectDlg ( CClient* pNCliP, QWidget* parent = 0, Qt::WindowFlags f = 0 ); + CConnectDlg ( QWidget* parent = 0, Qt::WindowFlags f = 0 ); - void AddPingTime ( QString strChatText ); + void SetServerList ( const CVector& vecServerInfo ); void SetPingTimeResult ( CHostAddress& InetAddr, const int iPingTime ); protected: virtual void showEvent ( QShowEvent* ); virtual void hideEvent ( QHideEvent* ); - CClient* pClient; - QTimer TimerPing; - + QTimer TimerPing; + QTimer TimerReRequestServList; + CHostAddress CentralServerAddress; + bool bServerListReceived; // TEST QTreeWidgetItem* pListViewItem; @@ -65,4 +73,8 @@ QTreeWidgetItem* pListViewItem; public slots: void OnTimerPing(); + void OnTimerReRequestServList(); + +signals: + void ReqServerListQuery ( CHostAddress InetAddr ); }; diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index de3960c6..bbe100af 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -46,7 +46,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, , Qt::WindowMinMaxButtonsHint #endif ), - ConnectDlg ( pNCliP, parent + ConnectDlg ( parent #ifdef _WIN32 // this somehow only works reliable on Windows , Qt::WindowMinMaxButtonsHint @@ -421,6 +421,10 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QObject::connect ( pClient, SIGNAL ( PingTimeReceived ( int ) ), this, SLOT ( OnPingTimeResult ( int ) ) ); + QObject::connect ( pClient, + SIGNAL ( CLServerListReceived ( CHostAddress, CVector ) ), + this, SLOT ( OnCLServerListReceived ( CHostAddress, CVector ) ) ); + QObject::connect ( pClient, SIGNAL ( CLPingTimeReceived ( CHostAddress, int ) ), this, SLOT ( OnCLPingTimeResult ( CHostAddress, int ) ) ); @@ -439,6 +443,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QObject::connect ( &ChatDlg, SIGNAL ( NewLocalInputText ( QString ) ), this, SLOT ( OnNewLocalInputText ( QString ) ) ); + QObject::connect ( &ConnectDlg, SIGNAL ( NewLocalInputText ( CHostAddress ) ), + this, SLOT ( OnReqServerListQuery ( CHostAddress ) ) ); + // Timers ------------------------------------------------------------------ // start timer for status bar @@ -716,7 +723,7 @@ void CLlconClientDlg::OnTimerSigMet() void CLlconClientDlg::OnTimerPing() { // send ping message to server - pClient->SendPingMess(); + pClient->CreatePingMes(); } void CLlconClientDlg::OnPingTimeResult ( int iPingTime ) diff --git a/src/llconclientdlg.h b/src/llconclientdlg.h index 0bd39e5d..147c5a0b 100755 --- a/src/llconclientdlg.h +++ b/src/llconclientdlg.h @@ -107,28 +107,54 @@ protected: public slots: void OnConnectDisconBut(); void OnTimerSigMet(); - void OnTimerStatus() { UpdateDisplay(); } + + void OnTimerStatus() + { UpdateDisplay(); } + void OnTimerPing(); void OnPingTimeResult ( int iPingTime ); void OnCLPingTimeResult ( CHostAddress InetAddr, int iPingTime ); void OnOpenGeneralSettings(); - void OnOpenChatDialog() { ShowChatWindow(); } + + void OnOpenChatDialog() + { ShowChatWindow(); } + void OnSliderAudInFader ( int value ); - void OnSliderAudReverb ( int value ) { pClient->SetReverbLevel ( value ); } - void OnRevSelL() { pClient->SetReverbOnLeftChan ( true ); } - void OnRevSelR() { pClient->SetReverbOnLeftChan ( false ); } + + void OnSliderAudReverb ( int value ) + { pClient->SetReverbLevel ( value ); } + + void OnRevSelL() + { pClient->SetReverbOnLeftChan ( true ); } + + void OnRevSelR() + { pClient->SetReverbOnLeftChan ( false ); } + void OnConClientListMesReceived ( CVector vecChanInfo ); - void OnChangeChanGain ( int iId, double dGain ) - { pClient->SetRemoteChanGain ( iId, dGain ); } void OnFaderTagTextChanged ( const QString& strNewName ); void OnChatTextReceived ( QString strChatText ); + + void OnChangeChanGain ( int iId, double dGain ) + { pClient->SetRemoteChanGain ( iId, dGain ); } + void OnNewLocalInputText ( QString strChatText ) - { pClient->SendTextMess ( strChatText ); } + { pClient->CreateChatTextMes ( strChatText ); } + + void OnReqServerListQuery ( CHostAddress InetAddr ) + { pClient->CreateCLReqServerListMes ( InetAddr ); } + + void OnCLServerListReceived ( CHostAddress InetAddr, + CVector vecServerInfo ) + { ConnectDlg.SetServerList ( vecServerInfo ); } + void OnLineEditServerAddrTextChanged ( const QString ); void OnLineEditServerAddrActivated ( int index ); void OnDisconnected(); void OnStopped(); - void OnGUIDesignChanged() { SetGUIDesign ( pClient->GetGUIDesign() ); } + + void OnGUIDesignChanged() + { SetGUIDesign ( pClient->GetGUIDesign() ); } + void OnStereoCheckBoxChanged() { UpdateRevSelection(); } void OnNumClientsChanged ( int iNewNumClients ); }; diff --git a/src/serverlist.cpp b/src/serverlist.cpp index a3f4c4ce..c3e77280 100755 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -240,6 +240,8 @@ void CServerListManager::QueryServerList ( const CHostAddress& InetAddr ) /* Slave server functionality *************************************************/ void CServerListManager::OnTimerRegistering() { + // we need the lock since the user might change the server properties at + // any time QMutexLocker locker ( &Mutex ); if ( !bIsCentralServer && bEnabled )