diff --git a/PhpAmqpLib/Wire/IO/SwooleIO.php b/PhpAmqpLib/Wire/IO/SwooleIO.php index 5518c7a37..99c9becdd 100644 --- a/PhpAmqpLib/Wire/IO/SwooleIO.php +++ b/PhpAmqpLib/Wire/IO/SwooleIO.php @@ -134,7 +134,7 @@ public function reconnect() /** * @param int $len - * @throws \PhpAmqpLib\Exception\AMQPIOException + * @throws \PhpAmqpLib\Exception\AMQPRuntimeException * @return mixed|string */ public function read($len) @@ -147,8 +147,7 @@ public function read($len) { $data = substr($this->buffer, 0, $len); $this->buffer = substr($this->buffer, $len); - - var_dump("recv: ".strlen($data)); + $this->last_read = microtime(true); return $data; } @@ -164,12 +163,9 @@ public function read($len) throw new AMQPRuntimeException('Error receiving data, errno=' . $this->sock->errCode); } - var_dump(strlen($read_buffer), $len); - - //TODO 这里需要处理关闭事件 if ($read_buffer === '') { - break; + continue; } $this->buffer .= $read_buffer; @@ -177,17 +173,6 @@ public function read($len) } while (true); -// if (mb_strlen($data, 'ASCII') !== $len) { -// throw new AMQPRuntimeException( -// sprintf( -// 'Error reading data. Received %s instead of expected %s bytes', -// mb_strlen($data, 'ASCII'), -// $len -// ) -// ); -// } - - $this->last_read = microtime(true); return false; } @@ -201,8 +186,6 @@ public function write($data) { $buffer = $this->sock->send($data); - var_dump("send: ".strlen($data)); - if ($buffer === false) { throw new AMQPRuntimeException('Error sending data');