2010-11-28 01:04:35 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* The ProtocolHandler for the IRC Protocol.
|
|
|
|
* @author JPT
|
|
|
|
* @package Protocol
|
|
|
|
*/
|
2010-11-28 02:15:20 +01:00
|
|
|
class Protocol_IrcProtocolHandler extends Protocol_AbstractProtocolHandler {
|
2010-11-28 01:04:35 +01:00
|
|
|
|
|
|
|
/**
|
2010-12-08 17:47:04 +01:00
|
|
|
* Is called by the constructor.
|
|
|
|
* Shall create the two buffers and set them up.
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
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.
|
2010-11-28 01:04:35 +01:00
|
|
|
* @return Protocol_IrcProtocolContentObject
|
|
|
|
*/
|
2010-12-08 17:47:04 +01:00
|
|
|
public function work() {
|
|
|
|
$data = $this->buffer_incoming->getNextLine();
|
2010-11-28 01:04:35 +01:00
|
|
|
return new Protocol_IrcProtocolContentObject($data);
|
|
|
|
}
|
2010-12-08 17:47:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 put raw data into the outgoing buffer.
|
|
|
|
* This function will be removed soon.
|
|
|
|
* The ProtocolHandler shall take care of this directly.
|
|
|
|
* @deprecated
|
|
|
|
* @param string $data
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function sendRaw($data) {
|
|
|
|
$this->buffer_outgoing->addData($data);
|
|
|
|
}
|
|
|
|
|
2010-11-28 01:04:35 +01:00
|
|
|
}
|
|
|
|
?>
|