Switch to use the new ComponentApplicationLifecycle system to listen for legacy systems to be ready

Signed-off-by: Gene Walters <genewalt@amazon.com>
monroegm-disable-blank-issue-2
Gene Walters 4 years ago
parent 9532e6c07f
commit 384d631485

@ -25,7 +25,6 @@ ly_add_target(
AZ::AzCore
AZ::AzFramework
AZ::AzNetworking
Legacy::CryCommon
PRIVATE
Gem::EMotionFXStaticLib
Gem::PhysX.Static
@ -144,6 +143,7 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS)
Include
BUILD_DEPENDENCIES
PRIVATE
Legacy::CryCommon
Legacy::Editor.Headers
AZ::AzCore
AZ::AzFramework

@ -21,6 +21,7 @@
#include <AzNetworking/ConnectionLayer/IConnection.h>
#include <AzNetworking/Framework/INetworking.h>
#include <AzCore/Console/IConsole.h>
#include <AzCore/Component/ComponentApplicationLifecycle.h>
namespace Multiplayer
{
@ -35,21 +36,24 @@ namespace Multiplayer
m_networkEditorInterface = AZ::Interface<INetworking>::Get()->CreateNetworkInterface(
AZ::Name(MpEditorInterfaceName), ProtocolType::Tcp, TrustZone::ExternalClientToServer, *this);
m_networkEditorInterface->SetTimeoutMs(AZ::TimeMs{ 0 }); // Disable timeouts on this network interface
CrySystemEventBus::Handler::BusConnect();
}
MultiplayerEditorConnection::~MultiplayerEditorConnection()
{
CrySystemEventBus::Handler::BusDisconnect();
}
void MultiplayerEditorConnection::OnCrySystemInitialized(ISystem&, const SSystemInitParams&)
{
// Wait to activate the editor-server until LegacySystemInterfaceCreated so that the logging system is ready
// Automated testing listens for these logs
if (editorsv_isDedicated)
{
// Wait to activate the editor-server until CrySystemInitialized so that the logging system is ready
// Automated testing listens for these logs
ActivateDedicatedEditorServer();
// 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");
}
}
}

@ -8,10 +8,10 @@
#pragma once
#include <CrySystemBus.h>
#include <Source/AutoGen/MultiplayerEditor.AutoPacketDispatcher.h>
#include <AzCore/IO/ByteContainerStream.h>
#include <AzNetworking/ConnectionLayer/IConnectionListener.h>
#include <AzCore/Settings/SettingsRegistry.h>
namespace AzNetworking
{
@ -23,12 +23,10 @@ namespace Multiplayer
//! MultiplayerEditorConnection is a connection listener to synchronize the Editor and a local server it launches
class MultiplayerEditorConnection final
: public AzNetworking::IConnectionListener
, public CrySystemEventBus::Handler
{
public:
MultiplayerEditorConnection();
~MultiplayerEditorConnection();
~MultiplayerEditorConnection() = default;
bool HandleRequest(AzNetworking::IConnection* connection, const AzNetworking::IPacketHeader& packetHeader, MultiplayerEditorPackets::EditorServerReadyForLevelData& packet);
bool HandleRequest(AzNetworking::IConnection* connection, const AzNetworking::IPacketHeader& packetHeader, MultiplayerEditorPackets::EditorServerLevelData& packet);
@ -42,11 +40,6 @@ namespace Multiplayer
void OnPacketLost([[maybe_unused]]AzNetworking::IConnection* connection, [[maybe_unused]]AzNetworking::PacketId packetId) override {}
void OnDisconnect([[maybe_unused]]AzNetworking::IConnection* connection, [[maybe_unused]]AzNetworking::DisconnectReason reason, [[maybe_unused]]AzNetworking::TerminationEndpoint endpoint) override {}
//! @}
//! CrySystemEvents interface
//! @{
void OnCrySystemInitialized(ISystem&, const SSystemInitParams&) override;
//! @}
private:
void ActivateDedicatedEditorServer() const;
@ -55,5 +48,6 @@ namespace Multiplayer
AZStd::vector<uint8_t> m_buffer;
AZ::IO::ByteContainerStream<AZStd::vector<uint8_t>> m_byteStream;
mutable bool m_isActivated = false;
AZ::SettingsRegistryInterface::NotifyEventHandler m_componentApplicationLifecycleHandler;
};
}

Loading…
Cancel
Save