コード例 #1
0
 /**
  * Reads from the buffer. When more data is required reads another entire
  * chunk and serves future reads out of that.
  *
  * @param int $len How much data
  */
 public function read($len)
 {
     if (!$this->read_) {
         return $this->transport_->read($len);
     }
     if (strlen($this->rBuf_) === 0) {
         $this->readFrame();
     }
     // Just return full buff
     if ($len >= strlen($this->rBuf_)) {
         $out = $this->rBuf_;
         $this->rBuf_ = null;
         return $out;
     }
     // Return substr
     $out = substr($this->rBuf_, 0, $len);
     $this->rBuf_ = substr($this->rBuf_, $len);
     return $out;
 }
コード例 #2
0
ファイル: TBufferedTransport.php プロジェクト: Leolh/hive
 public function read($len)
 {
     if (strlen($this->rBuf_) === 0) {
         $this->rBuf_ = $this->transport_->read($this->rBufSize_);
     }
     if (strlen($this->rBuf_) <= $len) {
         $ret = $this->rBuf_;
         $this->rBuf_ = '';
         return $ret;
     }
     $ret = substr($this->rBuf_, 0, $len);
     $this->rBuf_ = substr($this->rBuf_, $len);
     return $ret;
 }
コード例 #3
0
 /**
  * Reads from the buffer. When more data is required reads another entire
  * chunk and serves future reads out of that.
  *
  * @param int $len How much data
  */
 public function read($len)
 {
     if (!$this->read_) {
         return $this->transport_->read($len);
     }
     if (strlen($this->rBuf_) === 0) {
         $this->readFrame();
     }
     // Return substr
     $out = substr($this->rBuf_, $this->rIndex_, $len);
     $this->rIndex_ += $len;
     if (strlen($this->rBuf_) <= $this->rIndex_) {
         $this->rBuf_ = null;
         $this->rIndex_ = 0;
     }
     return $out;
 }
コード例 #4
0
ファイル: TFramedTransport.php プロジェクト: WickyLeo/bobcat
 /**
  * Reads from the buffer. When more data is required reads another entire
  * chunk and serves future reads out of that.
  *
  * @param int $len How much data
  */
 public function read($len)
 {
     if (!$this->read_) {
         return $this->transport_->read($len);
     }
     if (strlen($this->rBuf_) - $this->rBufIdx_ <= 0) {
         $this->readFrame();
     }
     // Just return full buff
     if ($len >= strlen($this->rBuf_) - $this->rBufIdx_) {
         $out = substr($this->rBuf_, $this->rBufIdx_);
         $this->rBuf_ = null;
         $this->rBufIdx_ = 0;
         return $out;
     }
     // Return substr
     $out = substr($this->rBuf_, $this->rBufIdx_, $len);
     $this->rBufIdx_ += $len;
     //$this->rBuf_ = substr($this->rBuf_, $len);
     return $out;
 }
コード例 #5
0
ファイル: TTransport.php プロジェクト: quequan/Web
 /**
  * Reads from the buffer. When more data is required reads another entire
  * chunk and serves future reads out of that.
  *
  * @param int $len How much data
  */
 public function read($len)
 {
     if (!$this->read_) {
         return $this->transport_->read($len);
     }
     if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) {
         $this->readFrame();
     }
     // Just return full buff
     if ($len >= TStringFuncFactory::create()->strlen($this->rBuf_)) {
         $out = $this->rBuf_;
         $this->rBuf_ = null;
         return $out;
     }
     // Return TStringFuncFactory::create()->substr
     $out = TStringFuncFactory::create()->substr($this->rBuf_, 0, $len);
     $this->rBuf_ = TStringFuncFactory::create()->substr($this->rBuf_, $len);
     return $out;
 }