Structure/stubs
This commit is contained in:
parent
5320efe4e7
commit
8c9f55240c
@ -2,4 +2,8 @@
|
||||
namespace Ratchet;
|
||||
|
||||
class Exception extends \Exception {
|
||||
public function __construct() {
|
||||
$int = socket_last_error();
|
||||
parent::__construct(socket_strerror($int), $int);
|
||||
}
|
||||
}
|
7
lib/Ratchet/Protocol/ProtocolInterface.php
Normal file
7
lib/Ratchet/Protocol/ProtocolInterface.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace Ratchet\Protocol;
|
||||
use Ratchet\Server;
|
||||
|
||||
interface ProtocolInterface {
|
||||
function __construct(Server $server);
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
namespace Ratchet\WebSocket;
|
||||
|
||||
class Adapter {
|
||||
/**
|
||||
* @param string
|
||||
* @return Ratchet\Protocol\WebSocket\Version\VersionInterface
|
||||
*/
|
||||
public function getProtocol($header) {
|
||||
|
||||
}
|
||||
}
|
12
lib/Ratchet/Protocol/WebSocket/Server.php
Normal file
12
lib/Ratchet/Protocol/WebSocket/Server.php
Normal 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;
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
||||
}
|
||||
}
|
@ -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() {
|
||||
}
|
||||
}
|
6
lib/Ratchet/ServerInterface.php
Normal file
6
lib/Ratchet/ServerInterface.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace Ratchet;
|
||||
|
||||
interface ServerInterface {
|
||||
function run();
|
||||
}
|
@ -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) {
|
||||
|
@ -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('', '')
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user