Exemple #1
0
 /**
  * Unserializes the data
  *
  * @param array $data data to be unserialized
  *
  * @return array unserialized message
  */
 public function unserialize($data)
 {
     $mssg = msgpack_unpack($data);
     //lets just make UUIDs readable incase we need to debug
     $mssg[0] = Helper::binToUuid($mssg[0]);
     $mssg[1] = Helper::binToUuid($mssg[1]);
     return $mssg;
 }
Exemple #2
0
 /**
  * Testing binary conversion FROM
  *
  * @return void
  */
 public function testConvertIntFrom32Bit()
 {
     $converted = Helper::convertIntFrom32Bit(Helper::convertIntTo32Bit(84));
     $this->assertEquals($converted, 84, 'The conversion of 32bit int to int is incorrect');
     $converted = Helper::convertIntFrom32Bit(Helper::convertIntTo32Bit(9999));
     $this->assertEquals($converted, 9999, 'The conversion of 32bit int to int is incorrect');
     $converted = Helper::convertIntFrom32Bit(Helper::convertIntTo32Bit(10000000000));
     $this->assertEquals($converted, 1410065408, 'The conversion of 32bit int to int is incorrect. Bit truncating issue');
     //bit truncating check
 }
 /**
  * Testing Helper random string generator with spaces
  *
  * @return void
  */
 public function testRandomGenerator()
 {
     $string = Helper::generateRandomString(10, TRUE, FALSE);
     $this->assertTrue(strlen($string) == 10, "string should contain 10 characters");
     $this->assertTrue(strpos($string, ' ') !== FALSE, "spaces should have been found");
 }
 /**
  * Retrieve the current session UUID
  *
  * @return string current UUID
  */
 public function getSession()
 {
     if (!isset($this->_sessionUuid)) {
         $this->_sessionUuid = Helper::createUuid();
     }
     return $this->_sessionUuid;
 }
Exemple #5
0
 /**
  * Connects to socket and starts a session on RexPro
  * 
  * @param string $host        host and port seperated by ":"
  * @param string $graph       graph to load into session. defaults to tinkergraph
  * @param string $username    username for authentification
  * @param string $password    password to use for authentification
  * @param string $graphObject Graph object name. defaults to 'g'
  * 
  * @return bool TRUE on success FALSE on error
  */
 public function open($host = 'localhost:8184', $graph = 'tinkergraph', $username = NULL, $password = NULL, $graphObject = 'g')
 {
     if ($this->_socket === NULL) {
         $this->error = NULL;
         $this->host = $host;
         $this->graph = $graph;
         $this->graphObject = $graphObject;
         $this->username = $username;
         $this->password = $password;
         if (!$this->connectSocket()) {
             return FALSE;
         }
         //lets make opening session message:
         $msg = new Messages($this->_serializer);
         $msg->buildSessionMessage(Helper::createUuid(), $this->username, $this->password, array('graphName' => $this->graph, 'graphObjName' => $this->graphObject), $this->protocolVersion);
         if (!$this->send($msg)) {
             return FALSE;
         }
         //lets get the response
         $response = $this->getResponse();
         if ($response === FALSE) {
             return FALSE;
         }
         $this->response = $response;
         $this->sessionUuid = $this->response[4][0];
         return TRUE;
     }
 }