2014-04-24 17:41:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl\Callbacks;
|
|
|
|
|
2014-10-10 16:19:46 +02:00
|
|
|
use ManiaControl\Callbacks\Structures\ArmorEmptyStructure;
|
|
|
|
use ManiaControl\Callbacks\Structures\CaptureStructure;
|
2017-04-13 16:12:10 +02:00
|
|
|
use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure;
|
|
|
|
use ManiaControl\Callbacks\Structures\Common\StatusCallbackStructure;
|
|
|
|
use ManiaControl\Callbacks\Structures\ManiaPlanet\LoadingUnloadingMapStructure;
|
|
|
|
use ManiaControl\Callbacks\Structures\ManiaPlanet\ModeUseTeamsStructure;
|
2017-03-24 17:08:27 +01:00
|
|
|
use ManiaControl\Callbacks\Structures\ManiaPlanet\StartEndStructure;
|
2017-03-24 16:49:54 +01:00
|
|
|
use ManiaControl\Callbacks\Structures\ManiaPlanet\StartServerStructure;
|
2014-10-10 16:19:46 +02:00
|
|
|
use ManiaControl\Callbacks\Structures\NearMissStructure;
|
2014-10-10 14:40:00 +02:00
|
|
|
use ManiaControl\Callbacks\Structures\PlayerHitStructure;
|
2017-04-07 23:03:56 +02:00
|
|
|
use ManiaControl\Callbacks\Structures\XmlRpc\AllApiVersionsStructure;
|
|
|
|
use ManiaControl\Callbacks\Structures\XmlRpc\ApiVersionStructure;
|
|
|
|
use ManiaControl\Callbacks\Structures\XmlRpc\CallbackHelpStructure;
|
|
|
|
use ManiaControl\Callbacks\Structures\XmlRpc\CallbackListStructure;
|
|
|
|
use ManiaControl\Callbacks\Structures\XmlRpc\DocumentationStructure;
|
|
|
|
use ManiaControl\Callbacks\Structures\XmlRpc\MethodHelpStructure;
|
|
|
|
use ManiaControl\Callbacks\Structures\XmlRpc\MethodListStructure;
|
2014-04-24 17:41:05 +02:00
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
|
2014-05-02 16:13:45 +02:00
|
|
|
/**
|
2014-05-13 01:18:47 +02:00
|
|
|
* Class converting LibXmlRpc Callbacks
|
2014-05-02 16:13:45 +02:00
|
|
|
*
|
2014-05-02 17:50:30 +02:00
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
2020-01-22 10:39:35 +01:00
|
|
|
* @copyright 2014-2020 ManiaControl Team
|
2014-05-02 17:50:30 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2014-05-02 16:13:45 +02:00
|
|
|
*/
|
2014-05-13 01:18:47 +02:00
|
|
|
class LibXmlRpcCallbacks implements CallbackListener {
|
2014-04-24 17:41:05 +02:00
|
|
|
/*
|
2014-08-02 22:31:46 +02:00
|
|
|
* Private properties
|
2014-04-24 17:41:05 +02:00
|
|
|
*/
|
2014-08-02 22:31:46 +02:00
|
|
|
/** @var ManiaControl $maniaControl */
|
2014-04-24 17:41:05 +02:00
|
|
|
private $maniaControl = null;
|
|
|
|
|
|
|
|
/**
|
2014-04-24 21:55:47 +02:00
|
|
|
* Create a new LibXmlRpc Callbacks Instance
|
2014-04-24 17:41:05 +02:00
|
|
|
*
|
2014-05-02 17:50:30 +02:00
|
|
|
* @param ManiaControl $maniaControl
|
2014-05-02 16:13:45 +02:00
|
|
|
* @param CallbackManager $callbackManager
|
2014-04-24 17:41:05 +02:00
|
|
|
*/
|
|
|
|
public function __construct(ManiaControl $maniaControl, CallbackManager $callbackManager) {
|
|
|
|
$this->maniaControl = $maniaControl;
|
2014-05-13 01:18:47 +02:00
|
|
|
|
|
|
|
$callbackManager->registerCallbackListener(Callbacks::SCRIPTCALLBACK, $this, 'handleScriptCallback');
|
2014-04-24 17:41:05 +02:00
|
|
|
}
|
|
|
|
|
2014-04-24 23:11:09 +02:00
|
|
|
/**
|
2014-05-13 01:18:47 +02:00
|
|
|
* Handle the Script Callback
|
2014-04-24 23:11:09 +02:00
|
|
|
*
|
2014-05-02 16:13:45 +02:00
|
|
|
* @param string $name
|
2014-05-03 21:12:44 +02:00
|
|
|
* @param mixed $data
|
2014-04-24 23:11:09 +02:00
|
|
|
*/
|
2014-05-13 01:18:47 +02:00
|
|
|
public function handleScriptCallback($name, $data) {
|
2017-07-17 14:40:52 +02:00
|
|
|
//Internal Callbacks always triggered
|
|
|
|
switch($name){
|
|
|
|
case 'Maniaplanet.StartMap_Start': //Use the MapManager Callback
|
|
|
|
//No use for this Implementation right now (as the MapManager Callback should be used
|
|
|
|
break;
|
|
|
|
case 'Maniaplanet.StartMap_End': //Use the MapManager Callback
|
2020-08-02 18:30:44 +02:00
|
|
|
// $jsonData = json_decode($data[0]);
|
|
|
|
// $this->maniaControl->getMapManager()->handleScriptBeginMap($jsonData->map->uid, $jsonData->restarted);
|
2017-07-17 14:40:52 +02:00
|
|
|
break;
|
|
|
|
case 'Maniaplanet.EndMap_Start':
|
|
|
|
//no need for this implementation, callback handled by Map Manager
|
|
|
|
break;
|
|
|
|
case 'Maniaplanet.EndMap_End': //Use the MapManager Callback
|
2020-08-02 18:30:44 +02:00
|
|
|
// $this->maniaControl->getMapManager()->handleScriptEndMap(); //Verify if better here or at EndMap_End
|
2017-07-17 14:40:52 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-03-25 13:57:42 +01:00
|
|
|
if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) {
|
2017-05-10 11:07:45 +02:00
|
|
|
return; //Leave that disabled while testing/implementing Callbacks
|
2017-03-25 13:40:37 +01:00
|
|
|
}
|
2014-05-02 17:50:30 +02:00
|
|
|
switch ($name) {
|
2017-03-22 18:10:21 +01:00
|
|
|
//New callbacks
|
2017-03-25 13:57:42 +01:00
|
|
|
case Callbacks::XMLRPC_CALLBACKSLIST:
|
2017-04-07 18:30:48 +02:00
|
|
|
case Callbacks::XMLRPC_ENABLEDCALLBACKS:
|
|
|
|
case Callbacks::XMLRPC_DISABLEDCALLBACKS:
|
2017-04-07 23:03:56 +02:00
|
|
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new CallbackListStructure($this->maniaControl, $data));
|
|
|
|
break;
|
|
|
|
case Callbacks::XMLRPC_CALLBACKHELP:
|
|
|
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new CallbackHelpStructure($this->maniaControl, $data));
|
2017-04-07 18:30:48 +02:00
|
|
|
break;
|
|
|
|
case Callbacks::XMLRPC_APIVERSION:
|
2017-04-07 23:03:56 +02:00
|
|
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new ApiVersionStructure($this->maniaControl, $data));
|
2017-04-07 18:30:48 +02:00
|
|
|
break;
|
|
|
|
case Callbacks::XMLRPC_ALLAPIVERSIONS:
|
2017-04-07 23:03:56 +02:00
|
|
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new AllApiVersionsStructure($this->maniaControl, $data));
|
2017-04-07 18:30:48 +02:00
|
|
|
break;
|
|
|
|
case Callbacks::XMLRPC_DOCUMENTATION:
|
2017-04-07 23:03:56 +02:00
|
|
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new DocumentationStructure($this->maniaControl, $data));
|
2017-04-07 18:30:48 +02:00
|
|
|
break;
|
|
|
|
case Callbacks::XMLRPC_METHODSLIST:
|
2017-04-07 23:03:56 +02:00
|
|
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new MethodListStructure($this->maniaControl, $data));
|
2017-04-07 18:30:48 +02:00
|
|
|
break;
|
|
|
|
case Callbacks::XMLRPC_METHODHELP:
|
2017-04-07 23:03:56 +02:00
|
|
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new MethodHelpStructure($this->maniaControl, $data));
|
2017-03-24 17:08:27 +01:00
|
|
|
break;
|
2017-03-25 13:57:42 +01:00
|
|
|
case Callbacks::MP_STARTMATCHEND:
|
2017-04-07 23:03:56 +02:00
|
|
|
case Callbacks::MP_STARTMATCHSTART:
|
2017-03-25 13:57:42 +01:00
|
|
|
case Callbacks::MP_STARTROUNDSTART:
|
|
|
|
case Callbacks::MP_STARTROUNDEND:
|
|
|
|
case Callbacks::MP_STARTTURNSTART:
|
|
|
|
case Callbacks::MP_STARTTURNEND:
|
|
|
|
case Callbacks::MP_STARTPLAYLOOP:
|
|
|
|
case Callbacks::MP_ENDPLAYLOOP:
|
|
|
|
case Callbacks::MP_ENDTURNSTART:
|
|
|
|
case Callbacks::MP_ENDTURNEND:
|
|
|
|
case Callbacks::MP_ENDROUNDSTART:
|
|
|
|
case Callbacks::MP_ENDROUNDEND:
|
2017-04-07 23:03:56 +02:00
|
|
|
case Callbacks::MP_ENDMATCHSTART:
|
|
|
|
case Callbacks::MP_ENDMATCHEND:
|
|
|
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new StartEndStructure($this->maniaControl, $data));
|
|
|
|
break;
|
|
|
|
case Callbacks::MP_STARTSERVERSTART:
|
|
|
|
case Callbacks::MP_STARTSERVEREND:
|
2017-03-25 13:57:42 +01:00
|
|
|
case Callbacks::MP_ENDSERVERSTART:
|
|
|
|
case Callbacks::MP_ENDSERVEREND:
|
2017-04-07 23:03:56 +02:00
|
|
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new StartServerStructure($this->maniaControl, $data));
|
2017-03-24 22:08:51 +01:00
|
|
|
break;
|
2017-03-25 13:57:42 +01:00
|
|
|
case Callbacks::MP_LOADINGMAPEND:
|
|
|
|
case Callbacks::MP_UNLOADINGMAPSTART:
|
2017-04-13 16:12:10 +02:00
|
|
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new LoadingUnloadingMapStructure($this->maniaControl, $data));
|
2017-03-24 22:08:51 +01:00
|
|
|
break;
|
2017-04-07 23:03:56 +02:00
|
|
|
case Callbacks::MP_LOADINGMAPSTART:
|
2017-03-25 13:57:42 +01:00
|
|
|
case Callbacks::MP_UNLOADINGMAPEND:
|
|
|
|
case Callbacks::MP_PODIUMSTART:
|
2017-03-25 19:15:50 +01:00
|
|
|
case Callbacks::MP_PODIUMEND:
|
2017-04-13 16:12:10 +02:00
|
|
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new BaseTimeStructure($this->maniaControl, $data));
|
|
|
|
break;
|
2017-04-07 17:28:04 +02:00
|
|
|
case Callbacks::MP_WARMUP_START:
|
|
|
|
case Callbacks::MP_WARMUP_END:
|
2017-04-07 23:03:56 +02:00
|
|
|
$this->maniaControl->getCallbackManager()->triggerCallback($name);
|
2017-04-07 17:28:04 +02:00
|
|
|
break;
|
|
|
|
case Callbacks::MP_WARMUP_STATUS:
|
2017-04-13 16:12:10 +02:00
|
|
|
case Callbacks::MP_PAUSE_STATUS:
|
2017-04-07 23:03:56 +02:00
|
|
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new StatusCallbackStructure($this->maniaControl, $data));
|
2017-04-07 17:28:04 +02:00
|
|
|
break;
|
2017-04-13 16:12:10 +02:00
|
|
|
case Callbacks::MP_USES_TEAMMODE:
|
|
|
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new ModeUseTeamsStructure($this->maniaControl, $data));
|
|
|
|
break;
|
2014-04-24 17:41:05 +02:00
|
|
|
}
|
|
|
|
}
|
2017-05-09 11:05:19 +02:00
|
|
|
|
2014-05-13 01:18:47 +02:00
|
|
|
}
|