mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 10:25:36 +08:00
Ref T730, Ref T739 update from own aircraft in one step
* update all values from own aircraft in "one step" * rational: avoid "single property" updates and numerous round trips (signals, transceiver updates) * also allow updates of not yet connect, as "a kind of preset" * do NOT send to network if not authenticated
This commit is contained in:
committed by
Mat Sutcliffe
parent
caa78395a9
commit
ef9e7b0bf1
@@ -138,6 +138,7 @@ namespace BlackCore
|
||||
|
||||
void CApiServerConnection::updateTransceivers(const QString &callsign, const QVector<TransceiverDto> &transceivers)
|
||||
{
|
||||
if (!this->sendToNetworkIfAuthenticated()) { return; }
|
||||
QJsonArray array;
|
||||
for (const TransceiverDto &tx : transceivers)
|
||||
{
|
||||
@@ -239,13 +240,7 @@ namespace BlackCore
|
||||
|
||||
void CApiServerConnection::postNoResponse(const QString &resource, const QJsonDocument &json)
|
||||
{
|
||||
if (isShuttingDown()) { return; } // avoid crash
|
||||
if (!m_isAuthenticated)
|
||||
{
|
||||
CLogMessage(this).debug(u"AFV not authenticated");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isShuttingDown()) { return; }
|
||||
this->checkExpiry();
|
||||
|
||||
QUrl url(m_addressUrl);
|
||||
@@ -273,8 +268,7 @@ namespace BlackCore
|
||||
|
||||
void CApiServerConnection::deleteResource(const QString &resource)
|
||||
{
|
||||
if (isShuttingDown()) { return; }
|
||||
if (!m_isAuthenticated) { return; }
|
||||
if (isShuttingDown()) { return; }
|
||||
|
||||
QUrl url(m_addressUrl);
|
||||
url.setPath(resource);
|
||||
@@ -345,6 +339,11 @@ namespace BlackCore
|
||||
return loop;
|
||||
}
|
||||
|
||||
bool CApiServerConnection::sendToNetworkIfAuthenticated() const
|
||||
{
|
||||
return m_isAuthenticated && !isShuttingDown();
|
||||
}
|
||||
|
||||
bool CApiServerConnection::isShuttingDown()
|
||||
{
|
||||
return !sApp || sApp->isShuttingDown();
|
||||
|
||||
@@ -80,9 +80,9 @@ namespace BlackCore
|
||||
template<typename TResponse>
|
||||
TResponse postNoRequest(const QString &resource)
|
||||
{
|
||||
if (!m_isAuthenticated)
|
||||
if (!this->sendToNetworkIfAuthenticated())
|
||||
{
|
||||
BlackMisc::CLogMessage(this).debug(u"AFV not authenticated");
|
||||
// BlackMisc::CLogMessage(this).debug(u"AFV not authenticated");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -103,9 +103,9 @@ namespace BlackCore
|
||||
template<typename TResponse>
|
||||
QVector<TResponse> getAsVector(const QString &resource)
|
||||
{
|
||||
if (! m_isAuthenticated)
|
||||
if (!this->sendToNetworkIfAuthenticated())
|
||||
{
|
||||
BlackMisc::CLogMessage(this).debug(u"AFV not authenticated");
|
||||
// BlackMisc::CLogMessage(this).debug(u"AFV not authenticated");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -156,6 +156,9 @@ namespace BlackCore
|
||||
//! Get QLoop for network access, using class must delete the loop
|
||||
QEventLoop *newEventLoop();
|
||||
|
||||
//! Send to network
|
||||
bool sendToNetworkIfAuthenticated() const;
|
||||
|
||||
//! Application shutting down
|
||||
static bool isShuttingDown();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user