improved mc quit handling

This commit is contained in:
Steffen Schröder 2014-06-20 16:34:19 +02:00
parent f4681da6c5
commit 51e2fde2b0
2 changed files with 16 additions and 7 deletions

View File

@ -89,7 +89,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
/*
* Private Properties
*/
private $shutdownRequested = false;
private $requestQuitMessage = null;
/**
* Construct ManiaControl
@ -280,7 +280,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
$this->authenticationManager->sendNotAllowed($player);
return;
}
$this->quit("ManiaControl Shutdown requested by '{$player->login}'!");
$this->requestQuit("ManiaControl Shutdown requested by '{$player->login}'!");
}
/**
@ -317,12 +317,12 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
$this->chat->sendInformation('ManiaControl v' . self::VERSION . ' successfully started!');
// Main loop
while (!$this->shutdownRequested) {
while (!$this->requestQuitMessage) {
$this->loop();
}
// Shutdown
$this->quit();
$this->quit($this->requestQuitMessage);
}
/**
@ -399,6 +399,15 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
* Handle Server Stop Callback
*/
public function handleServerStopCallback() {
$this->quit('The Server has been shut down!');
$this->requestQuit('The Server has been shut down!');
}
/**
* Request ManiaControl to quit
*
* @param mixed $message
*/
public function requestQuit($message = true) {
$this->requestQuitMessage = $message;
}
}

View File

@ -233,9 +233,9 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
*
* @param string $login
*/
private function shutdownServer($login = '#') {
private function shutdownServer($login = '-') {
$this->maniaControl->log("Server shutdown requested by '{$login}'!");
$this->maniaControl->client->stopServer();
$this->maniaControl->quit("Server shutdown requested by '{$login}'");
}
/**