Exemple #1
0
void cRoot::InputThread(cRoot & a_Params)
{
	cLogCommandOutputCallback Output;

	while (a_Params.m_InputThreadRunFlag.test_and_set() && std::cin.good())
	{
		AString Command;
		std::getline(std::cin, Command);
		if (!Command.empty())
		{
			// Execute and clear command string when submitted
			a_Params.ExecuteConsoleCommand(TrimString(Command), Output);
		}
	}

	// We have come here because the std::cin has received an EOF / a terminate signal has been sent, and the server is still running
	// Ignore this when running as a service, cin was never opened in that case
	if (!std::cin.good() && !m_RunAsService)
	{
		// Stop the server:
		a_Params.QueueExecuteConsoleCommand("stop");
	}
}
void cRoot::InputThread(cRoot & a_Params)
{
	cLogCommandOutputCallback Output;
	
	while (!a_Params.m_bStop && !a_Params.m_bRestart && !m_TerminateEventRaised && std::cin.good())
	{
		AString Command;
		std::getline(std::cin, Command);
		if (!Command.empty())
		{
			a_Params.ExecuteConsoleCommand(TrimString(Command), Output);
		}
	}

	if (m_TerminateEventRaised || !std::cin.good())
	{
		// We have come here because the std::cin has received an EOF / a terminate signal has been sent, and the server is still running; stop the server:
		a_Params.m_bStop = true;
	}
}