[TASK] Added an outputBuffer to the AbstractClientDispatcher.

[TASK] Added support for the new outputBuffer - it can be used in addition to the default behaviour "return a string on processRawData()".
This commit is contained in:
Jan Philipp Timme
2011-12-04 14:31:18 +01:00
parent e702124895
commit d0de3823a9
5 changed files with 69 additions and 25 deletions
+58
View File
@@ -0,0 +1,58 @@
<?php
namespace JPT\IrcClient;
/**
* BotClient class that handles the controls or whatever...edit this later...
*
* @author jpt
* @package Client
* @depends \JPT\SocketFramework\Client\AbstractClientDispatcher
*/
class BotClientDispatcher extends \JPT\SocketFramework\Client\AbstractClientDispatcher {
/**
* Forwards incoming data to the ProtocolHandler
* Let's the ProtocolHandler do all the work and forward its results to the Clients.
* Return resulting raw data.
*
* @param string $rawData
* @return string
*/
public function processRawData($rawData) {
$return = "";
if(trim($rawData) === "list") {
$return = print_r(array(
"IDs" => $this->clientManager->getIDs(),
"Groups" => $this->clientManager->getGroups()
), TRUE);
}
if(strpos($rawData, "-") !== FALSE ) {
$data = explode("-", $rawData, 2);
$this->clientManager->sendToID((int) $data[0], $data[1]."\r\n");
$return = print_r($data, TRUE);
}
if(strpos($rawData, "+") !== FALSE ) {
$data = explode("+", $rawData, 2);
$this->clientManager->sendToGroup($data[0], $data[1]."\r\n");
$return = print_r($data, TRUE);
}
//TODO: implement this correctly
$return = str_replace("\n", "\r\n", $return);
return $return;
}
/**
* Loads the given configuration.
* @param array $config
* @return void
*/
public function loadConfig($config) {
}
}
?>