added check if callback got subscribed before triggering and creating structures

This commit is contained in:
kremsy 2017-03-25 13:40:37 +01:00
parent 4804e0ab55
commit e8586586a3
3 changed files with 19 additions and 3 deletions

View File

@ -46,7 +46,7 @@ class CallbackManager {
/*
* Public properties
*/
public $libXmlRpcCallbacks = null;
public $libXmlRpcCallbacks = null;
public $shootManiaCallbacks = null;
public $trackManiaCallbacks = null;
@ -98,7 +98,7 @@ class CallbackManager {
return false;
}
if (!array_key_exists($callbackName, $this->callbackListenings)) {
if (!$this->callbackListeningExists($callbackName)) {
$this->callbackListenings[$callbackName] = array();
}
@ -108,6 +108,16 @@ class CallbackManager {
return true;
}
/**
* Checks if a Callback Listening exists
*
* @param $callbackName
* @return bool
*/
public function callbackListeningExists($callbackName) {
return array_key_exists($callbackName, $this->callbackListenings);
}
/**
* Register a new Script Callback Listener
*
@ -272,7 +282,7 @@ class CallbackManager {
} else {
$callbackName = $callback;
}
if (!array_key_exists($callbackName, $this->callbackListenings)) {
if (!$this->callbackListeningExists($callbackName)) {
return;
}

View File

@ -44,6 +44,9 @@ class LibXmlRpcCallbacks implements CallbackListener {
* @param mixed $data
*/
public function handleScriptCallback($name, $data) {
if(!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)){
return;
}
var_dump($name);
//var_dump($data);
switch ($name) {

View File

@ -52,6 +52,9 @@ class ShootManiaCallbacks implements CallbackListener {
* @param mixed $data
*/
public function handleScriptCallbacks($name, $data) {
if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) {
return;
}
switch ($name) {
//MP4 New Callbacks
case Callbacks::SM_EVENTDEFAULT: