[FS9] Test connection via FSUIPC in listener

Checking whether the FS2004 host is connected is not enough since we rely
on FSUIPC. Do not activate the simulator if FSUIPC is not available (e.g.
not installed).
This commit is contained in:
Roland Rossgotterer
2019-12-23 18:08:40 +01:00
committed by Mat Sutcliffe
parent b7c2775ea2
commit d29dec81d7
2 changed files with 7 additions and 2 deletions

View File

@@ -474,7 +474,8 @@ namespace BlackSimPlugin
ISimulatorListener(info),
m_timer(new QTimer(this)),
m_fs9Host(fs9Host),
m_lobbyClient(lobbyClient)
m_lobbyClient(lobbyClient),
m_fsuipc(new CFsuipc(this))
{
const int QueryInterval = 5 * 1000; // 5 seconds
m_timer->setInterval(QueryInterval);
@@ -517,6 +518,10 @@ namespace BlackSimPlugin
bool CSimulatorFs9Listener::checkConnection(bool canLobbyConnect)
{
m_fsuipc->open();
if (! m_fsuipc->isOpen()) { return false; }
m_fsuipc->close();
if (m_fs9Host->getHostAddress().isEmpty()) { return false; } // host not yet set up
if (canLobbyConnect)
{
@@ -533,7 +538,6 @@ namespace BlackSimPlugin
m_isConnecting = false;
emit this->simulatorStarted(this->getPluginInfo());
}
return m_isConnecting;
}

View File

@@ -148,6 +148,7 @@ namespace BlackSimPlugin
bool m_isStarted = false;
QSharedPointer<CFs9Host> m_fs9Host;
QSharedPointer<CLobbyClient> m_lobbyClient;
FsCommon::CFsuipc *m_fsuipc = nullptr;
};
//! Factory implementation to create CSimulatorFs9 instances