From 4b61d00dfe9a4ab789d7564a785d612577e39940 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sat, 7 Sep 2019 20:20:10 -0500 Subject: [PATCH] Implement Zone -> World keepalive so that Zone reconnects to world in the case of a world crash / reset --- zone/worldserver.cpp | 10 +++++++++- zone/worldserver.h | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index 97d02cc1f..1ed7d4998 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -85,6 +85,8 @@ void WorldServer::Connect() }); m_connection->OnMessage(std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2)); + + m_keepalive.reset(new EQ::Timer(2500, true, std::bind(&WorldServer::OnKeepAlive, this, std::placeholders::_1))); } bool WorldServer::SendPacket(ServerPacket *pack) @@ -563,7 +565,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) ServerZoneDropClient_Struct* drop = (ServerZoneDropClient_Struct*)pack->pBuffer; if (zone) { zone->RemoveAuth(drop->lsid); - + auto client = entity_list.GetClientByLSID(drop->lsid); if (client) { client->Kick("Dropped by world CLE subsystem"); @@ -2352,3 +2354,9 @@ void WorldServer::RequestTellQueue(const char *who) safe_delete(pack); return; } + +void WorldServer::OnKeepAlive(EQ::Timer *t) +{ + ServerPacket pack(ServerOP_KeepAlive, 0); + SendPacket(&pack); +} diff --git a/zone/worldserver.h b/zone/worldserver.h index 4c1b9ab12..1eee0b948 100644 --- a/zone/worldserver.h +++ b/zone/worldserver.h @@ -72,7 +72,10 @@ private: uint32 cur_groupid; uint32 last_groupid; + void OnKeepAlive(EQ::Timer *t); + std::unique_ptr m_connection; + std::unique_ptr m_keepalive; }; #endif