[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:
@@ -21,6 +21,13 @@ abstract class AbstractClientDispatcher implements \JPT\SocketFramework\Client\C
|
||||
* @var string
|
||||
*/
|
||||
protected $group;
|
||||
|
||||
/**
|
||||
* Contains data that the ClientDispatcher sends.
|
||||
*
|
||||
* @var \JPT\SocketFramework\Misc\Buffer
|
||||
*/
|
||||
protected $outputBuffer;
|
||||
|
||||
/**
|
||||
* Contains a reference to the ClientManager in order to change stuff on the fly.
|
||||
@@ -29,6 +36,35 @@ abstract class AbstractClientDispatcher implements \JPT\SocketFramework\Client\C
|
||||
*/
|
||||
protected $clientManager;
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
* Creates the outputBuffer.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->outputBuffer = new \JPT\SocketFramework\Misc\Buffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds data that shall be sent to the outputBuffer.
|
||||
* Feel free to overwrite this if you need something different.
|
||||
*
|
||||
* @param string $rawData
|
||||
*/
|
||||
protected function send($rawData) {
|
||||
$this->outputBuffer->addData($rawData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all data from the outputBuffer.
|
||||
* Feel free to overwrite this if you need something different.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOutputData() {
|
||||
return $this->outputBuffer->getAllBufferContents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Forwards incoming data to the ProtocolHandler
|
||||
* Let's the ProtocolHandler do all the work and forward its results to the Clients.
|
||||
|
||||
Reference in New Issue
Block a user