From 8c9f55240cf1ec7364845f8e02bfd5d2ce31e63e Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Sun, 4 Sep 2011 17:30:21 -0400 Subject: [PATCH] Structure/stubs --- lib/Ratchet/Exception.php | 4 +++ lib/Ratchet/Protocol/ProtocolInterface.php | 7 ++++ lib/Ratchet/Protocol/WebSocket/Adapter.php | 12 ------- lib/Ratchet/Protocol/WebSocket/Server.php | 12 +++++++ .../Protocol/WebSocket/Version/Hixie76.php | 17 +++++++++- lib/Ratchet/Server.php | 12 +++++-- lib/Ratchet/ServerInterface.php | 6 ++++ lib/Ratchet/Socket.php | 16 +++++++-- .../WebSocket/Version/Hixie76Test.php | 33 +++++++++++++++++++ 9 files changed, 101 insertions(+), 18 deletions(-) create mode 100644 lib/Ratchet/Protocol/ProtocolInterface.php delete mode 100644 lib/Ratchet/Protocol/WebSocket/Adapter.php create mode 100644 lib/Ratchet/Protocol/WebSocket/Server.php create mode 100644 lib/Ratchet/ServerInterface.php create mode 100644 tests/Ratchet/Tests/Protocol/WebSocket/Version/Hixie76Test.php diff --git a/lib/Ratchet/Exception.php b/lib/Ratchet/Exception.php index a6b7e27..4c1da15 100644 --- a/lib/Ratchet/Exception.php +++ b/lib/Ratchet/Exception.php @@ -2,4 +2,8 @@ namespace Ratchet; class Exception extends \Exception { + public function __construct() { + $int = socket_last_error(); + parent::__construct(socket_strerror($int), $int); + } } \ No newline at end of file diff --git a/lib/Ratchet/Protocol/ProtocolInterface.php b/lib/Ratchet/Protocol/ProtocolInterface.php new file mode 100644 index 0000000..35f0048 --- /dev/null +++ b/lib/Ratchet/Protocol/ProtocolInterface.php @@ -0,0 +1,7 @@ +_server = $server; + } +} \ No newline at end of file diff --git a/lib/Ratchet/Protocol/WebSocket/Version/Hixie76.php b/lib/Ratchet/Protocol/WebSocket/Version/Hixie76.php index 64f93b8..24d55ae 100644 --- a/lib/Ratchet/Protocol/WebSocket/Version/Hixie76.php +++ b/lib/Ratchet/Protocol/WebSocket/Version/Hixie76.php @@ -1,5 +1,20 @@ _master = $socket; + } + + public function run() { } } \ No newline at end of file diff --git a/lib/Ratchet/ServerInterface.php b/lib/Ratchet/ServerInterface.php new file mode 100644 index 0000000..087944d --- /dev/null +++ b/lib/Ratchet/ServerInterface.php @@ -0,0 +1,6 @@ +_socket = socket_open(); + public static $_defaults = Array( + 'domain' => AF_INET + , 'type' => SOCK_STREAM + , 'protocol' => SOL_TCP + ); + + public function __construct($domain = null, $type = null, $protocol = null) { + foreach (static::$_default as $key => $val) { + if (null === $$key) { + $$key = $val; + } + } + + $this->_socket = socket_create($domain, $type, $protocol); } public function __call($method, $arguments) { diff --git a/tests/Ratchet/Tests/Protocol/WebSocket/Version/Hixie76Test.php b/tests/Ratchet/Tests/Protocol/WebSocket/Version/Hixie76Test.php new file mode 100644 index 0000000..b9dffbd --- /dev/null +++ b/tests/Ratchet/Tests/Protocol/WebSocket/Version/Hixie76Test.php @@ -0,0 +1,33 @@ +_version = new Hixie76(); + } + + public function testClassImplementsVersionInterface() { + $constraint = $this->isInstanceOf('\\Ratchet\\Protocol\\WebSocket\\Version\\VersionInterface'); + $this->assertThat($this->_version, $constraint); + } + + /** + * @dataProvider HandshakeProvider + */ + public function INCOMPLETEtestKeySigningForHandshake($key, $accept) { +// $this->assertEquals($accept, $this->_version->sign($key)); + } + + public static function HandshakeProvider() { + return Array( + Array('', '') + , Array('', '') + ); + } +} \ No newline at end of file