From 1bfbe51d89f1589539044856a5fbeb01333e3a33 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sat, 7 Sep 2019 21:55:21 -0500 Subject: [PATCH] Add keepalives for world > login and login > world --- loginserver/world_server.cpp | 8 ++++++++ loginserver/world_server.h | 8 ++++++++ world/login_server.cpp | 9 ++++++++- world/login_server.h | 3 +++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/loginserver/world_server.cpp b/loginserver/world_server.cpp index 0ba78be5f..4a2dfb0bb 100644 --- a/loginserver/world_server.cpp +++ b/loginserver/world_server.cpp @@ -71,6 +71,8 @@ WorldServer::WorldServer(std::shared_ptr wo ServerOP_LSAccountUpdate, std::bind(&WorldServer::ProcessLSAccountUpdate, this, std::placeholders::_1, std::placeholders::_2) ); + + m_keepalive.reset(new EQ::Timer(5000, true, std::bind(&WorldServer::OnKeepAlive, this, std::placeholders::_1))); } WorldServer::~WorldServer() = default; @@ -1230,4 +1232,10 @@ const std::string &WorldServer::GetProtocol() const const std::string &WorldServer::GetVersion() const { return version; +} + +void WorldServer::OnKeepAlive(EQ::Timer *t) +{ + ServerPacket pack(ServerOP_KeepAlive, 0); + connection->SendPacket(&pack); } \ No newline at end of file diff --git a/loginserver/world_server.h b/loginserver/world_server.h index ffd2153cb..60697bc3d 100644 --- a/loginserver/world_server.h +++ b/loginserver/world_server.h @@ -26,6 +26,7 @@ #include "../common/servertalk.h" #include "../common/packet_dump.h" #include "database.h" +#include "../common/event/timer.h" #include #include @@ -180,6 +181,13 @@ private: bool is_server_logged_in; bool is_server_trusted; + /** + * Keepalive + * @param t + */ + void OnKeepAlive(EQ::Timer *t); + std::unique_ptr m_keepalive; + }; #endif diff --git a/world/login_server.cpp b/world/login_server.cpp index 699f12631..76b8298b1 100644 --- a/world/login_server.cpp +++ b/world/login_server.cpp @@ -446,7 +446,6 @@ bool LoginServer::Connect() std::placeholders::_2 ) ); - } else { client.reset(new EQ::Net::ServertalkClient(LoginServerAddress, LoginServerPort, false, "World", "")); @@ -553,6 +552,8 @@ bool LoginServer::Connect() ); } + m_keepalive.reset(new EQ::Timer(5000, true, std::bind(&LoginServer::OnKeepAlive, this, std::placeholders::_1))); + return true; } @@ -643,3 +644,9 @@ void LoginServer::SendAccountUpdate(ServerPacket *pack) SendPacket(pack); } } + +void LoginServer::OnKeepAlive(EQ::Timer *t) +{ + ServerPacket pack(ServerOP_KeepAlive, 0); + SendPacket(&pack); +} \ No newline at end of file diff --git a/world/login_server.h b/world/login_server.h index 3e5116247..a1bb35d7b 100644 --- a/world/login_server.h +++ b/world/login_server.h @@ -53,6 +53,9 @@ private: void ProcessLSRemoteAddr(uint16_t opcode, EQ::Net::Packet &p); void ProcessLSAccountUpdate(uint16_t opcode, EQ::Net::Packet &p); + void OnKeepAlive(EQ::Timer *t); + std::unique_ptr m_keepalive; + std::unique_ptr client; std::unique_ptr legacy_client; std::unique_ptr statusupdate_timer;