[TASK] Implemented the ProtocolHandler things so it works again.
[TASK] Added some comments. [TASK] Added TODOs concerning refactoring and more functions that are needed.
This commit is contained in:
@@ -7,11 +7,44 @@
|
||||
class Protocol_BotProtocolHandler extends Protocol_AbstractProtocolHandler {
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @return Protocol_RawProtocolContentObject
|
||||
* Is called by the constructor.
|
||||
* Shall create the two buffers and set them up.
|
||||
* @return void
|
||||
*/
|
||||
public function parse($data) {
|
||||
public function createBuffers() {
|
||||
$linebreak = "\r\n";
|
||||
$this->buffer_incoming = new Misc_Buffer($linebreak);
|
||||
$this->buffer_outgoing = new Misc_Buffer($linebreak);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main worker function. It will be called in a loop.
|
||||
* The returned ContentObject will be passed to the client.
|
||||
* @return Protocol_BotProtocolContentObject
|
||||
*/
|
||||
public function work() {
|
||||
$data = $this->buffer_incoming->getNextLine();
|
||||
return new Protocol_BotProtocolContentObject($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether there is work to be done.
|
||||
* Important in order to assure that a ContentObject is created and passed to the Client.
|
||||
* @return boolean
|
||||
*/
|
||||
public function canWork() {
|
||||
return $this->buffer_incoming->hasLines();
|
||||
}
|
||||
|
||||
/**
|
||||
* Will be replaced soon. Passes raw data into the outgoing buffer.
|
||||
* @deprecated
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function sendRaw($data) {
|
||||
$this->buffer_incoming->addData($data);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user