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 @@ +