Refactor rehosting logic in FSD client

This commit is contained in:
Mat Sutcliffe
2023-03-12 18:23:53 +00:00
parent 6dc2492d29
commit dfc288bfd7
2 changed files with 43 additions and 65 deletions

View File

@@ -389,8 +389,6 @@ namespace BlackCore::Fsd
void handleUnknownPacket(const QStringList &tokens);
//! @}
void handleVatsimServerIpResponse(QNetworkReply *nwReplyPtr);
void printSocketError(QAbstractSocket::SocketError socketError);
void handleSocketError(QAbstractSocket::SocketError socketError);
void handleSocketConnected();
@@ -479,9 +477,11 @@ namespace BlackCore::Fsd
// Parser
QHash<QString, MessageType> m_messageTypeMapping;
std::unique_ptr<QTcpSocket> m_socket = std::make_unique<QTcpSocket>(this); //!< used TCP socket, parent needed as it runs in worker thread
std::shared_ptr<QTcpSocket> m_socket = std::make_shared<QTcpSocket>(this); //!< used TCP socket, parent needed as it runs in worker thread
void connectSocketSignals();
void initiateConnection();
void initiateConnection(std::shared_ptr<QTcpSocket> rehostingSocket = {}, const QString &rehostingHost = {});
void resolveLoadBalancing(const QString &host, std::function<void(const QString &)> callback);
bool m_rehosting = false;
std::atomic_bool m_unitTestMode { false };
std::atomic_bool m_printToConsole { false };
@@ -558,11 +558,6 @@ namespace BlackCore::Fsd
ServerType m_serverType = ServerType::LegacyFsd;
Capabilities m_capabilities = Capabilities::None;
// Current rehosting
QTcpSocket* m_rehosting_socket = nullptr;
QString m_rehosting_host = "";
bool m_rehosting = false;
// buffered data for FSD
BlackMisc::Aviation::CCallsign m_ownCallsign; //!< "buffered callsign", as this must not change when connected
BlackMisc::Aviation::CCallsign m_partnerCallsign; //!< "buffered"callsign", of partner flying in shared cockpit