Log server registration flow
This commit is contained in:
parent
a4350f4f17
commit
8ca0635fea
5 changed files with 66 additions and 35 deletions
|
@ -545,7 +545,7 @@ int main ( int argc, char** argv )
|
||||||
eLicenceType );
|
eLicenceType );
|
||||||
if ( bUseGUI )
|
if ( bUseGUI )
|
||||||
{
|
{
|
||||||
// special case for the GUI mode: we want the licenct type to be
|
// special case for the GUI mode: we want the licence type to be
|
||||||
// creative commons per default (if not given in the settings file)
|
// creative commons per default (if not given in the settings file)
|
||||||
Server.SetLicenceType ( LT_CREATIVECOMMONS );
|
Server.SetLicenceType ( LT_CREATIVECOMMONS );
|
||||||
|
|
||||||
|
|
|
@ -545,36 +545,21 @@ void CServerDlg::UpdateGUIDependencies()
|
||||||
edtCentralServerAddress->setEnabled (
|
edtCentralServerAddress->setEnabled (
|
||||||
!bCurUseDefCentServAddr && bCurSerListEnabled );
|
!bCurUseDefCentServAddr && bCurSerListEnabled );
|
||||||
|
|
||||||
QString strStatus;
|
QString strStatus = svrRegStatusToString ( eSvrRegStatus );
|
||||||
|
|
||||||
switch ( eSvrRegStatus )
|
switch ( eSvrRegStatus )
|
||||||
{
|
{
|
||||||
case SRS_UNREGISTERED:
|
|
||||||
strStatus = "Unregistered";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SRS_BAD_ADDRESS:
|
case SRS_BAD_ADDRESS:
|
||||||
strStatus = "<font color=""red""><b>Bad address</b></font>";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SRS_REQUESTED:
|
|
||||||
strStatus = "Registration requested";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SRS_TIME_OUT:
|
case SRS_TIME_OUT:
|
||||||
strStatus = "<font color=""red""><b>Registration failed</b></font>";
|
case SRS_CENTRAL_SVR_FULL:
|
||||||
break;
|
strStatus = "<font color=""red""><b>" + strStatus + "</b></font>";
|
||||||
|
|
||||||
case SRS_UNKNOWN_RESP:
|
|
||||||
strStatus = "Check server version";
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SRS_REGISTERED:
|
case SRS_REGISTERED:
|
||||||
strStatus = "<font color=""darkGreen""><b>Registered</b></font>";
|
strStatus = "<font color=""darkGreen""><b>" + strStatus + "</b></font>";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SRS_CENTRAL_SVR_FULL:
|
default:
|
||||||
strStatus = "<font color=""red""><b>Central Server full</b></font>";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lblRegSvrStatus->setText ( strStatus );
|
lblRegSvrStatus->setText ( strStatus );
|
||||||
|
|
|
@ -479,6 +479,8 @@ void CServerListManager::CentralServerQueryServerList ( const CHostAddress& Inet
|
||||||
/* Slave server functionality *************************************************/
|
/* Slave server functionality *************************************************/
|
||||||
void CServerListManager::StoreRegistrationResult ( ESvrRegResult eResult )
|
void CServerListManager::StoreRegistrationResult ( ESvrRegResult eResult )
|
||||||
{
|
{
|
||||||
|
qInfo() << "Server Registration Result received:" << svrRegResultToString ( eResult );
|
||||||
|
|
||||||
// we need the lock since the user might change the server properties at
|
// we need the lock since the user might change the server properties at
|
||||||
// any time so another response could arrive
|
// any time so another response could arrive
|
||||||
QMutexLocker locker ( &Mutex );
|
QMutexLocker locker ( &Mutex );
|
||||||
|
@ -486,20 +488,18 @@ void CServerListManager::StoreRegistrationResult ( ESvrRegResult eResult )
|
||||||
// we got some response, so stop the retry timer
|
// we got some response, so stop the retry timer
|
||||||
TimerCLRegisterServerResp.stop();
|
TimerCLRegisterServerResp.stop();
|
||||||
|
|
||||||
eSvrRegStatus = ESvrRegStatus::SRS_UNKNOWN_RESP;
|
|
||||||
|
|
||||||
switch ( eResult )
|
switch ( eResult )
|
||||||
{
|
{
|
||||||
case ESvrRegResult::SRR_REGISTERED:
|
case ESvrRegResult::SRR_REGISTERED:
|
||||||
eSvrRegStatus = ESvrRegStatus::SRS_REGISTERED;
|
SetSvrRegStatus ( ESvrRegStatus::SRS_REGISTERED );
|
||||||
break;
|
return;
|
||||||
|
|
||||||
case ESvrRegResult::SRR_CENTRAL_SVR_FULL:
|
case ESvrRegResult::SRR_CENTRAL_SVR_FULL:
|
||||||
eSvrRegStatus = ESvrRegStatus::SRS_CENTRAL_SVR_FULL;
|
SetSvrRegStatus ( ESvrRegStatus::SRS_CENTRAL_SVR_FULL );
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit SvrRegStatusChanged();
|
SetSvrRegStatus ( ESvrRegStatus::SRS_UNKNOWN_RESP );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerListManager::OnTimerPingCentralServer()
|
void CServerListManager::OnTimerPingCentralServer()
|
||||||
|
@ -525,8 +525,7 @@ void CServerListManager::OnTimerCLRegisterServerResp()
|
||||||
|
|
||||||
if ( iSvrRegRetries >= REGISTER_SERVER_RETRY_LIMIT )
|
if ( iSvrRegRetries >= REGISTER_SERVER_RETRY_LIMIT )
|
||||||
{
|
{
|
||||||
eSvrRegStatus = SRS_TIME_OUT;
|
SetSvrRegStatus ( SRS_TIME_OUT );
|
||||||
emit SvrRegStatusChanged();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -565,8 +564,7 @@ void CServerListManager::SlaveServerRegisterServer ( const bool bIsRegister )
|
||||||
if ( bIsRegister )
|
if ( bIsRegister )
|
||||||
{
|
{
|
||||||
// register server
|
// register server
|
||||||
eSvrRegStatus = SRS_REQUESTED;
|
SetSvrRegStatus ( SRS_REQUESTED );
|
||||||
emit SvrRegStatusChanged();
|
|
||||||
|
|
||||||
pConnLessProtocol->CreateCLRegisterServerMes ( SlaveCurCentServerHostAddress,
|
pConnLessProtocol->CreateCLRegisterServerMes ( SlaveCurCentServerHostAddress,
|
||||||
SlaveCurLocalHostAddress,
|
SlaveCurLocalHostAddress,
|
||||||
|
@ -575,15 +573,20 @@ void CServerListManager::SlaveServerRegisterServer ( const bool bIsRegister )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// unregister server
|
// unregister server
|
||||||
eSvrRegStatus = SRS_UNREGISTERED;
|
SetSvrRegStatus ( SRS_UNREGISTERED );
|
||||||
emit SvrRegStatusChanged();
|
|
||||||
|
|
||||||
pConnLessProtocol->CreateCLUnregisterServerMes ( SlaveCurCentServerHostAddress );
|
pConnLessProtocol->CreateCLUnregisterServerMes ( SlaveCurCentServerHostAddress );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
eSvrRegStatus = SRS_BAD_ADDRESS;
|
SetSvrRegStatus ( SRS_BAD_ADDRESS );
|
||||||
emit SvrRegStatusChanged();
|
emit SvrRegStatusChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void CServerListManager::SetSvrRegStatus ( ESvrRegStatus eNSvrRegStatus )
|
||||||
|
{
|
||||||
|
qInfo() << "Server Registration Status update:" << svrRegStatusToString ( eNSvrRegStatus );
|
||||||
|
eSvrRegStatus = eNSvrRegStatus;
|
||||||
|
emit SvrRegStatusChanged();
|
||||||
|
}
|
||||||
|
|
|
@ -177,6 +177,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SlaveServerRegisterServer ( const bool bIsRegister );
|
void SlaveServerRegisterServer ( const bool bIsRegister );
|
||||||
|
void SetSvrRegStatus ( ESvrRegStatus eNSvrRegStatus );
|
||||||
|
|
||||||
QTimer TimerPollList;
|
QTimer TimerPollList;
|
||||||
QTimer TimerRegistering;
|
QTimer TimerRegistering;
|
||||||
|
|
42
src/util.h
42
src/util.h
|
@ -584,6 +584,35 @@ enum ESvrRegStatus
|
||||||
SRS_CENTRAL_SVR_FULL = 6
|
SRS_CENTRAL_SVR_FULL = 6
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline QString svrRegStatusToString ( ESvrRegStatus eSvrRegStatus )
|
||||||
|
{
|
||||||
|
switch ( eSvrRegStatus )
|
||||||
|
{
|
||||||
|
case SRS_UNREGISTERED:
|
||||||
|
return "Unregistered";
|
||||||
|
|
||||||
|
case SRS_BAD_ADDRESS:
|
||||||
|
return "Bad address";
|
||||||
|
|
||||||
|
case SRS_REQUESTED:
|
||||||
|
return "Registration requested";
|
||||||
|
|
||||||
|
case SRS_TIME_OUT:
|
||||||
|
return "Registration failed";
|
||||||
|
|
||||||
|
case SRS_UNKNOWN_RESP:
|
||||||
|
return "Check server version";
|
||||||
|
|
||||||
|
case SRS_REGISTERED:
|
||||||
|
return "Registered";
|
||||||
|
|
||||||
|
case SRS_CENTRAL_SVR_FULL:
|
||||||
|
return "Central Server full";
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString("Unknown value ").append( eSvrRegStatus );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Central server registration outcome -----------------------------------------
|
// Central server registration outcome -----------------------------------------
|
||||||
enum ESvrRegResult
|
enum ESvrRegResult
|
||||||
|
@ -593,6 +622,19 @@ enum ESvrRegResult
|
||||||
SRR_CENTRAL_SVR_FULL = 1
|
SRR_CENTRAL_SVR_FULL = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline QString svrRegResultToString ( ESvrRegResult eSvrRegResult )
|
||||||
|
{
|
||||||
|
switch ( eSvrRegResult )
|
||||||
|
{
|
||||||
|
case SRR_REGISTERED:
|
||||||
|
return "Registered";
|
||||||
|
case SRR_CENTRAL_SVR_FULL:
|
||||||
|
return "Central Server full";
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString("Unknown value ").append( eSvrRegResult );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Skill level enum ------------------------------------------------------------
|
// Skill level enum ------------------------------------------------------------
|
||||||
enum ESkillLevel
|
enum ESkillLevel
|
||||||
|
|
Loading…
Reference in a new issue