diff --git a/lib/Ratchet/Command/CloseConnection.php b/lib/Ratchet/Command/CloseConnection.php index f190669..4e36dc3 100644 --- a/lib/Ratchet/Command/CloseConnection.php +++ b/lib/Ratchet/Command/CloseConnection.php @@ -2,7 +2,13 @@ namespace Ratchet\Command; use Ratchet\SocketCollection; +/** + * Close the connection to the sockets passed in the constructor + */ class CloseConnection implements CommandInterface { + /** + * @var SocketCollection + */ protected $_sockets; public function __construct(SocketCollection $sockets) { @@ -10,6 +16,8 @@ class CloseConnection implements CommandInterface { } function execute() { - $this->_sockets->close(); + foreach ($this->_sockets as $socket) { + $socket->close(); + } } } \ No newline at end of file diff --git a/lib/Ratchet/Command/CommandInterface.php b/lib/Ratchet/Command/CommandInterface.php index ca45e57..f65e21a 100644 --- a/lib/Ratchet/Command/CommandInterface.php +++ b/lib/Ratchet/Command/CommandInterface.php @@ -2,8 +2,18 @@ namespace Ratchet\Command; use Ratchet\SocketCollection; +/** + * Socket implementation of the Command Pattern + * User created applications are to return a Command to the server for execution + */ interface CommandInterface { + /** + * Pass the Sockets to execute the command on + */ function __construct(SocketCollection $sockets); + /** + * The Server class will call the execution + */ function execute(); } \ No newline at end of file diff --git a/lib/Ratchet/Command/Null.php b/lib/Ratchet/Command/Null.php index 67865d1..c9c326b 100644 --- a/lib/Ratchet/Command/Null.php +++ b/lib/Ratchet/Command/Null.php @@ -2,6 +2,9 @@ namespace Ratchet\Command; use Ratchet\SocketCollection; +/** + * Null pattern - execution does nothing, something needs to be passed back though + */ class Null implements CommandInterface { public function __construct(SocketCollection $sockets) { } diff --git a/lib/Ratchet/Command/SendMessage.php b/lib/Ratchet/Command/SendMessage.php index 298d132..ca01b47 100644 --- a/lib/Ratchet/Command/SendMessage.php +++ b/lib/Ratchet/Command/SendMessage.php @@ -2,22 +2,43 @@ namespace Ratchet\Command; use Ratchet\SocketCollection; +/** + * Send text back to the client end of the socket(s) + */ class SendMessage implements CommandInterface { + /** + * @var SocketCollection + */ protected $_sockets; + + /** + * @var string + */ protected $_message = ''; public function __construct(SocketCollection $sockets) { $this->_sockets = $sockets; } + /** + * The message to send to the socket(s) + * @param string + */ public function setMessage($msg) { $this->_message = (string)$msg; } + /** + * Get the message from setMessage() + * @return string + */ public function getMessage() { return $this->_message; } + /** + * @throws \UnexpectedValueException if a message was not set with setMessage() + */ public function execute() { if (empty($this->_message)) { throw new \UnexpectedValueException("Message is empty"); diff --git a/lib/Ratchet/Exception.php b/lib/Ratchet/Exception.php index 62e2fb1..c1f217a 100644 --- a/lib/Ratchet/Exception.php +++ b/lib/Ratchet/Exception.php @@ -1,6 +1,9 @@ _version; diff --git a/lib/Ratchet/Protocol/WebSocket/Version/Hixie76.php b/lib/Ratchet/Protocol/WebSocket/Version/Hixie76.php index a5d5993..b97786f 100644 --- a/lib/Ratchet/Protocol/WebSocket/Version/Hixie76.php +++ b/lib/Ratchet/Protocol/WebSocket/Version/Hixie76.php @@ -1,6 +1,10 @@ sign($headers['Sec-Websocket-Key']); diff --git a/lib/Ratchet/Protocol/WebSocket/Version/VersionInterface.php b/lib/Ratchet/Protocol/WebSocket/Version/VersionInterface.php index 817344b..59e5b27 100644 --- a/lib/Ratchet/Protocol/WebSocket/Version/VersionInterface.php +++ b/lib/Ratchet/Protocol/WebSocket/Version/VersionInterface.php @@ -1,6 +1,10 @@ setIteratorMode(static::IT_MODE_DELETE); } + /** + * @param SocketInterface + */ public function enqueue(SocketInterface $value) { parent::enqueue($value); } diff --git a/lib/Ratchet/SocketInterface.php b/lib/Ratchet/SocketInterface.php index 15b93a3..3230bba 100644 --- a/lib/Ratchet/SocketInterface.php +++ b/lib/Ratchet/SocketInterface.php @@ -1,19 +1,27 @@