diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.cpp b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.cpp index 3c3c4f0664..59446e9889 100644 --- a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.cpp +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.cpp @@ -20,6 +20,8 @@ #include #include #include +#include +#include namespace Multiplayer { @@ -34,9 +36,27 @@ namespace Multiplayer m_networkEditorInterface = AZ::Interface::Get()->CreateNetworkInterface( AZ::Name(MpEditorInterfaceName), ProtocolType::Tcp, TrustZone::ExternalClientToServer, *this); m_networkEditorInterface->SetTimeoutMs(AZ::TimeMs{ 0 }); // Disable timeouts on this network interface - ActivateDedicatedEditorServer(); - } + // Wait to activate the editor-server until LegacySystemInterfaceCreated so that the logging system is ready + // Automated testing listens for these logs + if (editorsv_isDedicated) + { + // If the settings registry is not available at this point, + // then something catastrophic has happened in the application startup. + // That should have been caught and messaged out earlier in startup. + if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr) + { + AZ::ComponentApplicationLifecycle::RegisterHandler( + *settingsRegistry, m_componentApplicationLifecycleHandler, + [this](AZStd::string_view /*path*/, AZ::SettingsRegistryInterface::Type /*type*/) + { + ActivateDedicatedEditorServer(); + }, + "LegacySystemInterfaceCreated"); + } + } + } + void MultiplayerEditorConnection::ActivateDedicatedEditorServer() const { if (m_isActivated || !editorsv_isDedicated) diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.h b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.h index f6510896fe..0c892c847f 100644 --- a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.h +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.h @@ -9,12 +9,9 @@ #pragma once #include - -#include -#include #include -#include #include +#include namespace AzNetworking { @@ -51,5 +48,6 @@ namespace Multiplayer AZStd::vector m_buffer; AZ::IO::ByteContainerStream> m_byteStream; mutable bool m_isActivated = false; + AZ::SettingsRegistryInterface::NotifyEventHandler m_componentApplicationLifecycleHandler; }; }