コード例 #1
0
 /**
  * Test unmasking of packet
  *
  * @return void
  */
 public function testPackUnpack()
 {
     $message = new Message();
     //$message->status = ["code" => 200];
     $message->gremlin = "something";
     $message->registerSerializer('\\Brightzone\\GremlinDriver\\Serializers\\Json');
     $payload = $message->buildMessage();
     $expected = ['requestId' => $message->requestUuid, 'processor' => '', 'op' => 'eval', 'args' => ['gremlin' => 'something']];
     $connection = new \Brightzone\GremlinDriver\Tests\Stubs\Connection(["_acceptDiffResponseFormat" => TRUE]);
     $connection->setSocket($this->invokeMethod($connection, 'webSocketPack', [$payload, $type = 'binary', $masked = TRUE]));
     $data = $this->invokeMethod($connection, 'socketGetMessage');
     $this->assertEquals($expected, $data, "could not unpack properly");
 }
コード例 #2
0
 /**
  * Testing Example 5
  *
  * @return void
  */
 public function testExample5()
 {
     $message = new Message();
     $message->gremlin = 'g.V()';
     $message->op = 'eval';
     $message->processor = '';
     $message->setArguments(['language' => 'gremlin-groovy']);
     $message->registerSerializer('\\Brightzone\\GremlinDriver\\Serializers\\Json');
     $db = new Connection();
     $db->open();
     $db->send($message);
     //do something with result
     $db->close();
 }
コード例 #3
0
 /**
  * Builds an authentication message when challenged by the server
  *
  * @return void
  */
 protected function authenticate()
 {
     $msg = new Message();
     $msg->op = "authentication";
     $msg->processor = "";
     $msg->setArguments(['sasl' => base64_encode(utf8_encode("" . trim($this->username) . "" . trim($this->password)))]);
     $msg->registerSerializer(new Json());
     return $this->send($msg);
 }