mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 03:15:34 +08:00
INetwork: removed the five connectionStatus signals and added one signal with an enum argument to replace them.
Requested by Klaus, to ease the implementation of signal consumers.
This commit is contained in:
@@ -14,11 +14,7 @@ Client::Client(BlackMisc::IContext &ctx)
|
||||
using namespace BlackCore;
|
||||
connect(m_net, &INetwork::atcPositionUpdate, this, &Client::atcPositionUpdate);
|
||||
connect(m_net, &INetwork::atcDisconnected, this, &Client::atcDisconnected);
|
||||
connect(m_net, &INetwork::connectionStatusIdle, this, &Client::connectionStatusIdle);
|
||||
connect(m_net, &INetwork::connectionStatusConnecting, this, &Client::connectionStatusConnecting);
|
||||
connect(m_net, &INetwork::connectionStatusConnected, this, &Client::connectionStatusConnected);
|
||||
connect(m_net, &INetwork::connectionStatusDisconnected, this, &Client::connectionStatusDisconnected);
|
||||
connect(m_net, &INetwork::connectionStatusError, this, &Client::connectionStatusError);
|
||||
connect(m_net, &INetwork::connectionStatusChanged, this, &Client::connectionStatusChanged);
|
||||
connect(m_net, &INetwork::ipQueryReplyReceived, this, &Client::ipQueryReplyReceived);
|
||||
connect(m_net, &INetwork::frequencyQueryReplyReceived, this, &Client::freqQueryReplyReceived);
|
||||
connect(m_net, &INetwork::serverQueryReplyReceived, this, &Client::serverQueryReplyReceived);
|
||||
@@ -320,29 +316,14 @@ void Client::atcDisconnected(const BlackMisc::Aviation::CCallsign &callsign)
|
||||
std::cout << "ATC_DISCONNECTED " << callsign << std::endl;
|
||||
}
|
||||
|
||||
void Client::connectionStatusIdle()
|
||||
void Client::connectionStatusChanged(BlackCore::INetwork::ConnectionStatus status)
|
||||
{
|
||||
std::cout << "CONN_STATUS_IDLE" << std::endl;
|
||||
}
|
||||
|
||||
void Client::connectionStatusConnecting()
|
||||
{
|
||||
std::cout << "CONN_STATUS_CONNECTING" << std::endl;
|
||||
}
|
||||
|
||||
void Client::connectionStatusConnected()
|
||||
{
|
||||
std::cout << "CONN_STATUS_CONNECTED" << std::endl;
|
||||
}
|
||||
|
||||
void Client::connectionStatusDisconnected()
|
||||
{
|
||||
std::cout << "CONN_STATUS_DISCONNECTED" << std::endl;
|
||||
}
|
||||
|
||||
void Client::connectionStatusError()
|
||||
{
|
||||
std::cout << "CONN_STATUS_ERROR" << std::endl;
|
||||
switch (status)
|
||||
{
|
||||
case BlackCore::INetwork::Disconnected: std::cout << "CONN_STATUS_DISCONNECTED" << std::endl; break;
|
||||
case BlackCore::INetwork::Connecting: std::cout << "CONN_STATUS_CONNECTING" << std::endl; break;
|
||||
case BlackCore::INetwork::Connected: std::cout << "CONN_STATUS_CONNECTED" << std::endl; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Client::ipQueryReplyReceived(const QString &ip)
|
||||
|
||||
@@ -81,11 +81,7 @@ public slots: //to receive from INetwork
|
||||
void atcPositionUpdate(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &freq,
|
||||
const BlackMisc::Geo::CCoordinateGeodetic &pos, const BlackMisc::PhysicalQuantities::CLength &range);
|
||||
void atcDisconnected(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
void connectionStatusIdle();
|
||||
void connectionStatusConnecting();
|
||||
void connectionStatusConnected();
|
||||
void connectionStatusDisconnected();
|
||||
void connectionStatusError();
|
||||
void connectionStatusChanged(BlackCore::INetwork::ConnectionStatus status);
|
||||
void ipQueryReplyReceived(const QString &ip);
|
||||
void freqQueryReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &freq);
|
||||
void serverQueryReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &hostname);
|
||||
|
||||
@@ -55,6 +55,13 @@ namespace BlackCore
|
||||
SupportsModelDescriptions = 1 << 2
|
||||
};
|
||||
|
||||
enum ConnectionStatus
|
||||
{
|
||||
Disconnected = 0,
|
||||
Connecting,
|
||||
Connected
|
||||
};
|
||||
|
||||
public slots:
|
||||
// Network
|
||||
virtual void setServer(const BlackMisc::Network::CServer &server) = 0;
|
||||
@@ -108,11 +115,7 @@ namespace BlackCore
|
||||
|
||||
// Connection / Network in general
|
||||
void kicked(const QString &msg);
|
||||
void connectionStatusIdle();
|
||||
void connectionStatusConnecting();
|
||||
void connectionStatusConnected();
|
||||
void connectionStatusDisconnected();
|
||||
void connectionStatusError();
|
||||
void connectionStatusChanged(ConnectionStatus status);
|
||||
void pong(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CTime &elapsedTime);
|
||||
void capabilitiesQueryReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, quint32 flags);
|
||||
void ipQueryReplyReceived(const QString &ip);
|
||||
|
||||
@@ -447,11 +447,11 @@ namespace BlackCore
|
||||
cbvar_cast(cbvar)->m_status = newStatus;
|
||||
switch (newStatus)
|
||||
{
|
||||
case Cvatlib_Network::connStatus_Idle: emit cbvar_cast(cbvar)->connectionStatusIdle(); break;
|
||||
case Cvatlib_Network::connStatus_Connecting: emit cbvar_cast(cbvar)->connectionStatusConnecting(); break;
|
||||
case Cvatlib_Network::connStatus_Connected: emit cbvar_cast(cbvar)->connectionStatusConnected(); break;
|
||||
case Cvatlib_Network::connStatus_Disconnected: emit cbvar_cast(cbvar)->connectionStatusDisconnected(); break;
|
||||
case Cvatlib_Network::connStatus_Error: emit cbvar_cast(cbvar)->connectionStatusError(); break;
|
||||
case Cvatlib_Network::connStatus_Idle: emit cbvar_cast(cbvar)->connectionStatusChanged(Disconnected); break;
|
||||
case Cvatlib_Network::connStatus_Connecting: emit cbvar_cast(cbvar)->connectionStatusChanged(Connecting); break;
|
||||
case Cvatlib_Network::connStatus_Connected: emit cbvar_cast(cbvar)->connectionStatusChanged(Connected); break;
|
||||
case Cvatlib_Network::connStatus_Disconnected: emit cbvar_cast(cbvar)->connectionStatusChanged(Disconnected); break;
|
||||
case Cvatlib_Network::connStatus_Error: emit cbvar_cast(cbvar)->connectionStatusChanged(Disconnected); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ void BlackCoreTest::CTestNetwork::networkTest(BlackCore::INetwork *net)
|
||||
.send(&INetwork::setServer, CServer("", "", "vatsim-germany.org", 6809, CUser("guest", "", "", "guest")))
|
||||
.send(&INetwork::setCallsign, "BLACK")
|
||||
.send(&INetwork::initiateConnection)
|
||||
.expect(&INetwork::connectionStatusConnecting, [] { qDebug() << "CONNECTING"; })
|
||||
.expect(&INetwork::connectionStatusConnected, [] { qDebug() << "CONNECTED"; })
|
||||
.expect(&INetwork::connectionStatusChanged, [](INetwork::ConnectionStatus s) { QVERIFY(s == INetwork::Connecting); qDebug() << "CONNECTING"; })
|
||||
.expect(&INetwork::connectionStatusChanged, [](INetwork::ConnectionStatus s) { QVERIFY(s == INetwork::Connected); qDebug() << "CONNECTED"; })
|
||||
.wait(10);
|
||||
|
||||
EXPECT_UNIT(e)
|
||||
@@ -32,6 +32,6 @@ void BlackCoreTest::CTestNetwork::networkTest(BlackCore::INetwork *net)
|
||||
|
||||
EXPECT_UNIT(e)
|
||||
.send(&INetwork::terminateConnection)
|
||||
.expect(&INetwork::connectionStatusDisconnected, [] { qDebug() << "DISCONNECTED"; })
|
||||
.expect(&INetwork::connectionStatusChanged, [](INetwork::ConnectionStatus s) { QVERIFY(s == INetwork::Disconnected); qDebug() << "DISCONNECTED"; })
|
||||
.wait(10);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user