From 2c976d010271fbd30414142877acf86b228935f1 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Tue, 31 Jan 2012 20:47:59 -0500 Subject: [PATCH] Continuing logical NS refactor Updated more components to reflect new terminology when using Ratchet components --- composer.json | 2 +- composer.lock | 2 +- .../Server/{App.php => IOServerComponent.php} | 14 +++++++++++- ...PComponent.php => WAMPServerComponent.php} | 2 +- .../WAMP/WAMPServerComponentInterface.php | 3 ++- .../WebSocket/WebSocketComponent.php | 8 +++---- .../WebSocket/WebSocketComponentInterface.php | 4 ++-- .../Command/Action/ActionInterface.php | 1 + src/Ratchet/Resource/Command/Composite.php | 3 +++ ...{AppTest.php => IOServerComponentTest.php} | 20 ++++++++--------- vendor/.composer/ClassLoader.php | 2 -- vendor/.composer/autoload.php | 22 ------------------- vendor/.composer/autoload_namespaces.php | 11 ---------- vendor/.composer/installed.json | 22 ------------------- 14 files changed, 38 insertions(+), 78 deletions(-) rename src/Ratchet/Component/Server/{App.php => IOServerComponent.php} (96%) rename src/Ratchet/Component/WAMP/{WAMPComponent.php => WAMPServerComponent.php} (98%) rename tests/Ratchet/Tests/Component/Server/{AppTest.php => IOServerComponentTest.php} (77%) delete mode 100644 vendor/.composer/ClassLoader.php delete mode 100644 vendor/.composer/autoload.php delete mode 100644 vendor/.composer/autoload_namespaces.php delete mode 100644 vendor/.composer/installed.json diff --git a/composer.json b/composer.json index 33bdac6..464f025 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ , "autoload": { "psr-0": { "Ratchet\\Tests": "tests" - , "Ratchet": "lib" + , "Ratchet": "src" } } , "repositories": { diff --git a/composer.lock b/composer.lock index 7b8b66e..a2d950a 100644 --- a/composer.lock +++ b/composer.lock @@ -1,5 +1,5 @@ { - "hash": "75f85f47f6365abbeeabb065601c6ec2", + "hash": "9c9347f555af9a961102c4158e6d2ae8", "packages": [ { "package": "guzzle", diff --git a/src/Ratchet/Component/Server/App.php b/src/Ratchet/Component/Server/IOServerComponent.php similarity index 96% rename from src/Ratchet/Component/Server/App.php rename to src/Ratchet/Component/Server/IOServerComponent.php index c2c1ab8..47479e0 100644 --- a/src/Ratchet/Component/Server/App.php +++ b/src/Ratchet/Component/Server/IOServerComponent.php @@ -9,7 +9,7 @@ use Ratchet\Resource\Command\CommandInterface; /** * Creates an open-ended socket to listen on a port for incomming connections. Events are delegated through this to attached applications */ -class App implements MessageComponentInterface { +class IOServerComponent implements MessageComponentInterface { /** * @var array of Socket Resources */ @@ -145,6 +145,9 @@ class App implements MessageComponentInterface { } } + /** + * @{inheritdoc} + */ public function onOpen(ConnectionInterface $conn) { $new_socket = clone $conn->getSocket(); $new_socket->set_nonblock(); @@ -156,10 +159,16 @@ class App implements MessageComponentInterface { return $this->_decorating->onOpen($new_connection); } + /** + * @{inheritdoc} + */ public function onMessage(ConnectionInterface $from, $msg) { return $this->_decorating->onMessage($from, $msg); } + /** + * @{inheritdoc} + */ public function onClose(ConnectionInterface $conn) { $resource = $conn->getSocket()->getResource(); @@ -170,6 +179,9 @@ class App implements MessageComponentInterface { return $cmd; } + /** + * @{inheritdoc} + */ public function onError(ConnectionInterface $conn, \Exception $e) { return $this->_decorating->onError($conn, $e); } diff --git a/src/Ratchet/Component/WAMP/WAMPComponent.php b/src/Ratchet/Component/WAMP/WAMPServerComponent.php similarity index 98% rename from src/Ratchet/Component/WAMP/WAMPComponent.php rename to src/Ratchet/Component/WAMP/WAMPServerComponent.php index b437182..630e19c 100644 --- a/src/Ratchet/Component/WAMP/WAMPComponent.php +++ b/src/Ratchet/Component/WAMP/WAMPServerComponent.php @@ -25,7 +25,7 @@ use Ratchet\Component\WAMP\Command\Action\Prefix; * @link http://www.tavendo.de/autobahn/protocol.html * @link https://raw.github.com/oberstet/Autobahn/master/lib/javascript/autobahn.js */ -class WAMPComponent implements WebSocketAppInterface { +class WAMPServerComponent implements WebSocketAppInterface { const MSG_WELCOME = 0; const MSG_PREFIX = 1; const MSG_CALL = 2; diff --git a/src/Ratchet/Component/WAMP/WAMPServerComponentInterface.php b/src/Ratchet/Component/WAMP/WAMPServerComponentInterface.php index 48ebee6..7e47de8 100644 --- a/src/Ratchet/Component/WAMP/WAMPServerComponentInterface.php +++ b/src/Ratchet/Component/WAMP/WAMPServerComponentInterface.php @@ -1,5 +1,6 @@ _decorating = $component; $this->_factory = new Factory; } diff --git a/src/Ratchet/Component/WebSocket/WebSocketComponentInterface.php b/src/Ratchet/Component/WebSocket/WebSocketComponentInterface.php index 80e045b..01560d9 100644 --- a/src/Ratchet/Component/WebSocket/WebSocketComponentInterface.php +++ b/src/Ratchet/Component/WebSocket/WebSocketComponentInterface.php @@ -1,13 +1,13 @@ setIteratorMode(static::IT_MODE_DELETE); diff --git a/tests/Ratchet/Tests/Component/Server/AppTest.php b/tests/Ratchet/Tests/Component/Server/IOServerComponentTest.php similarity index 77% rename from tests/Ratchet/Tests/Component/Server/AppTest.php rename to tests/Ratchet/Tests/Component/Server/IOServerComponentTest.php index 220793c..0fa0601 100644 --- a/tests/Ratchet/Tests/Component/Server/AppTest.php +++ b/tests/Ratchet/Tests/Component/Server/IOServerComponentTest.php @@ -1,23 +1,23 @@ _catalyst = new Socket; - $this->_app = new TestApp; - $this->_server = new ServerApp($this->_app); + $this->_decorated = new TestApp; + $this->_server = new IOServerComponent($this->_decorated); - $ref = new \ReflectionClass('\\Ratchet\\Component\\Server\\App'); + $ref = new \ReflectionClass('\\Ratchet\\Component\\Server\\IOServerComponent'); $prop = $ref->getProperty('_run'); $prop->setAccessible(true); $prop->setValue($this->_server, false); @@ -41,7 +41,7 @@ class AppTest extends \PHPUnit_Framework_TestCase { $master = $this->getMasterConnection(); $this->_server->onOpen($master); - $clone = $this->_app->_conn_open; + $clone = $this->_decorated->_conn_open; $this->assertEquals($master->getID() + 1, $clone->getID()); } @@ -54,12 +54,12 @@ class AppTest extends \PHPUnit_Framework_TestCase { // that way can mimic the TCP fragmentation/buffer situation $this->_server->onOpen($master); - $clone = $this->_app->_conn_open; + $clone = $this->_decorated->_conn_open; // $this->_server->run($this->_catalyst); $msg = 'Hello World!'; $this->_server->onMessage($clone, $msg); - $this->assertEquals($msg, $this->_app->_msg_recv); + $this->assertEquals($msg, $this->_decorated->_msg_recv); } } \ No newline at end of file diff --git a/vendor/.composer/ClassLoader.php b/vendor/.composer/ClassLoader.php deleted file mode 100644 index d8fb367..0000000 --- a/vendor/.composer/ClassLoader.php +++ /dev/null @@ -1,2 +0,0 @@ -prefixes; } public function getFallbackDirs() { return $this->fallbackDirs; } public function add($prefix, $paths) { if (!$prefix) { $this->fallbackDirs = (array) $paths; return; } if (isset($this->prefixes[$prefix])) { $this->prefixes[$prefix] = array_merge( $this->prefixes[$prefix], (array) $paths ); } else { $this->prefixes[$prefix] = (array) $paths; } } public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); } public function loadClass($class) { if ($file = $this->findFile($class)) { require $file; return true; } } public function findFile($class) { if ('\\' == $class[0]) { $class = substr($class, 1); } if (false !== $pos = strrpos($class, '\\')) { $classPath = DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)); $className = substr($class, $pos + 1); } else { $classPath = null; $className = $class; } $classPath .= DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; foreach ($this->prefixes as $prefix => $dirs) { foreach ($dirs as $dir) { if (0 === strpos($class, $prefix)) { if (file_exists($dir . $classPath)) { return $dir . $classPath; } } } } foreach ($this->fallbackDirs as $dir) { if (file_exists($dir . $classPath)) { return $dir . $classPath; } } } } \ No newline at end of file diff --git a/vendor/.composer/autoload.php b/vendor/.composer/autoload.php deleted file mode 100644 index 3f20144..0000000 --- a/vendor/.composer/autoload.php +++ /dev/null @@ -1,22 +0,0 @@ - $path) { - $loader->add($namespace, $path); - } - - $loader->register(); - - return $loader; -}; - -return $__composer_autoload_init(); \ No newline at end of file diff --git a/vendor/.composer/autoload_namespaces.php b/vendor/.composer/autoload_namespaces.php deleted file mode 100644 index 1481677..0000000 --- a/vendor/.composer/autoload_namespaces.php +++ /dev/null @@ -1,11 +0,0 @@ - dirname($vendorDir) . '/tests', - 'Ratchet' => dirname($vendorDir) . '/lib', - 'Guzzle' => $vendorDir . '/guzzle/src', -); diff --git a/vendor/.composer/installed.json b/vendor/.composer/installed.json deleted file mode 100644 index 11ef412..0000000 --- a/vendor/.composer/installed.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "name": "guzzle", - "version": "2.0.2", - "version_normalized": "2.0.2.0", - "source": { - "type": "git", - "url": "https:\/\/github.com\/guzzle\/guzzle.git", - "reference": "ac64abc2c05b921efc4623379c1674a282475ae5" - }, - "type": "library", - "names": [ - "guzzle" - ], - "installation-source": "source", - "autoload": { - "psr-0": { - "Guzzle": "src" - } - } - } -] \ No newline at end of file