[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
@@ -1,31 +1,31 @@
<?php
namespace JPT\IrcClient;
/**
* IrcClient class that contains all the Plugins
* BotClient class that handles the controls or whatever...edit this later...
*
* @author jpt
* @package Client
* @depends Client_AbstractClient
* @depends \JPT\SocketFramework\Client\AbstractClientDispatcher
*/
class Client_BotClient extends Client_AbstractClient {
class BotClientDispatcher extends \JPT\SocketFramework\Client\AbstractClientDispatcher {
/**
* Default constructor.
* @return void
* 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 __construct() {
}
/**
* Does all the hard work.
* @param object $contentObject
* @return void
*/
public function processContentObject($contentObject) {
public function processRawData($rawData) {
$return = "";
$rawData = $contentObject->getRawData();
if(trim($rawData) === "list") {
$return = print_r(array("IDs" => $this->clientManager->getIDs(), "Groups" => $this->clientManager->getGroups()), TRUE);
$return = print_r(array(
"IDs" => $this->clientManager->getIDs(),
"Groups" => $this->clientManager->getGroups()
), TRUE);
}
if(strpos($rawData, "-") !== FALSE ) {
@@ -42,7 +42,7 @@ class Client_BotClient extends Client_AbstractClient {
//TODO: implement this correctly
$return = str_replace("\n", "\r\n", $return);
$this->protocolHandler->sendRaw($return);
return $return;
}
/**
@@ -2,12 +2,13 @@
namespace JPT\IrcClient;
/**
* The ClientDispatcher for this IrcBot.
* The IrcClientDispatcher for this IrcBot.
*
* @author jpt
* @package Client
* @depends \JPT\SocketFramework\Client\AbstractClientDispatcher
*/
class ClientDispatcher extends \JPT\SocketFramework\Client\AbstractClientDispatcher {
class IrcClientDispatcher extends \JPT\SocketFramework\Client\AbstractClientDispatcher {
/**
* @var boolean
@@ -44,6 +45,7 @@ class ClientDispatcher extends \JPT\SocketFramework\Client\AbstractClientDispatc
* @return void
*/
public function __construct() {
$this->outputBuffer = new \JPT\SocketFramework\Misc\Buffer("\r\n");
$this->nick = "Serena";
$this->channels = array();
$this->resetConnectionStatus();
@@ -70,7 +72,7 @@ class ClientDispatcher extends \JPT\SocketFramework\Client\AbstractClientDispatc
$data = "USER poweruser as as :JPTs Bot\r\nNICK " . $this->nick . "\r\n";
$this->authed = TRUE;
}
//$this->protocolHandler->sendRaw($data);
$this->send($data);
}
/**
@@ -106,7 +108,7 @@ class ClientDispatcher extends \JPT\SocketFramework\Client\AbstractClientDispatc
$return .= "QUIT :lol\r\n";
}
return $return;
$this->send($return);
}
/**