From 5386b4c066ad4a91a9bbdcf390f7b9b7c88dd62d Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Sat, 12 Nov 2011 14:29:10 -0500 Subject: [PATCH] Folder restructure Just reorganized the folders. Namespacing broken, unit tests broken, nothing works. --- .../Client/App.php} | 0 .../ProtocolInterface.php | 0 .../Server/App.php} | 0 .../WebSocket/App.php} | 0 .../WebSocket/AppInterface.php | 0 .../WebSocket/Client.php | 1 + .../WebSocket/Command/Action/Disconnect.php | 0 .../WebSocket/Command/Action/Ping.php | 0 .../WebSocket/Command/Action/Pong.php | 0 .../WebSocket/Util/HTTP.php | 0 .../WebSocket/Version/Hixie76.php | 0 .../WebSocket/Version/HyBi10.php | 0 .../WebSocket/Version/VersionInterface.php | 0 ...cketObserver.php => ObserverInterface.php} | 1 + .../Command/Action/CloseConnection.php | 0 .../{ => Resource}/Command/Action/Null.php | 0 .../{ => Resource}/Command/Action/Runtime.php | 0 .../Command/Action/SendMessage.php | 0 .../Command/ActionInterface.php | 0 .../{ => Resource}/Command/ActionTemplate.php | 0 .../Command/CommandInterface.php | 0 .../{ => Resource}/Command/Composite.php | 0 .../{ => Resource}/Command/Factory.php | 0 .../Resource/Connection/Connection.php | 39 +++++++++++++++++++ .../Connection/ConnectionInterface.php | 30 ++++++++++++++ lib/Ratchet/SocketInterface.php | 11 +++++- 26 files changed, 80 insertions(+), 2 deletions(-) rename lib/Ratchet/{Client.php => Application/Client/App.php} (100%) rename lib/Ratchet/{Protocol => Application}/ProtocolInterface.php (100%) rename lib/Ratchet/{Server.php => Application/Server/App.php} (100%) rename lib/Ratchet/{Protocol/WebSocket.php => Application/WebSocket/App.php} (100%) rename lib/Ratchet/{Protocol => Application}/WebSocket/AppInterface.php (100%) rename lib/Ratchet/{Protocol => Application}/WebSocket/Client.php (93%) rename lib/Ratchet/{Protocol => Application}/WebSocket/Command/Action/Disconnect.php (100%) rename lib/Ratchet/{Protocol => Application}/WebSocket/Command/Action/Ping.php (100%) rename lib/Ratchet/{Protocol => Application}/WebSocket/Command/Action/Pong.php (100%) rename lib/Ratchet/{Protocol => Application}/WebSocket/Util/HTTP.php (100%) rename lib/Ratchet/{Protocol => Application}/WebSocket/Version/Hixie76.php (100%) rename lib/Ratchet/{Protocol => Application}/WebSocket/Version/HyBi10.php (100%) rename lib/Ratchet/{Protocol => Application}/WebSocket/Version/VersionInterface.php (100%) rename lib/Ratchet/{SocketObserver.php => ObserverInterface.php} (97%) rename lib/Ratchet/{ => Resource}/Command/Action/CloseConnection.php (100%) rename lib/Ratchet/{ => Resource}/Command/Action/Null.php (100%) rename lib/Ratchet/{ => Resource}/Command/Action/Runtime.php (100%) rename lib/Ratchet/{ => Resource}/Command/Action/SendMessage.php (100%) rename lib/Ratchet/{ => Resource}/Command/ActionInterface.php (100%) rename lib/Ratchet/{ => Resource}/Command/ActionTemplate.php (100%) rename lib/Ratchet/{ => Resource}/Command/CommandInterface.php (100%) rename lib/Ratchet/{ => Resource}/Command/Composite.php (100%) rename lib/Ratchet/{ => Resource}/Command/Factory.php (100%) create mode 100644 lib/Ratchet/Resource/Connection/Connection.php create mode 100644 lib/Ratchet/Resource/Connection/ConnectionInterface.php diff --git a/lib/Ratchet/Client.php b/lib/Ratchet/Application/Client/App.php similarity index 100% rename from lib/Ratchet/Client.php rename to lib/Ratchet/Application/Client/App.php diff --git a/lib/Ratchet/Protocol/ProtocolInterface.php b/lib/Ratchet/Application/ProtocolInterface.php similarity index 100% rename from lib/Ratchet/Protocol/ProtocolInterface.php rename to lib/Ratchet/Application/ProtocolInterface.php diff --git a/lib/Ratchet/Server.php b/lib/Ratchet/Application/Server/App.php similarity index 100% rename from lib/Ratchet/Server.php rename to lib/Ratchet/Application/Server/App.php diff --git a/lib/Ratchet/Protocol/WebSocket.php b/lib/Ratchet/Application/WebSocket/App.php similarity index 100% rename from lib/Ratchet/Protocol/WebSocket.php rename to lib/Ratchet/Application/WebSocket/App.php diff --git a/lib/Ratchet/Protocol/WebSocket/AppInterface.php b/lib/Ratchet/Application/WebSocket/AppInterface.php similarity index 100% rename from lib/Ratchet/Protocol/WebSocket/AppInterface.php rename to lib/Ratchet/Application/WebSocket/AppInterface.php diff --git a/lib/Ratchet/Protocol/WebSocket/Client.php b/lib/Ratchet/Application/WebSocket/Client.php similarity index 93% rename from lib/Ratchet/Protocol/WebSocket/Client.php rename to lib/Ratchet/Application/WebSocket/Client.php index 6f4c6e2..c2f9392 100644 --- a/lib/Ratchet/Protocol/WebSocket/Client.php +++ b/lib/Ratchet/Application/WebSocket/Client.php @@ -4,6 +4,7 @@ use Ratchet\Protocol\WebSocket\Version\VersionInterface; /** * A representation of a Socket connection of the user on the other end of the socket + * @todo Replace this with Resource\Connection\ConnectionInterface */ class Client { /** diff --git a/lib/Ratchet/Protocol/WebSocket/Command/Action/Disconnect.php b/lib/Ratchet/Application/WebSocket/Command/Action/Disconnect.php similarity index 100% rename from lib/Ratchet/Protocol/WebSocket/Command/Action/Disconnect.php rename to lib/Ratchet/Application/WebSocket/Command/Action/Disconnect.php diff --git a/lib/Ratchet/Protocol/WebSocket/Command/Action/Ping.php b/lib/Ratchet/Application/WebSocket/Command/Action/Ping.php similarity index 100% rename from lib/Ratchet/Protocol/WebSocket/Command/Action/Ping.php rename to lib/Ratchet/Application/WebSocket/Command/Action/Ping.php diff --git a/lib/Ratchet/Protocol/WebSocket/Command/Action/Pong.php b/lib/Ratchet/Application/WebSocket/Command/Action/Pong.php similarity index 100% rename from lib/Ratchet/Protocol/WebSocket/Command/Action/Pong.php rename to lib/Ratchet/Application/WebSocket/Command/Action/Pong.php diff --git a/lib/Ratchet/Protocol/WebSocket/Util/HTTP.php b/lib/Ratchet/Application/WebSocket/Util/HTTP.php similarity index 100% rename from lib/Ratchet/Protocol/WebSocket/Util/HTTP.php rename to lib/Ratchet/Application/WebSocket/Util/HTTP.php diff --git a/lib/Ratchet/Protocol/WebSocket/Version/Hixie76.php b/lib/Ratchet/Application/WebSocket/Version/Hixie76.php similarity index 100% rename from lib/Ratchet/Protocol/WebSocket/Version/Hixie76.php rename to lib/Ratchet/Application/WebSocket/Version/Hixie76.php diff --git a/lib/Ratchet/Protocol/WebSocket/Version/HyBi10.php b/lib/Ratchet/Application/WebSocket/Version/HyBi10.php similarity index 100% rename from lib/Ratchet/Protocol/WebSocket/Version/HyBi10.php rename to lib/Ratchet/Application/WebSocket/Version/HyBi10.php diff --git a/lib/Ratchet/Protocol/WebSocket/Version/VersionInterface.php b/lib/Ratchet/Application/WebSocket/Version/VersionInterface.php similarity index 100% rename from lib/Ratchet/Protocol/WebSocket/Version/VersionInterface.php rename to lib/Ratchet/Application/WebSocket/Version/VersionInterface.php diff --git a/lib/Ratchet/SocketObserver.php b/lib/Ratchet/ObserverInterface.php similarity index 97% rename from lib/Ratchet/SocketObserver.php rename to lib/Ratchet/ObserverInterface.php index a316c44..f49c3d7 100644 --- a/lib/Ratchet/SocketObserver.php +++ b/lib/Ratchet/ObserverInterface.php @@ -6,6 +6,7 @@ namespace Ratchet; * @todo Consider an onException method. Since server is running its own loop the app currently doesn't know when a problem is handled * @todo Consider an onDisconnect method for a server-side close()'ing of a connection - onClose would be client side close() * @todo Consider adding __construct(SocketObserver $decorator = null) - on Server move Socket as parameter to run() + * @todo Does this belong in \Ratchet\Server\? */ interface SocketObserver { /** diff --git a/lib/Ratchet/Command/Action/CloseConnection.php b/lib/Ratchet/Resource/Command/Action/CloseConnection.php similarity index 100% rename from lib/Ratchet/Command/Action/CloseConnection.php rename to lib/Ratchet/Resource/Command/Action/CloseConnection.php diff --git a/lib/Ratchet/Command/Action/Null.php b/lib/Ratchet/Resource/Command/Action/Null.php similarity index 100% rename from lib/Ratchet/Command/Action/Null.php rename to lib/Ratchet/Resource/Command/Action/Null.php diff --git a/lib/Ratchet/Command/Action/Runtime.php b/lib/Ratchet/Resource/Command/Action/Runtime.php similarity index 100% rename from lib/Ratchet/Command/Action/Runtime.php rename to lib/Ratchet/Resource/Command/Action/Runtime.php diff --git a/lib/Ratchet/Command/Action/SendMessage.php b/lib/Ratchet/Resource/Command/Action/SendMessage.php similarity index 100% rename from lib/Ratchet/Command/Action/SendMessage.php rename to lib/Ratchet/Resource/Command/Action/SendMessage.php diff --git a/lib/Ratchet/Command/ActionInterface.php b/lib/Ratchet/Resource/Command/ActionInterface.php similarity index 100% rename from lib/Ratchet/Command/ActionInterface.php rename to lib/Ratchet/Resource/Command/ActionInterface.php diff --git a/lib/Ratchet/Command/ActionTemplate.php b/lib/Ratchet/Resource/Command/ActionTemplate.php similarity index 100% rename from lib/Ratchet/Command/ActionTemplate.php rename to lib/Ratchet/Resource/Command/ActionTemplate.php diff --git a/lib/Ratchet/Command/CommandInterface.php b/lib/Ratchet/Resource/Command/CommandInterface.php similarity index 100% rename from lib/Ratchet/Command/CommandInterface.php rename to lib/Ratchet/Resource/Command/CommandInterface.php diff --git a/lib/Ratchet/Command/Composite.php b/lib/Ratchet/Resource/Command/Composite.php similarity index 100% rename from lib/Ratchet/Command/Composite.php rename to lib/Ratchet/Resource/Command/Composite.php diff --git a/lib/Ratchet/Command/Factory.php b/lib/Ratchet/Resource/Command/Factory.php similarity index 100% rename from lib/Ratchet/Command/Factory.php rename to lib/Ratchet/Resource/Command/Factory.php diff --git a/lib/Ratchet/Resource/Connection/Connection.php b/lib/Ratchet/Resource/Connection/Connection.php new file mode 100644 index 0000000..329cfbd --- /dev/null +++ b/lib/Ratchet/Resource/Connection/Connection.php @@ -0,0 +1,39 @@ +_id = (string)$socket->getResource(); + $this->_id = (int)substr($this->_id, strrpos($this->_id, '#') + 1); + } + + /** + * @return int + */ + public function getID() { + return $this->_id; + } + + public function set($name, $val) { + $this->_data[$name] = $val; + } + + public function get($name) { + if (!isset($this->_data[$name])) { + throw new \UnexpectedValueException("Attribute '{$name}' not found in Connection {$this->getID()}"); + } + + return $this->_data[$name]; + } +} \ No newline at end of file diff --git a/lib/Ratchet/Resource/Connection/ConnectionInterface.php b/lib/Ratchet/Resource/Connection/ConnectionInterface.php new file mode 100644 index 0000000..37ae2b1 --- /dev/null +++ b/lib/Ratchet/Resource/Connection/ConnectionInterface.php @@ -0,0 +1,30 @@ +