Fail over to non-SRV master server connection

This will eliminate the connection failure dialog. Instead, the reconnect timer will run indefinitely.
This commit is contained in:
oldmud0 2017-12-29 17:03:24 -06:00
parent 0770c8f5bf
commit 2925c8c891
2 changed files with 28 additions and 4 deletions

View File

@ -34,13 +34,18 @@ void NetworkManager::connect_to_master()
#ifdef MS_FAILOVER_SUPPORTED #ifdef MS_FAILOVER_SUPPORTED
perform_srv_lookup(); perform_srv_lookup();
#else #else
connect_to_master_nosrv();
#endif
}
void NetworkManager::connect_to_master_nosrv()
{
QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)),
this, SLOT(on_ms_connect_error(QAbstractSocket::SocketError))); this, SLOT(on_ms_socket_error(QAbstractSocket::SocketError)));
QObject::connect(ms_socket, SIGNAL(connected()), QObject::connect(ms_socket, SIGNAL(connected()),
this, SLOT(on_ms_nosrv_connect_success())); this, SLOT(on_ms_nosrv_connect_success()));
ms_socket->connectToHost(ms_nosrv_hostname, ms_port); ms_socket->connectToHost(ms_nosrv_hostname, ms_port);
#endif
} }
void NetworkManager::connect_to_server(server_type p_server) void NetworkManager::connect_to_server(server_type p_server)
@ -165,7 +170,12 @@ void NetworkManager::on_srv_lookup()
} }
} }
} }
emit ms_connect_finished(connected, false);
// Failover to non-SRV connection
if (!connected)
connect_to_master_nosrv();
else
emit ms_connect_finished(connected, false);
#endif #endif
} }
@ -173,6 +183,9 @@ void NetworkManager::on_ms_nosrv_connect_success()
{ {
emit ms_connect_finished(true, false); emit ms_connect_finished(true, false);
QObject::disconnect(ms_socket, SIGNAL(connected()),
this, SLOT(on_ms_nosrv_connect_success()));
QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)),
this, SLOT(on_ms_socket_error(QAbstractSocket::SocketError))); this, SLOT(on_ms_socket_error(QAbstractSocket::SocketError)));
} }

View File

@ -8,6 +8,12 @@
#define MS_FAILOVER_SUPPORTED #define MS_FAILOVER_SUPPORTED
#endif #endif
//#define LOCAL_MS
#ifdef LOCAL_MS
#undef MS_FAILOVER_SUPPORTED
#endif
#include "aopacket.h" #include "aopacket.h"
#include "aoapplication.h" #include "aoapplication.h"
@ -31,12 +37,16 @@ public:
QTimer *ms_reconnect_timer; QTimer *ms_reconnect_timer;
const QString ms_srv_hostname = "_aoms._tcp.aceattorneyonline.com"; const QString ms_srv_hostname = "_aoms._tcp.aceattorneyonline.com";
#ifdef LOCAL_MS
const QString ms_nosrv_hostname = "localhost";
#else
const QString ms_nosrv_hostname = "master.aceattorneyonline.com"; const QString ms_nosrv_hostname = "master.aceattorneyonline.com";
#endif
const int ms_port = 27016; const int ms_port = 27016;
const int timeout_milliseconds = 2000; const int timeout_milliseconds = 2000;
const int ms_reconnect_delay_ms = 5000; const int ms_reconnect_delay_ms = 7000;
bool ms_partial_packet = false; bool ms_partial_packet = false;
QString ms_temp_packet = ""; QString ms_temp_packet = "";
@ -47,6 +57,7 @@ public:
unsigned int s_decryptor = 5; unsigned int s_decryptor = 5;
void connect_to_master(); void connect_to_master();
void connect_to_master_nosrv();
void connect_to_server(server_type p_server); void connect_to_server(server_type p_server);
public slots: public slots: