/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
release-24.9
Code/Tools/Fileserve/App.cpp
89 строк
3 KB
Jan Krassnigg
Some ezFoundation changes (#1317)
04 июн 2024, 13:15
Не верифицирован
04 июн 2024, 13:15
ded6365
Код
Авторство
О чём код?
#include <Fileserve/FileservePCH.h> #include <Fileserve/Fileserve.h> #include <FileservePlugin/Fileserver/Fileserver.h> #include <Foundation/IO/FileSystem/DataDirTypeFolder.h> #include <Foundation/IO/FileSystem/FileSystem.h> #include <Foundation/Logging/ConsoleWriter.h> #include <Foundation/Logging/Log.h> #include <Foundation/Logging/VisualStudioWriter.h> #include <Foundation/Utilities/CommandLineUtils.h> void ezFileserverApp::AfterCoreSystemsStartup() { ezGlobalLog::AddLogWriter(ezLogWriter::Console::LogMessageHandler); ezGlobalLog::AddLogWriter(ezLogWriter::VisualStudio::LogMessageHandler); // Add the empty data directory to access files via absolute paths ezFileSystem::AddDataDirectory("", "App", ":", ezDataDirUsage::AllowWrites).IgnoreResult(); EZ_DEFAULT_NEW(ezFileserver); ezFileserver::GetSingleton()->m_Events.AddEventHandler(ezMakeDelegate(&ezFileserverApp::FileserverEventHandler, this)); #ifndef EZ_USE_QT ezFileserver::GetSingleton()->m_Events.AddEventHandler(ezMakeDelegate(&ezFileserverApp::FileserverEventHandlerConsole, this)); ezFileserver::GetSingleton()->StartServer(); #endif ezPlugin::LoadPlugin("ezShaderCompilerDXC", ezPluginLoadFlags::PluginIsOptional).IgnoreResult(); ezPlugin::LoadPlugin("ezShaderCompilerHLSL", ezPluginLoadFlags::PluginIsOptional).IgnoreResult(); ezFileserver::GetSingleton()->SetCustomMessageHandler('SHDR', ezMakeDelegate(&ezFileserverApp::ShaderMessageHandler, this)); // TODO: CommandLine Option m_CloseAppTimeout = ezTime::MakeFromSeconds(ezCommandLineUtils::GetGlobalInstance()->GetIntOption("-fs_close_timeout", 0)); m_TimeTillClosing = ezTime::MakeFromSeconds(ezCommandLineUtils::GetGlobalInstance()->GetIntOption("-fs_wait_timeout", 0)); if (m_TimeTillClosing.GetSeconds() > 0) { m_TimeTillClosing += ezTime::Now(); } } void ezFileserverApp::BeforeCoreSystemsShutdown() { ezFileserver::GetSingleton()->StopServer(); #ifndef EZ_USE_QT ezFileserver::GetSingleton()->m_Events.RemoveEventHandler(ezMakeDelegate(&ezFileserverApp::FileserverEventHandlerConsole, this)); #endif ezFileserver::GetSingleton()->m_Events.RemoveEventHandler(ezMakeDelegate(&ezFileserverApp::FileserverEventHandler, this)); ezGlobalLog::RemoveLogWriter(ezLogWriter::Console::LogMessageHandler); ezGlobalLog::RemoveLogWriter(ezLogWriter::VisualStudio::LogMessageHandler); SUPER::BeforeCoreSystemsShutdown(); } ezApplication::Execution ezFileserverApp::Run() { // if there are no more connections, and we have a timeout to close when no connections are left, we return Quit if (m_uiConnections == 0 && m_TimeTillClosing > ezTime::MakeFromSeconds(0) && ezTime::Now() > m_TimeTillClosing) { return ezApplication::Execution::Quit; } if (ezFileserver::GetSingleton()->UpdateServer() == false) { m_uiSleepCounter++; if (m_uiSleepCounter > 1000) { // only sleep when no work had to be done in a while ezThreadUtils::Sleep(ezTime::MakeFromMilliseconds(10)); } else if (m_uiSleepCounter > 10) { // only sleep when no work had to be done in a while ezThreadUtils::Sleep(ezTime::MakeFromMilliseconds(1)); } } else { m_uiSleepCounter = 0; } return ezApplication::Execution::Continue; }