From f0e26d9637169a7a50ba7707ea080d9c4916fb3d Mon Sep 17 00:00:00 2001 From: David Dan Date: Sat, 27 Feb 2016 20:49:14 -0500 Subject: [PATCH 01/15] Set state down when the client session closes --- src/Thruway/ClientSession.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Thruway/ClientSession.php b/src/Thruway/ClientSession.php index 7939a779..aa9b0963 100644 --- a/src/Thruway/ClientSession.php +++ b/src/Thruway/ClientSession.php @@ -129,7 +129,6 @@ public function close() */ public function onClose() { - + $this->state = static::STATE_DOWN; } - } From 3354a84e8ddd790e59860b0eab8ad40342e82024 Mon Sep 17 00:00:00 2001 From: Matt Bonneau Date: Tue, 24 May 2016 21:32:43 -0400 Subject: [PATCH 02/15] Remove mcrypt requirement --- composer.json | 6 ++---- src/Thruway/Authentication/WampCraAuthProvider.php | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 12cf7932..73c255dd 100644 --- a/composer.json +++ b/composer.json @@ -32,10 +32,8 @@ "cboden/ratchet": "0.3.*", "ratchet/pawl": "0.1.*", "psr/log": "~1", - "guzzle/guzzle": "~3.9" - }, - "suggest": { - "ext-mcrypt":"If you want to use WAMP-CRA for authentication" + "guzzle/guzzle": "~3.9", + "ext-openssl": "*" }, "extra": { "branch-alias": { diff --git a/src/Thruway/Authentication/WampCraAuthProvider.php b/src/Thruway/Authentication/WampCraAuthProvider.php index 8e5de81e..51f056f8 100644 --- a/src/Thruway/Authentication/WampCraAuthProvider.php +++ b/src/Thruway/Authentication/WampCraAuthProvider.php @@ -67,7 +67,7 @@ public function processHello(array $args) } // create a challenge - $nonce = bin2hex(mcrypt_create_iv(22, MCRYPT_DEV_URANDOM)); + $nonce = bin2hex(openssl_random_pseudo_bytes(22)); $authRole = "user"; $authMethod = "wampcra"; $authProvider = "userdb"; From a1c879e534e91f3cf0102f1a473d097b453f1d1e Mon Sep 17 00:00:00 2001 From: Matt Bonneau Date: Tue, 24 May 2016 23:27:37 -0400 Subject: [PATCH 03/15] Fix issue with phpunit and travis php7 builds --- tests/Unit/Peer/RouterTest.php | 5 ++--- tests/WAMP/AuthExtraTest.php | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/Unit/Peer/RouterTest.php b/tests/Unit/Peer/RouterTest.php index 8c7d49b0..c0e2a067 100644 --- a/tests/Unit/Peer/RouterTest.php +++ b/tests/Unit/Peer/RouterTest.php @@ -161,14 +161,13 @@ function ($msg) { /** * Test Subscribe to an empty topic * - * @depends testHelloMessage - * @param $rt array * @return array * * https://github.com/tavendo/WAMP/blob/master/spec/basic.md#subscription-error */ - public function testSubscribeEmptyTopicMessage($rt) + public function testSubscribeEmptyTopicMessage() { + $rt = $this->getActiveRouterAndSession(); /** @var \Thruway\Session $session */ $session = $rt["session"]; $session->getTransport()->expects($this->exactly(1)) diff --git a/tests/WAMP/AuthExtraTest.php b/tests/WAMP/AuthExtraTest.php index 95bf0a4d..53bc918c 100644 --- a/tests/WAMP/AuthExtraTest.php +++ b/tests/WAMP/AuthExtraTest.php @@ -98,9 +98,9 @@ public function testAuthExtraSentBackOnHello() { }); }); - $router->addTransportProvider(new \Thruway\Transport\RatchetTransportProvider('127.0.0.1', 8088)); + $router->addTransportProvider(new \Thruway\Transport\RatchetTransportProvider('127.0.0.1', 58088)); - $client->addTransportProvider(new \Thruway\Transport\PawlTransportProvider('ws://127.0.0.1:8088/')); + $client->addTransportProvider(new \Thruway\Transport\PawlTransportProvider('ws://127.0.0.1:58088/')); $loop->addTimer(5, function () use ($loop) { $loop->stop(); From 0364d710da95e19f3f29425aa7b14712ea4db464 Mon Sep 17 00:00:00 2001 From: Matt Bonneau Date: Wed, 25 May 2016 00:23:46 -0400 Subject: [PATCH 04/15] Update Pawl to version 0.2 --- composer.json | 2 +- src/Thruway/Transport/PawlTransport.php | 57 +------------------ .../Transport/PawlTransportProvider.php | 21 +------ 3 files changed, 6 insertions(+), 74 deletions(-) diff --git a/composer.json b/composer.json index 73c255dd..a1826b5d 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "php": ">=5.4", "react/socket": "0.4.*", "cboden/ratchet": "0.3.*", - "ratchet/pawl": "0.1.*", + "ratchet/pawl": "0.2.*", "psr/log": "~1", "guzzle/guzzle": "~3.9", "ext-openssl": "*" diff --git a/src/Thruway/Transport/PawlTransport.php b/src/Thruway/Transport/PawlTransport.php index da1f041a..cddb9b56 100644 --- a/src/Thruway/Transport/PawlTransport.php +++ b/src/Thruway/Transport/PawlTransport.php @@ -2,8 +2,6 @@ namespace Thruway\Transport; - -use Ratchet\WebSocket\Version\RFC6455\Frame; use React\EventLoop\LoopInterface; use React\EventLoop\Timer\TimerInterface; use React\Promise\Deferred; @@ -82,56 +80,7 @@ public function getTransportDetails() */ public function ping($timeout = 10) { - if ($timeout <= 0) { - return false; - } - - $payload = $this->pingSeq; - $seq = $this->pingSeq; - - $this->conn->send(new Frame($payload, true, Frame::OP_PING)); - $this->pingSeq++; - - $timer = $this->loop->addTimer($timeout, function () use ($seq) { - if (isset($this->pingRequests[$seq])) { - $this->pingRequests[$seq]['deferred']->reject('timeout'); - unset($this->pingRequests[$seq]); - } - - }); - - $deferred = new Deferred(); - - $this->pingRequests[$seq] = [ - 'seq' => $seq, - 'deferred' => $deferred, - 'timer' => $timer - ]; - - return $deferred->promise(); - - } - - /** - * Handle on pong - * - * @param \Ratchet\WebSocket\Version\RFC6455\Frame $frame - */ - public function onPong(Frame $frame) - { - $seq = $frame->getPayload(); - - if (isset($this->pingRequests[$seq]) && isset($this->pingRequests[$seq]['deferred'])) { - $this->pingRequests[$seq]['deferred']->resolve(); - /** @var TimerInterface $timer */ - $timer = $this->pingRequests[$seq]['timer']; - $timer->cancel(); - - unset($this->pingRequests[$seq]); - } - - // all sequence numbers before this one are probably no good anymore - // and actually are probably errors + return false; + } - -} \ No newline at end of file +} diff --git a/src/Thruway/Transport/PawlTransportProvider.php b/src/Thruway/Transport/PawlTransportProvider.php index d1f67137..7cec64b9 100644 --- a/src/Thruway/Transport/PawlTransportProvider.php +++ b/src/Thruway/Transport/PawlTransportProvider.php @@ -2,7 +2,6 @@ namespace Thruway\Transport; -use Ratchet\Client\Factory; use Thruway\Exception\DeserializationException; use Thruway\Logging\Logger; use Ratchet\Client\WebSocket; @@ -17,23 +16,17 @@ */ class PawlTransportProvider extends AbstractClientTransportProvider { - /** * @var string */ private $URL; - /** - * @var Factory - */ - private $connector; - /** * Constructor * * @param string $URL */ - function __construct($URL = "ws://127.0.0.1:8080/") + public function __construct($URL = "ws://127.0.0.1:8080/") { $this->URL = $URL; } @@ -50,11 +43,9 @@ public function startTransportProvider(ClientInterface $client, LoopInterface $l $this->client = $client; $this->loop = $loop; - $this->connector = new Factory($this->loop); - $this->connector->__invoke($this->URL, ['wamp.2.json'])->then( + \Ratchet\Client\connect($this->URL, ['wamp.2.json'], [], $loop)->then( function (WebSocket $conn) { - Logger::info($this, "Pawl has connected"); $transport = new PawlTransport($conn, $this->loop); @@ -83,18 +74,10 @@ function ($conn) { $this->client->onClose('close'); } ); - - $conn->on( - 'pong', - function ($frame, $ws) use ($transport) { - $transport->onPong($frame, $ws); - } - ); }, function ($e) { $this->client->onClose('unreachable'); Logger::info($this, "Could not connect: {$e->getMessage()}"); - // $this->loop->stop(); } ); } From 5377fb6dbc73c1cca37ce374839bf3dc4ecc8946 Mon Sep 17 00:00:00 2001 From: Matt Bonneau Date: Wed, 1 Jun 2016 23:08:53 -0400 Subject: [PATCH 05/15] Move Message and Serializer to separate library --- composer.json | 4 +- src/Thruway/Message/AbortMessage.php | 82 ----- .../Message/ActionMessageInterface.php | 30 -- src/Thruway/Message/AuthenticateMessage.php | 91 ------ src/Thruway/Message/CallMessage.php | 111 ------- src/Thruway/Message/CancelMessage.php | 54 ---- src/Thruway/Message/ChallengeMessage.php | 71 ----- src/Thruway/Message/ErrorMessage.php | 211 ------------- src/Thruway/Message/EventMessage.php | 181 ----------- src/Thruway/Message/GoodbyeMessage.php | 76 ----- src/Thruway/Message/HeartbeatMessage.php | 109 ------- src/Thruway/Message/HelloMessage.php | 112 ------- src/Thruway/Message/InterruptMessage.php | 47 --- src/Thruway/Message/InvocationMessage.php | 110 ------- src/Thruway/Message/Message.php | 233 --------------- src/Thruway/Message/MessageException.php | 15 - src/Thruway/Message/PublishMessage.php | 280 ------------------ src/Thruway/Message/PublishedMessage.php | 78 ----- src/Thruway/Message/RegisterMessage.php | 97 ------ src/Thruway/Message/RegisteredMessage.php | 75 ----- src/Thruway/Message/ResultMessage.php | 71 ----- src/Thruway/Message/SubscribeMessage.php | 118 -------- src/Thruway/Message/SubscribedMessage.php | 78 ----- src/Thruway/Message/Traits/ArgumentsTrait.php | 107 ------- src/Thruway/Message/Traits/DetailsTrait.php | 50 ---- .../Message/Traits/OptionsMatchTypeTrait.php | 37 --- src/Thruway/Message/Traits/OptionsTrait.php | 33 --- src/Thruway/Message/Traits/RequestTrait.php | 38 --- src/Thruway/Message/UnregisterMessage.php | 77 ----- src/Thruway/Message/UnregisteredMessage.php | 61 ---- src/Thruway/Message/UnsubscribeMessage.php | 78 ----- src/Thruway/Message/UnsubscribedMessage.php | 50 ---- src/Thruway/Message/WelcomeMessage.php | 77 ----- src/Thruway/Message/YieldMessage.php | 64 ---- src/Thruway/Serializer/JsonSerializer.php | 46 --- .../Serializer/SerializerInterface.php | 34 --- 36 files changed, 2 insertions(+), 3084 deletions(-) delete mode 100644 src/Thruway/Message/AbortMessage.php delete mode 100644 src/Thruway/Message/ActionMessageInterface.php delete mode 100644 src/Thruway/Message/AuthenticateMessage.php delete mode 100644 src/Thruway/Message/CallMessage.php delete mode 100644 src/Thruway/Message/CancelMessage.php delete mode 100644 src/Thruway/Message/ChallengeMessage.php delete mode 100644 src/Thruway/Message/ErrorMessage.php delete mode 100644 src/Thruway/Message/EventMessage.php delete mode 100644 src/Thruway/Message/GoodbyeMessage.php delete mode 100644 src/Thruway/Message/HeartbeatMessage.php delete mode 100644 src/Thruway/Message/HelloMessage.php delete mode 100644 src/Thruway/Message/InterruptMessage.php delete mode 100644 src/Thruway/Message/InvocationMessage.php delete mode 100644 src/Thruway/Message/Message.php delete mode 100644 src/Thruway/Message/MessageException.php delete mode 100644 src/Thruway/Message/PublishMessage.php delete mode 100644 src/Thruway/Message/PublishedMessage.php delete mode 100644 src/Thruway/Message/RegisterMessage.php delete mode 100644 src/Thruway/Message/RegisteredMessage.php delete mode 100644 src/Thruway/Message/ResultMessage.php delete mode 100644 src/Thruway/Message/SubscribeMessage.php delete mode 100644 src/Thruway/Message/SubscribedMessage.php delete mode 100644 src/Thruway/Message/Traits/ArgumentsTrait.php delete mode 100644 src/Thruway/Message/Traits/DetailsTrait.php delete mode 100644 src/Thruway/Message/Traits/OptionsMatchTypeTrait.php delete mode 100644 src/Thruway/Message/Traits/OptionsTrait.php delete mode 100644 src/Thruway/Message/Traits/RequestTrait.php delete mode 100644 src/Thruway/Message/UnregisterMessage.php delete mode 100644 src/Thruway/Message/UnregisteredMessage.php delete mode 100644 src/Thruway/Message/UnsubscribeMessage.php delete mode 100644 src/Thruway/Message/UnsubscribedMessage.php delete mode 100644 src/Thruway/Message/WelcomeMessage.php delete mode 100644 src/Thruway/Message/YieldMessage.php delete mode 100644 src/Thruway/Serializer/JsonSerializer.php delete mode 100644 src/Thruway/Serializer/SerializerInterface.php diff --git a/composer.json b/composer.json index a1826b5d..b18674cc 100644 --- a/composer.json +++ b/composer.json @@ -32,8 +32,8 @@ "cboden/ratchet": "0.3.*", "ratchet/pawl": "0.2.*", "psr/log": "~1", - "guzzle/guzzle": "~3.9", - "ext-openssl": "*" + "ext-openssl": "*", + "voryx/thruway-message": "^1.0" }, "extra": { "branch-alias": { diff --git a/src/Thruway/Message/AbortMessage.php b/src/Thruway/Message/AbortMessage.php deleted file mode 100644 index 6bb68fbd..00000000 --- a/src/Thruway/Message/AbortMessage.php +++ /dev/null @@ -1,82 +0,0 @@ -[ABORT, Details|dict, Reason|uri] - * - * @package Thruway\Message - */ -class AbortMessage extends Message -{ - - use DetailsTrait; - - /** - * Response URI - * - * @var mixed - */ - private $responseURI; - - /** - * Constructor - * - * @param \stdClass $details - * @param mixed $responseURI - */ - public function __construct($details, $responseURI) - { - parent::__construct(); - - $this->setDetails($details); - $this->setResponseURI($responseURI); - } - - - /** - * Set response URI - * - * @param mixed $responseURI - */ - public function setResponseURI($responseURI) - { - $this->responseURI = $responseURI; - } - - /** - * get response URL - * - * @return mixed - */ - public function getResponseURI() - { - return $this->responseURI; - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return Message::MSG_ABORT; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [(object)$this->getDetails(), $this->getResponseURI()]; - } - -} diff --git a/src/Thruway/Message/ActionMessageInterface.php b/src/Thruway/Message/ActionMessageInterface.php deleted file mode 100644 index 88a1c6b1..00000000 --- a/src/Thruway/Message/ActionMessageInterface.php +++ /dev/null @@ -1,30 +0,0 @@ -[AUTHENTICATE, Signature|string, Extra|dict] - * - * @package Thruway\Message - */ -class AuthenticateMessage extends Message -{ - - /** - * @var mixed - */ - private $signature; - - /** - * @var array - */ - private $extra; - - /** - * @param string $signature - * @param \stdClass $extra - */ - public function __construct($signature, $extra = null) - { - $this->setSignature($signature); - $this->setExtra($extra); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_AUTHENTICATE; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [$this->getSignature(), (object)$this->getExtra()]; - } - - /** - * Get authentication signature - * - * @return mixed - */ - public function getSignature() - { - return $this->signature; - } - - /** - * Get authentication extra - * - * @return array - */ - public function getExtra() - { - return $this->extra; - } - - /** - * @param \stdClass | array $extra - */ - public function setExtra($extra) - { - $this->extra = (object)$extra; - } - - /** - * @param mixed $signature - */ - public function setSignature($signature) - { - $this->signature = $signature; - } -} diff --git a/src/Thruway/Message/CallMessage.php b/src/Thruway/Message/CallMessage.php deleted file mode 100644 index 684b1d0c..00000000 --- a/src/Thruway/Message/CallMessage.php +++ /dev/null @@ -1,111 +0,0 @@ -[CALL, Request|id, Options|dict, Procedure|uri] - * [CALL, Request|id, Options|dict, Procedure|uri, Arguments|list] - * [CALL, Request|id, Options|dict, Procedure|uri, Arguments|list, ArgumentsKw|dict] - * - * @package Thruway\Message - */ -class CallMessage extends Message implements ActionMessageInterface -{ - - use RequestTrait; - use OptionsTrait; - use ArgumentsTrait; - - /** - * @var string - */ - private $procedureName; - - /** - * Constructor - * - * @param int $requestId - * @param \stdClass $options - * @param string $procedureName - * @param mixed $arguments - * @param mixed $argumentsKw - */ - public function __construct($requestId, $options, $procedureName, $arguments = null, $argumentsKw = null) - { - $this->setRequestId($requestId); - $this->setOptions($options); - $this->setProcedureName($procedureName); - $this->setArguments($arguments); - $this->setArgumentsKw($argumentsKw); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_CALL; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - $a = [$this->getRequestId(), $this->getOptions(), $this->getProcedureName()]; - - return array_merge($a, $this->getArgumentsForSerialization()); - - } - - /** - * @return mixed - */ - public function getProcedureName() - { - return $this->procedureName; - } - - /** - * @param string $procedureName - */ - public function setProcedureName($procedureName) - { - $this->procedureName = strtolower($procedureName); - } - - /** - * This returns the Uri so that the authorization manager doesn't have to know - * exactly the type of object to get the Uri - * - * @return mixed - */ - public function getUri() - { - return $this->getProcedureName(); - } - - /** - * This returns the action name "publish", "subscribe", "register", "call" - * - * @return mixed - */ - public function getActionName() - { - return "call"; - } - - -} diff --git a/src/Thruway/Message/CancelMessage.php b/src/Thruway/Message/CancelMessage.php deleted file mode 100644 index db5282e8..00000000 --- a/src/Thruway/Message/CancelMessage.php +++ /dev/null @@ -1,54 +0,0 @@ -[CANCEL, CALL.Request|id, Options|dict] - * - * @package Thruway\Message - */ -class CancelMessage extends Message -{ - - use RequestTrait; - use OptionsTrait; - - /** - * Constructor - * - * @param int $requestId - * @param \stdClass $options - */ - public function __construct($requestId, $options) - { - $this->setRequestId($requestId); - $this->setOptions($options); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_CANCEL; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [$this->getRequestId(), (object)$this->getOptions()]; - } - -} diff --git a/src/Thruway/Message/ChallengeMessage.php b/src/Thruway/Message/ChallengeMessage.php deleted file mode 100644 index 00bed5ad..00000000 --- a/src/Thruway/Message/ChallengeMessage.php +++ /dev/null @@ -1,71 +0,0 @@ -[CHALLENGE, AuthMethod|string, Extra|dict] - * - * @package Thruway\Message - */ -class ChallengeMessage extends Message -{ - use DetailsTrait; - - /** - * @var mixed - */ - private $authMethod; - - /** - * @param mixed $authMethod - * @param \stdClass $details - */ - public function __construct($authMethod, $details = null) - { - $this->setAuthMethod($authMethod); - $this->setDetails($details); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_CHALLENGE; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [$this->getAuthMethod(), (object)$this->getDetails()]; - } - - /** - * @return mixed - */ - public function getAuthMethod() - { - return $this->authMethod; - } - - - /** - * @param mixed $authMethod - */ - public function setAuthMethod($authMethod) - { - $this->authMethod = $authMethod; - } - -} diff --git a/src/Thruway/Message/ErrorMessage.php b/src/Thruway/Message/ErrorMessage.php deleted file mode 100644 index 94270912..00000000 --- a/src/Thruway/Message/ErrorMessage.php +++ /dev/null @@ -1,211 +0,0 @@ -[ERROR, REQUEST.Type|int, REQUEST.Request|id, Details|dict, Error|uri] - * [ERROR, REQUEST.Type|int, REQUEST.Request|id, Details|dict, Error|uri, Arguments|list] - * [ERROR, REQUEST.Type|int, REQUEST.Request|id, Details|dict, Error|uri, Arguments|list, ArgumentsKw|dict] - * - * @package Thruway\Message - */ -class ErrorMessage extends Message -{ - - use DetailsTrait; - use ArgumentsTrait; - - /** - * Error message code - * @var int - */ - private $errorMsgCode; - - /** - * Error request id - * @var mixed - */ - private $errorRequestId; - - /** - * Error URI - * @var string - */ - private $errorURI; - - /** - * Constructor - * - * @param int $errorMsgCode - * @param mixed $errorRequestId - * @param \stdClass $details - * @param string $errorURI - * @param mixed $arguments - * @param mixed $argumentsKw - */ - public function __construct($errorMsgCode, $errorRequestId, $details, $errorURI, $arguments = null, $argumentsKw = null) - { - - $this->setErrorRequestId($errorRequestId); - $this->setErrorMsgCode($errorMsgCode); - $this->setDetails($details); - $this->setErrorURI($errorURI); - $this->setArguments($arguments); - $this->setArgumentsKw($argumentsKw); - } - - /** - * Set error URI - * - * @param string $errorURI - * @return \Thruway\Message\ErrorMessage - */ - public function setErrorURI($errorURI) - { - $this->errorURI = $errorURI; - - return $this; - } - - /** - * Get error URI - * - * @return string - */ - public function getErrorURI() - { - return $this->errorURI; - } - - /** - * This creates a specific error message depending on the message we are reporting - * an error on. - * - * @param \Thruway\Message\Message $msg - * @param string $errorUri - * @return \Thruway\Message\ErrorMessage - */ - public static function createErrorMessageFromMessage(Message $msg, $errorUri = null) - { - if ($errorUri === null) { - $errorUri = "wamp.error.unknown"; - } - - if (method_exists($msg, "getRequestId")) { - return new ErrorMessage($msg->getMsgCode(), $msg->getRequestId(), new \stdClass, $errorUri); - } - - Logger::error(null, "Can't send an error message because the message didn't not have a request id "); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_ERROR; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return mixed - */ - public function getAdditionalMsgFields() - { - $a = [$this->getErrorMsgCode(), $this->getErrorRequestId(), $this->getDetails(), $this->getErrorURI()]; - - $a = array_merge($a, $this->getArgumentsForSerialization()); - - return $a; - } - - /** - * Set error message code - * - * @param int $errorMsgCode - * @return \Thruway\Message\ErrorMessage - */ - public function setErrorMsgCode($errorMsgCode) - { - $this->errorMsgCode = $errorMsgCode; - - return $this; - } - - /** - * Get error message code - * - * @return mixed - */ - public function getErrorMsgCode() - { - return $this->errorMsgCode; - } - - /** - * Set request ID - * - * @param mixed $requestId - * @return \Thruway\Message\ErrorMessage - */ - public function setRequestId($requestId) - { - $this->errorRequestId = $requestId; - - return $this; - } - - /** - * Get request ID - * - * @return mixed - */ - public function getRequestId() - { - return $this->errorRequestId; - } - - /** - * Set error request ID - * - * @param mixed $errorRequestId - * @return \Thruway\Message\ErrorMessage - */ - public function setErrorRequestId($errorRequestId) - { - $this->errorRequestId = $errorRequestId; - - return $this; - } - - /** - * Get error request ID - * - * @return mixed - */ - public function getErrorRequestId() - { - return $this->errorRequestId; - } - - /** - * Convert error message to string - * - * @return string - */ - public function __toString() - { - return $this->getErrorURI(); - } - -} diff --git a/src/Thruway/Message/EventMessage.php b/src/Thruway/Message/EventMessage.php deleted file mode 100644 index 01e55e3f..00000000 --- a/src/Thruway/Message/EventMessage.php +++ /dev/null @@ -1,181 +0,0 @@ -[EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id, Details|dict] - * [EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id, Details|dict, PUBLISH.Arguments|list] - * [EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id, Details|dict, PUBLISH.Arguments|list, PUBLISH.ArgumentsKw|dict] - * - * @package Thruway\Message - */ -class EventMessage extends Message -{ - - use DetailsTrait; - use ArgumentsTrait; - - /** - * @var int - */ - private $subscriptionId; - /** - * @var int - */ - private $publicationId; - - /** - * @var - */ - private $topic; - - /** - * Constructor - * - * @param int $subscriptionId - * @param int $publicationId - * @param \stdClass $details - * @param mixed $arguments - * @param mixed $argumentsKw - * @param null $topic - */ - public function __construct($subscriptionId, $publicationId, $details, $arguments = null, $argumentsKw = null, $topic = null) - { - $this->setArguments($arguments); - $this->setArgumentsKw($argumentsKw); - $this->setDetails($details); - $this->setPublicationId($publicationId); - $this->setSubscriptionId($subscriptionId); - $this->topic = $topic; - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_EVENT; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - $a = [$this->getSubscriptionId(), $this->getPublicationId(), $this->getDetails()]; - - return array_merge($a, $this->getArgumentsForSerialization()); - } - - /** - * Create event message from publish message - * - * @param \Thruway\Message\PublishMessage $msg - * @param int $subscriptionId - * @return \Thruway\Message\EventMessage - */ - public static function createFromPublishMessage(PublishMessage $msg, $subscriptionId) - { - return new static( - $subscriptionId, - $msg->getPublicationId(), - new \stdClass(), - $msg->getArguments(), - $msg->getArgumentsKw(), - $msg->getTopicName() - ); - } - - /** - * Set publication ID - * - * @param int $publicationId - */ - public function setPublicationId($publicationId) - { - $this->publicationId = $publicationId; - } - - /** - * Get publication ID - * - * @return int - */ - public function getPublicationId() - { - return $this->publicationId; - } - - /** - * Set subscription ID - * - * @param int $subscriptionId - */ - public function setSubscriptionId($subscriptionId) - { - $this->subscriptionId = $subscriptionId; - } - - /** - * Get subscription ID - * - * @return int - */ - public function getSubscriptionId() - { - return $this->subscriptionId; - } - - /** - * @param Session $session - */ - public function disclosePublisher(Session $session) - { - - $details = $this->getDetails(); - $details->publisher = $session->getSessionId(); - $details->topic = $this->topic; - $authenticationDetails = $session->getAuthenticationDetails(); - $details->authid = $authenticationDetails->getAuthId(); - $details->authrole = $authenticationDetails->getAuthRole(); - $details->authroles = $authenticationDetails->getAuthRoles(); - $details->authmethod = $authenticationDetails->getAuthMethod(); - - if ($authenticationDetails->getAuthExtra() !== null) { - $details->_thruway_authextra = $authenticationDetails->getAuthExtra(); - } - - } - - /** - * @return boolean - */ - public function isRestoringState() - { - $restoringState = isset($this->getDetails()->_thruway_restoring_state) ? $this->getDetails()->_thruway_restoring_state : false; - - return $restoringState; - } - - /** - * @param boolean $restoringState - */ - public function setRestoringState($restoringState) - { - $details = $this->getDetails(); - if (is_object($details)) { - $details->_thruway_restoring_state = true; - } - } -} \ No newline at end of file diff --git a/src/Thruway/Message/GoodbyeMessage.php b/src/Thruway/Message/GoodbyeMessage.php deleted file mode 100644 index 788e6107..00000000 --- a/src/Thruway/Message/GoodbyeMessage.php +++ /dev/null @@ -1,76 +0,0 @@ -[GOODBYE, Details|dict, Reason|uri] - * - * @package Thruway\Message - */ -class GoodbyeMessage extends Message -{ - - use DetailsTrait; - - /** - * @var string - */ - private $reason; - - /** - * @param \stdClass $details - * @param string $reason - */ - public function __construct($details, $reason) - { - $this->setDetails($details); - $this->setReason($reason); - } - - /** - * Set reason - * - * @param string $reason - */ - public function setReason($reason) - { - $this->reason = $reason; - } - - /** - * Get reason - * - * @return string - */ - public function getReason() - { - return $this->reason; - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_GOODBYE; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [(object)$this->getDetails(), $this->getReason()]; - } - -} \ No newline at end of file diff --git a/src/Thruway/Message/HeartbeatMessage.php b/src/Thruway/Message/HeartbeatMessage.php deleted file mode 100644 index 2784948a..00000000 --- a/src/Thruway/Message/HeartbeatMessage.php +++ /dev/null @@ -1,109 +0,0 @@ -setDiscard($discard); - $this->setIncomingSeq($incomingSeq); - $this->setOutgoingSeq($outgoingSeq); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return Message::MSG_HEARTBEAT; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - $a = [$this->getIncomingSeq(), $this->getOutgoingSeq()]; - - if (is_string($this->getDiscard())) { - array_push($a, $this->getDiscard()); - } - - return $a; - } - - /** - * @return string - */ - public function getDiscard() - { - return $this->discard; - } - - /** - * @param string $discard - */ - public function setDiscard($discard) - { - $this->discard = $discard; - } - - /** - * @return int - */ - public function getIncomingSeq() - { - return $this->incomingSeq; - } - - /** - * @param int $incomingSeq - */ - public function setIncomingSeq($incomingSeq) - { - $this->incomingSeq = $incomingSeq; - } - - /** - * @return int - */ - public function getOutgoingSeq() - { - return $this->outgoingSeq; - } - - /** - * @param int $outgoingSeq - */ - public function setOutgoingSeq($outgoingSeq) - { - $this->outgoingSeq = $outgoingSeq; - } - - -} \ No newline at end of file diff --git a/src/Thruway/Message/HelloMessage.php b/src/Thruway/Message/HelloMessage.php deleted file mode 100644 index 37bee5e3..00000000 --- a/src/Thruway/Message/HelloMessage.php +++ /dev/null @@ -1,112 +0,0 @@ -[HELLO, Realm|uri, Details|dict] - * - * @package Thruway\Message - */ -class HelloMessage extends Message -{ - - use DetailsTrait; - - /** - * @var string - */ - private $realm; - - /** - * @var array - */ - private $roles; - - /** - * @var array - */ - private $authMethods; - - /** - * Constructor - * - * @param string $realm - * @param \stdClass $details - */ - public function __construct($realm, $details) - { - if (!is_scalar($realm)) { - throw new \InvalidArgumentException("Non-scalar realm name."); - } - - $this->setDetails($details); - $this->setRealm($realm); - $authMethods = isset($details->authmethods) ? $details->authmethods : []; - $this->setAuthMethods($authMethods); - } - - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_HELLO; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [$this->getRealm(), $this->getDetails()]; - } - - /** - * Set realm - * - * @param string $realm - */ - public function setRealm($realm) - { - $this->realm = $realm; - } - - /** - * Get realm - * - * @return string - */ - public function getRealm() - { - return $this->realm; - } - - /** - * Get list authenticate methods - * - * @return array - */ - public function getAuthMethods() - { - return $this->authMethods; - } - - /** - * @param array $authMethods - */ - public function setAuthMethods($authMethods) - { - $this->authMethods = $authMethods; - } - -} diff --git a/src/Thruway/Message/InterruptMessage.php b/src/Thruway/Message/InterruptMessage.php deleted file mode 100644 index 8ab6c233..00000000 --- a/src/Thruway/Message/InterruptMessage.php +++ /dev/null @@ -1,47 +0,0 @@ -setRequestId($requestId); - $this->setOptions($options); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return Message::MSG_INTERRUPT; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [$this->getRequestId(), (object)$this->getOptions()]; - } - -} \ No newline at end of file diff --git a/src/Thruway/Message/InvocationMessage.php b/src/Thruway/Message/InvocationMessage.php deleted file mode 100644 index 112b5b10..00000000 --- a/src/Thruway/Message/InvocationMessage.php +++ /dev/null @@ -1,110 +0,0 @@ -[INVOCATION, Request|id, REGISTERED.Registration|id, Details|dict] - * [INVOCATION, Request|id, REGISTERED.Registration|id, Details|dict, CALL.Arguments|list] - * [INVOCATION, Request|id, REGISTERED.Registration|id, Details|dict, CALL.Arguments|list, CALL.ArgumentsKw|dict] - * - * @package Thruway\Message - */ -class InvocationMessage extends Message -{ - - use RequestTrait; - use DetailsTrait; - use ArgumentsTrait; - - /** - * @var int - */ - private $registrationId; - - /** - * Constructor - * - * @param int $requestId - * @param int $registrationId - * @param \stdClass $details - * @param mixed $arguments - * @param mixed $argumentsKw - */ - public function __construct($requestId, $registrationId, $details, $arguments = null, $argumentsKw = null) - { - $this->setRequestId($requestId); - $this->setRegistrationId($registrationId); - $this->setDetails($details); - $this->setArguments($arguments); - $this->setArgumentsKw($argumentsKw); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_INVOCATION; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - - $a = [$this->getRequestId(), $this->getRegistrationId(), $this->getDetails()]; - - return array_merge($a, $this->getArgumentsForSerialization()); - } - - /** - * Create Invocation message from Call message and registration - * - * @param \Thruway\Message\CallMessage $msg - * @param \Thruway\Registration $registration - * @return \Thruway\Message\InvocationMessage - */ - public static function createMessageFrom(CallMessage $msg, Registration $registration) - { - $requestId = Utils::getUniqueId(); - $details = new \stdClass(); - - return new static($requestId, $registration->getId(), $details, $msg->getArguments(), $msg->getArgumentsKw()); - } - - /** - * Get Registration ID - * - * @return int - */ - public function getRegistrationId() - { - return $this->registrationId; - } - - /** - * Set Registration ID - * - * @param int $registrationId - */ - public function setRegistrationId($registrationId) - { - $this->registrationId = $registrationId; - } - -} diff --git a/src/Thruway/Message/Message.php b/src/Thruway/Message/Message.php deleted file mode 100644 index f326c4a1..00000000 --- a/src/Thruway/Message/Message.php +++ /dev/null @@ -1,233 +0,0 @@ -getMsgCode()], $this->getAdditionalMsgFields()); - } - - /** - * (PHP 5 >= 5.4.0)
- * Specify data which should be serialized to JSON - * @link http://php.net/manual/en/jsonserializable.jsonserialize.php - * @return mixed data which can be serialized by json_encode, - * which is a value of any type other than a resource. - */ - public function jsonSerialize() - { - return $this->getMessageParts(); - } - - /** - * Convert object to string - * - * @return string - */ - public function __toString() - { - return "[" . get_class($this) . "]"; - } - - /** - * Check and convert empty array to \stdClass object - * - * @param mixed $a - * @return \stdClass|mixed - */ - public static function shouldBeDictionary($a) - { - if (is_array($a)) { - $a = (object)$a; - } - return $a; - } - - /** - * Check array is associative array - * @param array $arr - * @return boolean - */ - public static function isAssoc($arr) - { - // if this is an empty stdClass (which we use as empty dictionaries) - $arr = (array)$arr; - - return array_keys($arr) !== range(0, count($arr) - 1); - } - - /** - * Get the args from the message data - * - * @param array $data - * @param int $position - * @return mixed|null - */ - protected static function getArgs($data, $position) - { - return isset($data[$position]) ? $data[$position] : null; - } - -} \ No newline at end of file diff --git a/src/Thruway/Message/MessageException.php b/src/Thruway/Message/MessageException.php deleted file mode 100644 index 0a9fd9c1..00000000 --- a/src/Thruway/Message/MessageException.php +++ /dev/null @@ -1,15 +0,0 @@ -[PUBLISH, Request|id, Options|dict, Topic|uri] - * [PUBLISH, Request|id, Options|dict, Topic|uri, Arguments|list] - * [PUBLISH, Request|id, Options|dict, Topic|uri, Arguments|list, ArgumentsKw|dict] - * - * @package Thruway\Message - */ -class PublishMessage extends Message implements ActionMessageInterface -{ - - use RequestTrait; - use OptionsTrait { - setOptions as traitSetOptions; - } - use ArgumentsTrait; - - /** - * - * @var string - */ - private $topicName; - - - /** - * @var boolean - */ - private $acknowledge; - - /** - * @var boolean - */ - private $exclude_me; - - /** - * @var array - */ - private $exclude; - - /** - * @var array - */ - private $eligible; - - /** @var array */ - private $eligible_authroles; - - /** @var array */ - private $eligible_authids; - - /** - * @var int - */ - private $publicationId; - - /** - * Constructor - * - * @param int $requestId - * @param \stdClass $options - * @param string $topicName - * @param mixed $arguments - * @param mixed $argumentsKw - */ - public function __construct($requestId, $options, $topicName, $arguments = null, $argumentsKw = null) - { - $this->setRequestId($requestId); - $this->setArguments($arguments); - $this->setArgumentsKw($argumentsKw); - $this->setOptions($options); - $this->setTopicName($topicName); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_PUBLISH; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - - $a = [$this->getRequestId(), $this->getOptions(), $this->getTopicName()]; - - return array_merge($a, $this->getArgumentsForSerialization()); - - } - - /** - * Set topic name - * - * @param string $topicName - */ - public function setTopicName($topicName) - { - $this->topicName = $topicName; - } - - /** - * Get topic name - * - * @return string - */ - public function getTopicName() - { - return $this->topicName; - } - - /** - * This returns the Uri so that the authorization manager doesn't have to know - * exactly the type of object to get the Uri - * - * @return mixed - */ - public function getUri() - { - return $this->getTopicName(); - } - - /** - * This returns the action name "publish", "subscribe", "register", "call" - * - * @return mixed - */ - public function getActionName() - { - return "publish"; - } - - - /** - * @param $options - */ - public function setOptions($options) - { - $this->traitSetOptions($options); - - //Get the options that have been cast to an object - $options = $this->getOptions(); - - $this->acknowledge = isset($options->acknowledge) && $options->acknowledge === true ? true : false; - $this->exclude_me = isset($options->exclude_me) && $options->exclude_me === false ? false : true; - $this->exclude = isset($options->exclude) && is_array($options->exclude) ? $options->exclude : []; - $this->eligible = isset($options->eligible) && is_array($options->eligible) ? $options->eligible : null; - $this->eligible_authroles = []; // default to no auth roles eligible - - if (isset($options->_thruway_eligible_authroles)) { - if (is_array($options->_thruway_eligible_authroles)) { - $this->eligible_authroles = $options->_thruway_eligible_authroles; - } - } else { - $this->eligible_authroles = null; // null says every authrole is valid - } - - $this->eligible_authids = []; // default to no authids eligible - if (isset($options->_thruway_eligible_authids)) { - if (is_array($options->_thruway_eligible_authids)) { - $this->eligible_authids = $options->_thruway_eligible_authids; - } - } else { - $this->eligible_authids = null; // null says every authid is valid - } - } - - /** - * @return boolean - */ - public function acknowledge() - { - return $this->acknowledge; - } - - /** - * @return boolean - */ - public function excludeMe() - { - return $this->exclude_me; - } - - /** - * @return array - */ - public function getExclude() - { - return $this->exclude; - } - - /** - * @return array | null - */ - public function getEligible() - { - return $this->eligible; - } - - /** - * @param $sessionId - * @return bool - */ - public function isWhiteListed($sessionId) - { - return null === $this->getEligible() || in_array($sessionId, $this->getEligible()); - } - - /** - * @param $sessionId - * @return bool - */ - public function isExcluded($sessionId) - { - return in_array($sessionId, $this->getExclude()); - } - - /** - * @return int - */ - public function getPublicationId() - { - return $this->publicationId; - } - - /** - * @param int $publicationId - */ - public function setPublicationId($publicationId) - { - $this->publicationId = $publicationId; - } - - public function hasEligibleAuthrole($authroles) - { - if (!is_array($authroles)) { - $authroles = []; - } - if ($this->eligible_authroles === null) { - return true; - } - $intersect = array_intersect($authroles, $this->eligible_authroles); - if (count($intersect) > 0) { - return true; - } - - return false; - } - - public function hasEligibleAuthid($authid) - { - if ($this->eligible_authids === null) { - return true; - } - if (in_array($authid, $this->eligible_authids)) { - return true; - } - - return false; - } -} - - diff --git a/src/Thruway/Message/PublishedMessage.php b/src/Thruway/Message/PublishedMessage.php deleted file mode 100644 index 7a492f64..00000000 --- a/src/Thruway/Message/PublishedMessage.php +++ /dev/null @@ -1,78 +0,0 @@ -[PUBLISHED, PUBLISH.Request|id, Publication|id] - * - * @package Thruway\Message - */ -class PublishedMessage extends Message -{ - - use RequestTrait; - - /** - * - * @var int - */ - private $publicationId; - - /** - * Constructor - * - * @param int $requestId - * @param int $publicationId - */ - public function __construct($requestId, $publicationId) - { - $this->setRequestId($requestId); - $this->setPublicationId($publicationId); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_PUBLISHED; - } - - /** - * Set publication ID - * - * @param int $publicationId - */ - public function setPublicationId($publicationId) - { - $this->publicationId = $publicationId; - } - - /** - * Get publication ID - * - * @return int - */ - public function getPublicationId() - { - return $this->publicationId; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [$this->getRequestId(), $this->getPublicationId()]; - } - -} diff --git a/src/Thruway/Message/RegisterMessage.php b/src/Thruway/Message/RegisterMessage.php deleted file mode 100644 index 7ea3966c..00000000 --- a/src/Thruway/Message/RegisterMessage.php +++ /dev/null @@ -1,97 +0,0 @@ -[REGISTER, Request|id, Options|dict, Procedure|uri] - * - * @package Thruway\Message - */ -class RegisterMessage extends Message implements ActionMessageInterface -{ - use RequestTrait; - use OptionsTrait; - - /** - * @var string - */ - private $procedureName; - - /** - * @param int $requestId - * @param \stdClass $options - * @param string $procedureName - */ - public function __construct($requestId, $options, $procedureName) - { - $this->setOptions($options); - $this->setProcedureName(strtolower($procedureName)); - $this->setRequestId($requestId); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_REGISTER; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [$this->requestId, (object)$this->getOptions(), $this->getProcedureName()]; - } - - /** - * Get procedure name - * - * @return string - */ - public function getProcedureName() - { - return $this->procedureName; - } - - /** - * This returns the Uri so that the authorization manager doesn't have to know - * exactly the type of object to get the Uri - * - * @return mixed - */ - public function getUri() - { - return $this->getProcedureName(); - } - - /** - * This returns the action name "publish", "subscribe", "register", "call" - * - * @return mixed - */ - public function getActionName() - { - return "register"; - } - - /** - * @param string $procedureName - */ - public function setProcedureName($procedureName) - { - $this->procedureName = $procedureName; - } - -} diff --git a/src/Thruway/Message/RegisteredMessage.php b/src/Thruway/Message/RegisteredMessage.php deleted file mode 100644 index 107084bf..00000000 --- a/src/Thruway/Message/RegisteredMessage.php +++ /dev/null @@ -1,75 +0,0 @@ -[REGISTERED, REGISTER.Request|id, Registration|id] - * - * @package Thruway\Message - */ -class RegisteredMessage extends Message -{ - - use RequestTrait; - - /** - * @var int - */ - private $registrationId; - - /** - * Constructor - * - * @param int $requestId - * @param int $registrationId - */ - public function __construct($requestId, $registrationId) - { - $this->setRequestId($requestId); - $this->setRegistrationId($registrationId); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_REGISTERED; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [$this->getRequestId(), $this->getRegistrationId()]; - } - - /** - * Get registration ID - * - * @return int - */ - public function getRegistrationId() - { - return $this->registrationId; - } - - /** - * @param int $registrationId - */ - public function setRegistrationId($registrationId) - { - $this->registrationId = $registrationId; - } - -} diff --git a/src/Thruway/Message/ResultMessage.php b/src/Thruway/Message/ResultMessage.php deleted file mode 100644 index 286e1e02..00000000 --- a/src/Thruway/Message/ResultMessage.php +++ /dev/null @@ -1,71 +0,0 @@ -[RESULT, CALL.Request|id, Details|dict] - * [RESULT, CALL.Request|id, Details|dict, YIELD.Arguments|list] - * [RESULT, CALL.Request|id, Details|dict, YIELD.Arguments|list, YIELD.ArgumentsKw|dict] - * - * @package Thruway\Message - */ -class ResultMessage extends Message -{ - use RequestTrait; - use DetailsTrait; - - /** - * using arguments trait - * @see \Thruway\Message\ArgumentsTrait - */ - use ArgumentsTrait; - - - /** - * Constructor - * - * @param int $requestId - * @param \stdClass $details - * @param array $arguments - * @param array $argumentsKw - */ - public function __construct($requestId, $details, $arguments = null, $argumentsKw = null) - { - $this->setRequestId($requestId); - $this->setDetails($details); - $this->setArguments($arguments); - $this->setArgumentsKw($argumentsKw); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_RESULT; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - - $a = [$this->getRequestId(), $this->getDetails()]; - - return array_merge($a, $this->getArgumentsForSerialization()); - } - - -} diff --git a/src/Thruway/Message/SubscribeMessage.php b/src/Thruway/Message/SubscribeMessage.php deleted file mode 100644 index 40c031e1..00000000 --- a/src/Thruway/Message/SubscribeMessage.php +++ /dev/null @@ -1,118 +0,0 @@ -[SUBSCRIBE, Request|id, Options|dict, Topic|uri] - * - * @package Thruway\Message - */ -class SubscribeMessage extends Message implements ActionMessageInterface -{ - - use RequestTrait; - use OptionsTrait; - use OptionsMatchTypeTrait; - - /** - * - * @var string - */ - private $topicName; - - /** - * Constructor - * - * @param int $requestId - * @param \stdClass $options - * @param string $topicName - */ - public function __construct($requestId, $options, $topicName) - { - $this->setOptions($options); - $this->setTopicName($topicName); - $this->setRequestId($requestId); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_SUBSCRIBE; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [$this->getRequestId(), (object)$this->getOptions(), $this->getTopicName()]; - } - - /** - * Set topic name - * - * @param string $topicName - */ - public function setTopicName($topicName) - { - $this->topicName = $topicName; - } - - /** - * Get topic name - * - * @return string - */ - public function getTopicName() - { - return $this->topicName; - } - - /** - * This returns the Uri so that the authorization manager doesn't have to know - * exactly the type of object to get the Uri - * - * @return mixed - */ - public function getUri() - { - return $this->getTopicName(); - } - - /** - * This returns the action name "publish", "subscribe", "register", "call" - * - * @return mixed - */ - public function getActionName() - { - return "subscribe"; - } - - /** - * @param $options - * @return string - */ - static public function getMatchTypeFromOption($options) - { - if (is_object($options) && isset($options->match) && is_scalar($options->match)) { - return $options->match; - } - - return "exact"; - } - -} diff --git a/src/Thruway/Message/SubscribedMessage.php b/src/Thruway/Message/SubscribedMessage.php deleted file mode 100644 index 2fa55281..00000000 --- a/src/Thruway/Message/SubscribedMessage.php +++ /dev/null @@ -1,78 +0,0 @@ -[SUBSCRIBED, SUBSCRIBE.Request|id, Subscription|id] - * - * @package Thruway\Message - */ -class SubscribedMessage extends Message -{ - - use RequestTrait; - - /** - * - * @var int - */ - private $subscriptionId; - - /** - * Constructor - * - * @param int $requestId - * @param int $subscriptionId - */ - public function __construct($requestId, $subscriptionId) - { - $this->setRequestId($requestId); - $this->setSubscriptionId($subscriptionId); - } - - /** - * Set subscription ID - * - * @param int $subscriptionId - */ - public function setSubscriptionId($subscriptionId) - { - $this->subscriptionId = $subscriptionId; - } - - /** - * Get Subscription ID - * - * @return int - */ - public function getSubscriptionId() - { - return $this->subscriptionId; - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_SUBSCRIBED; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [$this->getRequestId(), $this->getSubscriptionId()]; - } - -} diff --git a/src/Thruway/Message/Traits/ArgumentsTrait.php b/src/Thruway/Message/Traits/ArgumentsTrait.php deleted file mode 100644 index a5ad8fc9..00000000 --- a/src/Thruway/Message/Traits/ArgumentsTrait.php +++ /dev/null @@ -1,107 +0,0 @@ -getArguments(); - $argsKw = $this->getArgumentsKw(); - if ($args !== null && is_array($args) && count($args) > 0) { - $a = array_merge($a, [$args]); - if ($argsKw !== null && Message::isAssoc($argsKw) && count((array)$argsKw) > 0) { - $a = array_merge($a, [$argsKw]); - } - } else { - if ($argsKw !== null && Message::isAssoc($argsKw) && count((array)$argsKw) > 0) { - $a = array_merge($a, [[], $argsKw]); - } - } - - return $a; - } - - /** - * Get arguments - * - * @return mixed - */ - public function getArguments() - { - return $this->arguments ?: []; - } - - /** - * Set arguments - * - * @param mixed $arguments - */ - public function setArguments($arguments) - { - if (is_array($arguments) || $arguments === null) { - $this->arguments = $arguments; - } else { - $this->arguments = null; - throw new \InvalidArgumentException(); - } - } - - /** - * Get arguments kw - * - * @return mixed - */ - public function getArgumentsKw() - { - return $this->argumentsKw; - } - - /** - * Set arguments - * - * @param mixed $argumentsKw - */ - public function setArgumentsKw($argumentsKw) - { - $this->argumentsKw = (object)$argumentsKw; - } - - /** - * Set arguments from result - * - * @param \Thruway\Result $result - */ - public function setArgumentsFromResult(Result $result) - { - $this->setArguments($result->getArguments()); - $this->setArgumentsKw($result->getArgumentsKw()); - } - -} diff --git a/src/Thruway/Message/Traits/DetailsTrait.php b/src/Thruway/Message/Traits/DetailsTrait.php deleted file mode 100644 index 0ce934ee..00000000 --- a/src/Thruway/Message/Traits/DetailsTrait.php +++ /dev/null @@ -1,50 +0,0 @@ -details = (object) $details; - } - - /** - * Get abort message details - * - * @return \stdClass - */ - public function getDetails() - { - return $this->details; - } - - /** - * @param $name - * @param \stdClass $features - */ - public function addFeatures($name, \stdClass $features) - { - $this->details = isset($this->details) ? $this->details : new \stdClass(); - $this->details->roles = isset($this->details->roles) ? $this->details->roles : new \stdClass(); - - $this->details->roles->$name = (object) ["features" => $features]; - } -} \ No newline at end of file diff --git a/src/Thruway/Message/Traits/OptionsMatchTypeTrait.php b/src/Thruway/Message/Traits/OptionsMatchTypeTrait.php deleted file mode 100644 index ab3bb4e7..00000000 --- a/src/Thruway/Message/Traits/OptionsMatchTypeTrait.php +++ /dev/null @@ -1,37 +0,0 @@ -getOptions()); - } - - /** - * @param string $matchType - */ - public function setMatchType($matchType) - { - $options = $this->getOptions(); - if (is_object($options)) { - $options->match = $matchType; - if ($matchType == "exact") { - unset($options->match); - } - } - $this->setOptions($options); - } -} \ No newline at end of file diff --git a/src/Thruway/Message/Traits/OptionsTrait.php b/src/Thruway/Message/Traits/OptionsTrait.php deleted file mode 100644 index 70b29259..00000000 --- a/src/Thruway/Message/Traits/OptionsTrait.php +++ /dev/null @@ -1,33 +0,0 @@ -options; - } - - /** - * @param \stdClass|array $options - */ - public function setOptions($options) - { - $this->options = (object)$options; - } - -} \ No newline at end of file diff --git a/src/Thruway/Message/Traits/RequestTrait.php b/src/Thruway/Message/Traits/RequestTrait.php deleted file mode 100644 index bee0ffa3..00000000 --- a/src/Thruway/Message/Traits/RequestTrait.php +++ /dev/null @@ -1,38 +0,0 @@ -requestId; - } - - /** - * Set request ID - * - * @param int $requestId - */ - public function setRequestId($requestId) - { - $this->requestId = $requestId; - } - -} \ No newline at end of file diff --git a/src/Thruway/Message/UnregisterMessage.php b/src/Thruway/Message/UnregisterMessage.php deleted file mode 100644 index 029029d1..00000000 --- a/src/Thruway/Message/UnregisterMessage.php +++ /dev/null @@ -1,77 +0,0 @@ -[UNREGISTER, Request|id, REGISTERED.Registration|id] - * - * @package Thruway\Message - */ -class UnregisterMessage extends Message -{ - - use RequestTrait; - - /** - * - * @var int - */ - private $registrationId; - - /** - * Constructor - * - * @param int $requestId - * @param int $registrationId - */ - public function __construct($requestId, $registrationId) - { - $this->setRegistrationId($registrationId); - $this->setRequestId($requestId); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_UNREGISTER; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [$this->getRequestId(), $this->getRegistrationId()]; - } - - /** - * Get registration ID - * - * @return int - */ - public function getRegistrationId() - { - return $this->registrationId; - } - - /** - * @param int $registrationId - */ - public function setRegistrationId($registrationId) - { - $this->registrationId = $registrationId; - } - - -} diff --git a/src/Thruway/Message/UnregisteredMessage.php b/src/Thruway/Message/UnregisteredMessage.php deleted file mode 100644 index d7b0ed75..00000000 --- a/src/Thruway/Message/UnregisteredMessage.php +++ /dev/null @@ -1,61 +0,0 @@ -[UNREGISTERED, UNREGISTER.Request|id] - * - * @package Thruway\Message - */ -class UnregisteredMessage extends Message -{ - - use RequestTrait; - - /** - * Constructor - * - * @param int $requestId - */ - public function __construct($requestId) - { - $this->requestId = $requestId; - } - - /** - * Create Unregisterd message from unregister message - * - * @param \Thruway\Message\UnregisterMessage $msg - * @return \Thruway\Message\UnregisteredMessage - */ - public static function createFromUnregisterMessage(UnregisterMessage $msg) - { - return new UnregisteredMessage($msg->getRequestId()); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_UNREGISTERED; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [$this->getRequestId()]; - } - -} diff --git a/src/Thruway/Message/UnsubscribeMessage.php b/src/Thruway/Message/UnsubscribeMessage.php deleted file mode 100644 index e58bb3a8..00000000 --- a/src/Thruway/Message/UnsubscribeMessage.php +++ /dev/null @@ -1,78 +0,0 @@ -[UNSUBSCRIBE, Request|id, SUBSCRIBED.Subscription|id] - * - * @package Thruway\Message - */ -class UnsubscribeMessage extends Message -{ - - use RequestTrait; - - /** - * - * @var int - */ - private $subscriptionId; - - /** - * Constructor - * - * @param int $requestId - * @param int $subscriptionId - */ - public function __construct($requestId, $subscriptionId) - { - $this->setRequestId($requestId); - $this->setSubscriptionId($subscriptionId); - } - - /** - * Set subscription ID - * - * @param int $subscriptionId - */ - public function setSubscriptionId($subscriptionId) - { - $this->subscriptionId = $subscriptionId; - } - - /** - * Get subscription ID - * - * @return int - */ - public function getSubscriptionId() - { - return $this->subscriptionId; - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_UNSUBSCRIBE; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [$this->getRequestId(), $this->getSubscriptionId()]; - } - -} diff --git a/src/Thruway/Message/UnsubscribedMessage.php b/src/Thruway/Message/UnsubscribedMessage.php deleted file mode 100644 index 6f15dc5d..00000000 --- a/src/Thruway/Message/UnsubscribedMessage.php +++ /dev/null @@ -1,50 +0,0 @@ -[UNSUBSCRIBED, UNSUBSCRIBE.Request|id] - * - * @package Thruway\Message - */ -class UnsubscribedMessage extends Message -{ - - use RequestTrait; - - /** - * Constructor - * - * @param int $requestId - */ - public function __construct($requestId) - { - $this->setRequestId($requestId); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_UNSUBSCRIBED; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [$this->getRequestId()]; - } - -} diff --git a/src/Thruway/Message/WelcomeMessage.php b/src/Thruway/Message/WelcomeMessage.php deleted file mode 100644 index dea8b76e..00000000 --- a/src/Thruway/Message/WelcomeMessage.php +++ /dev/null @@ -1,77 +0,0 @@ -setDetails($details); - $this->setSessionId($sessionId); - } - - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_WELCOME; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - return [$this->sessionId, $this->details]; - } - - /** - * Get session ID - * - * @return int - */ - public function getSessionId() - { - return $this->sessionId; - } - - /** - * @param int $sessionId - */ - public function setSessionId($sessionId) - { - $this->sessionId = $sessionId; - } - -} \ No newline at end of file diff --git a/src/Thruway/Message/YieldMessage.php b/src/Thruway/Message/YieldMessage.php deleted file mode 100644 index 76604d86..00000000 --- a/src/Thruway/Message/YieldMessage.php +++ /dev/null @@ -1,64 +0,0 @@ -[YIELD, INVOCATION.Request|id, Options|dict] - * [YIELD, INVOCATION.Request|id, Options|dict, Arguments|list] - * [YIELD, INVOCATION.Request|id, Options|dict, Arguments|list, ArgumentsKw|dict] - * - * @package Thruway\Message - */ -class YieldMessage extends Message -{ - - use RequestTrait; - use OptionsTrait; - use ArgumentsTrait; - - /** - * Constructor - * - * @param mixed $requestId - * @param \stdClass $options - * @param mixed $arguments - * @param mixed $argumentsKw - */ - public function __construct($requestId, $options, $arguments = null, $argumentsKw = null) - { - $this->setRequestId($requestId); - $this->setOptions($options); - $this->setArguments($arguments); - $this->setArgumentsKw($argumentsKw); - } - - /** - * Get message code - * - * @return int - */ - public function getMsgCode() - { - return static::MSG_YIELD; - } - - /** - * This is used by get message parts to get the parts of the message beyond - * the message code - * - * @return array - */ - public function getAdditionalMsgFields() - { - $a = [$this->getRequestId(), $this->getOptions()]; - - return array_merge($a, $this->getArgumentsForSerialization()); - } - -} diff --git a/src/Thruway/Serializer/JsonSerializer.php b/src/Thruway/Serializer/JsonSerializer.php deleted file mode 100644 index 07a033d9..00000000 --- a/src/Thruway/Serializer/JsonSerializer.php +++ /dev/null @@ -1,46 +0,0 @@ - Date: Sun, 14 Aug 2016 14:45:07 -0400 Subject: [PATCH 06/15] Housekeeping and Logger improvements --- src/Thruway/AbstractSession.php | 7 +- .../AbstractAuthProviderClient.php | 1 - .../Authentication/AnonymousAuthenticator.php | 3 - .../Authentication/AuthenticationDetails.php | 2 - .../Authentication/AuthenticationManager.php | 2 - .../Authentication/AuthorizationManager.php | 3 - .../ClientWampCraAuthenticator.php | 8 +- .../Authentication/WampCraAuthProvider.php | 2 - .../Authentication/WampCraUserDbInterface.php | 1 - src/Thruway/Call.php | 6 +- src/Thruway/CallResult.php | 77 +------------------ src/Thruway/ClientSession.php | 2 - src/Thruway/Common/Utils.php | 1 - src/Thruway/Connection.php | 8 +- src/Thruway/Event/ConnectionCloseEvent.php | 7 +- src/Thruway/Event/ConnectionOpenEvent.php | 9 +-- src/Thruway/Event/Event.php | 7 +- src/Thruway/Event/EventDispatcher.php | 12 +-- .../Event/EventDispatcherInterface.php | 7 +- .../Event/EventSubscriberInterface.php | 7 +- src/Thruway/Event/LeaveRealmEvent.php | 9 +-- src/Thruway/Event/MessageEvent.php | 9 +-- src/Thruway/Event/NewRealmEvent.php | 8 +- src/Thruway/Event/RouterStartEvent.php | 7 +- src/Thruway/Event/RouterStopEvent.php | 7 +- .../Exception/DeserializationException.php | 3 +- .../Exception/InvalidRealmNameException.php | 3 +- .../Exception/PingNotSupportedException.php | 3 +- .../Exception/RealmNotFoundException.php | 3 +- .../Exception/SerializationException.php | 3 +- src/Thruway/Exception/WampErrorException.php | 10 +-- src/Thruway/Logging/ConsoleLogger.php | 2 - src/Thruway/Logging/Logger.php | 21 +++-- src/Thruway/Module/RealmModuleInterface.php | 4 +- src/Thruway/Module/RouterModule.php | 1 - src/Thruway/Module/RouterModuleClient.php | 2 - src/Thruway/Module/RouterModuleInterface.php | 2 - src/Thruway/Peer/Client.php | 4 +- src/Thruway/Peer/ClientInterface.php | 4 +- src/Thruway/Peer/PeerInterface.php | 4 +- src/Thruway/Peer/Router.php | 2 - src/Thruway/Peer/RouterInterface.php | 3 - src/Thruway/PingRequest.php | 22 +++--- src/Thruway/Procedure.php | 3 - src/Thruway/Realm.php | 6 +- src/Thruway/RealmManager.php | 4 - src/Thruway/Registration.php | 2 - src/Thruway/Result.php | 7 +- src/Thruway/Role/AbstractRole.php | 4 +- src/Thruway/Role/Broker.php | 4 +- src/Thruway/Role/Callee.php | 6 +- src/Thruway/Role/Caller.php | 6 +- src/Thruway/Role/Dealer.php | 6 +- src/Thruway/Role/Publisher.php | 9 +-- src/Thruway/Role/Subscriber.php | 10 +-- src/Thruway/Session.php | 10 ++- src/Thruway/Subscription/ExactMatcher.php | 1 - src/Thruway/Subscription/MatcherInterface.php | 1 - src/Thruway/Subscription/PrefixMatcher.php | 16 ++-- .../Subscription/StateHandlerRegistration.php | 8 +- .../Subscription/StateHandlerRegistry.php | 2 - src/Thruway/Subscription/Subscription.php | 3 +- .../Subscription/SubscriptionGroup.php | 4 +- .../AbstractClientTransportProvider.php | 7 +- .../AbstractRouterTransportProvider.php | 7 +- src/Thruway/Transport/AbstractTransport.php | 5 +- .../ClientTransportProviderInterface.php | 8 +- src/Thruway/Transport/DummyTransport.php | 2 - .../Transport/DummyTransportProvider.php | 5 +- .../Transport/InternalClientTransport.php | 4 +- .../InternalClientTransportProvider.php | 3 - src/Thruway/Transport/PawlTransport.php | 3 +- src/Thruway/Transport/RatchetTransport.php | 6 +- .../Transport/RatchetTransportProvider.php | 3 +- .../RawSocketClientTransportProvider.php | 1 - .../Transport/RawSocketTransportProvider.php | 3 - .../RouterTransportProviderInterface.php | 7 +- src/Thruway/Transport/TransportInterface.php | 2 - 78 files changed, 142 insertions(+), 344 deletions(-) diff --git a/src/Thruway/AbstractSession.php b/src/Thruway/AbstractSession.php index ad23cc2a..2d89a488 100644 --- a/src/Thruway/AbstractSession.php +++ b/src/Thruway/AbstractSession.php @@ -2,7 +2,6 @@ namespace Thruway; - use Thruway\Message\AbortMessage; use Thruway\Message\Message; @@ -13,7 +12,6 @@ */ abstract class AbstractSession { - /** * Session state * @const int @@ -93,7 +91,6 @@ public function getState() return $this->state; } - /** * Set athentication state (authenticated or not) * @@ -144,7 +141,6 @@ public function getRealm() return $this->realm; } - /** * Get session ID * @@ -248,5 +244,4 @@ public function getLoop() { return $this->loop; } - -} \ No newline at end of file +} diff --git a/src/Thruway/Authentication/AbstractAuthProviderClient.php b/src/Thruway/Authentication/AbstractAuthProviderClient.php index afa8797d..d25477cb 100644 --- a/src/Thruway/Authentication/AbstractAuthProviderClient.php +++ b/src/Thruway/Authentication/AbstractAuthProviderClient.php @@ -3,7 +3,6 @@ namespace Thruway\Authentication; use React\EventLoop\LoopInterface; -use Thruway\ClientSession; use Thruway\Logging\Logger; use Thruway\Peer\Client; diff --git a/src/Thruway/Authentication/AnonymousAuthenticator.php b/src/Thruway/Authentication/AnonymousAuthenticator.php index d45e55fc..0b7feacd 100644 --- a/src/Thruway/Authentication/AnonymousAuthenticator.php +++ b/src/Thruway/Authentication/AnonymousAuthenticator.php @@ -2,19 +2,16 @@ namespace Thruway\Authentication; - use Thruway\Event\MessageEvent; use Thruway\Message\HelloMessage; use Thruway\Message\WelcomeMessage; use Thruway\Module\RealmModuleInterface; - /** * Class AnonymousAuthenticator * @package Thruway\Authentication */ class AnonymousAuthenticator implements RealmModuleInterface - { /** diff --git a/src/Thruway/Authentication/AuthenticationDetails.php b/src/Thruway/Authentication/AuthenticationDetails.php index cd9b9980..e4eebe3f 100644 --- a/src/Thruway/Authentication/AuthenticationDetails.php +++ b/src/Thruway/Authentication/AuthenticationDetails.php @@ -7,10 +7,8 @@ * * @package Thruway\Authentication */ - class AuthenticationDetails implements \JsonSerializable { - /** * @var int */ diff --git a/src/Thruway/Authentication/AuthenticationManager.php b/src/Thruway/Authentication/AuthenticationManager.php index 4550f434..492504a8 100644 --- a/src/Thruway/Authentication/AuthenticationManager.php +++ b/src/Thruway/Authentication/AuthenticationManager.php @@ -17,14 +17,12 @@ use Thruway\Realm; use Thruway\Session; - /** * Class AuthenticationManager * * @package Thruway\Authentication */ class AuthenticationManager extends RouterModuleClient implements RealmModuleInterface - { /** * List authentication methods diff --git a/src/Thruway/Authentication/AuthorizationManager.php b/src/Thruway/Authentication/AuthorizationManager.php index f4a8b467..9e45e6eb 100644 --- a/src/Thruway/Authentication/AuthorizationManager.php +++ b/src/Thruway/Authentication/AuthorizationManager.php @@ -1,9 +1,7 @@ getDetails(); if (!is_object($details)) { - Logger::info($this, "No details sent with challenge"); + Logger::debug($this, "No details sent with challenge"); return false; } if (isset($details->challenge)) { $challenge = $details->challenge; } else { - Logger::info($this, "No challenge for wampcra?"); + Logger::debug($this, "No challenge for wampcra?"); return false; } diff --git a/src/Thruway/Authentication/WampCraAuthProvider.php b/src/Thruway/Authentication/WampCraAuthProvider.php index 51f056f8..80934556 100644 --- a/src/Thruway/Authentication/WampCraAuthProvider.php +++ b/src/Thruway/Authentication/WampCraAuthProvider.php @@ -2,7 +2,6 @@ namespace Thruway\Authentication; - use Thruway\Message\HelloMessage; use Thruway\Message\Message; @@ -13,7 +12,6 @@ */ class WampCraAuthProvider extends AbstractAuthProviderClient { - /** * @var \Thruway\Authentication\WampCraUserDbInterface */ diff --git a/src/Thruway/Authentication/WampCraUserDbInterface.php b/src/Thruway/Authentication/WampCraUserDbInterface.php index 37ab7990..01ce4e7c 100644 --- a/src/Thruway/Authentication/WampCraUserDbInterface.php +++ b/src/Thruway/Authentication/WampCraUserDbInterface.php @@ -7,7 +7,6 @@ * * @package Thruway\Authentication */ - interface WampCraUserDbInterface { diff --git a/src/Thruway/Call.php b/src/Thruway/Call.php index 5e99ccff..629a4a6e 100644 --- a/src/Thruway/Call.php +++ b/src/Thruway/Call.php @@ -2,7 +2,6 @@ namespace Thruway; - use Thruway\Common\Utils; use Thruway\Logging\Logger; use Thruway\Message\CallMessage; @@ -21,7 +20,6 @@ */ class Call { - /** * @var \Thruway\Session */ @@ -89,7 +87,7 @@ class Call * * @param \Thruway\Session $callerSession * @param \Thruway\Message\CallMessage $callMessage - * @param Registration $registration + * @param Procedure $procedure */ public function __construct( Session $callerSession, @@ -161,7 +159,7 @@ public function processYield(Session $session, YieldMessage $msg) */ public function processCancel(Session $session, CancelMessage $msg) { if ($this->getCallerSession() !== $session) { - Logger::warning($this, "session attempted to cancel call they did not own."); + Logger::warning($this, "session " . $session->getSessionId() . " attempted to cancel call they did not own."); return false; } diff --git a/src/Thruway/CallResult.php b/src/Thruway/CallResult.php index 3c8cbea5..a0cdfb07 100644 --- a/src/Thruway/CallResult.php +++ b/src/Thruway/CallResult.php @@ -11,7 +11,6 @@ */ class CallResult extends \ArrayObject { - /** * @var \Thruway\Message\ResultMessage */ @@ -86,78 +85,4 @@ public function getDetails() { return $this->getResultMessage()->getDetails(); } - -// // ArrayAccess interface -// /** -// * (PHP 5 >= 5.0.0)
-// * Whether a offset exists -// * @link http://php.net/manual/en/arrayaccess.offsetexists.php -// * @param mixed $offset

-// * An offset to check for. -// *

-// * @return boolean true on success or false on failure. -// *

-// *

-// * The return value will be casted to boolean if non-boolean was returned. -// */ -// public function offsetExists($offset) -// { -// $args = $this->getArguments(); -// -// if ($args === null) return false; -// -// return isset($args[$offset]); -// } -// -// /** -// * (PHP 5 >= 5.0.0)
-// * Offset to retrieve -// * @link http://php.net/manual/en/arrayaccess.offsetget.php -// * @param mixed $offset

-// * The offset to retrieve. -// *

-// * @return mixed Can return all value types. -// */ -// public function offsetGet($offset) -// { -// $args = $this->getArguments(); -// -// return $args[$offset]; -// } -// -// /** -// * (PHP 5 >= 5.0.0)
-// * Offset to set -// * @link http://php.net/manual/en/arrayaccess.offsetset.php -// * @param mixed $offset

-// * The offset to assign the value to. -// *

-// * @param mixed $value

-// * The value to set. -// *

-// * @return void -// */ -// public function offsetSet($offset, $value) -// { -// if ($offset === null) { -// $this->getArguments()[] = $value; -// } else { -// $this->getArguments()[$offset] = $value; -// } -// } -// -// /** -// * (PHP 5 >= 5.0.0)
-// * Offset to unset -// * @link http://php.net/manual/en/arrayaccess.offsetunset.php -// * @param mixed $offset

-// * The offset to unset. -// *

-// * @return void -// */ -// public function offsetUnset($offset) -// { -// unset($this->getArguments()[$offset]); -// } - -} \ No newline at end of file +} diff --git a/src/Thruway/ClientSession.php b/src/Thruway/ClientSession.php index aa9b0963..bce4feb4 100644 --- a/src/Thruway/ClientSession.php +++ b/src/Thruway/ClientSession.php @@ -2,7 +2,6 @@ namespace Thruway; - use React\Promise\Promise; use Thruway\Message\Message; use Thruway\Peer\ClientInterface; @@ -15,7 +14,6 @@ */ class ClientSession extends AbstractSession { - /** * @var \Thruway\Peer\Client */ diff --git a/src/Thruway/Common/Utils.php b/src/Thruway/Common/Utils.php index eff4dc43..34faba9d 100644 --- a/src/Thruway/Common/Utils.php +++ b/src/Thruway/Common/Utils.php @@ -1,6 +1,5 @@ options = $options; @@ -176,5 +173,4 @@ private function handleOnChallenge() }); } } - -} \ No newline at end of file +} diff --git a/src/Thruway/Event/ConnectionCloseEvent.php b/src/Thruway/Event/ConnectionCloseEvent.php index 6996599d..c915beba 100644 --- a/src/Thruway/Event/ConnectionCloseEvent.php +++ b/src/Thruway/Event/ConnectionCloseEvent.php @@ -1,16 +1,15 @@ session = $session; } diff --git a/src/Thruway/Event/ConnectionOpenEvent.php b/src/Thruway/Event/ConnectionOpenEvent.php index c94ab539..d8448ba4 100644 --- a/src/Thruway/Event/ConnectionOpenEvent.php +++ b/src/Thruway/Event/ConnectionOpenEvent.php @@ -1,16 +1,15 @@ session = $session; } diff --git a/src/Thruway/Event/Event.php b/src/Thruway/Event/Event.php index fdc94255..ed95fcbe 100644 --- a/src/Thruway/Event/Event.php +++ b/src/Thruway/Event/Event.php @@ -1,9 +1,8 @@ getSubscribedRealmEvents(); foreach ($events as $eventName => $event) { - $this->addListener($eventName,[$subscriber, $event[0]], $event[1]); + $this->addListener($eventName, [$subscriber, $event[0]], $event[1]); } } -} \ No newline at end of file +} diff --git a/src/Thruway/Event/EventDispatcherInterface.php b/src/Thruway/Event/EventDispatcherInterface.php index a928eecb..3cdefc0f 100644 --- a/src/Thruway/Event/EventDispatcherInterface.php +++ b/src/Thruway/Event/EventDispatcherInterface.php @@ -1,11 +1,10 @@ realm = $realm; $this->session = $session; } -} \ No newline at end of file +} diff --git a/src/Thruway/Event/MessageEvent.php b/src/Thruway/Event/MessageEvent.php index 0720b653..9772fe3e 100644 --- a/src/Thruway/Event/MessageEvent.php +++ b/src/Thruway/Event/MessageEvent.php @@ -1,21 +1,20 @@ session = $session; $this->message = $message; } -} \ No newline at end of file +} diff --git a/src/Thruway/Event/NewRealmEvent.php b/src/Thruway/Event/NewRealmEvent.php index f20c1631..10319973 100644 --- a/src/Thruway/Event/NewRealmEvent.php +++ b/src/Thruway/Event/NewRealmEvent.php @@ -1,9 +1,7 @@ realm = $realm; } - -} \ No newline at end of file +} diff --git a/src/Thruway/Event/RouterStartEvent.php b/src/Thruway/Event/RouterStartEvent.php index 20d07745..cc34450a 100644 --- a/src/Thruway/Event/RouterStartEvent.php +++ b/src/Thruway/Event/RouterStartEvent.php @@ -1,9 +1,8 @@ setErrorUri($errorUri); $this->setArguments($arguments); @@ -48,6 +48,4 @@ public function setErrorUri($errorUri) { $this->errorUri = $errorUri; } - - -} \ No newline at end of file +} diff --git a/src/Thruway/Logging/ConsoleLogger.php b/src/Thruway/Logging/ConsoleLogger.php index ff0972bf..d9246f9d 100644 --- a/src/Thruway/Logging/ConsoleLogger.php +++ b/src/Thruway/Logging/ConsoleLogger.php @@ -11,7 +11,6 @@ */ class ConsoleLogger extends AbstractLogger { - /** * Logs with an arbitrary level. * @@ -25,5 +24,4 @@ public function log($level, $message, array $context = []) $now = date("Y-m-d\TH:i:s") . substr((string)microtime(), 1, 8); echo $now . " " . str_pad($level, 10, " ") . " " . $message . "\n"; } - } diff --git a/src/Thruway/Logging/Logger.php b/src/Thruway/Logging/Logger.php index 3a9532eb..8cd8e107 100644 --- a/src/Thruway/Logging/Logger.php +++ b/src/Thruway/Logging/Logger.php @@ -2,18 +2,19 @@ namespace Thruway\Logging; - use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; class Logger { - /** * @var LoggerInterface */ private static $logger; + /** @var bool */ + private static $showDebug = false; + /** * @param LoggerInterface $logger */ @@ -22,6 +23,16 @@ public static function set(LoggerInterface $logger) static::$logger = $logger; } + public static function setDebug($debug = false) + { + static::$showDebug = $debug; + } + + public static function getDebug() + { + return static::$showDebug; + } + /** * @param null $object * @param $level @@ -75,8 +86,9 @@ public static function critical($object = null, $message, $context = []) */ public static function debug($object = null, $message, $context = []) { - - static::log($object, LogLevel::DEBUG, $message, $context); + if (static::$showDebug) { + static::log($object, LogLevel::DEBUG, $message, $context); + } } /** @@ -87,7 +99,6 @@ public static function debug($object = null, $message, $context = []) */ public static function emergency($object = null, $message, $context = []) { - static::log($object, LogLevel::EMERGENCY, $message, $context); } diff --git a/src/Thruway/Module/RealmModuleInterface.php b/src/Thruway/Module/RealmModuleInterface.php index edc92943..447df621 100644 --- a/src/Thruway/Module/RealmModuleInterface.php +++ b/src/Thruway/Module/RealmModuleInterface.php @@ -1,9 +1,7 @@ on('open', [$this, 'onSessionStart']); Logger::info($this, "New client created"); - } /** * @return string */ - function __toString() + public function __toString() { return get_class($this); } @@ -323,7 +322,6 @@ public function addRole(AbstractRole $role) */ public function onMessage(TransportInterface $transport, Message $msg) { - Logger::debug($this, "Client onMessage: {$msg}"); $session = $this->session; diff --git a/src/Thruway/Peer/ClientInterface.php b/src/Thruway/Peer/ClientInterface.php index 76d5af74..ccc75cfd 100644 --- a/src/Thruway/Peer/ClientInterface.php +++ b/src/Thruway/Peer/ClientInterface.php @@ -1,9 +1,7 @@ deferred === null) { $this->deferred = new Deferred(); @@ -69,27 +68,27 @@ function getDeferred() /** * Set timer - * + * * @param \React\EventLoop\Timer\TimerInterface $timer */ - function setTimer($timer) + public function setTimer($timer) { $this->timer = $timer; } /** * Get timer - * + * * @return \React\EventLoop\Timer\TimerInterface */ - function getTimer() + public function getTimer() { return $this->timer; } /** * Set ping message - * + * * @param \Thruway\Message\PingMessage $pingMsg */ public function setPingMsg($pingMsg) @@ -99,7 +98,7 @@ public function setPingMsg($pingMsg) /** * Get ping message - * + * * @return \Thruway\Message\PingMessage */ public function getPingMsg() @@ -109,7 +108,7 @@ public function getPingMsg() /** * Set loop - * + * * @param \React\EventLoop\LoopInterface $loop */ public function setLoop($loop) @@ -119,12 +118,11 @@ public function setLoop($loop) /** * Get loop - * + * * @return \React\EventLoop\LoopInterface */ public function getLoop() { return $this->loop; } - } diff --git a/src/Thruway/Procedure.php b/src/Thruway/Procedure.php index d739de2b..929f0676 100644 --- a/src/Thruway/Procedure.php +++ b/src/Thruway/Procedure.php @@ -7,7 +7,6 @@ use Thruway\Message\RegisterMessage; use Thruway\Message\UnregisteredMessage; use Thruway\Message\UnregisterMessage; -use Thruway\Registration; use SplQueue; /** @@ -19,7 +18,6 @@ */ class Procedure { - /** * @var string */ @@ -521,5 +519,4 @@ public function managerGetRegistrations() ]; } } - } diff --git a/src/Thruway/Realm.php b/src/Thruway/Realm.php index fb6eb418..8ee83b2b 100644 --- a/src/Thruway/Realm.php +++ b/src/Thruway/Realm.php @@ -2,7 +2,6 @@ namespace Thruway; -use Thruway\Authentication\AllPermissiveAuthorizationManager; use Thruway\Authentication\AnonymousAuthenticator; use Thruway\Common\Utils; use Thruway\Event\LeaveRealmEvent; @@ -158,15 +157,13 @@ private function processAbort(Session $session, Message $msg) */ private function processSendWelcome(Session $session, WelcomeMessage $msg) { - $details = $session->getHelloMessage()->getDetails(); if (is_object($details) && isset($details->roles) && is_object($details->roles)) { $session->setRoleFeatures($details->roles); } - $session->setState(Session::STATE_UP); // this should probably be after authentication - + $session->setState(Session::STATE_UP); } @@ -242,7 +239,6 @@ public function getRealmName() */ public function leave(Session $session) { - Logger::debug($this, "Leaving realm {$session->getRealm()->getRealmName()}"); $this->sessions->detach($session); } diff --git a/src/Thruway/RealmManager.php b/src/Thruway/RealmManager.php index 9a00aba2..c1f16bc1 100644 --- a/src/Thruway/RealmManager.php +++ b/src/Thruway/RealmManager.php @@ -19,14 +19,12 @@ */ class RealmManager extends Module\RouterModule implements RealmModuleInterface { - /** @var array */ private $realms; /** @var boolean */ private $allowRealmAutocreate; - /** * Constructor * @@ -85,7 +83,6 @@ public function handleConnectionClose(ConnectionCloseEvent $event) */ public function handlePreHelloMessage(MessageEvent $event) { - Logger::info($this, "Got prehello..."); /** @var HelloMessage $msg */ $msg = $event->message; $session = $event->session; @@ -212,5 +209,4 @@ public function getAllowRealmAutocreate() { return $this->allowRealmAutocreate; } - } diff --git a/src/Thruway/Registration.php b/src/Thruway/Registration.php index 1629fed0..3b38fe7d 100644 --- a/src/Thruway/Registration.php +++ b/src/Thruway/Registration.php @@ -13,7 +13,6 @@ */ class Registration { - /** * @var mixed */ @@ -389,5 +388,4 @@ public function getStatistics() 'completedCallTimeTotal' => $this->completedCallTimeTotal ]; } - } diff --git a/src/Thruway/Result.php b/src/Thruway/Result.php index 47b83230..a4ccffee 100644 --- a/src/Thruway/Result.php +++ b/src/Thruway/Result.php @@ -2,7 +2,6 @@ namespace Thruway; - /** * Class Result * @@ -10,7 +9,6 @@ */ class Result { - /** @var array|null */ private $arguments; @@ -23,7 +21,7 @@ class Result * @param array|null $arguments * @param array|null $argumentsKw */ - function __construct($arguments = null, $argumentsKw = null) + public function __construct($arguments = null, $argumentsKw = null) { $this->setArguments($arguments); $this->setArgumentsKw($argumentsKw); @@ -73,5 +71,4 @@ public function getArgumentsKw() { return $this->argumentsKw; } - -} \ No newline at end of file +} diff --git a/src/Thruway/Role/AbstractRole.php b/src/Thruway/Role/AbstractRole.php index 6fb86942..80536182 100644 --- a/src/Thruway/Role/AbstractRole.php +++ b/src/Thruway/Role/AbstractRole.php @@ -2,7 +2,6 @@ namespace Thruway\Role; - use Thruway\AbstractSession; use Thruway\Message\Message; @@ -38,5 +37,4 @@ public function getFeatures() { return new \stdClass(); } - -} \ No newline at end of file +} diff --git a/src/Thruway/Role/Broker.php b/src/Thruway/Role/Broker.php index 64142d52..4debd470 100644 --- a/src/Thruway/Role/Broker.php +++ b/src/Thruway/Role/Broker.php @@ -2,13 +2,11 @@ namespace Thruway\Role; -use Thruway\AbstractSession; use Thruway\Common\Utils; use Thruway\Event\LeaveRealmEvent; use Thruway\Event\MessageEvent; use Thruway\Logging\Logger; use Thruway\Message\ErrorMessage; -use Thruway\Message\Message; use Thruway\Message\PublishedMessage; use Thruway\Message\PublishMessage; use Thruway\Message\SubscribeMessage; @@ -47,7 +45,7 @@ class Broker implements RealmModuleInterface /** * */ - function __construct() + public function __construct() { $this->addMatcher(new ExactMatcher()); $this->addMatcher(new PrefixMatcher()); diff --git a/src/Thruway/Role/Callee.php b/src/Thruway/Role/Callee.php index 9ce04907..790e2c36 100644 --- a/src/Thruway/Role/Callee.php +++ b/src/Thruway/Role/Callee.php @@ -26,13 +26,11 @@ */ class Callee extends AbstractRole { - /** * @var array */ private $registrations; - /** * Constructor */ @@ -475,6 +473,4 @@ public static function is_list($array) // not be associative (e.g. the keys array looked like {0:0, 1:1...}). return array_keys($keys) === $keys; } - - -} +} diff --git a/src/Thruway/Role/Caller.php b/src/Thruway/Role/Caller.php index 5152501b..415f8ebc 100644 --- a/src/Thruway/Role/Caller.php +++ b/src/Thruway/Role/Caller.php @@ -2,7 +2,6 @@ namespace Thruway\Role; - use Thruway\AbstractSession; use Thruway\CallResult; use Thruway\ClientSession; @@ -12,7 +11,6 @@ use Thruway\Message\ErrorMessage; use Thruway\Message\Message; use Thruway\Message\ResultMessage; -use Thruway\Session; use React\Promise\Deferred; /** @@ -22,7 +20,6 @@ */ class Caller extends AbstractRole { - /** * @var array */ @@ -177,5 +174,4 @@ public function call(ClientSession $session, $procedureName, $arguments = null, return $futureResult->promise(); } - -} \ No newline at end of file +} diff --git a/src/Thruway/Role/Dealer.php b/src/Thruway/Role/Dealer.php index 673a8ed9..e0328231 100644 --- a/src/Thruway/Role/Dealer.php +++ b/src/Thruway/Role/Dealer.php @@ -2,7 +2,6 @@ namespace Thruway\Role; - use Thruway\Call; use Thruway\Common\Utils; use Thruway\Event\LeaveRealmEvent; @@ -283,13 +282,12 @@ private function processCall(Session $session, CallMessage $msg) */ private function processYield(Session $session, YieldMessage $msg) { - /* @var $call Call */ $call = isset($this->callInvocationIndex[$msg->getRequestId()]) ? $this->callInvocationIndex[$msg->getRequestId()] : null; if (!$call) { $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg)); - Logger::error($this, "Was expecting a call"); + Logger::error($this, "Received YieldMessage for non-existent call from " . $session->getSessionId()); return; } @@ -588,6 +586,4 @@ public function managerGetRegistrations() return [$theRegistrations]; } - - } diff --git a/src/Thruway/Role/Publisher.php b/src/Thruway/Role/Publisher.php index 477ed9db..654e0b74 100644 --- a/src/Thruway/Role/Publisher.php +++ b/src/Thruway/Role/Publisher.php @@ -2,7 +2,6 @@ namespace Thruway\Role; - use Thruway\AbstractSession; use Thruway\ClientSession; use Thruway\Common\Utils; @@ -10,7 +9,6 @@ use Thruway\Message\Message; use Thruway\Message\PublishedMessage; use Thruway\Message\PublishMessage; -use Thruway\Session; use React\Promise\Deferred; /** @@ -20,7 +18,6 @@ */ class Publisher extends AbstractRole { - /** * @var array */ @@ -39,7 +36,8 @@ public function __construct() * * @return \stdClass */ - public function getFeatures() { + public function getFeatures() + { $features = new \stdClass(); $features->subscriber_blackwhite_listing = true; @@ -147,5 +145,4 @@ public function publish(ClientSession $session, $topicName, $arguments, $argumen return isset($futureResult) ? $futureResult->promise() : false; } - -} \ No newline at end of file +} diff --git a/src/Thruway/Role/Subscriber.php b/src/Thruway/Role/Subscriber.php index cecdfe55..7fc70ad0 100644 --- a/src/Thruway/Role/Subscriber.php +++ b/src/Thruway/Role/Subscriber.php @@ -2,7 +2,6 @@ namespace Thruway\Role; - use React\Promise\Deferred; use React\Promise\Promise; use Thruway\AbstractSession; @@ -86,10 +85,10 @@ protected function processError(AbstractSession $session, ErrorMessage $msg) $this->processSubscribeError($session, $msg); break; case Message::MSG_UNSUBSCRIBE: - // TODO + Logger::error($this, "Unhandled unsubscribe error"); break; default: - Logger::critical($this, "Unhandled error"); + Logger::error($this, "Unhandled error"); } } @@ -147,7 +146,7 @@ protected function processUnsubscribed(ClientSession $session, UnsubscribedMessa return; } } -// $this->logger->error("---Got an Unsubscribed Message, but couldn't find corresponding request.\n"); + Logger::error($this, "Got an Unsubscribed Message, but couldn't find corresponding request.\n"); } /** @@ -227,5 +226,4 @@ public function subscribe(ClientSession $session, $topicName, callable $callback return $deferred->promise(); } - -} +} diff --git a/src/Thruway/Session.php b/src/Thruway/Session.php index 537a9fd1..ea888ac0 100644 --- a/src/Thruway/Session.php +++ b/src/Thruway/Session.php @@ -2,7 +2,6 @@ namespace Thruway; - use Thruway\Authentication\AuthenticationDetails; use Thruway\Common\Utils; use Thruway\Event\EventDispatcher; @@ -21,7 +20,6 @@ */ class Session extends AbstractSession implements RealmModuleInterface { - /** @var \Thruway\Authentication\AuthenticationDetails */ private $authenticationDetails; @@ -134,7 +132,9 @@ public function onClose() // only send the leave metaevent if we actually made it into the realm if ($this->isAuthenticated()) { // metaevent - $this->getRealm()->publishMeta('wamp.metaevent.session.on_leave', [$this->getMetaInfo()]); + $metaInfo = $this->getMetaInfo(); + $this->getRealm()->publishMeta('wamp.metaevent.session.on_leave', [$metaInfo]); + Logger::info($this, "Session close: " . json_encode($metaInfo)); } $this->dispatcher->dispatch("LeaveRealm", new LeaveRealmEvent($this->realm, $this)); @@ -202,7 +202,9 @@ public function setAuthenticated($authenticated) // not-authenticate to authenticated if ($authenticated && !$this->authenticated) { // metaevent - $this->getRealm()->publishMeta('wamp.metaevent.session.on_join', [$this->getMetaInfo()]); + $metaInfo = $this->getMetaInfo(); + $this->getRealm()->publishMeta('wamp.metaevent.session.on_join', [$metaInfo]); + Logger::info($this, "Session joined: " . json_encode($metaInfo)); } parent::setAuthenticated($authenticated); diff --git a/src/Thruway/Subscription/ExactMatcher.php b/src/Thruway/Subscription/ExactMatcher.php index 39351efb..9e3ec413 100644 --- a/src/Thruway/Subscription/ExactMatcher.php +++ b/src/Thruway/Subscription/ExactMatcher.php @@ -60,5 +60,4 @@ public function isSubGroup($parentUri, $parentOptions, $childUri, $childOptions) { return $parentUri == $childUri; } - } diff --git a/src/Thruway/Subscription/MatcherInterface.php b/src/Thruway/Subscription/MatcherInterface.php index a0dd962e..1e5d7eed 100644 --- a/src/Thruway/Subscription/MatcherInterface.php +++ b/src/Thruway/Subscription/MatcherInterface.php @@ -2,7 +2,6 @@ namespace Thruway\Subscription; - /** * Interface MatcherInterface * @package Thruway\Subscription diff --git a/src/Thruway/Subscription/PrefixMatcher.php b/src/Thruway/Subscription/PrefixMatcher.php index d60a208a..24de0083 100644 --- a/src/Thruway/Subscription/PrefixMatcher.php +++ b/src/Thruway/Subscription/PrefixMatcher.php @@ -1,9 +1,7 @@ fixupUri($uri); // if the uri is empty - then match everything - if ($uri == "") return true; + if ($uri == "") { + return true; + } // if there is a trailing . then remove it and run it through the // regular validator - if (substr($uri, strlen($uri) - 1) == ".") $uri = substr($uri, 0, strlen($uri) - 1); + $uri = substr($uri, strlen($uri) - 1) == "." ? substr($uri, 0, strlen($uri) - 1) : $uri; // allow matches to a normal URI or one with a trailing dot return Utils::uriIsValid($uri) || Utils::uriIsValid($uri . "."); } - private function fixupUri($uri) { + private function fixupUri($uri) + { // a single "." matches everything - if ($uri == ".") return ""; + if ($uri == ".") { + return ""; + } return $uri; } @@ -82,5 +85,4 @@ public function isSubGroup($parentUri, $parentOptions, $childUri, $childOptions) { return $this->matches($childUri, $parentUri, $parentOptions); } - } diff --git a/src/Thruway/Subscription/StateHandlerRegistration.php b/src/Thruway/Subscription/StateHandlerRegistration.php index 605e4eff..4a1425d7 100644 --- a/src/Thruway/Subscription/StateHandlerRegistration.php +++ b/src/Thruway/Subscription/StateHandlerRegistration.php @@ -1,9 +1,7 @@ setClientSession($clientSession); $this->setProcedureName($procedureName); @@ -67,7 +65,7 @@ function ($res) use ($subscription) { $subscription->unPauseForState($pubId); }, function ($error) use ($subscription) { - Logger::error($this, "Could not call '{$this->getProcedureName()}'"); + Logger::error($this, "Could not call '{$this->getProcedureName()}' when restoring state"); $subscription->unPauseForState(); } ); @@ -150,4 +148,4 @@ public function handlesStateFor(SubscriptionGroup $subscriptionGroup) return false; } -} \ No newline at end of file +} diff --git a/src/Thruway/Subscription/StateHandlerRegistry.php b/src/Thruway/Subscription/StateHandlerRegistry.php index 717e8912..cfff268d 100644 --- a/src/Thruway/Subscription/StateHandlerRegistry.php +++ b/src/Thruway/Subscription/StateHandlerRegistry.php @@ -1,9 +1,7 @@ getSession()->sendMessage($msg); } -} \ No newline at end of file +} diff --git a/src/Thruway/Subscription/SubscriptionGroup.php b/src/Thruway/Subscription/SubscriptionGroup.php index 3abfcd37..d6681abc 100644 --- a/src/Thruway/Subscription/SubscriptionGroup.php +++ b/src/Thruway/Subscription/SubscriptionGroup.php @@ -209,7 +209,7 @@ public function hasStateHandler() public function setStateHandler($handlerUri) { if (!Utils::uriIsValid($handlerUri)) { - Logger::error($this, "Invalid URI"); + Logger::error($this, "Invalid URI '" . $handlerUri . "' for state handler."); throw new \InvalidArgumentException("Invalid URI"); } @@ -313,4 +313,4 @@ public function getLastPublicationId() { return $this->lastPublicationId; } -} \ No newline at end of file +} diff --git a/src/Thruway/Transport/AbstractClientTransportProvider.php b/src/Thruway/Transport/AbstractClientTransportProvider.php index 19289445..bac4261b 100644 --- a/src/Thruway/Transport/AbstractClientTransportProvider.php +++ b/src/Thruway/Transport/AbstractClientTransportProvider.php @@ -1,10 +1,9 @@ setLastMessageSent($msg); } - } diff --git a/src/Thruway/Transport/DummyTransportProvider.php b/src/Thruway/Transport/DummyTransportProvider.php index 81604630..55e81395 100644 --- a/src/Thruway/Transport/DummyTransportProvider.php +++ b/src/Thruway/Transport/DummyTransportProvider.php @@ -2,7 +2,6 @@ namespace Thruway\Transport; - use React\EventLoop\LoopInterface; use Thruway\Peer\ClientInterface; @@ -13,7 +12,6 @@ */ class DummyTransportProvider extends AbstractClientTransportProvider { - /** * Start transport provider * @@ -23,5 +21,4 @@ class DummyTransportProvider extends AbstractClientTransportProvider public function startTransportProvider(ClientInterface $client, LoopInterface $loop) { } - -} \ No newline at end of file +} diff --git a/src/Thruway/Transport/InternalClientTransport.php b/src/Thruway/Transport/InternalClientTransport.php index 4f512da7..b49140df 100644 --- a/src/Thruway/Transport/InternalClientTransport.php +++ b/src/Thruway/Transport/InternalClientTransport.php @@ -4,7 +4,6 @@ use React\EventLoop\LoopInterface; use Thruway\Message\Message; -use Thruway\Peer\PeerInterface; /** * Class InternalClientTransport @@ -50,5 +49,4 @@ public function getTransportDetails() "transport_address" => "internal" ]; } - -} \ No newline at end of file +} diff --git a/src/Thruway/Transport/InternalClientTransportProvider.php b/src/Thruway/Transport/InternalClientTransportProvider.php index 36a1260f..9be80aff 100644 --- a/src/Thruway/Transport/InternalClientTransportProvider.php +++ b/src/Thruway/Transport/InternalClientTransportProvider.php @@ -2,7 +2,6 @@ namespace Thruway\Transport; - use Thruway\Event\ConnectionOpenEvent; use Thruway\Event\RouterStartEvent; use Thruway\Event\RouterStopEvent; @@ -88,6 +87,4 @@ public static function getSubscribedEvents() "router.stop" => ['handleRouterStop', 10] ]; } - - } diff --git a/src/Thruway/Transport/PawlTransport.php b/src/Thruway/Transport/PawlTransport.php index cddb9b56..63530a4e 100644 --- a/src/Thruway/Transport/PawlTransport.php +++ b/src/Thruway/Transport/PawlTransport.php @@ -14,7 +14,6 @@ */ class PawlTransport extends AbstractTransport { - /** * @var mixed */ @@ -36,7 +35,7 @@ class PawlTransport extends AbstractTransport * @param \Ratchet\Client\WebSocket $conn * @param \React\EventLoop\LoopInterface $loop */ - function __construct($conn, LoopInterface $loop) + public function __construct($conn, LoopInterface $loop) { $this->conn = $conn; $this->pingSeq = 0; diff --git a/src/Thruway/Transport/RatchetTransport.php b/src/Thruway/Transport/RatchetTransport.php index c49c7554..498b2708 100644 --- a/src/Thruway/Transport/RatchetTransport.php +++ b/src/Thruway/Transport/RatchetTransport.php @@ -2,7 +2,6 @@ namespace Thruway\Transport; - use Guzzle\Http\Message\Header\HeaderCollection; use Guzzle\Http\Message\Request; use Ratchet\WebSocket\Version\RFC6455\Frame; @@ -15,7 +14,6 @@ */ class RatchetTransport extends AbstractTransport { - /** * @var \Ratchet\ConnectionInterface */ @@ -37,7 +35,7 @@ class RatchetTransport extends AbstractTransport * @param \Ratchet\ConnectionInterface $conn * @param \React\EventLoop\LoopInterface $loop */ - function __construct($conn, LoopInterface $loop) + public function __construct($conn, LoopInterface $loop) { $this->conn = $conn; $this->pingSeq = 1234; @@ -147,4 +145,4 @@ public function onPong(Frame $frame) } } -} \ No newline at end of file +} diff --git a/src/Thruway/Transport/RatchetTransportProvider.php b/src/Thruway/Transport/RatchetTransportProvider.php index b02611ef..79ca97b8 100644 --- a/src/Thruway/Transport/RatchetTransportProvider.php +++ b/src/Thruway/Transport/RatchetTransportProvider.php @@ -5,7 +5,6 @@ use Ratchet\WebSocket\Version\RFC6455\Frame; use Thruway\Event\ConnectionCloseEvent; use Thruway\Event\ConnectionOpenEvent; -use Thruway\Event\MessageEvent; use Thruway\Event\RouterStartEvent; use Thruway\Event\RouterStopEvent; use Thruway\Exception\DeserializationException; @@ -103,7 +102,7 @@ public function onClose(ConnectionInterface $conn) unset($this->sessions[$conn]); - Logger::info($this, "Ratchet has closed"); + Logger::debug($this, "Ratchet has closed"); } /** @inheritdoc */ diff --git a/src/Thruway/Transport/RawSocketClientTransportProvider.php b/src/Thruway/Transport/RawSocketClientTransportProvider.php index 660327c6..97002b1f 100644 --- a/src/Thruway/Transport/RawSocketClientTransportProvider.php +++ b/src/Thruway/Transport/RawSocketClientTransportProvider.php @@ -27,7 +27,6 @@ class RawSocketClientTransportProvider extends AbstractClientTransportProvider */ private $port; - /** * Constructor * diff --git a/src/Thruway/Transport/RawSocketTransportProvider.php b/src/Thruway/Transport/RawSocketTransportProvider.php index eb02048c..dc6d527c 100644 --- a/src/Thruway/Transport/RawSocketTransportProvider.php +++ b/src/Thruway/Transport/RawSocketTransportProvider.php @@ -20,7 +20,6 @@ */ class RawSocketTransportProvider extends AbstractRouterTransportProvider { - /** * @var string */ @@ -125,6 +124,4 @@ public static function getSubscribedEvents() "router.stop" => ['handleRouterStop', 10] ]; } - - } diff --git a/src/Thruway/Transport/RouterTransportProviderInterface.php b/src/Thruway/Transport/RouterTransportProviderInterface.php index 354c7a64..3b806067 100644 --- a/src/Thruway/Transport/RouterTransportProviderInterface.php +++ b/src/Thruway/Transport/RouterTransportProviderInterface.php @@ -1,14 +1,13 @@ Date: Wed, 7 Sep 2016 18:45:53 -0400 Subject: [PATCH 07/15] Send a CancelMessage to all active calls, when the caller's session terminates --- src/Thruway/Role/Dealer.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Thruway/Role/Dealer.php b/src/Thruway/Role/Dealer.php index e0328231..6b1fd660 100644 --- a/src/Thruway/Role/Dealer.php +++ b/src/Thruway/Role/Dealer.php @@ -355,7 +355,7 @@ private function processCancel(Session $session, CancelMessage $msg) { $call = $this->getCallByRequestId($msg->getRequestId()); - if ($call->getCallerSession() !== $session) { + if ($call && $call->getCallerSession() !== $session) { Logger::warning($this, "Attempt to cancel call by non-owner"); return; @@ -554,6 +554,13 @@ public function leave(Session $session) $procedure->leave($session); } + foreach ($this->callInvocationIndex as $call) { + if ($session->getSessionId() === $call->getCallerSession()->getSessionId()) { + $cancelMsg = new CancelMessage($call->getCallMessage()->getRequestId(), (object)[]); + $this->processCancel($session, $cancelMsg); + } + } + // remove the list of registrations if ($this->registrationsBySession->contains($session)) { $this->registrationsBySession->detach($session); From 97dbd5e6db3ca08e84b16cbf16959d20de046fc6 Mon Sep 17 00:00:00 2001 From: Matt Bonneau Date: Thu, 8 Sep 2016 16:08:58 -0400 Subject: [PATCH 08/15] Unit tests for Exception when Cancel with no call --- tests/Unit/Role/DealerTest.php | 178 ++++++++++++++++++++++++++++++++- 1 file changed, 177 insertions(+), 1 deletion(-) diff --git a/tests/Unit/Role/DealerTest.php b/tests/Unit/Role/DealerTest.php index dca625c1..5895d169 100644 --- a/tests/Unit/Role/DealerTest.php +++ b/tests/Unit/Role/DealerTest.php @@ -1,7 +1,22 @@ assertEquals($callRequestId, $returnedError->getErrorRequestId()); $this->assertEquals('the.error.uri', $returnedError->getErrorURI()); } -} \ No newline at end of file + + public function testCallCancelWithNoCall() + { + $dealer = new Dealer(); + + $callerTransport = new DummyTransport(); + $callerSession = new Session($callerTransport); + + $dealer->handleCancelMessage(new MessageEvent($callerSession, new CancelMessage(1234, (object)[]))); + $this->assertEquals( + json_encode(new ErrorMessage(Message::MSG_CANCEL, 1234, (object)[], 'wamp.error.no_such_call')), + json_encode($callerTransport->getLastMessageSent()) + ); + } + + public function testInterruptSentToSupportingClient() + { + $dealer = new Dealer(); + + $calleeTransport = new DummyTransport(); + $calleeSession = new Session($calleeTransport); + // make sure this callee supports call cancellation + $calleeSession->setHelloMessage(new HelloMessage( + 'some.realm', + (object)[ + "roles" => (object)[ + 'callee' => (object)[ + 'features' => (object)[ + 'call_canceling' => true + ] + ] + ] + ] + )); + + $dealer->handleRegisterMessage(new MessageEvent($calleeSession, new RegisterMessage(1234, (object)[], 'some.proc'))); + $this->assertInstanceOf(RegisteredMessage::class, $calleeTransport->getLastMessageSent()); + $registrationId = $calleeTransport->getLastMessageSent()->getRegistrationId(); + + $callerTransport = new DummyTransport(); + $callerSession = new Session($callerTransport); + $callMessage = new CallMessage(2345, (object)[], 'some.proc'); + + $dealer->handleCallMessage(new MessageEvent($callerSession, $callMessage)); + + $this->assertInstanceOf(InvocationMessage::class, $calleeTransport->getLastMessageSent()); + $invocationId = $calleeTransport->getLastMessageSent()->getRequestId(); + + $dealer->handleCancelMessage(new MessageEvent($callerSession, new CancelMessage(2345, (object)[]))); + $this->assertInstanceOf( + InterruptMessage::class, + $calleeTransport->getLastMessageSent() + ); + + $this->assertEquals($invocationId, $calleeTransport->getLastMessageSent()->getRequestId()); + } + + public function testInterruptSentToNonSupportingClient() + { + $dealer = new Dealer(); + + $calleeTransport = new DummyTransport(); + $calleeSession = new Session($calleeTransport); + // make sure this callee supports call cancellation + $calleeSession->setHelloMessage(new HelloMessage( + 'some.realm', + (object)[ + "roles" => (object)[ + 'callee' => (object)[ + 'features' => (object)[ + 'call_canceling' => false + ] + ] + ] + ] + )); + + $dealer->handleRegisterMessage(new MessageEvent($calleeSession, new RegisterMessage(1234, (object)[], 'some.proc'))); + $this->assertInstanceOf(RegisteredMessage::class, $calleeTransport->getLastMessageSent()); + $registrationId = $calleeTransport->getLastMessageSent()->getRegistrationId(); + + $callerTransport = new DummyTransport(); + $callerSession = new Session($callerTransport); + $callMessage = new CallMessage(2345, (object)[], 'some.proc'); + + $dealer->handleCallMessage(new MessageEvent($callerSession, $callMessage)); + + $this->assertInstanceOf(InvocationMessage::class, $calleeTransport->getLastMessageSent()); + $invocationId = $calleeTransport->getLastMessageSent()->getRequestId(); + + $dealer->handleCancelMessage(new MessageEvent($callerSession, new CancelMessage(2345, (object)[]))); + + // callee should not have received anything + $this->assertInstanceOf( + InvocationMessage::class, + $calleeTransport->getLastMessageSent() + ); + + } + + public function testCancelAfterUnregister() + { + $dealer = new Dealer(); + + $calleeTransport = new DummyTransport(); + $calleeSession = new Session($calleeTransport); + // make sure this callee supports call cancellation + $calleeSession->setHelloMessage(new HelloMessage( + 'some.realm', + (object)[ + "roles" => (object)[ + 'callee' => (object)[ + 'features' => (object)[ + 'call_canceling' => true + ] + ] + ] + ] + )); + + $dealer->handleRegisterMessage(new MessageEvent($calleeSession, new RegisterMessage(1234, (object)[], 'some.proc'))); + $this->assertInstanceOf(RegisteredMessage::class, $calleeTransport->getLastMessageSent()); + $registrationId = $calleeTransport->getLastMessageSent()->getRegistrationId(); + + $callerTransport = new DummyTransport(); + $callerSession = new Session($callerTransport); + $callMessage = new CallMessage(2345, (object)[], 'some.proc'); + + $dealer->handleCallMessage(new MessageEvent($callerSession, $callMessage)); + + $this->assertInstanceOf(InvocationMessage::class, $calleeTransport->getLastMessageSent()); + $invocationId = $calleeTransport->getLastMessageSent()->getRequestId(); + + // unregister + $dealer->handleUnregisterMessage(new MessageEvent( + $calleeSession, + new UnregisterMessage(3456, $registrationId) + )); + + // this may need to be addressed as the behavior of unregistration is still + // not completely defined if you have calls pending + $this->assertInstanceOf(UnregisteredMessage::class, $calleeTransport->getLastMessageSent()); + + //$this->assertEquals(0, count($dealer->getProcedures())); + + $this->assertEquals(0, count($dealer->getProcedures()['some.proc']->getRegistrations())); + + $dealer->handleCancelMessage(new MessageEvent($callerSession, new CancelMessage(2345, (object)[]))); + + $call = $dealer->getCallByRequestId(2345); + + $this->assertNotNull($call); + + $dealer->handleLeaveRealm(new LeaveRealmEvent(new Realm('some.realm'), $callerSession)); + $dealer->handleLeaveRealm(new LeaveRealmEvent(new Realm('some.realm'), $calleeSession)); + + $call = $dealer->getCallByRequestId(2345); + + $this->assertNotNull($call); + + } +} From 4d38490d7136db05c5e81824806476286d69cb16 Mon Sep 17 00:00:00 2001 From: Matt Bonneau Date: Thu, 8 Sep 2016 16:34:42 -0400 Subject: [PATCH 09/15] Remove PHP 5.4 and add PHP 7.1 for travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 67ad3692..b3b19367 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,16 @@ language: php php: - - 5.4 - 5.5 - 5.6 - 7 + - 7.1 - hhvm matrix: allow_failures: - php: hhvm + - php: 7.1 before_install: - export PATH=$HOME/.local/bin:$PATH From 3b8ba712c9bccaba276742d650df8464dcde7680 Mon Sep 17 00:00:00 2001 From: Matt Bonneau Date: Wed, 15 Feb 2017 11:06:49 -0500 Subject: [PATCH 10/15] Update pip install for crossbar in travis config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b3b19367..aa666e57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ matrix: before_install: - export PATH=$HOME/.local/bin:$PATH - - pip install crossbar --user `whoami` + - pip install --user crossbar before_script: - composer install From b9061626629c80d3c73ba1b3e6a2ccd98b391b36 Mon Sep 17 00:00:00 2001 From: Matt Bonneau Date: Wed, 15 Feb 2017 11:26:14 -0500 Subject: [PATCH 11/15] Removed 7.1 from allowed failures --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index aa666e57..3f133b75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ php: matrix: allow_failures: - php: hhvm - - php: 7.1 before_install: - export PATH=$HOME/.local/bin:$PATH From 6a239122a06665568e68981cc2f865a4c3986650 Mon Sep 17 00:00:00 2001 From: Matt Bonneau Date: Sun, 5 Mar 2017 17:14:12 -0500 Subject: [PATCH 12/15] Add phpunit as dev dep and update deprecated getMock --- composer.json | 3 +++ tests/Unit/Peer/RouterTest.php | 14 +++++++------- tests/Unit/Role/BrokerTest.php | 2 +- tests/bootstrap.php | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index b18674cc..f864e500 100644 --- a/composer.json +++ b/composer.json @@ -35,6 +35,9 @@ "ext-openssl": "*", "voryx/thruway-message": "^1.0" }, + "require-dev": { + "phpunit/phpunit": "^5.5.4" + }, "extra": { "branch-alias": { "dev-master": "0.4-dev" diff --git a/tests/Unit/Peer/RouterTest.php b/tests/Unit/Peer/RouterTest.php index c0e2a067..67ed051f 100644 --- a/tests/Unit/Peer/RouterTest.php +++ b/tests/Unit/Peer/RouterTest.php @@ -45,7 +45,7 @@ public function testStart() */ public function testConnectionOpen(\Thruway\Peer\Router $router) { - $transport = $this->getMock('Thruway\Transport\TransportInterface'); + $transport = $this->createMock('Thruway\Transport\TransportInterface'); // Configure the stub. $transport->expects($this->any()) @@ -68,7 +68,7 @@ public function testConnectionOpen(\Thruway\Peer\Router $router) private function getNewRouterAndSession() { $router = new \Thruway\Peer\Router(); $router->start(false); - $transport = $this->getMock('Thruway\Transport\TransportInterface'); + $transport = $this->createMock('Thruway\Transport\TransportInterface'); // Configure the stub. $transport->expects($this->any()) @@ -401,7 +401,7 @@ function (\Thruway\Message\EventMessage $msg) { public function testPublishMessage(\Thruway\Peer\Router $router) { - $transport = $this->getMock('Thruway\Transport\TransportInterface'); + $transport = $this->createMock('Thruway\Transport\TransportInterface'); $session = new \Thruway\Session($transport); // Configure the stub. @@ -433,7 +433,7 @@ public function testUnSubscribeMessage() { $router = $this->router; $router->start(); - $transport = $this->getMock('Thruway\Transport\TransportInterface'); + $transport = $this->createMock('Thruway\Transport\TransportInterface'); // Configure the stub. $transport->expects($this->any()) @@ -515,7 +515,7 @@ public function testGetSessionBySessionIdFalse($rt) public function testAbortMessage(\Thruway\Peer\Router $router) { - $transport = $this->getMock('Thruway\Transport\TransportInterface'); + $transport = $this->createMock('Thruway\Transport\TransportInterface'); // Configure the stub. $transport->expects($this->any()) @@ -548,7 +548,7 @@ public function xtestUnhandledMessage(\Thruway\Peer\Router $router) { $this->markTestSkipped(); - $transport = $this->getMock('Thruway\Transport\TransportInterface'); + $transport = $this->createMock('Thruway\Transport\TransportInterface'); // Configure the stub. $transport->expects($this->any()) @@ -591,7 +591,7 @@ function (\Thruway\Message\AbortMessage $msg) { public function testInvalidRealm(\Thruway\Peer\Router $router) { - $transport = $this->getMock('Thruway\Transport\TransportInterface'); + $transport = $this->createMock('Thruway\Transport\TransportInterface'); // Configure the stub. $transport->expects($this->any()) diff --git a/tests/Unit/Role/BrokerTest.php b/tests/Unit/Role/BrokerTest.php index 32c34edd..307609e2 100644 --- a/tests/Unit/Role/BrokerTest.php +++ b/tests/Unit/Role/BrokerTest.php @@ -277,7 +277,7 @@ public function testRemoveRegistration() } private function createTransportInterfaceMock() { - return $this->getMock('\Thruway\Transport\TransportInterface'); + return $this->createMock('\Thruway\Transport\TransportInterface'); } public function testProcessSubscriptionAddedCalled() { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d0337f0f..fecd1aea 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -3,7 +3,7 @@ ini_set("xdebug.max_nesting_level","200"); if (file_exists($file = __DIR__.'/../vendor/autoload.php')) { - $loader = require_once $file; + $loader = require $file; $loader->addPsr4('Thruway\\', __DIR__); } else { throw new RuntimeException('Install dependencies to run test suite.'); From 60b54f77c45d2f2d9778175444103fa1e2502fc8 Mon Sep 17 00:00:00 2001 From: Matt Bonneau Date: Sun, 5 Mar 2017 17:28:07 -0500 Subject: [PATCH 13/15] Bump php to 5.6 and allow react/socket 0.5.* --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index f864e500..1a533ec5 100644 --- a/composer.json +++ b/composer.json @@ -27,8 +27,8 @@ } }, "require": { - "php": ">=5.4", - "react/socket": "0.4.*", + "php": ">=5.6", + "react/socket": "0.4.* | 0.5.*", "cboden/ratchet": "0.3.*", "ratchet/pawl": "0.2.*", "psr/log": "~1", From ef6133083a183f5877a239a4ff2706bceea63dc4 Mon Sep 17 00:00:00 2001 From: Matt Bonneau Date: Sun, 5 Mar 2017 18:52:53 -0500 Subject: [PATCH 14/15] Remove php 5.5 from travis and change to thruway-common --- .travis.yml | 1 - composer.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3f133b75..3663df9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.5 - 5.6 - 7 - 7.1 diff --git a/composer.json b/composer.json index 1a533ec5..4b0c16a4 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "ratchet/pawl": "0.2.*", "psr/log": "~1", "ext-openssl": "*", - "voryx/thruway-message": "^1.0" + "voryx/thruway-common": "^1.0" }, "require-dev": { "phpunit/phpunit": "^5.5.4" From d625da535c068daea4b8462b90af28a5fd73fdb2 Mon Sep 17 00:00:00 2001 From: nanodesu88 Date: Fri, 16 Jun 2017 14:00:25 +0400 Subject: [PATCH 15/15] invocation details for autobahn --- src/Thruway/Call.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Thruway/Call.php b/src/Thruway/Call.php index 629a4a6e..93f345a7 100644 --- a/src/Thruway/Call.php +++ b/src/Thruway/Call.php @@ -302,6 +302,8 @@ public function getInvocationMessage() "authrole" => $authenticationDetails->getAuthRole(), "authroles" => $authenticationDetails->getAuthRoles(), "authmethod" => $authenticationDetails->getAuthMethod(), + 'caller_authid' => $authenticationDetails->getAuthId(), + 'caller_authrole' => $authenticationDetails->getAuthRoles() ]; if ($authenticationDetails->getAuthExtra() !== null) { @@ -321,6 +323,7 @@ public function getInvocationMessage() if (count($details) == 0) { $details = new \stdClass(); } + $invocationMessage->setDetails($details); $this->setIsProgressive($isProgressive);