diff --git a/world/main.cpp b/world/main.cpp index 526f839e5..baffd499d 100644 --- a/world/main.cpp +++ b/world/main.cpp @@ -200,7 +200,7 @@ void RegisterLoginservers() /** * World process entrypoint - * + * * @param argc * @param argv * @return @@ -481,14 +481,19 @@ int main(int argc, char** argv) { zoneserver_list.UpdateUCSServerAvailable(); }); - server_connection->OnConnectionRemoved("UCS", [](std::shared_ptr connection) { - LogInfo("Removed UCS Server connection from [{0}]", - connection->GetUUID()); + server_connection->OnConnectionRemoved( + "UCS", [](std::shared_ptr connection) { + LogInfo("Connection lost from UCS Server [{0}]", connection->GetUUID()); - UCSLink.SetConnection(nullptr); + auto ucs_connection = UCSLink.GetConnection(); - zoneserver_list.UpdateUCSServerAvailable(false); - }); + if (ucs_connection->GetUUID() == connection->GetUUID()) { + LogInfo("Removing currently active UCS connection"); + UCSLink.SetConnection(nullptr); + zoneserver_list.UpdateUCSServerAvailable(false); + } + } + ); server_connection->OnConnectionIdentified("WebInterface", [](std::shared_ptr connection) { LogInfo("New WebInterface Server connection from [{2}] at [{0}:{1}]", diff --git a/world/ucs.cpp b/world/ucs.cpp index cde94b8d9..170e49dea 100644 --- a/world/ucs.cpp +++ b/world/ucs.cpp @@ -19,7 +19,7 @@ void UCSConnection::SetConnection(std::shared_ptrHandle()->Disconnect(); } - + connection = inStream; if (connection) { connection->OnMessage( @@ -32,7 +32,12 @@ void UCSConnection::SetConnection(std::shared_ptr &UCSConnection::GetConnection() const +{ + return connection; } void UCSConnection::ProcessPacket(uint16 opcode, EQ::Net::Packet &p) diff --git a/world/ucs.h b/world/ucs.h index c32872ccb..679229736 100644 --- a/world/ucs.h +++ b/world/ucs.h @@ -16,6 +16,8 @@ public: void SendPacket(ServerPacket* pack); void Disconnect() { if(connection && connection->Handle()) connection->Handle()->Disconnect(); } void SendMessage(const char *From, const char *Message); + const std::shared_ptr &GetConnection() const; + private: inline std::string GetIP() const { return (connection && connection->Handle()) ? connection->Handle()->RemoteIP() : 0; } std::shared_ptr connection;