mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Added check if network connection can be established
as discussed in #101
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "context_network.h"
|
#include "context_network.h"
|
||||||
#include "coreruntime.h"
|
#include "coreruntime.h"
|
||||||
|
#include "blackmisc/networkchecks.h"
|
||||||
#include "blackmisc/avatcstationlist.h"
|
#include "blackmisc/avatcstationlist.h"
|
||||||
#include "blackcore/context_settings_interface.h"
|
#include "blackcore/context_settings_interface.h"
|
||||||
#include <QtXml/QDomElement>
|
#include <QtXml/QDomElement>
|
||||||
@@ -107,17 +108,26 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
INetwork::LoginMode mode = static_cast<INetwork::LoginMode>(loginMode);
|
QString msg;
|
||||||
this->m_ownAircraft.setPilot(currentServer.getUser()); // still needed?
|
if (CNetworkChecks::canConnect(currentServer, msg, 2000))
|
||||||
this->m_network->presetServer(currentServer);
|
{
|
||||||
this->m_network->presetLoginMode(mode);
|
INetwork::LoginMode mode = static_cast<INetwork::LoginMode>(loginMode);
|
||||||
this->m_network->presetCallsign(this->m_ownAircraft.getCallsign());
|
this->m_ownAircraft.setPilot(currentServer.getUser()); // still needed?
|
||||||
this->m_network->presetIcaoCodes(this->m_ownAircraft.getIcaoInfo());
|
this->m_network->presetServer(currentServer);
|
||||||
this->m_network->setOwnAircraft(this->m_ownAircraft);
|
this->m_network->presetLoginMode(mode);
|
||||||
this->m_network->initiateConnection();
|
this->m_network->presetCallsign(this->m_ownAircraft.getCallsign());
|
||||||
QString msg = "Connection pending ";
|
this->m_network->presetIcaoCodes(this->m_ownAircraft.getIcaoInfo());
|
||||||
msg.append(" ").append(currentServer.getAddress()).append(" ").append(QString::number(currentServer.getPort()));
|
this->m_network->setOwnAircraft(this->m_ownAircraft);
|
||||||
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityInfo, msg));
|
this->m_network->initiateConnection();
|
||||||
|
msg = "Connection pending ";
|
||||||
|
msg.append(" ").append(currentServer.getAddress()).append(" ").append(QString::number(currentServer.getPort()));
|
||||||
|
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityInfo, msg));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// I cannot connect, add error message
|
||||||
|
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityError, msg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return msgs;
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user