[TASK] Introduced addLine() to the buffer class.

[TASK] Made createBuffer function protected in ProtocolHandler classes.
This commit is contained in:
Jan Philipp Timme
2011-06-26 14:03:32 +00:00
parent df030e453d
commit 8e32f35edf
8 changed files with 50 additions and 21 deletions
+19 -11
View File
@@ -16,7 +16,7 @@ class Protocol_IrcProtocolHandler extends Protocol_AbstractProtocolHandler {
* Shall create the two buffers and set them up.
* @return void
*/
public function createBuffers() {
protected function createBuffers() {
$this->linebreak = "\n";
$this->bufferIncoming = new Misc_Buffer($this->linebreak);
$this->bufferOutgoing = new Misc_Buffer($this->linebreak);
@@ -52,25 +52,29 @@ class Protocol_IrcProtocolHandler extends Protocol_AbstractProtocolHandler {
//determine what command was sent
$command = "";
list($command, $data) = explode(" ", $data, 2);
if(strpos($data, " ") !== FALSE) {
list($command, $data) = explode(" ", $data, 2);
} else {
$command = $data;
}
$contentObject->setCommand($command);
//we'll write these values into the contentObject later!
//contains a user or the channel a command is addressed to.
$target = "";
$target = NULL;
//parameters of the command
$params = "";
$params = NULL;
//content or message
$message = "";
//affected nickname
$subject = "";
$message = NULL;
//affected nickname(s) (e.g. by a KICK or MODE +b)
$subject = NULL;
//command-dependent parsing
switch($command) {
case "PRIVMSG":
case "NOTICE":
list($target, $message) = explode(" ", $data, 2);
list($target, $params) = explode(" ", $data, 2);
//cut the colon
$message = substr($params, 1);
break;
@@ -83,8 +87,12 @@ class Protocol_IrcProtocolHandler extends Protocol_AbstractProtocolHandler {
case "ERROR":
case "QUIT":
//cut the colon
$message = substr($data, 1);
if(strpos($data, " :") !== FALSE) {
list($params, $message) = explode(" :", $data);
$message = substr($message, 1);
} else {
$params = $data;
}
break;
case "PING":
@@ -95,7 +103,7 @@ class Protocol_IrcProtocolHandler extends Protocol_AbstractProtocolHandler {
//channel, <comment>
case "PART":
if(strpos(" :", $data) !== FALSE) {
if(strpos($data, " :") !== FALSE) {
list($params, $message) = explode(" :", $data);
$message = substr($message, 1);
} else {