From 5ce4a7b837216f9c8688223d59a7c8afe17a41e0 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Mon, 5 Sep 2011 08:53:21 -0400 Subject: [PATCH] Stubs, coverage, api docs --- lib/Ratchet/ApplicationInterface.php | 5 ++++ lib/Ratchet/Protocol/ProtocolInterface.php | 4 ++++ .../WebSocket/ApplicationInterface.php | 6 +++++ lib/Ratchet/Protocol/WebSocket/Server.php | 14 +++++++++++ lib/Ratchet/Server.php | 4 ++++ lib/Ratchet/Socket.php | 24 ++++++++++++++++++- phpunit.xml.dist | 7 ++++++ 7 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 lib/Ratchet/ApplicationInterface.php create mode 100644 lib/Ratchet/Protocol/WebSocket/ApplicationInterface.php diff --git a/lib/Ratchet/ApplicationInterface.php b/lib/Ratchet/ApplicationInterface.php new file mode 100644 index 0000000..cf8cfbd --- /dev/null +++ b/lib/Ratchet/ApplicationInterface.php @@ -0,0 +1,5 @@ +_server = $server; } + /** + * @return Array + */ + public static function getDefaultConfig() { + return Array( + 'domain' => AF_INET + , 'type' => SOCK_STREAM + , 'protocol' => SOL_TCP + , 'options' => Array( + SOL_SOCKET => Array(SO_REUSEADDR => 1) + ) + ); + } + public function run() { } } \ No newline at end of file diff --git a/lib/Ratchet/Server.php b/lib/Ratchet/Server.php index dfe411e..0041b3a 100644 --- a/lib/Ratchet/Server.php +++ b/lib/Ratchet/Server.php @@ -10,5 +10,9 @@ class Server implements ServerInterface { } public function run() { + set_time_limit(0); + ob_implicit_flush(); +// $this->_master->set_nonblock(); +// declare(ticks = 1); } } \ No newline at end of file diff --git a/lib/Ratchet/Socket.php b/lib/Ratchet/Socket.php index fdd4898..8fdb733 100644 --- a/lib/Ratchet/Socket.php +++ b/lib/Ratchet/Socket.php @@ -1,7 +1,14 @@ + */ class Socket { + /** + * @type resource + */ protected $_socket; public static $_defaults = Array( @@ -10,11 +17,23 @@ class Socket { , 'protocol' => SOL_TCP ); + /** + * @param int Specifies the protocol family to be used by the socket. + * @param int The type of communication to be used by the socket + * @param int Sets the specific protocol within the specified domain to be used when communicating on the returned socket + * @throws Ratchet\Exception + */ public function __construct($domain = null, $type = null, $protocol = null) { list($domain, $type, $protocol) = static::getConfig($domain, $type, $protocol); - $this->_socket = socket_create($domain, $type, $protocol); + + if (false === ($this->_socket = socket_create($domain, $type, $protocol))) { + throw new Exception(); + } } + /** + * @internal + */ protected static function getConfig($domain = null, $type = null, $protocol = null) { foreach (static::$_defaults as $key => $val) { if (null === $$key) { @@ -25,6 +44,9 @@ class Socket { return Array($domain, $type, $protocol); } + /** + * @internal + */ public function __call($method, $arguments) { if (function_exists('socket_' . $method)) { array_unshift($arguments, $this->_socket); diff --git a/phpunit.xml.dist b/phpunit.xml.dist index de09a7b..bb897be 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -7,6 +7,7 @@ backupGlobals="false" backupStaticAttributes="false" syntaxCheck="false" + stopOnError="false" > @@ -14,4 +15,10 @@ ./tests/Ratchet/ + + + + ./tests/ + + \ No newline at end of file