Prevent old/bad "backup MS" values from preventing connection
This commit is contained in:
parent
ee76c2ce61
commit
5d79a83fb5
@ -22,15 +22,16 @@ class NetworkManager : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NetworkManager(AOApplication *parent);
|
||||
~NetworkManager();
|
||||
explicit NetworkManager(AOApplication *parent);
|
||||
~NetworkManager() = default;
|
||||
|
||||
AOApplication *ao_app;
|
||||
QNetworkAccessManager *http;
|
||||
QTcpSocket *server_socket;
|
||||
QTimer *heartbeat_timer;
|
||||
|
||||
QString ms_baseurl = "https://servers.aceattorneyonline.com";
|
||||
const QString DEFAULT_MS_BASEURL = "https://servers.aceattorneyonline.com";
|
||||
QString ms_baseurl = DEFAULT_MS_BASEURL;
|
||||
|
||||
const int heartbeat_interval = 60 * 5;
|
||||
|
||||
|
@ -382,10 +382,9 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app)
|
||||
|
||||
row += 1;
|
||||
ui_ms_lbl = new QLabel(ui_form_layout_widget);
|
||||
ui_ms_lbl->setText(tr("Backup MS:"));
|
||||
ui_ms_lbl->setText(tr("Alternate Server List:"));
|
||||
ui_ms_lbl->setToolTip(
|
||||
tr("If the built-in server lookups fail, the game will try the "
|
||||
"address given here and use it as a backup master server address."));
|
||||
tr("Overrides the base URL to retrieve server information from."));
|
||||
|
||||
ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_ms_lbl);
|
||||
|
||||
|
@ -23,15 +23,15 @@ NetworkManager::NetworkManager(AOApplication *parent) : QObject(parent)
|
||||
|
||||
QString master_config =
|
||||
ao_app->configini->value("master", "").value<QString>();
|
||||
if (!master_config.isEmpty())
|
||||
if (!master_config.isEmpty() && QUrl(master_config).scheme().startsWith("http")) {
|
||||
qInfo() << "using alternate master server" << master_config;
|
||||
ms_baseurl = master_config;
|
||||
}
|
||||
|
||||
connect(heartbeat_timer, &QTimer::timeout, this, &NetworkManager::send_heartbeat);
|
||||
heartbeat_timer->start(heartbeat_interval);
|
||||
}
|
||||
|
||||
NetworkManager::~NetworkManager() {}
|
||||
|
||||
void NetworkManager::get_server_list(const std::function<void()> &cb)
|
||||
{
|
||||
QNetworkRequest req(QUrl(ms_baseurl + "/servers"));
|
||||
@ -120,7 +120,8 @@ void NetworkManager::request_document(MSDocumentType document_type,
|
||||
<< "Failed to get " << endpoint << " (" << reply->errorString() << ") "
|
||||
<< "(http status " << http_status << ")";
|
||||
content = QString();
|
||||
} cb(content);
|
||||
}
|
||||
cb(content);
|
||||
reply->deleteLater();
|
||||
});
|
||||
}
|
||||
@ -130,6 +131,9 @@ void NetworkManager::connect_to_server(server_type p_server)
|
||||
server_socket->close();
|
||||
server_socket->abort();
|
||||
|
||||
qInfo().nospace().noquote() << "connecting to " << p_server.ip << ":"
|
||||
<< p_server.port;
|
||||
|
||||
server_socket->connectToHost(p_server.ip, p_server.port);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user