mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-03 07:35:53 +08:00
Ref T732, FSDClient to CFsdClient + style
This commit is contained in:
committed by
Mat Sutcliffe
parent
34d1e8268c
commit
a24d948acd
@@ -77,7 +77,7 @@ namespace BlackCore
|
|||||||
return escaped;
|
return escaped;
|
||||||
}
|
}
|
||||||
|
|
||||||
FSDClient::FSDClient(IClientProvider *clientProvider,
|
CFSDClient::CFSDClient(IClientProvider *clientProvider,
|
||||||
IOwnAircraftProvider *ownAircraftProvider,
|
IOwnAircraftProvider *ownAircraftProvider,
|
||||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
@@ -88,16 +88,16 @@ namespace BlackCore
|
|||||||
m_tokenBucket(10, CTime(5, CTimeUnit::s()), 1)
|
m_tokenBucket(10, CTime(5, CTimeUnit::s()), 1)
|
||||||
{
|
{
|
||||||
initializeMessageTypes();
|
initializeMessageTypes();
|
||||||
connect(&m_socket, &QTcpSocket::readyRead, this, &FSDClient::readDataFromSocket);
|
connect(&m_socket, &QTcpSocket::readyRead, this, &CFSDClient::readDataFromSocket);
|
||||||
connect(&m_socket, qOverload<QAbstractSocket::SocketError>(&QTcpSocket::error), this, &FSDClient::printSocketError);
|
connect(&m_socket, qOverload<QAbstractSocket::SocketError>(&QTcpSocket::error), this, &CFSDClient::printSocketError);
|
||||||
|
|
||||||
m_positionUpdateTimer.setObjectName(this->objectName().append(":m_positionUpdateTimer"));
|
m_positionUpdateTimer.setObjectName(this->objectName().append(":m_positionUpdateTimer"));
|
||||||
connect(&m_positionUpdateTimer, &QTimer::timeout, this, &FSDClient::sendPilotDataUpdate);
|
connect(&m_positionUpdateTimer, &QTimer::timeout, this, &CFSDClient::sendPilotDataUpdate);
|
||||||
|
|
||||||
m_interimPositionUpdateTimer.setObjectName(this->objectName().append(":m_interimPositionUpdateTimer"));
|
m_interimPositionUpdateTimer.setObjectName(this->objectName().append(":m_interimPositionUpdateTimer"));
|
||||||
connect(&m_interimPositionUpdateTimer, &QTimer::timeout, this, &FSDClient::sendInterimPilotDataUpdate);
|
connect(&m_interimPositionUpdateTimer, &QTimer::timeout, this, &CFSDClient::sendInterimPilotDataUpdate);
|
||||||
|
|
||||||
connect(&m_scheduledConfigUpdate, &QTimer::timeout, this, &FSDClient::sendIncrementalAircraftConfig);
|
connect(&m_scheduledConfigUpdate, &QTimer::timeout, this, &CFSDClient::sendIncrementalAircraftConfig);
|
||||||
m_scheduledConfigUpdate.setSingleShot(true);
|
m_scheduledConfigUpdate.setSingleShot(true);
|
||||||
|
|
||||||
fsdMessageSettingsChanged();
|
fsdMessageSettingsChanged();
|
||||||
@@ -109,13 +109,13 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::setClientIdAndKey(quint16 id, const QByteArray &key)
|
void CFSDClient::setClientIdAndKey(quint16 id, const QByteArray &key)
|
||||||
{
|
{
|
||||||
clientAuth = vatsim_auth_create(id, qPrintable(key));
|
clientAuth = vatsim_auth_create(id, qPrintable(key));
|
||||||
serverAuth = vatsim_auth_create(id, qPrintable(key));
|
serverAuth = vatsim_auth_create(id, qPrintable(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::setServer(const CServer &server)
|
void CFSDClient::setServer(const CServer &server)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(m_connectionStatus.isDisconnected(), Q_FUNC_INFO, "Can't change server details while still connected");
|
Q_ASSERT_X(m_connectionStatus.isDisconnected(), Q_FUNC_INFO, "Can't change server details while still connected");
|
||||||
|
|
||||||
@@ -136,20 +136,20 @@ namespace BlackCore
|
|||||||
if (!m_fsdTextCodec) { m_fsdTextCodec = QTextCodec::codecForName("utf-8"); }
|
if (!m_fsdTextCodec) { m_fsdTextCodec = QTextCodec::codecForName("utf-8"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::setSimulatorInfo(const CSimulatorPluginInfo &simInfo)
|
void CFSDClient::setSimulatorInfo(const CSimulatorPluginInfo &simInfo)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(m_connectionStatus.isDisconnected(), Q_FUNC_INFO, "Can't change server details while still connected");
|
Q_ASSERT_X(m_connectionStatus.isDisconnected(), Q_FUNC_INFO, "Can't change server details while still connected");
|
||||||
m_simulatorInfo = simInfo;
|
m_simulatorInfo = simInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::setCallsign(const CCallsign &callsign)
|
void CFSDClient::setCallsign(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(m_connectionStatus.isDisconnected(), Q_FUNC_INFO, "Can't change callsign while still connected");
|
Q_ASSERT_X(m_connectionStatus.isDisconnected(), Q_FUNC_INFO, "Can't change callsign while still connected");
|
||||||
m_ownCallsign = callsign;
|
m_ownCallsign = callsign;
|
||||||
updateOwnCallsign(callsign);
|
updateOwnCallsign(callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::setIcaoCodes(const CSimulatedAircraft &ownAircraft)
|
void CFSDClient::setIcaoCodes(const CSimulatedAircraft &ownAircraft)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(m_connectionStatus.isDisconnected(), Q_FUNC_INFO, "Can't change ICAO codes while still connected");
|
Q_ASSERT_X(m_connectionStatus.isDisconnected(), Q_FUNC_INFO, "Can't change ICAO codes while still connected");
|
||||||
m_ownAircraftIcaoCode = ownAircraft.getAircraftIcaoCode();
|
m_ownAircraftIcaoCode = ownAircraft.getAircraftIcaoCode();
|
||||||
@@ -161,7 +161,7 @@ namespace BlackCore
|
|||||||
updateOwnIcaoCodes(m_ownAircraftIcaoCode, m_ownAirlineIcaoCode);
|
updateOwnIcaoCodes(m_ownAircraftIcaoCode, m_ownAirlineIcaoCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::setLiveryAndModelString(const QString &livery, bool sendLiveryString, const QString &modelString, bool sendModelString)
|
void CFSDClient::setLiveryAndModelString(const QString &livery, bool sendLiveryString, const QString &modelString, bool sendModelString)
|
||||||
{
|
{
|
||||||
m_ownLivery = livery;
|
m_ownLivery = livery;
|
||||||
m_ownModelString = modelString;
|
m_ownModelString = modelString;
|
||||||
@@ -169,7 +169,7 @@ namespace BlackCore
|
|||||||
m_sendMModelString = sendModelString;
|
m_sendMModelString = sendModelString;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::setSimType(const CSimulatorPluginInfo &simInfo)
|
void CFSDClient::setSimType(const CSimulatorPluginInfo &simInfo)
|
||||||
{
|
{
|
||||||
//! \fixme Define recognized simulators somewhere */
|
//! \fixme Define recognized simulators somewhere */
|
||||||
if (simInfo.getSimulator() == "fs9")
|
if (simInfo.getSimulator() == "fs9")
|
||||||
@@ -194,7 +194,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList FSDClient::getPresetValues() const
|
QStringList CFSDClient::getPresetValues() const
|
||||||
{
|
{
|
||||||
const QStringList v =
|
const QStringList v =
|
||||||
{
|
{
|
||||||
@@ -208,7 +208,7 @@ namespace BlackCore
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::connectToServer()
|
void CFSDClient::connectToServer()
|
||||||
{
|
{
|
||||||
if (m_socket.isOpen()) { return; }
|
if (m_socket.isOpen()) { return; }
|
||||||
Q_ASSERT(! m_clientName.isEmpty());
|
Q_ASSERT(! m_clientName.isEmpty());
|
||||||
@@ -228,7 +228,7 @@ namespace BlackCore
|
|||||||
startPositionTimers();
|
startPositionTimers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::disconnectFromServer()
|
void CFSDClient::disconnectFromServer()
|
||||||
{
|
{
|
||||||
this->stopPositionTimers();
|
this->stopPositionTimers();
|
||||||
if (! m_socket.isOpen()) { return; }
|
if (! m_socket.isOpen()) { return; }
|
||||||
@@ -244,7 +244,7 @@ namespace BlackCore
|
|||||||
this->clearState();
|
this->clearState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendLogin()
|
void CFSDClient::sendLogin()
|
||||||
{
|
{
|
||||||
QString cid = m_server.getUser().getId();
|
QString cid = m_server.getUser().getId();
|
||||||
QString password = m_server.getUser().getPassword();
|
QString password = m_server.getUser().getPassword();
|
||||||
@@ -262,21 +262,21 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendDeletePilot()
|
void CFSDClient::sendDeletePilot()
|
||||||
{
|
{
|
||||||
QString cid = m_server.getUser().getId();
|
QString cid = m_server.getUser().getId();
|
||||||
DeletePilot deletePilot(m_ownCallsign.asString(), cid);
|
DeletePilot deletePilot(m_ownCallsign.asString(), cid);
|
||||||
sendMessage(deletePilot);
|
sendMessage(deletePilot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendDeleteAtc()
|
void CFSDClient::sendDeleteAtc()
|
||||||
{
|
{
|
||||||
QString cid = m_server.getUser().getId();
|
QString cid = m_server.getUser().getId();
|
||||||
DeleteAtc deleteAtc(m_ownCallsign.asString(), cid);
|
DeleteAtc deleteAtc(m_ownCallsign.asString(), cid);
|
||||||
sendMessage(deleteAtc);
|
sendMessage(deleteAtc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendPilotDataUpdate()
|
void CFSDClient::sendPilotDataUpdate()
|
||||||
{
|
{
|
||||||
if (m_connectionStatus.isDisconnected() && ! m_unitTestMode) { return; }
|
if (m_connectionStatus.isDisconnected() && ! m_unitTestMode) { return; }
|
||||||
CSimulatedAircraft myAircraft(getOwnAircraft());
|
CSimulatedAircraft myAircraft(getOwnAircraft());
|
||||||
@@ -303,7 +303,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendInterimPilotDataUpdate()
|
void CFSDClient::sendInterimPilotDataUpdate()
|
||||||
{
|
{
|
||||||
if (m_connectionStatus.isDisconnected()) { return; }
|
if (m_connectionStatus.isDisconnected()) { return; }
|
||||||
CSimulatedAircraft myAircraft(getOwnAircraft());
|
CSimulatedAircraft myAircraft(getOwnAircraft());
|
||||||
@@ -326,13 +326,13 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendAtcDataUpdate(double latitude, double longitude)
|
void CFSDClient::sendAtcDataUpdate(double latitude, double longitude)
|
||||||
{
|
{
|
||||||
AtcDataUpdate atcDataUpdate(m_ownCallsign.asString(), 199998, CFacilityType::OBS, 300, AtcRating::Observer, latitude, longitude, 0);
|
AtcDataUpdate atcDataUpdate(m_ownCallsign.asString(), 199998, CFacilityType::OBS, 300, AtcRating::Observer, latitude, longitude, 0);
|
||||||
sendMessage(atcDataUpdate);
|
sendMessage(atcDataUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendPing(const QString &receiver)
|
void CFSDClient::sendPing(const QString &receiver)
|
||||||
{
|
{
|
||||||
qint64 msecSinceEpoch = QDateTime::currentMSecsSinceEpoch();
|
qint64 msecSinceEpoch = QDateTime::currentMSecsSinceEpoch();
|
||||||
QString timeString = QString::number(msecSinceEpoch);
|
QString timeString = QString::number(msecSinceEpoch);
|
||||||
@@ -344,49 +344,49 @@ namespace BlackCore
|
|||||||
this->increaseStatisticsValue(QStringLiteral("sendPing"));
|
this->increaseStatisticsValue(QStringLiteral("sendPing"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendClientQueryIsValidAtc(const CCallsign &callsign)
|
void CFSDClient::sendClientQueryIsValidAtc(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
sendClientQuery(ClientQueryType::IsValidATC, {}, { callsign.asString() });
|
sendClientQuery(ClientQueryType::IsValidATC, {}, { callsign.asString() });
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendClientQueryCapabilities(const CCallsign &callsign)
|
void CFSDClient::sendClientQueryCapabilities(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
sendClientQuery(ClientQueryType::Capabilities, callsign);
|
sendClientQuery(ClientQueryType::Capabilities, callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendClientQueryCom1Freq(const CCallsign &callsign)
|
void CFSDClient::sendClientQueryCom1Freq(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
sendClientQuery(ClientQueryType::Com1Freq, callsign);
|
sendClientQuery(ClientQueryType::Com1Freq, callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendClientQueryRealName(const CCallsign &callsign)
|
void CFSDClient::sendClientQueryRealName(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
sendClientQuery(ClientQueryType::RealName, callsign);
|
sendClientQuery(ClientQueryType::RealName, callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendClientQueryServer(const CCallsign &callsign)
|
void CFSDClient::sendClientQueryServer(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
sendClientQuery(ClientQueryType::Server, callsign);
|
sendClientQuery(ClientQueryType::Server, callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendClientQueryAtis(const CCallsign &callsign)
|
void CFSDClient::sendClientQueryAtis(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
sendClientQuery(ClientQueryType::ATIS, callsign);
|
sendClientQuery(ClientQueryType::ATIS, callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendClientQueryFlightPlan(const CCallsign callsign)
|
void CFSDClient::sendClientQueryFlightPlan(const CCallsign callsign)
|
||||||
{
|
{
|
||||||
sendClientQuery(ClientQueryType::FP, {}, { callsign.toQString() } );
|
sendClientQuery(ClientQueryType::FP, {}, { callsign.toQString() } );
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendClientQueryAircraftConfig(const CCallsign callsign)
|
void CFSDClient::sendClientQueryAircraftConfig(const CCallsign callsign)
|
||||||
{
|
{
|
||||||
QString data = QJsonDocument(JsonPackets::aircraftConfigRequest()).toJson(QJsonDocument::Compact);
|
QString data = QJsonDocument(JsonPackets::aircraftConfigRequest()).toJson(QJsonDocument::Compact);
|
||||||
data = convertToUnicodeEscaped(data);
|
data = convertToUnicodeEscaped(data);
|
||||||
sendClientQuery(ClientQueryType::AircraftConfig, callsign, { data });
|
sendClientQuery(ClientQueryType::AircraftConfig, callsign, { data });
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendClientQuery(ClientQueryType queryType, const CCallsign &receiver, const QStringList &queryData)
|
void CFSDClient::sendClientQuery(ClientQueryType queryType, const CCallsign &receiver, const QStringList &queryData)
|
||||||
{
|
{
|
||||||
if (queryType == ClientQueryType::Unknown)
|
if (queryType == ClientQueryType::Unknown)
|
||||||
{
|
{
|
||||||
@@ -463,7 +463,7 @@ namespace BlackCore
|
|||||||
this->increaseStatisticsValue(QStringLiteral("sendClientQuery"), toQString(queryType));
|
this->increaseStatisticsValue(QStringLiteral("sendClientQuery"), toQString(queryType));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendTextMessages(const CTextMessageList &messages)
|
void CFSDClient::sendTextMessages(const CTextMessageList &messages)
|
||||||
{
|
{
|
||||||
if (messages.isEmpty()) { return; }
|
if (messages.isEmpty()) { return; }
|
||||||
|
|
||||||
@@ -500,12 +500,12 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendTextMessage(const CTextMessage &message)
|
void CFSDClient::sendTextMessage(const CTextMessage &message)
|
||||||
{
|
{
|
||||||
sendTextMessages({message});
|
sendTextMessages({message});
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendTextMessage(TextMessageGroups receiverGroup, const QString &message)
|
void CFSDClient::sendTextMessage(TextMessageGroups receiverGroup, const QString &message)
|
||||||
{
|
{
|
||||||
QString receiver;
|
QString receiver;
|
||||||
if (receiverGroup == TextMessageGroups::AllClients) { receiver = '*'; }
|
if (receiverGroup == TextMessageGroups::AllClients) { receiver = '*'; }
|
||||||
@@ -518,13 +518,13 @@ namespace BlackCore
|
|||||||
this->increaseStatisticsValue(QStringLiteral("sendTextMessages"));
|
this->increaseStatisticsValue(QStringLiteral("sendTextMessages"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendTextMessage(const QString &receiver, const QString &message)
|
void CFSDClient::sendTextMessage(const QString &receiver, const QString &message)
|
||||||
{
|
{
|
||||||
const CTextMessage msg (message, getOwnCallsign(), { receiver });
|
const CTextMessage msg (message, getOwnCallsign(), { receiver });
|
||||||
sendTextMessage(msg);
|
sendTextMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendRadioMessage(const QVector<int> &frequencies, const QString &message)
|
void CFSDClient::sendRadioMessage(const QVector<int> &frequencies, const QString &message)
|
||||||
{
|
{
|
||||||
QStringList receivers;
|
QStringList receivers;
|
||||||
for (const int &frequency : frequencies)
|
for (const int &frequency : frequencies)
|
||||||
@@ -537,7 +537,7 @@ namespace BlackCore
|
|||||||
this->increaseStatisticsValue(QStringLiteral("sendTextMessages"));
|
this->increaseStatisticsValue(QStringLiteral("sendTextMessages"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendFlightPlan(const CFlightPlan &flightPlan)
|
void CFSDClient::sendFlightPlan(const CFlightPlan &flightPlan)
|
||||||
{
|
{
|
||||||
// Removed with T353 although it is standard
|
// Removed with T353 although it is standard
|
||||||
// const QString route = QString(flightPlan.getRoute()).replace(" ", ".");
|
// const QString route = QString(flightPlan.getRoute()).replace(" ", ".");
|
||||||
@@ -583,14 +583,14 @@ namespace BlackCore
|
|||||||
this->increaseStatisticsValue(QStringLiteral("sendFlightPlan"));
|
this->increaseStatisticsValue(QStringLiteral("sendFlightPlan"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendPlaneInfoRequest(const BlackMisc::Aviation::CCallsign &receiver)
|
void CFSDClient::sendPlaneInfoRequest(const BlackMisc::Aviation::CCallsign &receiver)
|
||||||
{
|
{
|
||||||
PlaneInfoRequest planeInfoRequest(m_ownCallsign.asString(), receiver.toQString());
|
PlaneInfoRequest planeInfoRequest(m_ownCallsign.asString(), receiver.toQString());
|
||||||
sendMessage(planeInfoRequest);
|
sendMessage(planeInfoRequest);
|
||||||
this->increaseStatisticsValue(QStringLiteral("sendPlaneInfoRequest"));
|
this->increaseStatisticsValue(QStringLiteral("sendPlaneInfoRequest"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendPlaneInfoRequestFsinn(const CCallsign &callsign)
|
void CFSDClient::sendPlaneInfoRequestFsinn(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(isConnected(), Q_FUNC_INFO, "Can't send to server when disconnected");
|
Q_ASSERT_X(isConnected(), Q_FUNC_INFO, "Can't send to server when disconnected");
|
||||||
const CSimulatedAircraft myAircraft(getOwnAircraft());
|
const CSimulatedAircraft myAircraft(getOwnAircraft());
|
||||||
@@ -606,14 +606,14 @@ namespace BlackCore
|
|||||||
this->increaseStatisticsValue(QStringLiteral("sendPlaneInfoRequestFsinn"));
|
this->increaseStatisticsValue(QStringLiteral("sendPlaneInfoRequestFsinn"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendPlaneInformation(const QString &receiver, const QString &aircraft, const QString &airline, const QString &livery)
|
void CFSDClient::sendPlaneInformation(const QString &receiver, const QString &aircraft, const QString &airline, const QString &livery)
|
||||||
{
|
{
|
||||||
PlaneInformation planeInformation(m_ownCallsign.asString(), receiver, aircraft, airline, livery);
|
PlaneInformation planeInformation(m_ownCallsign.asString(), receiver, aircraft, airline, livery);
|
||||||
sendMessage(planeInformation);
|
sendMessage(planeInformation);
|
||||||
this->increaseStatisticsValue(QStringLiteral("sendPlaneInformation"));
|
this->increaseStatisticsValue(QStringLiteral("sendPlaneInformation"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendPlaneInformationFsinn(const CCallsign &callsign)
|
void CFSDClient::sendPlaneInformationFsinn(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
if (m_connectionStatus.isDisconnected() && ! m_unitTestMode) { return; }
|
if (m_connectionStatus.isDisconnected() && ! m_unitTestMode) { return; }
|
||||||
const CSimulatedAircraft myAircraft(getOwnAircraft());
|
const CSimulatedAircraft myAircraft(getOwnAircraft());
|
||||||
@@ -629,38 +629,38 @@ namespace BlackCore
|
|||||||
this->increaseStatisticsValue(QStringLiteral("sendPlaneInformationFsinn"));
|
this->increaseStatisticsValue(QStringLiteral("sendPlaneInformationFsinn"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendAircraftConfiguration(const QString &receiver, const QString &aircraftConfigJson)
|
void CFSDClient::sendAircraftConfiguration(const QString &receiver, const QString &aircraftConfigJson)
|
||||||
{
|
{
|
||||||
sendClientQuery(ClientQueryType::AircraftConfig, receiver, { aircraftConfigJson });
|
sendClientQuery(ClientQueryType::AircraftConfig, receiver, { aircraftConfigJson });
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendFsdMessage(const QString &message)
|
void CFSDClient::sendFsdMessage(const QString &message)
|
||||||
{
|
{
|
||||||
parseMessage(message);
|
parseMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendAuthChallenge(const QString &challenge)
|
void CFSDClient::sendAuthChallenge(const QString &challenge)
|
||||||
{
|
{
|
||||||
AuthChallenge pduAuthChallenge(m_ownCallsign.asString(), "SERVER", challenge);
|
AuthChallenge pduAuthChallenge(m_ownCallsign.asString(), "SERVER", challenge);
|
||||||
sendMessage(pduAuthChallenge);
|
sendMessage(pduAuthChallenge);
|
||||||
this->increaseStatisticsValue(QStringLiteral("sendAuthChallenge"));
|
this->increaseStatisticsValue(QStringLiteral("sendAuthChallenge"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendAuthResponse(const QString &response)
|
void CFSDClient::sendAuthResponse(const QString &response)
|
||||||
{
|
{
|
||||||
AuthResponse pduAuthResponse(m_ownCallsign.asString(), "SERVER", response);
|
AuthResponse pduAuthResponse(m_ownCallsign.asString(), "SERVER", response);
|
||||||
sendMessage(pduAuthResponse);
|
sendMessage(pduAuthResponse);
|
||||||
this->increaseStatisticsValue(QStringLiteral("sendAuthResponse"));
|
this->increaseStatisticsValue(QStringLiteral("sendAuthResponse"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendPong(const QString &receiver, const QString ×tamp)
|
void CFSDClient::sendPong(const QString &receiver, const QString ×tamp)
|
||||||
{
|
{
|
||||||
Pong pong(m_ownCallsign.asString(), receiver, timestamp);
|
Pong pong(m_ownCallsign.asString(), receiver, timestamp);
|
||||||
sendMessage(pong);
|
sendMessage(pong);
|
||||||
this->increaseStatisticsValue(QStringLiteral("sendPong"));
|
this->increaseStatisticsValue(QStringLiteral("sendPong"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendClientResponse(ClientQueryType queryType, const QString &receiver)
|
void CFSDClient::sendClientResponse(ClientQueryType queryType, const QString &receiver)
|
||||||
{
|
{
|
||||||
QStringList responseData;
|
QStringList responseData;
|
||||||
if(queryType == ClientQueryType::IsValidATC)
|
if(queryType == ClientQueryType::IsValidATC)
|
||||||
@@ -760,7 +760,7 @@ namespace BlackCore
|
|||||||
this->increaseStatisticsValue(QStringLiteral("sendClientResponse"), toQString(queryType));
|
this->increaseStatisticsValue(QStringLiteral("sendClientResponse"), toQString(queryType));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendClientIdentification(const QString &fsdChallenge)
|
void CFSDClient::sendClientIdentification(const QString &fsdChallenge)
|
||||||
{
|
{
|
||||||
char sysuid[50];
|
char sysuid[50];
|
||||||
vatsim_get_system_unique_id(sysuid);
|
vatsim_get_system_unique_id(sysuid);
|
||||||
@@ -773,7 +773,7 @@ namespace BlackCore
|
|||||||
this->increaseStatisticsValue(QStringLiteral("sendClientIdentification"));
|
this->increaseStatisticsValue(QStringLiteral("sendClientIdentification"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::sendIncrementalAircraftConfig()
|
void CFSDClient::sendIncrementalAircraftConfig()
|
||||||
{
|
{
|
||||||
if (!this->isConnected()) { return; }
|
if (!this->isConnected()) { return; }
|
||||||
if (!this->getSetupForServer().sendAircraftParts()) { return; }
|
if (!this->getSetupForServer().sendAircraftParts()) { return; }
|
||||||
@@ -802,7 +802,7 @@ namespace BlackCore
|
|||||||
m_sentAircraftConfig = currentParts;
|
m_sentAircraftConfig = currentParts;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::initializeMessageTypes()
|
void CFSDClient::initializeMessageTypes()
|
||||||
{
|
{
|
||||||
m_messageTypeMapping["#AA"] = MessageType::AddAtc;
|
m_messageTypeMapping["#AA"] = MessageType::AddAtc;
|
||||||
m_messageTypeMapping["#AP"] = MessageType::AddPilot;
|
m_messageTypeMapping["#AP"] = MessageType::AddPilot;
|
||||||
@@ -825,7 +825,7 @@ namespace BlackCore
|
|||||||
m_messageTypeMapping["#SB"] = MessageType::PilotClientCom;
|
m_messageTypeMapping["#SB"] = MessageType::PilotClientCom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handleAtcDataUpdate(const QStringList &tokens)
|
void CFSDClient::handleAtcDataUpdate(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
AtcDataUpdate atcDataUpdate = AtcDataUpdate::fromTokens(tokens);
|
AtcDataUpdate atcDataUpdate = AtcDataUpdate::fromTokens(tokens);
|
||||||
|
|
||||||
@@ -843,7 +843,7 @@ namespace BlackCore
|
|||||||
emit atcDataUpdateReceived(cs, freq, position, range);
|
emit atcDataUpdateReceived(cs, freq, position, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handleAuthChallenge(const QStringList &tokens)
|
void CFSDClient::handleAuthChallenge(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
AuthChallenge authChallenge = AuthChallenge::fromTokens(tokens);
|
AuthChallenge authChallenge = AuthChallenge::fromTokens(tokens);
|
||||||
char response[33];
|
char response[33];
|
||||||
@@ -856,7 +856,7 @@ namespace BlackCore
|
|||||||
sendAuthChallenge(m_lastServerAuthChallenge);
|
sendAuthChallenge(m_lastServerAuthChallenge);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handleAuthResponse(const QStringList &tokens)
|
void CFSDClient::handleAuthResponse(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
AuthResponse authResponse = AuthResponse::fromTokens(tokens);
|
AuthResponse authResponse = AuthResponse::fromTokens(tokens);
|
||||||
|
|
||||||
@@ -869,13 +869,13 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handleDeleteATC(const QStringList &tokens)
|
void CFSDClient::handleDeleteATC(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
DeleteAtc deleteAtc = DeleteAtc::fromTokens(tokens);
|
DeleteAtc deleteAtc = DeleteAtc::fromTokens(tokens);
|
||||||
emit deleteAtcReceived(deleteAtc.m_cid);
|
emit deleteAtcReceived(deleteAtc.m_cid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handleDeletePilot(const QStringList &tokens)
|
void CFSDClient::handleDeletePilot(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
DeletePilot deletePilot = DeletePilot::fromTokens(tokens);
|
DeletePilot deletePilot = DeletePilot::fromTokens(tokens);
|
||||||
const CCallsign cs(deletePilot.sender(), CCallsign::Aircraft);
|
const CCallsign cs(deletePilot.sender(), CCallsign::Aircraft);
|
||||||
@@ -883,7 +883,7 @@ namespace BlackCore
|
|||||||
emit deletePilotReceived(deletePilot.m_cid);
|
emit deletePilotReceived(deletePilot.m_cid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handleTextMessage(const QStringList &tokens)
|
void CFSDClient::handleTextMessage(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
TextMessage textMessage = TextMessage::fromTokens(tokens);
|
TextMessage textMessage = TextMessage::fromTokens(tokens);
|
||||||
|
|
||||||
@@ -932,7 +932,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handlePilotDataUpdate(const QStringList &tokens)
|
void CFSDClient::handlePilotDataUpdate(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
PilotDataUpdate dataUpdate = PilotDataUpdate::fromTokens(tokens);
|
PilotDataUpdate dataUpdate = PilotDataUpdate::fromTokens(tokens);
|
||||||
const CCallsign callsign(dataUpdate.sender(), CCallsign::Aircraft);
|
const CCallsign callsign(dataUpdate.sender(), CCallsign::Aircraft);
|
||||||
@@ -972,13 +972,13 @@ namespace BlackCore
|
|||||||
emit pilotDataUpdateReceived(situation, transponder);
|
emit pilotDataUpdateReceived(situation, transponder);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handlePing(const QStringList &tokens)
|
void CFSDClient::handlePing(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
Ping ping = Ping::fromTokens(tokens);
|
Ping ping = Ping::fromTokens(tokens);
|
||||||
sendPong(ping.sender(), ping.m_timestamp);
|
sendPong(ping.sender(), ping.m_timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handlePong(const QStringList &tokens)
|
void CFSDClient::handlePong(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
Pong pong = Pong::fromTokens(tokens);
|
Pong pong = Pong::fromTokens(tokens);
|
||||||
qint64 msecSinceEpoch = QDateTime::currentMSecsSinceEpoch();
|
qint64 msecSinceEpoch = QDateTime::currentMSecsSinceEpoch();
|
||||||
@@ -986,14 +986,14 @@ namespace BlackCore
|
|||||||
emit pongReceived(pong.sender(), elapsedTime);
|
emit pongReceived(pong.sender(), elapsedTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handleKillRequest(const QStringList &tokens)
|
void CFSDClient::handleKillRequest(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
KillRequest killRequest = KillRequest::fromTokens(tokens);
|
KillRequest killRequest = KillRequest::fromTokens(tokens);
|
||||||
emit killRequestReceived(killRequest.m_reason);
|
emit killRequestReceived(killRequest.m_reason);
|
||||||
disconnectFromServer();
|
disconnectFromServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handleFlightPlan(const QStringList &tokens)
|
void CFSDClient::handleFlightPlan(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
FlightPlan fp = FlightPlan::fromTokens(tokens);
|
FlightPlan fp = FlightPlan::fromTokens(tokens);
|
||||||
|
|
||||||
@@ -1064,7 +1064,7 @@ namespace BlackCore
|
|||||||
emit flightPlanReceived(callsign, flightPlan);
|
emit flightPlanReceived(callsign, flightPlan);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handleClientQuery(const QStringList &tokens)
|
void CFSDClient::handleClientQuery(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
ClientQuery clientQuery = ClientQuery::fromTokens(tokens);
|
ClientQuery clientQuery = ClientQuery::fromTokens(tokens);
|
||||||
|
|
||||||
@@ -1158,7 +1158,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handleClientReponse(const QStringList &tokens)
|
void CFSDClient::handleClientReponse(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
ClientResponse clientResponse = ClientResponse::fromTokens(tokens);
|
ClientResponse clientResponse = ClientResponse::fromTokens(tokens);
|
||||||
if (clientResponse.isUnknownQuery()) { return; }
|
if (clientResponse.isUnknownQuery()) { return; }
|
||||||
@@ -1256,7 +1256,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handleServerError(const QStringList &tokens)
|
void CFSDClient::handleServerError(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
ServerError serverError = ServerError::fromTokens(tokens);
|
ServerError serverError = ServerError::fromTokens(tokens);
|
||||||
switch (serverError.m_errorNumber)
|
switch (serverError.m_errorNumber)
|
||||||
@@ -1287,7 +1287,7 @@ namespace BlackCore
|
|||||||
if (serverError.isFatalError()) { disconnectFromServer(); }
|
if (serverError.isFatalError()) { disconnectFromServer(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handleCustomPilotPacket(const QStringList &tokens)
|
void CFSDClient::handleCustomPilotPacket(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
const QString subType = tokens.at(2);
|
const QString subType = tokens.at(2);
|
||||||
|
|
||||||
@@ -1371,7 +1371,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handleFsdIdentification(const QStringList &tokens)
|
void CFSDClient::handleFsdIdentification(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
if (m_protocolRevision >= PROTOCOL_REVISION_VATSIM_AUTH)
|
if (m_protocolRevision >= PROTOCOL_REVISION_VATSIM_AUTH)
|
||||||
{
|
{
|
||||||
@@ -1390,17 +1390,17 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::handleUnknownPacket(const QStringList &tokens)
|
void CFSDClient::handleUnknownPacket(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
qDebug() << "handleUnknownPacket:" << tokens;
|
qDebug() << "handleUnknownPacket:" << tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::printSocketError(QAbstractSocket::SocketError)
|
void CFSDClient::printSocketError(QAbstractSocket::SocketError)
|
||||||
{
|
{
|
||||||
qDebug() << m_socket.errorString();
|
qDebug() << m_socket.errorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::updateConnectionStatus(CConnectionStatus newStatus)
|
void CFSDClient::updateConnectionStatus(CConnectionStatus newStatus)
|
||||||
{
|
{
|
||||||
if (m_connectionStatus != newStatus)
|
if (m_connectionStatus != newStatus)
|
||||||
{
|
{
|
||||||
@@ -1429,7 +1429,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::consolidateTextMessage(const CTextMessage &textMessage)
|
void CFSDClient::consolidateTextMessage(const CTextMessage &textMessage)
|
||||||
{
|
{
|
||||||
if (textMessage.isSupervisorMessage())
|
if (textMessage.isSupervisorMessage())
|
||||||
{
|
{
|
||||||
@@ -1442,13 +1442,13 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::emitConsolidatedTextMessages()
|
void CFSDClient::emitConsolidatedTextMessages()
|
||||||
{
|
{
|
||||||
emit this->textMessagesReceived(m_textMessagesToConsolidate);
|
emit this->textMessagesReceived(m_textMessagesToConsolidate);
|
||||||
m_textMessagesToConsolidate.clear();
|
m_textMessagesToConsolidate.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 FSDClient::receivedPositionFixTsAndGetOffsetTime(const CCallsign &callsign, qint64 markerTs)
|
qint64 CFSDClient::receivedPositionFixTsAndGetOffsetTime(const CCallsign &callsign, qint64 markerTs)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Need callsign");
|
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Need callsign");
|
||||||
|
|
||||||
@@ -1478,7 +1478,7 @@ namespace BlackCore
|
|||||||
return m_additionalOffsetTime + offsetTime;
|
return m_additionalOffsetTime + offsetTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 FSDClient::currentOffsetTime(const CCallsign &callsign) const
|
qint64 CFSDClient::currentOffsetTime(const CCallsign &callsign) const
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Need callsign");
|
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Need callsign");
|
||||||
|
|
||||||
@@ -1486,7 +1486,7 @@ namespace BlackCore
|
|||||||
return m_lastOffsetTimes[callsign].front();
|
return m_lastOffsetTimes[callsign].front();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::clearState()
|
void CFSDClient::clearState()
|
||||||
{
|
{
|
||||||
m_textMessagesToConsolidate.clear();
|
m_textMessagesToConsolidate.clear();
|
||||||
m_pendingAtisQueries.clear();
|
m_pendingAtisQueries.clear();
|
||||||
@@ -1495,7 +1495,7 @@ namespace BlackCore
|
|||||||
m_sentAircraftConfig = CAircraftParts::null();
|
m_sentAircraftConfig = CAircraftParts::null();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::clearState(const CCallsign &callsign)
|
void CFSDClient::clearState(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
if (callsign.isEmpty()) { return; }
|
if (callsign.isEmpty()) { return; }
|
||||||
m_pendingAtisQueries.remove(callsign);
|
m_pendingAtisQueries.remove(callsign);
|
||||||
@@ -1504,14 +1504,14 @@ namespace BlackCore
|
|||||||
m_lastOffsetTimes.remove(callsign);
|
m_lastOffsetTimes.remove(callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::insertLatestOffsetTime(const CCallsign &callsign, qint64 offsetMs)
|
void CFSDClient::insertLatestOffsetTime(const CCallsign &callsign, qint64 offsetMs)
|
||||||
{
|
{
|
||||||
QList<qint64> &offsets = m_lastOffsetTimes[callsign];
|
QList<qint64> &offsets = m_lastOffsetTimes[callsign];
|
||||||
offsets.push_front(offsetMs);
|
offsets.push_front(offsetMs);
|
||||||
if (offsets.size() > MaxOffseTimes) { offsets.removeLast(); }
|
if (offsets.size() > MaxOffseTimes) { offsets.removeLast(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 FSDClient::averageOffsetTimeMs(const CCallsign &callsign, int &count, int maxLastValues) const
|
qint64 CFSDClient::averageOffsetTimeMs(const CCallsign &callsign, int &count, int maxLastValues) const
|
||||||
{
|
{
|
||||||
const QList<qint64> &offsets = m_lastOffsetTimes[callsign];
|
const QList<qint64> &offsets = m_lastOffsetTimes[callsign];
|
||||||
if (offsets.size() < 1) { return -1; }
|
if (offsets.size() < 1) { return -1; }
|
||||||
@@ -1526,30 +1526,30 @@ namespace BlackCore
|
|||||||
return qRound(static_cast<double>(sum) / count);
|
return qRound(static_cast<double>(sum) / count);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 FSDClient::averageOffsetTimeMs(const CCallsign &callsign, int maxLastValues) const
|
qint64 CFSDClient::averageOffsetTimeMs(const CCallsign &callsign, int maxLastValues) const
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
return this->averageOffsetTimeMs(callsign, maxLastValues, count);
|
return this->averageOffsetTimeMs(callsign, maxLastValues, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FSDClient::isInterimPositionSendingEnabledForServer() const
|
bool CFSDClient::isInterimPositionSendingEnabledForServer() const
|
||||||
{
|
{
|
||||||
const CFsdSetup::SendReceiveDetails d = this->getSetupForServer().getSendReceiveDetails();
|
const CFsdSetup::SendReceiveDetails d = this->getSetupForServer().getSendReceiveDetails();
|
||||||
return (d & CFsdSetup::SendInterimPositions);
|
return (d & CFsdSetup::SendInterimPositions);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FSDClient::isInterimPositionReceivingEnabledForServer() const
|
bool CFSDClient::isInterimPositionReceivingEnabledForServer() const
|
||||||
{
|
{
|
||||||
const CFsdSetup::SendReceiveDetails d = this->getSetupForServer().getSendReceiveDetails();
|
const CFsdSetup::SendReceiveDetails d = this->getSetupForServer().getSendReceiveDetails();
|
||||||
return (d & CFsdSetup::ReceiveInterimPositions);
|
return (d & CFsdSetup::ReceiveInterimPositions);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CFsdSetup &FSDClient::getSetupForServer() const
|
const CFsdSetup &CFSDClient::getSetupForServer() const
|
||||||
{
|
{
|
||||||
return m_server.getFsdSetup();
|
return m_server.getFsdSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::maybeHandleAtisReply(const CCallsign &sender, const CCallsign &receiver, const QString &message)
|
void CFSDClient::maybeHandleAtisReply(const CCallsign &sender, const CCallsign &receiver, const QString &message)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_pendingAtisQueries.contains(sender));
|
Q_ASSERT(m_pendingAtisQueries.contains(sender));
|
||||||
PendingAtisQuery &pendingQuery = m_pendingAtisQueries[sender];
|
PendingAtisQuery &pendingQuery = m_pendingAtisQueries[sender];
|
||||||
@@ -1586,7 +1586,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::fsdMessageSettingsChanged()
|
void CFSDClient::fsdMessageSettingsChanged()
|
||||||
{
|
{
|
||||||
if (m_rawFsdMessageLogFile.isOpen()) { m_rawFsdMessageLogFile.close(); }
|
if (m_rawFsdMessageLogFile.isOpen()) { m_rawFsdMessageLogFile.close(); }
|
||||||
const CRawFsdMessageSettings setting = m_fsdMessageSetting.get();
|
const CRawFsdMessageSettings setting = m_fsdMessageSetting.get();
|
||||||
@@ -1617,17 +1617,17 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BlackMisc::Aviation::CCallsignSet FSDClient::getInterimPositionReceivers() const
|
BlackMisc::Aviation::CCallsignSet CFSDClient::getInterimPositionReceivers() const
|
||||||
{
|
{
|
||||||
return m_interimPositionReceivers;
|
return m_interimPositionReceivers;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::setInterimPositionReceivers(const BlackMisc::Aviation::CCallsignSet &interimPositionReceivers)
|
void CFSDClient::setInterimPositionReceivers(const BlackMisc::Aviation::CCallsignSet &interimPositionReceivers)
|
||||||
{
|
{
|
||||||
m_interimPositionReceivers = interimPositionReceivers;
|
m_interimPositionReceivers = interimPositionReceivers;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FSDClient::increaseStatisticsValue(const QString &identifier, const QString &appendix)
|
int CFSDClient::increaseStatisticsValue(const QString &identifier, const QString &appendix)
|
||||||
{
|
{
|
||||||
if (identifier.isEmpty() || !m_statistics) { return -1; }
|
if (identifier.isEmpty() || !m_statistics) { return -1; }
|
||||||
const QString i = appendix.isEmpty() ? identifier : identifier % u"." % appendix;
|
const QString i = appendix.isEmpty() ? identifier : identifier % u"." % appendix;
|
||||||
@@ -1640,18 +1640,18 @@ namespace BlackCore
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FSDClient::increaseStatisticsValue(const QString &identifier, int value)
|
int CFSDClient::increaseStatisticsValue(const QString &identifier, int value)
|
||||||
{
|
{
|
||||||
return this->increaseStatisticsValue(identifier, QString::number(value));
|
return this->increaseStatisticsValue(identifier, QString::number(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::clearStatistics()
|
void CFSDClient::clearStatistics()
|
||||||
{
|
{
|
||||||
m_callStatistics.clear();
|
m_callStatistics.clear();
|
||||||
m_callByTime.clear();
|
m_callByTime.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FSDClient::getNetworkStatisticsAsText(bool reset, const QString &separator)
|
QString CFSDClient::getNetworkStatisticsAsText(bool reset, const QString &separator)
|
||||||
{
|
{
|
||||||
QVector<std::pair<int, QString>> transformed;
|
QVector<std::pair<int, QString>> transformed;
|
||||||
if (m_callStatistics.isEmpty()) { return QString(); }
|
if (m_callStatistics.isEmpty()) { return QString(); }
|
||||||
@@ -1693,12 +1693,12 @@ namespace BlackCore
|
|||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLoginMode FSDClient::getLoginMode() const
|
CLoginMode CFSDClient::getLoginMode() const
|
||||||
{
|
{
|
||||||
return m_loginMode;
|
return m_loginMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::readDataFromSocket()
|
void CFSDClient::readDataFromSocket()
|
||||||
{
|
{
|
||||||
while (m_socket.canReadLine())
|
while (m_socket.canReadLine())
|
||||||
{
|
{
|
||||||
@@ -1708,7 +1708,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::parseMessage(const QString &line)
|
void CFSDClient::parseMessage(const QString &line)
|
||||||
{
|
{
|
||||||
MessageType messageType = MessageType::Unknown;
|
MessageType messageType = MessageType::Unknown;
|
||||||
QString cmd;
|
QString cmd;
|
||||||
@@ -1762,7 +1762,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::emitRawFsdMessage(const QString &fsdMessage, bool isSent)
|
void CFSDClient::emitRawFsdMessage(const QString &fsdMessage, bool isSent)
|
||||||
{
|
{
|
||||||
if (!m_unitTestMode && !m_rawFsdMessagesEnabled) { return; }
|
if (!m_unitTestMode && !m_rawFsdMessagesEnabled) { return; }
|
||||||
QString fsdMessageFiltered(fsdMessage);
|
QString fsdMessageFiltered(fsdMessage);
|
||||||
@@ -1787,7 +1787,7 @@ namespace BlackCore
|
|||||||
emit rawFsdMessage(rawMessage);
|
emit rawFsdMessage(rawMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FSDClient::saveNetworkStatistics(const QString &server)
|
bool CFSDClient::saveNetworkStatistics(const QString &server)
|
||||||
{
|
{
|
||||||
if (m_callStatistics.isEmpty()) { return false; }
|
if (m_callStatistics.isEmpty()) { return false; }
|
||||||
|
|
||||||
@@ -1798,19 +1798,19 @@ namespace BlackCore
|
|||||||
return CFileUtils::writeStringToFile(s, fp);
|
return CFileUtils::writeStringToFile(s, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::startPositionTimers()
|
void CFSDClient::startPositionTimers()
|
||||||
{
|
{
|
||||||
m_positionUpdateTimer.start(c_updatePostionIntervalMsec);
|
m_positionUpdateTimer.start(c_updatePostionIntervalMsec);
|
||||||
if (this->isInterimPositionSendingEnabledForServer()) { m_interimPositionUpdateTimer.start(c_updateInterimPostionIntervalMsec); }
|
if (this->isInterimPositionSendingEnabledForServer()) { m_interimPositionUpdateTimer.start(c_updateInterimPostionIntervalMsec); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::stopPositionTimers()
|
void CFSDClient::stopPositionTimers()
|
||||||
{
|
{
|
||||||
m_positionUpdateTimer.stop();
|
m_positionUpdateTimer.stop();
|
||||||
m_interimPositionUpdateTimer.stop();
|
m_interimPositionUpdateTimer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSDClient::updateAtisMap(const QString &callsign, AtisLineType type, const QString &line)
|
void CFSDClient::updateAtisMap(const QString &callsign, AtisLineType type, const QString &line)
|
||||||
{
|
{
|
||||||
if (type == AtisLineType::VoiceRoom)
|
if (type == AtisLineType::VoiceRoom)
|
||||||
{
|
{
|
||||||
@@ -1870,7 +1870,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const CLength &FSDClient::fixAtcRange(const CLength &networkRange, const CCallsign &cs)
|
const CLength &CFSDClient::fixAtcRange(const CLength &networkRange, const CCallsign &cs)
|
||||||
{
|
{
|
||||||
/** T702, https://discordapp.com/channels/539048679160676382/539846348275449887/597814208125730826
|
/** T702, https://discordapp.com/channels/539048679160676382/539846348275449887/597814208125730826
|
||||||
DEL 5 NM
|
DEL 5 NM
|
||||||
@@ -1894,14 +1894,14 @@ namespace BlackCore
|
|||||||
return networkRange;
|
return networkRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CLength &FSDClient::maxOrNotNull(const CLength &l1, const CLength &l2)
|
const CLength &CFSDClient::maxOrNotNull(const CLength &l1, const CLength &l2)
|
||||||
{
|
{
|
||||||
if (l1.isNull()) { return l2; }
|
if (l1.isNull()) { return l2; }
|
||||||
if (l2.isNull()) { return l1; }
|
if (l2.isNull()) { return l1; }
|
||||||
return (l2 > l1) ? l2 : l1;
|
return (l2 > l1) ? l2 : l1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QJsonObject &FSDClient::JsonPackets::aircraftConfigRequest()
|
const QJsonObject &CFSDClient::JsonPackets::aircraftConfigRequest()
|
||||||
{
|
{
|
||||||
static const QJsonObject jsonObject{ { "request", "full" } };
|
static const QJsonObject jsonObject{ { "request", "full" } };
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#ifndef BLACKCORE_FSD_CLIENT_H
|
#ifndef BLACKCORE_FSD_CLIENT_H
|
||||||
#define BLACKCORE_FSD_CLIENT_H
|
#define BLACKCORE_FSD_CLIENT_H
|
||||||
|
|
||||||
|
|
||||||
#include "blackcore/blackcoreexport.h"
|
#include "blackcore/blackcoreexport.h"
|
||||||
#include "blackcore/vatsim/vatsimsettings.h"
|
#include "blackcore/vatsim/vatsimsettings.h"
|
||||||
#include "blackcore/fsd/enums.h"
|
#include "blackcore/fsd/enums.h"
|
||||||
@@ -48,7 +47,6 @@
|
|||||||
#define PROTOCOL_REVISION_VATSIM_AUTH 100
|
#define PROTOCOL_REVISION_VATSIM_AUTH 100
|
||||||
|
|
||||||
namespace BlackFsdTest { class CTestFSDClient; }
|
namespace BlackFsdTest { class CTestFSDClient; }
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
namespace Fsd
|
namespace Fsd
|
||||||
@@ -65,22 +63,22 @@ namespace BlackCore
|
|||||||
//! Send (interim) data updates automatically
|
//! Send (interim) data updates automatically
|
||||||
//! Check ':' in FSD messages. Disconnect if there is a wrong one
|
//! Check ':' in FSD messages. Disconnect if there is a wrong one
|
||||||
|
|
||||||
class BLACKCORE_EXPORT FSDClient :
|
class BLACKCORE_EXPORT CFSDClient :
|
||||||
public QObject,
|
public QObject,
|
||||||
public BlackMisc::Network::IEcosystemProvider, // provide info about used ecosystem
|
public BlackMisc::Network::IEcosystemProvider, // provide info about used ecosystem
|
||||||
public BlackMisc::Network::CClientAware, // network can set client information
|
public BlackMisc::Network::CClientAware, // network can set client information
|
||||||
public BlackMisc::Simulation::COwnAircraftAware, // network vatlib consumes own aircraft data and sets ICAO/callsign data
|
public BlackMisc::Simulation::COwnAircraftAware, // network vatlib consumes own aircraft data and sets ICAO/callsign data
|
||||||
public BlackMisc::Simulation::CRemoteAircraftAware, // check if we really need to process network packets (e.g. parts)
|
public BlackMisc::Simulation::CRemoteAircraftAware, // check if we really need to process network packets (e.g. parts)
|
||||||
public BlackMisc::Simulation::CSimulationEnvironmentAware // allows to consume ground elevations
|
public BlackMisc::Simulation::CSimulationEnvironmentAware // allows to consume ground elevations
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(BlackMisc::Network::IEcosystemProvider)
|
Q_INTERFACES(BlackMisc::Network::IEcosystemProvider)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FSDClient(BlackMisc::Network::IClientProvider *clientProvider,
|
CFSDClient(BlackMisc::Network::IClientProvider *clientProvider,
|
||||||
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
|
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
|
||||||
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
|
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
|
||||||
QObject *parent = nullptr);
|
QObject *parent = nullptr);
|
||||||
|
|
||||||
// Necessary functions to setup client. Set them all!
|
// Necessary functions to setup client. Set them all!
|
||||||
void setClientName(const QString &clientName) { m_clientName = clientName; }
|
void setClientName(const QString &clientName) { m_clientName = clientName; }
|
||||||
@@ -160,24 +158,27 @@ namespace BlackCore
|
|||||||
void setInterimPositionReceivers(const BlackMisc::Aviation::CCallsignSet &interimPositionReceivers);
|
void setInterimPositionReceivers(const BlackMisc::Aviation::CCallsignSet &interimPositionReceivers);
|
||||||
|
|
||||||
bool isConnected() const { return m_connectionStatus.isConnected(); }
|
bool isConnected() const { return m_connectionStatus.isConnected(); }
|
||||||
bool isPendingConnection() const { return m_connectionStatus.isConnecting() ||
|
bool isPendingConnection() const
|
||||||
m_connectionStatus.isDisconnecting(); }
|
{
|
||||||
|
return m_connectionStatus.isConnecting() ||
|
||||||
|
m_connectionStatus.isDisconnecting();
|
||||||
|
}
|
||||||
|
|
||||||
//! Statistics enable functions @{
|
//! Statistics enable functions @{
|
||||||
bool setStatisticsEnable(bool enabled) { m_statistics = enabled; return enabled; }
|
bool setStatisticsEnable(bool enabled) { m_statistics = enabled; return enabled; }
|
||||||
bool isStatisticsEnabled() const { return m_statistics; }
|
bool isStatisticsEnabled() const { return m_statistics; }
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! Increase the statistics value for given identifier @{
|
//! Increase the statistics value for given identifier @{
|
||||||
int increaseStatisticsValue(const QString &identifier, const QString &appendix = {});
|
int increaseStatisticsValue(const QString &identifier, const QString &appendix = {});
|
||||||
int increaseStatisticsValue(const QString &identifier, int value);
|
int increaseStatisticsValue(const QString &identifier, int value);
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! Clear the statistics
|
//! Clear the statistics
|
||||||
void clearStatistics();
|
void clearStatistics();
|
||||||
|
|
||||||
//! Text statistics
|
//! Text statistics
|
||||||
QString getNetworkStatisticsAsText(bool reset, const QString &separator = "\n");
|
QString getNetworkStatisticsAsText(bool reset, const QString &separator = "\n");
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void atcDataUpdateReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &freq,
|
void atcDataUpdateReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &freq,
|
||||||
@@ -380,7 +381,7 @@ namespace BlackCore
|
|||||||
BlackMisc::CTokenBucket m_tokenBucket; //!< used with aircraft parts messages
|
BlackMisc::CTokenBucket m_tokenBucket; //!< used with aircraft parts messages
|
||||||
BlackMisc::Aviation::CCallsignSet m_interimPositionReceivers; //!< all aircraft receiving interim positions
|
BlackMisc::Aviation::CCallsignSet m_interimPositionReceivers; //!< all aircraft receiving interim positions
|
||||||
|
|
||||||
BlackMisc::CDigestSignal m_dsSendTextMessage { this, &FSDClient::emitConsolidatedTextMessages, 500, 10 };
|
BlackMisc::CDigestSignal m_dsSendTextMessage { this, &CFSDClient::emitConsolidatedTextMessages, 500, 10 };
|
||||||
BlackMisc::Network::CTextMessageList m_textMessagesToConsolidate;
|
BlackMisc::Network::CTextMessageList m_textMessagesToConsolidate;
|
||||||
|
|
||||||
struct AtisMessage
|
struct AtisMessage
|
||||||
@@ -404,7 +405,7 @@ namespace BlackCore
|
|||||||
QHash<BlackMisc::Aviation::CCallsign, qint64> m_lastPositionUpdate;
|
QHash<BlackMisc::Aviation::CCallsign, qint64> m_lastPositionUpdate;
|
||||||
QHash<BlackMisc::Aviation::CCallsign, QList<qint64>> m_lastOffsetTimes; //!< latest offset first
|
QHash<BlackMisc::Aviation::CCallsign, QList<qint64>> m_lastOffsetTimes; //!< latest offset first
|
||||||
|
|
||||||
BlackMisc::CSettingReadOnly<BlackCore::Vatsim::TRawFsdMessageSetting> m_fsdMessageSetting { this, &FSDClient::fsdMessageSettingsChanged };
|
BlackMisc::CSettingReadOnly<BlackCore::Vatsim::TRawFsdMessageSetting> m_fsdMessageSetting { this, &CFSDClient::fsdMessageSettingsChanged };
|
||||||
QFile m_rawFsdMessageLogFile;
|
QFile m_rawFsdMessageLogFile;
|
||||||
bool m_rawFsdMessagesEnabled = false;
|
bool m_rawFsdMessagesEnabled = false;
|
||||||
bool m_filterPasswordFromLogin = false;
|
bool m_filterPasswordFromLogin = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user