/** * Testing Example 5 * * @return void */ public function testExample5() { $message = new Messages(); $message->gremlin = 'g.V()'; $message->op = 'eval'; $message->processor = ''; $message->setArguments(['language' => 'gremlin-groovy']); $message->registerSerializer('\\brightzone\\rexpro\\serializers\\Json'); $db = new Connection(); $db->open(); $result = $db->send($message); //do something with result $db->close(); }
/** * Close connection to server * This closes the current session on the server then closes the socket * * @return bool TRUE on success FALSE on error */ public function close() { if ($this->_socket !== NULL) { $this->error = NULL; //lets make opening session message: $msg = new Messages($this->_serializer); $msg->buildSessionMessage($this->sessionUuid, $this->username, $this->password, array('killSession' => TRUE), $this->protocolVersion); if (!$this->send($msg)) { return FALSE; } //lets get the response $response = $this->getResponse(); if ($response === FALSE) { return FALSE; } $this->response = $response; @stream_socket_shutdown($this->_socket, STREAM_SHUT_RDWR); //ignore error $this->_socket = NULL; $this->sessionUuid = NULL; return TRUE; } }