callbacks draft

This commit is contained in:
kremsy 2014-04-24 17:41:05 +02:00 committed by Steffen Schröder
parent 157a4347a4
commit ff054839ea
3 changed files with 73 additions and 1 deletions

View File

@ -49,7 +49,8 @@ class CallbackManager {
* Public Properties
*/
public $shootManiaCallbacks = null;
public $libXmlRpcCallbacks = null;
/*
* Private Properties
*/
@ -66,6 +67,7 @@ class CallbackManager {
$this->maniaControl = $maniaControl;
$this->shootManiaCallbacks = new ShootManiaCallbacks($maniaControl, $this);
$this->libXmlRpcCallbacks = new LibXmlRpcCallbackManager($maniaControl, $this);
}
/**
@ -249,5 +251,6 @@ class CallbackManager {
$scriptCallbackData = $callback[1];
$scriptCallbackName = $scriptCallbackData[0];
$this->triggerScriptCallback($scriptCallbackName, $scriptCallbackData);
$this->triggerCallback(Callbacks::ScriptCallback, $scriptCallbackName, $scriptCallbackData[1]);
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace ManiaControl\Callbacks;
/**
* Callbacks Interface
*
* @author steeffeen & kremsy
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
interface Callbacks {
const ScriptCallback = 'Callbacks.ScriptCallback';
/** BeginMatch Callback, param1 MapNumber */
const LibXmlRpc_BeginMatch = "Callbacks.LibXmlRpc_BeginMatch";
/** BeginMatch Callback, param1 MapNumber */
const LibXmlRpc_LoadingMap = "Callbacks.LibXmlRpc_LoadingMap";
/** BeginMatch Callback, param1 MapNumber */
const LibXmlRpc_BeginMap = "Callbacks.LibXmlRpc_BeginMap";
}

View File

@ -0,0 +1,50 @@
<?php
/**
* Created by PhpStorm.
* User: Lukas
* Date: 24.04.14
* Time: 16:57
*/
namespace ManiaControl\Callbacks;
use ManiaControl\ManiaControl;
class LibXmlRpcCallbackManager implements CallbackListener{
/*
* Private Properties
*/
private $maniaControl = null;
/**
* Create a new ShootMania Callbacks Instance
*
* @param ManiaControl $maniaControl
*/
public function __construct(ManiaControl $maniaControl, CallbackManager $callbackManager) {
$this->maniaControl = $maniaControl;
$callbackManager->registerCallbackListener(Callbacks::ScriptCallback, $this, 'handleScriptCallbacks');
}
public function handleScriptCallbacks($name, $data){
switch($name){
case 'LibXmlRpc_BeginMatch':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::LibXmlRpc_BeginMatch, $data[0]);
break;
case 'LibXmlRpc_LoadingMap':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::LibXmlRpc_LoadingMap, $data[0]);
break;
case 'LibXmlRpc_BeginMap':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::LibXmlRpc_BeginMap, $data[0]);
break;
}
var_dump($name);
var_dump($data);
}
}