implementation of sendChat communication
This commit is contained in:
@ -259,12 +259,14 @@ class CommunicationManager implements CallbackListener {
|
||||
} else if (!property_exists($data, "method") || !property_exists($data, "data")) {
|
||||
$data = array("error" => true, "data" => "Invalid Message");
|
||||
} else {
|
||||
$answer = $this->triggerCommuncationCallback($data->method, $data->error, $data->data);
|
||||
$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");
|
||||
} else {
|
||||
$data = array("error" => false, "data" => $answer);
|
||||
$data = array("error" => $answer["error"], "data" => $answer["data"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,4 +12,15 @@ namespace ManiaControl\Communication;
|
||||
interface CommunicationMethods {
|
||||
/** Returns the last 200 lines of the chat (inclusive player logins and nicknames) */
|
||||
const GET_SERVER_CHAT = "Chat.GetServerChat";
|
||||
|
||||
/** Sends a ChatMessage to the Server
|
||||
* Required Params:
|
||||
* - message
|
||||
* Optional Params
|
||||
* - prefix (use custom prefix or false for no prefix)
|
||||
* - login (login of a receiver if the message don't get sent to all)
|
||||
* - adminLevel (minimum Admin Level if the Message should get sent to an Admin)
|
||||
* - type (type of the message (information, error, success or usage)
|
||||
*/
|
||||
const SEND_CHAT_MESSAGE = "Chat.SendChatMessage";
|
||||
}
|
@ -5,11 +5,15 @@ There the following settings are existing:
|
||||
-- Passsword (Password which get used to encrypt and decrypt the messages for the openssl connection)
|
||||
-- Listening port for every server (this is the port the CommunicationManager listens at)
|
||||
|
||||
|
||||
For the description of the available implemented communcation Methods check the CommunicationMethods interface.
|
||||
|
||||
|
||||
Sample ManiaControl Implementation (for ManiaControl to ManiaControl connections)
|
||||
|
||||
##php code begin
|
||||
$communication = $this->maniaControl->getCommunicationManager()->createCommunication(IP/Domain, PORT, 'YOUR_PASSWORD');
|
||||
$communication->call(function($error, $data){
|
||||
$communication->call(function($data){
|
||||
var_dump($data);
|
||||
}, CommunicationMethods::GET_SERVER_CHAT);
|
||||
##php code end
|
||||
|
Reference in New Issue
Block a user