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

@ -98,7 +98,7 @@ class CallbackManager {
return false; return false;
} }
if (!array_key_exists($callbackName, $this->callbackListenings)) { if (!$this->callbackListeningExists($callbackName)) {
$this->callbackListenings[$callbackName] = array(); $this->callbackListenings[$callbackName] = array();
} }
@ -108,6 +108,16 @@ class CallbackManager {
return true; 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 * Register a new Script Callback Listener
* *
@ -272,7 +282,7 @@ class CallbackManager {
} else { } else {
$callbackName = $callback; $callbackName = $callback;
} }
if (!array_key_exists($callbackName, $this->callbackListenings)) { if (!$this->callbackListeningExists($callbackName)) {
return; return;
} }

View File

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

View File

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