[TASK] Removed the linebreak from the buffers in the ConnectionHandler.
[TASK] Added a WrongDatatypeException [TASK] Started to implement the ProtocolHandler in a different way. [TASK] Started to put buffers into the ProtocolHandler. [!!!] Committing broken code.
This commit is contained in:
@@ -13,6 +13,7 @@ class Connection_ConnectionHandler {
|
||||
/**
|
||||
* Buffer that contains incoming data.
|
||||
* Contents were received from the SocketHandler.
|
||||
* This buffer does not use a linebreak, it's a temporary store for data.
|
||||
* @var Misc_Buffer
|
||||
*/
|
||||
protected $buffer_incoming;
|
||||
@@ -20,6 +21,7 @@ class Connection_ConnectionHandler {
|
||||
/**
|
||||
* Buffer that contains outgoing data.
|
||||
* Contents will be sent to the SocketHandler.
|
||||
* This buffer does not use a linebreak, it's a temporary store for data.
|
||||
* @var Misc_Buffer
|
||||
*/
|
||||
protected $buffer_outgoing;
|
||||
@@ -85,9 +87,9 @@ class Connection_ConnectionHandler {
|
||||
* @param $linebreak
|
||||
* @return void
|
||||
*/
|
||||
function __construct($socket, $id, $group = "", $protocol = "", $linebreak = "\r\n") {
|
||||
$this->buffer_incoming = new Misc_Buffer($linebreak);
|
||||
$this->buffer_outgoing = new Misc_Buffer($linebreak);
|
||||
function __construct($socket, $id, $group = "", $protocol = "") {
|
||||
$this->buffer_incoming = new Misc_Buffer();
|
||||
$this->buffer_outgoing = new Misc_Buffer();
|
||||
$this->socketHandler = new Socket_SocketHandler($socket);
|
||||
$this->id = $id;
|
||||
$this->group = $group;
|
||||
@@ -202,12 +204,10 @@ class Connection_ConnectionHandler {
|
||||
* @return boolean
|
||||
*/
|
||||
public function writeFromBuffer() {
|
||||
while($this->buffer_outgoing->hasLines()) {
|
||||
$result = $this->socketHandler->write($this->buffer_outgoing->getNextLine());
|
||||
if($result === FALSE) {
|
||||
$this->shutdown();
|
||||
return FALSE;
|
||||
}
|
||||
$result = $this->socketHandler->write($this->buffer_outgoing->getAllBufferContents());
|
||||
if($result === FALSE) {
|
||||
$this->shutdown();
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -226,7 +226,7 @@ class Connection_ConnectionHandler {
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead() {
|
||||
return $this->buffer_incoming->hasLines();
|
||||
return $this->buffer_incoming->hasData();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +234,7 @@ class Connection_ConnectionHandler {
|
||||
* @return boolean
|
||||
*/
|
||||
public function canWrite() {
|
||||
return $this->buffer_outgoing->hasLines();
|
||||
return $this->buffer_outgoing->hasData();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,7 +243,7 @@ class Connection_ConnectionHandler {
|
||||
* @return string
|
||||
*/
|
||||
public function read() {
|
||||
return $this->buffer_incoming->getNextLine();
|
||||
return $this->buffer_incoming->getAllBufferContents();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user