Structure/stubs

This commit is contained in:
Chris Boden 2011-09-04 17:30:21 -04:00
parent 5320efe4e7
commit 8c9f55240c
9 changed files with 101 additions and 18 deletions

View File

@ -2,4 +2,8 @@
namespace Ratchet;
class Exception extends \Exception {
public function __construct() {
$int = socket_last_error();
parent::__construct(socket_strerror($int), $int);
}
}

View File

@ -0,0 +1,7 @@
<?php
namespace Ratchet\Protocol;
use Ratchet\Server;
interface ProtocolInterface {
function __construct(Server $server);
}

View File

@ -1,12 +0,0 @@
<?php
namespace Ratchet\WebSocket;
class Adapter {
/**
* @param string
* @return Ratchet\Protocol\WebSocket\Version\VersionInterface
*/
public function getProtocol($header) {
}
}

View File

@ -0,0 +1,12 @@
<?php
namespace Ratchet\Protocol\WebSocket;
use Ratchet\ServerInterface;
use Ratchet\Protocol\ProtocolInterface;
class Server implements ServerInterface, ProtocolInterface {
protected $_server = null;
public function __construct(ServerInterface $server) {
$this->_server = $server;
}
}

View File

@ -1,5 +1,20 @@
<?php
namespace Ratchet\Protocol\WebSocket\Version;
class Hixi76 {
class Hixie76 implements VersionInterface {
/**
* @param Headers
* @return string
*/
public function concatinateKeyString($headers) {
}
/**
* @param string
* @return string
*/
public function sign($key) {
}
}

View File

@ -1,8 +1,14 @@
<?php
namespace Ratchet;
use Ratchet\Protocol\ProtocolInterface;
class Server {
public function __construct($host, $port) {
class Server implements ServerInterface {
protected $master = null;
public function __construct(Socket $socket) {
$this->_master = $socket;
}
public function run() {
}
}

View File

@ -0,0 +1,6 @@
<?php
namespace Ratchet;
interface ServerInterface {
function run();
}

View File

@ -4,8 +4,20 @@ namespace Ratchet;
class Socket {
protected $_socket;
public function __construct() {
// $this->_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) {

View File

@ -0,0 +1,33 @@
<?php
namespace Ratchet\Tests\Protocol\WebSocket\Version;
use Ratchet\Protocol\WebSocket\Version\Hixie76;
/**
* @covers Ratchet\Protocol\WebSocket\Version\Hixie76
*/
class Hixie76Test extends \PHPUnit_Framework_TestCase {
protected $_version;
public function setUp() {
$this->_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('', '')
);
}
}