-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af9d8e6
commit 77425e0
Showing
25 changed files
with
361 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Bolt\protocol; | ||
|
||
/** | ||
* Class Protocol version 5.1 | ||
* | ||
* @author Michal Stefanak | ||
* @link https://github.com/neo4j-php/Bolt | ||
* @see https://www.neo4j.com/docs/bolt/current/bolt/message/ | ||
* @package Bolt\protocol | ||
*/ | ||
class V5_1 extends AProtocol | ||
{ | ||
use \Bolt\protocol\v5\AvailableStructures; | ||
|
||
use \Bolt\protocol\v1\ResetMessage; | ||
|
||
use \Bolt\protocol\v3\RunMessage; | ||
use \Bolt\protocol\v3\BeginMessage; | ||
use \Bolt\protocol\v3\CommitMessage; | ||
use \Bolt\protocol\v3\RollbackMessage; | ||
use \Bolt\protocol\v3\GoodbyeMessage; | ||
|
||
use \Bolt\protocol\v4\PullMessage; | ||
use \Bolt\protocol\v4\DiscardMessage; | ||
|
||
use \Bolt\protocol\v4_4\RouteMessage; | ||
|
||
use \Bolt\protocol\v5_1\HelloMessage; | ||
use \Bolt\protocol\v5_1\LogonMessage; | ||
use \Bolt\protocol\v5_1\LogoffMessage; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Bolt\protocol\v5_1; | ||
|
||
use Bolt\protocol\{ServerState, Response}; | ||
use Bolt\error\BoltException; | ||
|
||
trait HelloMessage | ||
{ | ||
/** | ||
* Send HELLO message | ||
* The HELLO message request the connection to be authorized for use with the remote database. | ||
* | ||
* @link https://www.neo4j.com/docs/bolt/current/bolt/message/#messages-hello | ||
* @throws BoltException | ||
*/ | ||
public function hello(array $extra = []): Response | ||
{ | ||
$this->serverState->is(ServerState::CONNECTED); | ||
|
||
if (empty($extra['user_agent'])) | ||
$extra['user_agent'] = \Bolt\helpers\Auth::$defaultUserAgent; | ||
if (isset($extra['routing']) && is_array($extra['routing'])) | ||
$extra['routing'] = (object)$extra['routing']; | ||
|
||
$this->write($this->packer->pack(0x01, (object)$extra)); | ||
$content = $this->read($signature); | ||
|
||
if ($signature == Response::SIGNATURE_SUCCESS) { | ||
$this->serverState->set(ServerState::UNAUTHENTICATED); | ||
} elseif ($signature == Response::SIGNATURE_FAILURE) { | ||
$this->connection->disconnect(); | ||
$this->serverState->set(ServerState::DEFUNCT); | ||
} | ||
|
||
return new Response(Response::MESSAGE_HELLO, $signature, $content); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Bolt\protocol\v5_1; | ||
|
||
use Bolt\error\BoltException; | ||
use Bolt\protocol\Response; | ||
use Bolt\protocol\ServerState; | ||
use Bolt\protocol\V5_1; | ||
|
||
trait LogoffMessage | ||
{ | ||
/** | ||
* Send LOGOFF message | ||
* A LOGOFF message logs off the currently authenticated user. The connection is then ready for another LOGON message. | ||
* | ||
* @link https://www.neo4j.com/docs/bolt/current/bolt/message/#messages-logoff | ||
* @throws BoltException | ||
*/ | ||
public function logoff(): Response | ||
{ | ||
$this->serverState->is(ServerState::READY); | ||
$this->write($this->packer->pack(0x6B)); | ||
$content = $this->read($signature); | ||
if ($signature == Response::SIGNATURE_SUCCESS) { | ||
$this->serverState->set(ServerState::UNAUTHENTICATED); | ||
} else { | ||
$this->connection->disconnect(); | ||
$this->serverState->set(ServerState::DEFUNCT); | ||
} | ||
return new Response(Response::MESSAGE_LOGOFF, $signature, $content); | ||
} | ||
} |
Oops, something went wrong.