mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 08:36:52 +08:00
[FSD] Pending connection timeout - avoid that a pending FSD conenction blocks forever
This commit is contained in:
@@ -211,6 +211,16 @@ namespace BlackCore
|
||||
this->clearState();
|
||||
m_filterPasswordFromLogin = true;
|
||||
|
||||
m_loginSince = QDateTime::currentMSecsSinceEpoch();
|
||||
QPointer<CFSDClient> myself(this);
|
||||
const qint64 timerMs = qRound(PendingConnectionTimeoutMs * 1.25);
|
||||
|
||||
QTimer::singleShot(timerMs, this, [ = ]
|
||||
{
|
||||
if (!myself || !sApp || sApp->isShuttingDown()) { return; }
|
||||
this->pendingTimeoutCheck();
|
||||
});
|
||||
|
||||
this->updateConnectionStatus(CConnectionStatus::Connecting);
|
||||
|
||||
const QString host = m_server.getAddress();
|
||||
@@ -1479,6 +1489,7 @@ namespace BlackCore
|
||||
m_lastPositionUpdate.clear();
|
||||
m_lastOffsetTimes.clear();
|
||||
m_sentAircraftConfig = CAircraftParts::null();
|
||||
m_loginSince = -1;
|
||||
}
|
||||
|
||||
void CFSDClient::clearState(const CCallsign &callsign)
|
||||
@@ -1853,13 +1864,25 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
emit atisReplyReceived(cs, atisMessage);
|
||||
emit this->atisReplyReceived(cs, atisMessage);
|
||||
|
||||
m_mapAtisMessages.remove(callsign);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CFSDClient::pendingTimeoutCheck()
|
||||
{
|
||||
if (!this->isPendingConnection()) { return; }
|
||||
|
||||
const qint64 age = QDateTime::currentMSecsSinceEpoch() - m_loginSince;
|
||||
if (age < PendingConnectionTimeoutMs) { return; }
|
||||
|
||||
// time out
|
||||
CLogMessage(this).warning(u"Timeout on pending connection to '%1'") << this->getServer().getName();
|
||||
this->disconnectFromServer();
|
||||
}
|
||||
|
||||
const CLength &CFSDClient::fixAtcRange(const CLength &networkRange, const CCallsign &cs)
|
||||
{
|
||||
/** T702, https://discordapp.com/channels/539048679160676382/539846348275449887/597814208125730826
|
||||
|
||||
@@ -235,6 +235,7 @@ namespace BlackCore
|
||||
void killRequestReceived(const QString &reason);
|
||||
|
||||
private:
|
||||
//! \private
|
||||
friend BlackFsdTest::CTestFSDClient;
|
||||
|
||||
//! Send FSD message
|
||||
@@ -283,6 +284,7 @@ namespace BlackCore
|
||||
QString socketErrorToQString(QAbstractSocket::SocketError error);
|
||||
void parseMessage(const QString &line);
|
||||
|
||||
//! Init. the message types
|
||||
void initializeMessageTypes();
|
||||
|
||||
//! Handle response tokens @{
|
||||
@@ -342,10 +344,11 @@ namespace BlackCore
|
||||
bool isInterimPositionReceivingEnabledForServer() const;
|
||||
const BlackMisc::Network::CFsdSetup &getSetupForServer() const;
|
||||
|
||||
//! Handles ATIS replies from non-VATSIM servers. If the conditions are not met, the message is
|
||||
//! released as normal text message.
|
||||
//! Handles ATIS replies from non-VATSIM servers. If the conditions are not met,
|
||||
//! the message is released as normal text message.
|
||||
void maybeHandleAtisReply(const BlackMisc::Aviation::CCallsign &sender, const BlackMisc::Aviation::CCallsign &receiver, const QString &message);
|
||||
|
||||
//! Settings have been changed
|
||||
void fsdMessageSettingsChanged();
|
||||
|
||||
//! Emit raw FSD message (mostly for debugging)
|
||||
@@ -364,8 +367,12 @@ namespace BlackCore
|
||||
void stopPositionTimers();
|
||||
//! @}
|
||||
|
||||
//! Update the ATIS map
|
||||
void updateAtisMap(const QString &callsign, AtisLineType type, const QString &line);
|
||||
|
||||
//! Check if there is a pending logon attempt which "hangs"
|
||||
void pendingTimeoutCheck();
|
||||
|
||||
//! Fix ATC station range
|
||||
static const BlackMisc::PhysicalQuantities::CLength &fixAtcRange(const BlackMisc::PhysicalQuantities::CLength &networkRange, const BlackMisc::Aviation::CCallsign &cs);
|
||||
|
||||
@@ -387,6 +394,8 @@ namespace BlackCore
|
||||
vatsim_auth *clientAuth = nullptr;
|
||||
vatsim_auth *serverAuth = nullptr;
|
||||
QString m_lastServerAuthChallenge;
|
||||
qint64 m_loginSince = -1; //!< when login was triggered
|
||||
static constexpr qint64 PendingConnectionTimeoutMs = 7500;
|
||||
|
||||
// User data
|
||||
BlackMisc::Network::CServer m_server;
|
||||
@@ -399,7 +408,7 @@ namespace BlackCore
|
||||
// Parser
|
||||
QHash<QString, MessageType> m_messageTypeMapping;
|
||||
|
||||
QTcpSocket m_socket;
|
||||
QTcpSocket m_socket; //!< used TCP socket
|
||||
|
||||
bool m_unitTestMode = false;
|
||||
bool m_printToConsole = false;
|
||||
|
||||
Reference in New Issue
Block a user