示例#1
0
 public function testReadCompletelyOffset()
 {
     fseek($this->stream, $this->size1 + 4);
     $this->obj = new Kafka_BoundedByteBuffer_Receive();
     $this->assertEquals($this->size2 + 4, $this->obj->readCompletely($this->stream));
     $this->assertEquals($this->msg2, stream_get_contents($this->obj->buffer));
     //test that we reached the end of the stream (2nd message set)
     $this->assertEquals(0, $this->obj->readCompletely($this->stream));
     $this->assertEquals($this->size1 + 4 + $this->size2 + 4, ftell($this->stream));
 }
示例#2
0
 /**
  * Get the response
  * 
  * @return array
  */
 protected function getResponse()
 {
     $response = new Kafka_BoundedByteBuffer_Receive();
     $response->readCompletely($this->conn);
     rewind($response->buffer);
     // this has the side effect of setting the initial position of buffer correctly
     $errorCode = array_shift(unpack('n', fread($response->buffer, 2)));
     //rewind($response->buffer);
     return array('response' => $response, 'errorCode' => $errorCode);
 }