refresh the server list if Central Server type is changed

This commit is contained in:
Volker Fischer 2020-04-12 12:33:50 +02:00
parent c59173d076
commit a98e98f2a9
6 changed files with 60 additions and 32 deletions

View file

@ -347,6 +347,16 @@ int CClient::EvaluatePingMessage ( const int iMs )
return PreciseTime.elapsed() - iMs;
}
void CClient::SetCentralServerAddressType ( const ECSAddType eNCSAT )
{
if ( eCentralServerAddressType != eNCSAT )
{
// update type and emit message to update the server list, too
eCentralServerAddressType = eNCSAT;
emit CentralServerAddressTypeChanged();
}
}
void CClient::SetDoAutoSockBufSize ( const bool bValue )
{
// first, set new value in the channel object

View file

@ -140,7 +140,7 @@ public:
void SetServerListCentralServerAddress ( const QString& sNCentServAddr ) { strCentralServerAddress = sNCentServAddr; }
QString GetServerListCentralServerAddress() { return strCentralServerAddress; }
void SetCentralServerAddressType ( const ECSAddType eNCSAT ) { eCentralServerAddressType = eNCSAT; }
void SetCentralServerAddressType ( const ECSAddType eNCSAT );
ECSAddType GetCentralServerAddressType() { return eCentralServerAddressType; }
int GetAudioInFader() const { return iAudioInFader; }
@ -206,8 +206,7 @@ public:
int GetSndCrdRightOutputChannel() { return Sound.GetRightOutputChannel(); }
void SetSndCrdPrefFrameSizeFactor ( const int iNewFactor );
int GetSndCrdPrefFrameSizeFactor()
{ return iSndCrdPrefFrameSizeFactor; }
int GetSndCrdPrefFrameSizeFactor() { return iSndCrdPrefFrameSizeFactor; }
int GetSndCrdActualMonoBlSize()
{
@ -429,4 +428,5 @@ signals:
void Disconnected();
void ControllerInFaderLevel ( int iChannelIdx, int iValue );
void CentralServerAddressTypeChanged();
};

View file

@ -454,6 +454,10 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
SIGNAL ( Disconnected() ),
this, SLOT ( OnDisconnected() ) );
QObject::connect ( pClient,
SIGNAL ( CentralServerAddressTypeChanged() ),
this, SLOT ( OnCentralServerAddressTypeChanged() ) );
QObject::connect ( pClient,
SIGNAL ( ChatTextReceived ( QString ) ),
this, SLOT ( OnChatTextReceived ( QString ) ) );
@ -725,6 +729,18 @@ void CClientDlg::OnDisconnected()
UpdateDisplay();
}
void CClientDlg::OnCentralServerAddressTypeChanged()
{
// if the server list is shown and the server type was changed, update the list
if ( ConnectDlg.isVisible() )
{
ConnectDlg.SetCentralServerAddress ( NetworkUtil::GetCentralServerAddress ( pClient->GetCentralServerAddressType(),
pClient->GetServerListCentralServerAddress() ) );
ConnectDlg.RequestServerList();
}
}
void CClientDlg::OnChatTextReceived ( QString strChatText )
{
ChatDlg.AddChatText ( strChatText );
@ -814,13 +830,10 @@ void CClientDlg::SetMyWindowTitle ( const int iNumClients )
void CClientDlg::ShowConnectionSetupDialog()
{
// get the central server address string
const QString strCurCentServAddr =
NetworkUtil::GetCentralServerAddress ( pClient->GetCentralServerAddressType(),
pClient->GetServerListCentralServerAddress() );
// init the connect dialog
ConnectDlg.Init ( strCurCentServAddr, pClient->vstrIPAddress );
ConnectDlg.Init ( pClient->vstrIPAddress );
ConnectDlg.SetCentralServerAddress ( NetworkUtil::GetCentralServerAddress ( pClient->GetCentralServerAddressType(),
pClient->GetServerListCentralServerAddress() ) );
// show connect dialog
ConnectDlg.show();

View file

@ -198,6 +198,7 @@ public slots:
void OnConnectDlgAccepted();
void OnDisconnected();
void OnCentralServerAddressTypeChanged();
void OnGUIDesignChanged()
{ SetGUIDesign ( pClient->GetGUIDesign() ); }

View file

@ -154,12 +154,8 @@ CConnectDlg::CConnectDlg ( const bool bNewShowCompleteRegList,
this, SLOT ( OnTimerReRequestServList() ) );
}
void CConnectDlg::Init ( const QString strNewCentralServerAddr,
const CVector<QString>& vstrIPAddresses )
void CConnectDlg::Init ( const CVector<QString>& vstrIPAddresses )
{
// take central server address string
strCentralServerAddress = strNewCentralServerAddr;
// load stored IP addresses in combo box
cbxServerAddr->clear();
cbxServerAddr->clearEditText();
@ -175,8 +171,14 @@ void CConnectDlg::Init ( const QString strNewCentralServerAddr,
void CConnectDlg::showEvent ( QShowEvent* )
{
// reset flags (on opening the connect dialg, we always want to request a
// new updated server list per definition)
// on opening the connect dialg, we always want to request a
// new updated server list per definition
RequestServerList();
}
void CConnectDlg::RequestServerList()
{
// reset flags
bServerListReceived = false;
bServerListItemWasChosen = false;
@ -215,6 +217,8 @@ void CConnectDlg::OnTimerReRequestServList()
// server list
if ( !bServerListReceived )
{
// note that this is a connection less message which may get lost
// and therefore it makes sense to re-transmit it
emit ReqServerListQuery ( CentralServerAddress );
}
}

View file

@ -51,8 +51,8 @@ public:
QWidget* parent = nullptr,
Qt::WindowFlags f = nullptr );
void Init ( const QString strNewCentralServerAddr,
const CVector<QString>& vstrIPAddresses );
void Init ( const CVector<QString>& vstrIPAddresses );
void SetCentralServerAddress ( const QString strNewCentralServerAddr ) { strCentralServerAddress = strNewCentralServerAddr; }
void SetServerList ( const CHostAddress& InetAddr,
const CVector<CServerInfo>& vecServerInfo );
@ -74,6 +74,7 @@ public:
bool GetServerListItemWasChosen() const { return bServerListItemWasChosen; }
QString GetSelectedAddress() const { return strSelectedAddress; }
QString GetSelectedServerName() const { return strSelectedServerName; }
void RequestServerList();
protected:
virtual void showEvent ( QShowEvent* );
@ -87,7 +88,6 @@ protected:
QTimer TimerReRequestServList;
QString strCentralServerAddress;
CHostAddress CentralServerAddress;
CVector<QString> vstrIPAddresses;
QString strSelectedAddress;
QString strSelectedServerName;
bool bShowCompleteRegList;