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; 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 ) void CClient::SetDoAutoSockBufSize ( const bool bValue )
{ {
// first, set new value in the channel object // first, set new value in the channel object

View file

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

View file

@ -454,6 +454,10 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
SIGNAL ( Disconnected() ), SIGNAL ( Disconnected() ),
this, SLOT ( OnDisconnected() ) ); this, SLOT ( OnDisconnected() ) );
QObject::connect ( pClient,
SIGNAL ( CentralServerAddressTypeChanged() ),
this, SLOT ( OnCentralServerAddressTypeChanged() ) );
QObject::connect ( pClient, QObject::connect ( pClient,
SIGNAL ( ChatTextReceived ( QString ) ), SIGNAL ( ChatTextReceived ( QString ) ),
this, SLOT ( OnChatTextReceived ( QString ) ) ); this, SLOT ( OnChatTextReceived ( QString ) ) );
@ -725,6 +729,18 @@ void CClientDlg::OnDisconnected()
UpdateDisplay(); 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 ) void CClientDlg::OnChatTextReceived ( QString strChatText )
{ {
ChatDlg.AddChatText ( strChatText ); ChatDlg.AddChatText ( strChatText );
@ -814,13 +830,10 @@ void CClientDlg::SetMyWindowTitle ( const int iNumClients )
void CClientDlg::ShowConnectionSetupDialog() void CClientDlg::ShowConnectionSetupDialog()
{ {
// get the central server address string
const QString strCurCentServAddr =
NetworkUtil::GetCentralServerAddress ( pClient->GetCentralServerAddressType(),
pClient->GetServerListCentralServerAddress() );
// init the connect dialog // init the connect dialog
ConnectDlg.Init ( strCurCentServAddr, pClient->vstrIPAddress ); ConnectDlg.Init ( pClient->vstrIPAddress );
ConnectDlg.SetCentralServerAddress ( NetworkUtil::GetCentralServerAddress ( pClient->GetCentralServerAddressType(),
pClient->GetServerListCentralServerAddress() ) );
// show connect dialog // show connect dialog
ConnectDlg.show(); ConnectDlg.show();

View file

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

View file

@ -154,12 +154,8 @@ CConnectDlg::CConnectDlg ( const bool bNewShowCompleteRegList,
this, SLOT ( OnTimerReRequestServList() ) ); this, SLOT ( OnTimerReRequestServList() ) );
} }
void CConnectDlg::Init ( const QString strNewCentralServerAddr, void CConnectDlg::Init ( const CVector<QString>& vstrIPAddresses )
const CVector<QString>& vstrIPAddresses )
{ {
// take central server address string
strCentralServerAddress = strNewCentralServerAddr;
// load stored IP addresses in combo box // load stored IP addresses in combo box
cbxServerAddr->clear(); cbxServerAddr->clear();
cbxServerAddr->clearEditText(); cbxServerAddr->clearEditText();
@ -175,8 +171,14 @@ void CConnectDlg::Init ( const QString strNewCentralServerAddr,
void CConnectDlg::showEvent ( QShowEvent* ) void CConnectDlg::showEvent ( QShowEvent* )
{ {
// reset flags (on opening the connect dialg, we always want to request a // on opening the connect dialg, we always want to request a
// new updated server list per definition) // new updated server list per definition
RequestServerList();
}
void CConnectDlg::RequestServerList()
{
// reset flags
bServerListReceived = false; bServerListReceived = false;
bServerListItemWasChosen = false; bServerListItemWasChosen = false;
@ -215,6 +217,8 @@ void CConnectDlg::OnTimerReRequestServList()
// server list // server list
if ( !bServerListReceived ) 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 ); emit ReqServerListQuery ( CentralServerAddress );
} }
} }

View file

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