cleanup communicationmanager
This commit is contained in:
22
core/Communication/CommunicationAnswer.php
Normal file
22
core/Communication/CommunicationAnswer.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Communication;
|
||||
|
||||
/**
|
||||
* Class for Answer of Communication Request
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2015 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CommunicationAnswer {
|
||||
/** Properties are Public for serialization */
|
||||
public $error;
|
||||
public $data;
|
||||
|
||||
public function __construct($data = "", $error = false) {
|
||||
$this->data = $data;
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
}
|
@ -262,11 +262,9 @@ class CommunicationManager implements CallbackListener {
|
||||
$answer = $this->triggerCommuncationCallback($data->method, $data->data);
|
||||
//Prepare Response
|
||||
if (!$answer) {
|
||||
$data = array("error" => true, "data" => "No listener or response on the given Message");
|
||||
} else if (!array_key_exists("error", $answer) || !array_key_exists("data", $answer)) {
|
||||
$data = array("error" => true, "data" => "Invalid Response on the Message");
|
||||
$data = new CommunicationAnswer("No listener or response on the given Message", true);
|
||||
} else {
|
||||
$data = array("error" => $answer["error"], "data" => $answer["data"]);
|
||||
$data = $answer;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user