Added keep alive to relay link for backwards compat with emu_tcp_connection (they disconnect you after about 45 seconds if you don't send keep alives even if the tcp connection is fine...)

This commit is contained in:
KimLS 2016-10-14 21:19:14 -07:00
parent 44b9c99781
commit 23120bcde6
3 changed files with 15 additions and 2 deletions

View File

@ -5,7 +5,8 @@
#include "../servertalk.h"
EQ::Net::RelayLink::RelayLink(const std::string &addr, int port, const std::string &identifier, const std::string &password)
: m_timer(std::unique_ptr<EQ::Timer>(new EQ::Timer(250, true, std::bind(&EQ::Net::RelayLink::Connect, this))))
: m_timer(std::unique_ptr<EQ::Timer>(new EQ::Timer(250, true, std::bind(&EQ::Net::RelayLink::Connect, this)))),
m_keepalive(std::unique_ptr<EQ::Timer>(new EQ::Timer(5000, true, std::bind(&EQ::Net::RelayLink::SendKeepAlive, this))))
{
m_established = false;
m_connecting = false;
@ -224,3 +225,12 @@ void EQ::Net::RelayLink::OnAuthFailed(const EQ::Net::Packet &p)
m_connection->Disconnect();
}
}
void EQ::Net::RelayLink::SendKeepAlive()
{
if (!m_connection)
return;
EQ::Net::WritablePacket p;
SendPacket(0, p);
}

View File

@ -32,8 +32,10 @@ namespace EQ
void SendInternal(const EQ::Net::Packet &p);
void SendPassword();
void OnAuthFailed(const EQ::Net::Packet &p);
void SendKeepAlive();
std::unique_ptr<EQ::Timer> m_timer;
std::unique_ptr<EQ::Timer> m_keepalive;
std::string m_addr;
std::string m_identifier;
std::string m_password;

View File

@ -69,7 +69,7 @@ bool QueryServConnection::Process()
{
struct in_addr in;
in.s_addr = GetIP();
Log.Out(Logs::Detail, Logs::QS_Server, "QueryServ authorization failed.");
Log.Out(Logs::General, Logs::QS_Server, "QueryServ authorization failed.");
auto pack = new ServerPacket(ServerOP_ZAAuthFailed);
SendPacket(pack);
delete pack;
@ -82,6 +82,7 @@ bool QueryServConnection::Process()
Log.Out(Logs::Detail, Logs::QS_Server,"**WARNING** You have not configured a world shared key in your config file. You should add a <key>STRING</key> element to your <world> element to prevent unauthroized zone access.");
authenticated = true;
}
delete pack;
continue;
}