コード例 #1
0
ファイル: RexsterTest.php プロジェクト: atomicjets/rexpro-php
 /**
  * Testing Unknown error type
  * 
  * @return void
  */
 public function testUnknownErrorType()
 {
     $unpacked = array(1, 0, 0, 44, array('721afec3-c9c9-407f-8beb-7cfee17dde7d', '91bfab5-8069-4a83-a52e-55fae4dc4f72', array('flag' => 10), "Custom error message"));
     $error = Exceptions::checkError($unpacked);
     $this->AssertTrue($error instanceof Exceptions, 'testUnknownErrorType doesn\'t return Exceptions object');
     $this->AssertTrue($error->code == 10, 'testUnknownErrorType doesn\'t return the correct error code');
     $this->AssertTrue($error->description == 'Unknown error type. > Custom error message', 'testUnknownErrorType doesn\'t return the correct error description');
 }
コード例 #2
0
ファイル: Connection.php プロジェクト: atomicjets/rexpro-php
 /**
  * Recieves binary data over socket and parses it
  * 
  * @return mixed unpacked message if TRUE, FALSE on error
  */
 public function getResponse()
 {
     $header = @stream_get_contents($this->_socket, 7);
     $messageLength = @stream_get_contents($this->_socket, 4);
     $body = @stream_get_contents($this->_socket, (int) hexdec(bin2hex($messageLength)));
     if ($header === FALSE || $messageLength === FALSE || $body === FALSE) {
         $this->error = new Exceptions(0, 'Could not stream contents');
         return FALSE;
     }
     if (empty($header) || empty($messageLength) || empty($body)) {
         $this->error = new Exceptions(0, 'Empty reply. Most likely the result of an irregular request. (Check custom Meta, or lack of in the case of a non-isolated query)');
         return FALSE;
     }
     $msgPack = $header . $messageLength . $body;
     //now that we have the binary package lets parse it
     $message = new Messages($this->_serializer);
     $unpacked = $message->parse($msgPack);
     //lets check if this is an error message from the server
     $error = Exceptions::checkError($unpacked);
     if ($error === FALSE) {
         return $unpacked;
     }
     $this->error = $error;
     return FALSE;
 }