added restart maniacontrol communication method
This commit is contained in:
parent
2f25069845
commit
abaeb24d96
@ -10,7 +10,15 @@ namespace ManiaControl\Communication;
|
|||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
interface CommunicationMethods {
|
interface CommunicationMethods {
|
||||||
/** Returns the last 200 lines of the chat (inclusive player logins and nicknames) */
|
/** Restarts Mania Control
|
||||||
|
* Optional Params
|
||||||
|
* - message
|
||||||
|
*/
|
||||||
|
const RESTART_MANIA_CONTROL = "ManiaControl.Restart";
|
||||||
|
|
||||||
|
/** Returns the last 200 lines of the chat (inclusive player logins and nicknames)
|
||||||
|
* No Params
|
||||||
|
*/
|
||||||
const GET_SERVER_CHAT = "Chat.GetServerChat";
|
const GET_SERVER_CHAT = "Chat.GetServerChat";
|
||||||
|
|
||||||
/** Sends a ChatMessage to the Server
|
/** Sends a ChatMessage to the Server
|
||||||
|
@ -13,6 +13,9 @@ use ManiaControl\Callbacks\TimerListener;
|
|||||||
use ManiaControl\Callbacks\TimerManager;
|
use ManiaControl\Callbacks\TimerManager;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\Commands\CommandManager;
|
use ManiaControl\Commands\CommandManager;
|
||||||
|
use ManiaControl\Communication\CommunicationListener;
|
||||||
|
use ManiaControl\Communication\CommunicationManager;
|
||||||
|
use ManiaControl\Communication\CommunicationMethods;
|
||||||
use ManiaControl\Configurator\Configurator;
|
use ManiaControl\Configurator\Configurator;
|
||||||
use ManiaControl\Database\Database;
|
use ManiaControl\Database\Database;
|
||||||
use ManiaControl\Files\AsynchronousFileReader;
|
use ManiaControl\Files\AsynchronousFileReader;
|
||||||
@ -24,7 +27,6 @@ use ManiaControl\Players\PlayerManager;
|
|||||||
use ManiaControl\Plugins\PluginManager;
|
use ManiaControl\Plugins\PluginManager;
|
||||||
use ManiaControl\Server\Server;
|
use ManiaControl\Server\Server;
|
||||||
use ManiaControl\Settings\SettingManager;
|
use ManiaControl\Settings\SettingManager;
|
||||||
use ManiaControl\Communication\CommunicationManager;
|
|
||||||
use ManiaControl\Statistics\StatisticManager;
|
use ManiaControl\Statistics\StatisticManager;
|
||||||
use ManiaControl\Update\UpdateManager;
|
use ManiaControl\Update\UpdateManager;
|
||||||
use ManiaControl\Utils\CommandLineHelper;
|
use ManiaControl\Utils\CommandLineHelper;
|
||||||
@ -40,7 +42,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\TransportException;
|
|||||||
* @copyright 2014-2015 ManiaControl Team
|
* @copyright 2014-2015 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class ManiaControl implements CallbackListener, CommandListener, TimerListener {
|
class ManiaControl implements CallbackListener, CommandListener, TimerListener, CommunicationListener {
|
||||||
/*
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -216,6 +218,18 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
|
|||||||
|
|
||||||
// Check connection every 30 seconds
|
// Check connection every 30 seconds
|
||||||
$this->getTimerManager()->registerTimerListening($this, 'checkConnection', 1000 * 30);
|
$this->getTimerManager()->registerTimerListening($this, 'checkConnection', 1000 * 30);
|
||||||
|
|
||||||
|
// Communication Methods
|
||||||
|
$this->getCommunicationManager()->registerCommunicationListener(CommunicationMethods::RESTART_MANIA_CONTROL, $this, function ($data) {
|
||||||
|
//Delay Shutdown to send answer first
|
||||||
|
$this->getTimerManager()->registerOneTimeListening($this, function () use ($data) {
|
||||||
|
if (is_object($data) && property_exists($data, "message")) {
|
||||||
|
$this->restart($data->message);
|
||||||
|
}
|
||||||
|
$this->restart();
|
||||||
|
}, 5000);
|
||||||
|
return array("error" => false, "data" => "");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user