Stubs, coverage, api docs
This commit is contained in:
parent
04875dadcd
commit
5ce4a7b837
5
lib/Ratchet/ApplicationInterface.php
Normal file
5
lib/Ratchet/ApplicationInterface.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
namespace Ratchet;
|
||||||
|
|
||||||
|
interface ApplicationInterface {
|
||||||
|
}
|
@ -3,4 +3,8 @@ namespace Ratchet\Protocol;
|
|||||||
use Ratchet\ServerInterface;
|
use Ratchet\ServerInterface;
|
||||||
|
|
||||||
interface ProtocolInterface extends ServerInterface {
|
interface ProtocolInterface extends ServerInterface {
|
||||||
|
/**
|
||||||
|
* @return Array
|
||||||
|
*/
|
||||||
|
static function getDefaultConfig();
|
||||||
}
|
}
|
6
lib/Ratchet/Protocol/WebSocket/ApplicationInterface.php
Normal file
6
lib/Ratchet/Protocol/WebSocket/ApplicationInterface.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
namespace Ratchet\Protocol\WebSocket;
|
||||||
|
use Ratchet\ApplicationInterface as AI;
|
||||||
|
|
||||||
|
class ApplicationInterface extends AI {
|
||||||
|
}
|
@ -10,6 +10,20 @@ class Server implements ProtocolInterface {
|
|||||||
$this->_server = $server;
|
$this->_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() {
|
public function run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,5 +10,9 @@ class Server implements ServerInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function run() {
|
public function run() {
|
||||||
|
set_time_limit(0);
|
||||||
|
ob_implicit_flush();
|
||||||
|
// $this->_master->set_nonblock();
|
||||||
|
// declare(ticks = 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Ratchet;
|
namespace Ratchet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A wrapper for the PHP socket_ functions
|
||||||
|
* @author Chris Boden <shout at chrisboden dot ca>
|
||||||
|
*/
|
||||||
class Socket {
|
class Socket {
|
||||||
|
/**
|
||||||
|
* @type resource
|
||||||
|
*/
|
||||||
protected $_socket;
|
protected $_socket;
|
||||||
|
|
||||||
public static $_defaults = Array(
|
public static $_defaults = Array(
|
||||||
@ -10,11 +17,23 @@ class Socket {
|
|||||||
, 'protocol' => SOL_TCP
|
, '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) {
|
public function __construct($domain = null, $type = null, $protocol = null) {
|
||||||
list($domain, $type, $protocol) = static::getConfig($domain, $type, $protocol);
|
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) {
|
protected static function getConfig($domain = null, $type = null, $protocol = null) {
|
||||||
foreach (static::$_defaults as $key => $val) {
|
foreach (static::$_defaults as $key => $val) {
|
||||||
if (null === $$key) {
|
if (null === $$key) {
|
||||||
@ -25,6 +44,9 @@ class Socket {
|
|||||||
return Array($domain, $type, $protocol);
|
return Array($domain, $type, $protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
public function __call($method, $arguments) {
|
public function __call($method, $arguments) {
|
||||||
if (function_exists('socket_' . $method)) {
|
if (function_exists('socket_' . $method)) {
|
||||||
array_unshift($arguments, $this->_socket);
|
array_unshift($arguments, $this->_socket);
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
backupGlobals="false"
|
backupGlobals="false"
|
||||||
backupStaticAttributes="false"
|
backupStaticAttributes="false"
|
||||||
syntaxCheck="false"
|
syntaxCheck="false"
|
||||||
|
stopOnError="false"
|
||||||
>
|
>
|
||||||
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
@ -14,4 +15,10 @@
|
|||||||
<directory>./tests/Ratchet/</directory>
|
<directory>./tests/Ratchet/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<blacklist>
|
||||||
|
<directory>./tests/</directory>
|
||||||
|
</blacklist>
|
||||||
|
</filter>
|
||||||
</phpunit>
|
</phpunit>
|
Loading…
Reference in New Issue
Block a user