added direct invoke callback for methods

This commit is contained in:
kremsy
2017-04-07 18:30:48 +02:00
parent 6ad6768caa
commit 067536458e
8 changed files with 256 additions and 76 deletions

View File

@ -30,7 +30,15 @@ interface Callbacks {
*/
//NEW Callbacks
const XMLRPC_CALLBACKSLIST = 'XmlRpc.CallbacksList';
const XMLRPC_CALLBACKSLIST = 'XmlRpc.CallbacksList';
const XMLRPC_ENABLEDCALLBACKS = 'XmlRpc.CallbacksList_Enabled';
const XMLRPC_DISABLEDCALLBACKS = 'XmlRpc.CallbacksList_Disabled';
const XMLRPC_CALLBACKHELP = 'XmlRpc.CallbackHelp';
const XMLRPC_METHODSLIST = 'XmlRpc.MethodsList';
const XMLRPC_METHODHELP = 'XmlRpc.MethodHelp';
const XMLRPC_DOCUMENTATION = 'XmlRpc.MethodHelp';
const XMLRPC_APIVERSION = 'XmlRpc.ApiVersion';
const XMLRPC_ALLAPIVERSIONS = 'XmlRpc.AllApiVersions';
const MP_STARTSERVERSTART = 'Maniaplanet.StartServer_Start';
const MP_STARTSERVEREND = 'Maniaplanet.StartServer_End';
@ -61,11 +69,12 @@ interface Callbacks {
const MP_PODIUMSTART = 'Maniaplanet.Podium_Start';
const MP_PODIUMEND = 'Maniaplanet.Podium_End';
const MP_WARMUP_START = 'Maniaplanet.WarmUp.Start';
const MP_WARMUP_END = 'Maniaplanet.WarmUp.End';
const MP_WARMUP_START = 'Maniaplanet.WarmUp.Start';
const MP_WARMUP_END = 'Maniaplanet.WarmUp.End';
const MP_WARMUP_STATUS = 'Maniaplanet.WarmUp.Status';
const SM_SCORES = "Shootmania.Scores";
const SM_UIPROPERTIES = 'Shootmania.UIProperties';
const SM_SCORES = "Shootmania.Scores";
const SM_ONEVENTDEFAULT = "Shootmania.Event.Default";
const SM_ONSHOOT = "Shootmania.Event.OnShoot";
@ -86,15 +95,15 @@ interface Callbacks {
const SM_ONPLAYERREQUESTACTIONCHANGE = "Shootmania.Event.OnPlayerRequestActionChange";
//SM GameMode Callbacks
const SM_COMBO_PAUSE = 'Shootmania.Combo.Pause';
const SM_ELITE_STARTTURN = 'Shootmania.Elite.StartTurn';
const SM_ELITE_ENDTURN = 'Shootmania.Elite.EndTurn';
const SM_JOUST_ONRELOAD = 'Shootmania.Joust.OnReload';
const SM_COMBO_PAUSESTATUS = 'Shootmania.Combo.Pause';
const SM_ELITE_STARTTURN = 'Shootmania.Elite.StartTurn';
const SM_ELITE_ENDTURN = 'Shootmania.Elite.EndTurn';
const SM_JOUST_ONRELOAD = 'Shootmania.Joust.OnReload';
const SM_JOUST_SELECTEDPLAYERS = 'Shootmania.Joust.SelectedPlayers';
const SM_JOUST_ROUNDRESULT = 'Shootmania.Joust.RoundResult';
const SM_ROYAL_POINTS = 'Shootmania.Royal.Points';
const SM_ROYAL_PLAYERSPAWN = 'Shootmania.Royal.PlayerSpawn';
const SM_ROYAL_ROUNDWINNER = 'Shootmania.Royal.RoundWinner';
const SM_JOUST_ROUNDRESULT = 'Shootmania.Joust.RoundResult';
const SM_ROYAL_POINTS = 'Shootmania.Royal.Points';
const SM_ROYAL_PLAYERSPAWN = 'Shootmania.Royal.PlayerSpawn';
const SM_ROYAL_ROUNDWINNER = 'Shootmania.Royal.RoundWinner';
// New TM Callbacks
const TM_ONEVENTDEFAULT = "Trackmania.Event.Default";
@ -113,6 +122,10 @@ interface Callbacks {
const TM_WARMUPENDROUND = "Trackmania.WarmUp.EndRound";
const TM_WARMUPEND = "Trackmania.WarmUp.End";
const TM_UIPROPERTIES = 'Trackmania.UIProperties';
const TM_POINTSREPARTITION = 'Trackmania.PointsRepartition';
//ManiaControl Callbacks
/** BeginMap Callback: Map */
const BEGINMAP = 'Callbacks.BeginMap';

View File

@ -52,6 +52,27 @@ class LibXmlRpcCallbacks implements CallbackListener {
case Callbacks::XMLRPC_CALLBACKSLIST:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_CALLBACKSLIST, new CallbacksListStructure($this->maniaControl, $data));
break;
case Callbacks::XMLRPC_ENABLEDCALLBACKS:
//TODO
break;
case Callbacks::XMLRPC_DISABLEDCALLBACKS:
//TODO
break;
case Callbacks::XMLRPC_APIVERSION:
//TODO
break;
case Callbacks::XMLRPC_ALLAPIVERSIONS:
//TODO
break;
case Callbacks::XMLRPC_DOCUMENTATION:
//TODO
break;
case Callbacks::XMLRPC_METHODSLIST:
//TODO
break;
case Callbacks::XMLRPC_METHODHELP:
//TODO
break;
case Callbacks::MP_STARTSERVERSTART:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTSERVERSTART, new StartServerStructure($this->maniaControl, $data));
break;

View File

@ -71,7 +71,9 @@ class ShootManiaCallbacks implements CallbackListener {
case Callbacks::SM_SCORES:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_SCORES, new OnScoresStructure($this->maniaControl, $data));
break;
//TODO UI Properties Later
case Callbacks::SM_UIPROPERTIES:
//TODO
break;
case Callbacks::SM_ONEVENTDEFAULT:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONEVENTDEFAULT, new OnDefaultEventStructure($this->maniaControl, $data));
break;
@ -117,7 +119,7 @@ class ShootManiaCallbacks implements CallbackListener {
case Callbacks::SM_ONPLAYERREQUESTACTIONCHANGE:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERREQUESTACTIONCHANGE, new OnPlayerRequestActionChange($this->maniaControl, $data));
break;
case Callbacks::SM_COMBO_PAUSE:
case Callbacks::SM_COMBO_PAUSESTATUS:
//TODO
break;
case Callbacks::SM_ELITE_STARTTURN:

View File

@ -0,0 +1,29 @@
<?php
/**
* Created by PhpStorm.
* User: Lukas
* Date: 07. Apr. 2017
* Time: 17:56
*/
namespace ManiaControl\Callbacks\Structures\Common;
use ManiaControl\ManiaControl;
class BaseResponseStructure extends BaseStructure {
protected $responseId;
/**
* Get the Response Id
*
* @return string
*/
public function getResponseId() {
return $this->responseId;
}
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
}
}

View File

@ -16,8 +16,7 @@ use ManiaControl\ManiaControl;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CommonScoresStructure extends BaseStructure {
protected $responseId;
class CommonScoresStructure extends BaseResponseStructure {
protected $section;
protected $useTeams;
protected $winnerTeam;
@ -64,15 +63,6 @@ class CommonScoresStructure extends BaseStructure {
return $this->winnerPlayer;
}
/**
* Get the Response Id
*
* @return string
*/
public function getResponseId() {
return $this->responseId;
}
/**
* < Current progress of the match. Can be "" | "EndRound" | "EndMap" | "EndMatch"
*

View File

@ -2,6 +2,7 @@
namespace ManiaControl\Callbacks\Structures\XmlRpc;
use ManiaControl\Callbacks\Structures\Common\BaseResponseStructure;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
@ -12,9 +13,7 @@ use ManiaControl\ManiaControl;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CallbacksListStructure extends BaseStructure {
/** @var string $responseId */
private $responseId;
class CallbacksListStructure extends BaseResponseStructure {
/** @var array $callbacks */
private $callbacks;
@ -31,14 +30,6 @@ class CallbacksListStructure extends BaseStructure {
$this->callbacks = $this->getPlainJsonObject()->callbacks;
}
/**
* Get the Response Id //TODO Trait for all Response Ids
*
* @return string
*/
public function getResponseId() {
return $this->responseId;
}
/**
* Get Array of the Callbacks