[BCB] Namespace changes

Removed the `Component` namespace
Removed the `Resource` namespace
Renamed components:
`IOServerComponent` => `IoServer`
`WebSocketComponent` => `WsServer`
`SessionComponent` => `SessionProvider`
`WAMPServerComponent` => `WampServer`
`IpBlackListComponent` => `IpBlackList`
`FlashPolicyComponent` => `FlashPolicy`
This commit is contained in:
Chris Boden 2012-05-08 23:14:28 -04:00
parent 5785a1ca93
commit 4735218aa0
56 changed files with 179 additions and 388 deletions

View File

@ -1,5 +1,5 @@
<?php
namespace Ratchet\Resource;
namespace Ratchet;
abstract class AbstractConnectionDecorator implements ConnectionInterface {
/**

View File

@ -1,79 +0,0 @@
<?php
namespace Ratchet\Component\WAMP\Command\Action;
use Ratchet\Resource\Command\Action\SendMessage;
use Ratchet\Component\WAMP\WAMPServerComponent as WAMP;
/**
* Respond to a client RPC with an error
*/
class CallError extends SendMessage {
/**
* @var string
*/
protected $_id;
/**
* @var string
*/
protected $_uri;
/**
* @var string
*/
protected $_desc = '';
/**
* @var string
*/
protected $_details;
/**
* @param string The unique ID given by the client to respond to
* @param string The URI given by the client ot respond to
* @param string A developer-oriented description of the error
* @param string|null An optional human readable detail message to send back
* @return CallError
*/
public function setError($callId, $uri, $desc = '', $details = null) {
$this->_id = $callId;
$this->_uri = $uri;
$this->_desc = $desc;
$data = array(WAMP::MSG_CALL_ERROR, $callId, $uri, $desc);
if (null !== $details) {
$data[] = $details;
$this->_details = $details;
}
return $this->setMessage(json_encode($data));
}
/**
* @return string|null
*/
public function getId() {
return $this->_id;
}
/**
* @return string|null
*/
public function getUri() {
return $this->_uri;
}
/**
* @return string
*/
public function getDescription() {
return $this->_desc;
}
/**
* @return string|null
*/
public function getDetails() {
return $this->_details;
}
}

View File

@ -1,45 +0,0 @@
<?php
namespace Ratchet\Component\WAMP\Command\Action;
use Ratchet\Resource\Command\Action\SendMessage;
use Ratchet\Component\WAMP\WAMPServerComponent as WAMP;
/**
* Respond to a client RPC
*/
class CallResult extends SendMessage {
/**
* @var string
*/
protected $_id;
/**
* @var array
*/
protected $_data;
/**
* @param string The unique ID given by the client to respond to
* @param array An array of data to return to the client
* @return CallResult
*/
public function setResult($callId, array $data = array()) {
$this->_id = $callId;
$this->_data = $data;
return $this->setMessage(json_encode(array(WAMP::MSG_CALL_RESULT, $callId, $data)));
}
/**
* @return string|null
*/
public function getId() {
return $this->_id;
}
/**
* @return array|null
*/
public function getData() {
return $this->_data;
}
}

View File

@ -1,19 +0,0 @@
<?php
namespace Ratchet\Component\WAMP\Command\Action;
use Ratchet\Resource\Command\Action\SendMessage;
use Ratchet\Component\WAMP\WAMPServerComponent as WAMP;
/**
* This is an event in the context of a topicURI
* This event (message) is to be sent to all subscribers of $uri
*/
class Event extends SendMessage {
/**
* @param string The URI or CURIE to broadcast to
* @param mixed Data to send with the event. Anything that is json'able
* @return Event
*/
public function setEvent($uri, $msg) {
return $this->setMessage(json_encode(array(WAMP::MSG_EVENT, $uri, $msg)));
}
}

View File

@ -1,40 +0,0 @@
<?php
namespace Ratchet\Component\WAMP\Command\Action;
use Ratchet\Resource\Command\Action\SendMessage;
use Ratchet\Component\WAMP\WAMPServerComponent as WAMP;
/**
* Send a curie to uri mapping to the client
* Both sides will agree to send the curie, representing the uri,
* resulting in less data transfered
*/
class Prefix extends SendMessage {
protected $_curie;
protected $_uri;
/**
* @param string
* @param string
* @return Prefix
*/
public function setPrefix($curie, $uri) {
$this->_curie = $curie;
$this->_uri = $uri;
return $this->setMessage(json_encode(array(WAMP::MSG_PREFIX, $curie, $uri)));
}
/**
* @return string
*/
public function getCurie() {
return $this->_curie;
}
/**
* @return string
*/
public function getUri() {
return $this->_uri;
}
}

View File

@ -1,18 +0,0 @@
<?php
namespace Ratchet\Component\WAMP\Command\Action;
use Ratchet\Resource\Command\Action\SendMessage;
use Ratchet\Component\WAMP\WAMPServerComponent as WAMP;
/**
* Send Welcome message to each new connecting client
*/
class Welcome extends SendMessage {
/**
* @param string The unique identifier to mark the client
* @param string The server application name/version
* @return Welcome
*/
public function setWelcome($sessionId, $serverIdent = '') {
return $this->setMessage(json_encode(array(WAMP::MSG_WELCOME, $sessionId, 1, $serverIdent)));
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace Ratchet\Component;
use Ratchet\Resource\ConnectionInterface;
namespace Ratchet;
use Ratchet\ConnectionInterface;
/**
* This is the interface to build a Ratchet application with
@ -9,16 +9,14 @@ use Ratchet\Resource\ConnectionInterface;
interface ComponentInterface {
/**
* When a new connection is opened it will be passed to this method
* @param Ratchet\Resource\Connection The socket/connection that just connected to your application
* @return Ratchet\Resource\Command\CommandInterface|null
* @param Ratchet\Connection The socket/connection that just connected to your application
* @throws Exception
*/
function onOpen(ConnectionInterface $conn);
/**
* This is called before or after a socket is closed (depends on how it's closed). SendMessage to $conn will not result in an error if it has already been closed.
* @param Ratchet\Resource\Connection The socket/connection that is closing/closed
* @return Ratchet\Resource\Command\CommandInterface|null
* @param Ratchet\Connection The socket/connection that is closing/closed
* @throws Exception
*/
function onClose(ConnectionInterface $conn);
@ -26,9 +24,8 @@ interface ComponentInterface {
/**
* If there is an error with one of the sockets, or somewhere in the application where an Exception is thrown,
* the Exception is sent back down the stack, handled by the Server and bubbled back up the application through this method
* @param Ratchet\Resource\Connection
* @param Ratchet\Connection
* @param \Exception
* @return Ratchet\Resource\Command\CommandInterface|null
* @throws Exception
*/
function onError(ConnectionInterface $conn, \Exception $e);

View File

@ -1,5 +1,5 @@
<?php
namespace Ratchet\Resource;
namespace Ratchet;
const VERSION = 'Ratchet/0.1';

View File

@ -1,13 +1,12 @@
<?php
namespace Ratchet\Component;
use Ratchet\Resource\ConnectionInterface;
namespace Ratchet;
use Ratchet\ConnectionInterface;
interface MessageComponentInterface extends ComponentInterface {
/**
* Triggered when a client sends data through the socket
* @param Ratchet\Resource\ConnectionInterface The socket/connection that sent the message to your application
* @param Ratchet\ConnectionInterface The socket/connection that sent the message to your application
* @param string The message received
* @return Ratchet\Resource\Command\CommandInterface|null
* @throws Exception
*/
function onMessage(ConnectionInterface $from, $msg);

View File

@ -1,7 +1,7 @@
<?php
namespace Ratchet\Component\Server;
use Ratchet\Component\MessageComponentInterface;
use Ratchet\Resource\ConnectionInterface;
namespace Ratchet\Server;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
/**
* An app to go on a server stack to pass a policy file to a Flash socket
@ -13,7 +13,7 @@ use Ratchet\Resource\ConnectionInterface;
* @link http://learn.adobe.com/wiki/download/attachments/64389123/CrossDomain_PolicyFile_Specification.pdf?version=1
* @link view-source:http://www.adobe.com/xml/schemas/PolicyFileSocket.xsd
*/
class FlashPolicyComponent implements MessageComponentInterface {
class FlashPolicy implements MessageComponentInterface {
/**
* Contains the root policy node
@ -54,7 +54,7 @@ class FlashPolicyComponent implements MessageComponentInterface {
* Ranges can be used with individual ports when separated with a comma. A single wildcard (*) can
* be used to allow all ports.
* @param bool
* @return FlashPolicyComponent
* @return FlashPolicy
*/
public function addAllowedAccess($domain, $ports = '*', $secure = false) {
if (!$this->validateDomain($domain)) {
@ -77,7 +77,7 @@ class FlashPolicyComponent implements MessageComponentInterface {
* crossdomain.xml.
*
* @param string
* @return FlashPolicyComponent
* @return FlashPolicy
*/
public function setSiteControl($permittedCrossDomainPolicies = 'all') {
if (!$this->validateSiteControl($permittedCrossDomainPolicies)) {

View File

@ -1,6 +1,6 @@
<?php
namespace Ratchet\Component\Server;
use Ratchet\Resource\ConnectionInterface;
namespace Ratchet\Server;
use Ratchet\ConnectionInterface;
use React\Socket\ConnectionInterface as ReactConn;
/**
@ -9,7 +9,7 @@ use React\Socket\ConnectionInterface as ReactConn;
*/
class IoConnection implements ConnectionInterface {
/**
* @var Ratchet\Component\Server\IOServer
* @var Ratchet\Server\IOServer
*/
protected $server;
@ -18,7 +18,7 @@ class IoConnection implements ConnectionInterface {
*/
protected $conn;
public function __construct(ReactConn $conn, IOServerComponent $server) {
public function __construct(ReactConn $conn, IoServer $server) {
$this->conn = $conn;
$this->server = $server;
}

View File

@ -1,7 +1,7 @@
<?php
namespace Ratchet\Component\Server;
use Ratchet\Component\MessageComponentInterface;
use Ratchet\Resource\ConnectionInterface;
namespace Ratchet\Server;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
use React\EventLoop\LoopInterface;
use React\Socket\ServerInterface;
use React\EventLoop\Factory as LoopFactory;
@ -10,7 +10,7 @@ use React\Socket\Server as Reactor;
/**
* Creates an open-ended socket to listen on a port for incomming connections. Events are delegated through this to attached applications
*/
class IOServerComponent {
class IoServer {
/**
* @var React\EventLoop\LoopInterface
*/

View File

@ -1,16 +1,16 @@
<?php
namespace Ratchet\Component\Server;
use Ratchet\Component\MessageComponentInterface;
use Ratchet\Resource\ConnectionInterface;
namespace Ratchet\Server;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
class IpBlackListComponent implements MessageComponentInterface {
class IpBlackList implements MessageComponentInterface {
/**
* @var array
*/
protected $_blacklist = array();
/**
* @var Ratchet\Component\MessageComponentInterface
* @var Ratchet\MessageComponentInterface
*/
protected $_decorating;

View File

@ -1,5 +1,5 @@
<?php
namespace Ratchet\Component\Session\Serialize;
namespace Ratchet\Session\Serialize;
interface HandlerInterface {
/**

View File

@ -1,5 +1,5 @@
<?php
namespace Ratchet\Component\Session\Serialize;
namespace Ratchet\Session\Serialize;
class PhpBinaryHandler implements HandlerInterface {
/**

View File

@ -1,5 +1,5 @@
<?php
namespace Ratchet\Component\Session\Serialize;
namespace Ratchet\Session\Serialize;
class PhpHandler implements HandlerInterface {
/**

View File

@ -1,9 +1,9 @@
<?php
namespace Ratchet\Component\Session;
use Ratchet\Component\MessageComponentInterface;
use Ratchet\Resource\ConnectionInterface;
use Ratchet\Component\Session\Storage\VirtualSessionStorage;
use Ratchet\Component\Session\Serialize\HandlerInterface;
namespace Ratchet\Session;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
use Ratchet\Session\Storage\VirtualSessionStorage;
use Ratchet\Session\Serialize\HandlerInterface;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;
@ -13,9 +13,9 @@ use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;
* Your website must also use Symfony HttpFoundation Sessions to read your sites session data
* If your are not using at least PHP 5.4 you must include a SessionHandlerInterface stub (is included in Symfony HttpFoundation, loaded w/ composer)
*/
class SessionComponent implements MessageComponentInterface {
class SessionProvider implements MessageComponentInterface {
/**
* @var Ratchet\Component\MessageComponentInterface
* @var Ratchet\MessageComponentInterface
*/
protected $_app;
@ -32,15 +32,15 @@ class SessionComponent implements MessageComponentInterface {
protected $_null;
/**
* @var Ratchet\Component\Session\Serialize\HandlerInterface
* @var Ratchet\Session\Serialize\HandlerInterface
*/
protected $_serializer;
/**
* @param Ratchet\Component\MessageComponentInterface
* @param Ratchet\MessageComponentInterface
* @param SessionHandlerInterface
* @param array
* @param Ratchet\Component\Session\Serialize\HandlerInterface
* @param Ratchet\Session\Serialize\HandlerInterface
* @throws RuntimeException If unable to match serialization methods
*/
public function __construct(MessageComponentInterface $app, \SessionHandlerInterface $handler, array $options = array(), HandlerInterface $serializer = null) {

View File

@ -1,5 +1,5 @@
<?php
namespace Ratchet\Component\Session\Storage\Proxy;
namespace Ratchet\Session\Storage\Proxy;
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
class VirtualProxy extends SessionHandlerProxy {

View File

@ -1,19 +1,19 @@
<?php
namespace Ratchet\Component\Session\Storage;
namespace Ratchet\Session\Storage;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
use Ratchet\Component\Session\Storage\Proxy\VirtualProxy;
use Ratchet\Component\Session\Serialize\HandlerInterface;
use Ratchet\Session\Storage\Proxy\VirtualProxy;
use Ratchet\Session\Serialize\HandlerInterface;
class VirtualSessionStorage extends NativeSessionStorage {
/**
* @var Ratchet\Component\Session\Serialize\HandlerInterface
* @var Ratchet\Session\Serialize\HandlerInterface
*/
protected $_serializer;
/**
* @param SessionHandlerInterface
* @param string The ID of the session to retreive
* @param Ratchet\Component\Session\Serialize\HandlerInterface
* @param Ratchet\Session\Serialize\HandlerInterface
*/
public function __construct(\SessionHandlerInterface $handler, $sessionId, HandlerInterface $serializer) {
$this->setSaveHandler($handler);

View File

@ -1,5 +1,5 @@
<?php
namespace Ratchet\Component\WAMP;
namespace Ratchet\Wamp;
class Exception extends \Exception {
}

View File

@ -1,5 +1,5 @@
<?php
namespace Ratchet\Component\WAMP;
namespace Ratchet\Wamp;
class JSONException extends Exception {
public function __construct() {

View File

@ -1,8 +1,8 @@
<?php
namespace Ratchet\Component\WAMP;
use Ratchet\Resource\ConnectionInterface;
use Ratchet\Resource\AbstractConnectionDecorator;
use Ratchet\Component\WAMP\WAMPServerComponent as WAMP;
namespace Ratchet\Wamp;
use Ratchet\ConnectionInterface;
use Ratchet\AbstractConnectionDecorator;
use Ratchet\Wamp\WampServer as WAMP;
/**
* @property stdClass $WAMP
@ -15,7 +15,7 @@ class WampConnection extends AbstractConnectionDecorator {
$this->WAMP->sessionId = uniqid();
$this->WAMP->prefixes = array();
$this->send(json_encode(array(WAMP::MSG_WELCOME, $this->WAMP->sessionId, 1, \Ratchet\Resource\VERSION)));
$this->send(json_encode(array(WAMP::MSG_WELCOME, $this->WAMP->sessionId, 1, \Ratchet\VERSION)));
}
/**

View File

@ -1,7 +1,7 @@
<?php
namespace Ratchet\Component\WAMP;
use Ratchet\Component\WebSocket\WebSocketComponentInterface;
use Ratchet\Resource\ConnectionInterface;
namespace Ratchet\Wamp;
use Ratchet\WebSocket\WsServerInterface;
use Ratchet\ConnectionInterface;
/**
* WebSocket Application Messaging Protocol
@ -23,7 +23,7 @@ use Ratchet\Resource\ConnectionInterface;
* | EVENT | 8 | Server-to-Client |
* +--------------+----+------------------+
*/
class WAMPServerComponent implements WebSocketComponentInterface {
class WampServer implements WsServerInterface {
const MSG_WELCOME = 0;
const MSG_PREFIX = 1;
const MSG_CALL = 2;
@ -35,7 +35,7 @@ class WAMPServerComponent implements WebSocketComponentInterface {
const MSG_EVENT = 8;
/**
* @var WAMPServerComponentInterface
* @var WampServerInterface
*/
protected $_decorating;
@ -45,9 +45,9 @@ class WAMPServerComponent implements WebSocketComponentInterface {
protected $connections;
/**
* @param WAMPServerComponentInterface An class to propagate calls through
* @param WampServerInterface An class to propagate calls through
*/
public function __construct(WAMPServerComponentInterface $server_component) {
public function __construct(WampServerInterface $server_component) {
$this->_decorating = $server_component;
$this->connections = new \SplObjectStorage;
}

View File

@ -1,46 +1,42 @@
<?php
namespace Ratchet\Component\WAMP;
use Ratchet\Component\ComponentInterface;
use Ratchet\Resource\ConnectionInterface;
namespace Ratchet\Wamp;
use Ratchet\ComponentInterface;
use Ratchet\ConnectionInterface;
/**
* A (not literal) extension of Ratchet\Component\ComponentInterface
* A (not literal) extension of Ratchet\ConnectionInterface
* onMessage is replaced by various types of messages for this protocol (pub/sub or rpc)
* @todo Thought: URI as class. Class has short and long version stored (if as prefix)
*/
interface WAMPServerComponentInterface extends ComponentInterface {
interface WampServerInterface extends ComponentInterface {
/**
* An RPC call has been received
* @param Ratchet\Resource\Connection
* @param Ratchet\Connection
* @param string
* @param ...
* @param array Call parameters received from the client
* @return Ratchet\Resource\Command\CommandInterface|null
*/
function onCall(ConnectionInterface $conn, $id, $procURI, array $params);
/**
* A request to subscribe to a URI has been made
* @param Ratchet\Resource\Connection
* @param Ratchet\Connection
* @param ...
* @return Ratchet\Resource\Command\CommandInterface|null
*/
function onSubscribe(ConnectionInterface $conn, $uri);
/**
* A request to unsubscribe from a URI has been made
* @param Ratchet\Resource\Connection
* @param Ratchet\Connection
* @param ...
* @return Ratchet\Resource\Command\CommandInterface|null
*/
function onUnSubscribe(ConnectionInterface $conn, $uri);
/**
* A client is attempting to publish content to a subscribed connections on a URI
* @param Ratchet\Resource\Connection
* @param Ratchet\Connection
* @param ...
* @param string
* @return Ratchet\Resource\Command\CommandInterface|null
*/
function onPublish(ConnectionInterface $conn, $uri, $event);
}

View File

@ -1,5 +1,5 @@
<?php
namespace Ratchet\Component\WebSocket\Guzzle\Http\Message;
namespace Ratchet\WebSocket\Guzzle\Http\Message;
use Guzzle\Http\Message\RequestFactory as GuzzleRequestFactory;
use Guzzle\Http\EntityBody;

View File

@ -1,5 +1,5 @@
<?php
namespace Ratchet\Component\WebSocket\Version;
namespace Ratchet\WebSocket\Version;
interface FrameInterface {
/**

View File

@ -1,5 +1,5 @@
<?php
namespace Ratchet\Component\WebSocket\Version;
namespace Ratchet\WebSocket\Version;
use Guzzle\Http\Message\RequestInterface;
use Guzzle\Http\Message\Response;

View File

@ -1,6 +1,6 @@
<?php
namespace Ratchet\Component\WebSocket\Version\Hixie76;
use Ratchet\Component\WebSocket\Version\FrameInterface;
namespace Ratchet\WebSocket\Version\Hixie76;
use Ratchet\WebSocket\Version\FrameInterface;
/**
* This does not entirely follow the protocol to spec, but (mostly) works

View File

@ -1,11 +1,11 @@
<?php
namespace Ratchet\Component\WebSocket\Version\Hixie76;
use Ratchet\Component\WebSocket\Version\MessageInterface;
use Ratchet\Component\WebSocket\Version\FrameInterface;
namespace Ratchet\WebSocket\Version\Hixie76;
use Ratchet\WebSocket\Version\MessageInterface;
use Ratchet\WebSocket\Version\FrameInterface;
class Message implements MessageInterface {
/**
* @var Ratchet\Component\WebSocket\Version\FrameInterface
* @var Ratchet\WebSocket\Version\FrameInterface
*/
protected $_frame = null;

View File

@ -1,5 +1,5 @@
<?php
namespace Ratchet\Component\WebSocket\Version;
namespace Ratchet\WebSocket\Version;
use Guzzle\Http\Message\RequestInterface;
class HyBi10 extends RFC6455 {

View File

@ -1,5 +1,5 @@
<?php
namespace Ratchet\Component\WebSocket\Version;
namespace Ratchet\WebSocket\Version;
/**
* @todo Consider making parent interface/composite for Message/Frame with (isCoalesced, getOpcdoe, getPayloadLength, getPayload)

View File

@ -1,6 +1,6 @@
<?php
namespace Ratchet\Component\WebSocket\Version;
use Ratchet\Component\WebSocket\Version\RFC6455\HandshakeVerifier;
namespace Ratchet\WebSocket\Version;
use Ratchet\WebSocket\Version\RFC6455\HandshakeVerifier;
use Guzzle\Http\Message\RequestInterface;
use Guzzle\Http\Message\Response;

View File

@ -1,6 +1,6 @@
<?php
namespace Ratchet\Component\WebSocket\Version\RFC6455;
use Ratchet\Component\WebSocket\Version\FrameInterface;
namespace Ratchet\WebSocket\Version\RFC6455;
use Ratchet\WebSocket\Version\FrameInterface;
class Frame implements FrameInterface {
/**

View File

@ -1,5 +1,5 @@
<?php
namespace Ratchet\Component\WebSocket\Version\RFC6455;
namespace Ratchet\WebSocket\Version\RFC6455;
use Guzzle\Http\Message\RequestInterface;
/**

View File

@ -1,7 +1,7 @@
<?php
namespace Ratchet\Component\WebSocket\Version\RFC6455;
use Ratchet\Component\WebSocket\Version\MessageInterface;
use Ratchet\Component\WebSocket\Version\FrameInterface;
namespace Ratchet\WebSocket\Version\RFC6455;
use Ratchet\WebSocket\Version\MessageInterface;
use Ratchet\WebSocket\Version\FrameInterface;
class Message implements MessageInterface {
/**

View File

@ -1,5 +1,5 @@
<?php
namespace Ratchet\Component\WebSocket\Version;
namespace Ratchet\WebSocket\Version;
use Guzzle\Http\Message\RequestInterface;
/**

View File

@ -1,6 +1,6 @@
<?php
namespace Ratchet\Component\WebSocket;
use Ratchet\Resource\AbstractConnectionDecorator;
namespace Ratchet\WebSocket;
use Ratchet\AbstractConnectionDecorator;
/**
* @property stdClass $WebSocket

View File

@ -1,9 +1,9 @@
<?php
namespace Ratchet\Component\WebSocket;
use Ratchet\Component\MessageComponentInterface;
use Ratchet\Resource\ConnectionInterface;
namespace Ratchet\WebSocket;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
use Guzzle\Http\Message\RequestInterface;
use Ratchet\Component\WebSocket\Guzzle\Http\Message\RequestFactory;
use Ratchet\WebSocket\Guzzle\Http\Message\RequestFactory;
/**
* The adapter to handle WebSocket requests/responses
@ -12,10 +12,10 @@ use Ratchet\Component\WebSocket\Guzzle\Http\Message\RequestFactory;
* @link http://ca.php.net/manual/en/ref.http.php
* @link http://dev.w3.org/html5/websockets/
*/
class WebSocketComponent implements MessageComponentInterface {
class WsServer implements MessageComponentInterface {
/**
* Decorated component
* @var Ratchet\Component\MessageComponentInterface
* @var Ratchet\MessageComponentInterface
*/
protected $_decorating;
@ -90,7 +90,7 @@ class WebSocketComponent implements MessageComponentInterface {
if (count($agreed_protocols) > 0) {
$response->setHeader('Sec-WebSocket-Protocol', implode(',', $agreed_protocols));
}
$response->setHeader('X-Powered-By', \Ratchet\Resource\VERSION);
$response->setHeader('X-Powered-By', \Ratchet\VERSION);
$header = (string)$response;
$from->send($header);

View File

@ -1,8 +1,8 @@
<?php
namespace Ratchet\Component\WebSocket;
use Ratchet\Component\MessageComponentInterface;
namespace Ratchet\WebSocket;
use Ratchet\MessageComponentInterface;
interface WebSocketComponentInterface extends MessageComponentInterface {
interface WsServerInterface extends MessageComponentInterface {
/**
* Currently instead of this, I'm setting header in the Connection object passed around...not sure which I like more
* @param string

View File

@ -1,10 +1,10 @@
<?php
namespace Ratchet\Tests\Resource;
namespace Ratchet\Tests;
use Ratchet\Tests\Mock\ConnectionDecorator;
use Ratchet\Tests\Mock\Connection;
/**
* @covers Ratchet\Resource\AbstractConnectionDecorator
* @covers Ratchet\AbstractConnectionDecorator
*/
class AbstractConnectionDecoratorTest extends \PHPUnit_Framework_TestCase {
protected $mock;
@ -84,7 +84,7 @@ class AbstractConnectionDecoratorTest extends \PHPUnit_Framework_TestCase {
}
public function testGetConnection() {
$class = new \ReflectionClass('\\Ratchet\\Resource\\AbstractConnectionDecorator');
$class = new \ReflectionClass('\\Ratchet\\AbstractConnectionDecorator');
$method = $class->getMethod('getConnection');
$method->setAccessible(true);
@ -94,7 +94,7 @@ class AbstractConnectionDecoratorTest extends \PHPUnit_Framework_TestCase {
}
public function testGetConnectionLevel2() {
$class = new \ReflectionClass('\\Ratchet\\Resource\\AbstractConnectionDecorator');
$class = new \ReflectionClass('\\Ratchet\\AbstractConnectionDecorator');
$method = $class->getMethod('getConnection');
$method->setAccessible(true);

View File

@ -1,8 +1,8 @@
<?php
namespace Ratchet\Tests\Mock;
use Ratchet\Component\MessageComponentInterface;
use Ratchet\MessageComponentInterface;
use Ratchet\Tests\Mock\Socket as MockSocket;
use Ratchet\Resource\ConnectionInterface;
use Ratchet\ConnectionInterface;
/**
* @todo Rename to MessageComponent

View File

@ -1,6 +1,6 @@
<?php
namespace Ratchet\Tests\Mock;
use Ratchet\Resource\ConnectionInterface;
use Ratchet\ConnectionInterface;
class Connection implements ConnectionInterface {
public $last = array(

View File

@ -1,6 +1,6 @@
<?php
namespace Ratchet\Tests\Mock;
use Ratchet\Resource\AbstractConnectionDecorator;
use Ratchet\AbstractConnectionDecorator;
class ConnectionDecorator extends AbstractConnectionDecorator {
public $last = array(

View File

@ -1,9 +1,9 @@
<?php
namespace Ratchet\Tests\Mock;
use Ratchet\Component\WAMP\WAMPServerComponentInterface;
use Ratchet\Resource\ConnectionInterface;
use Ratchet\Wamp\WampServerInterface;
use Ratchet\ConnectionInterface;
class WAMPComponent implements WAMPServerComponentInterface {
class WAMPComponent implements WampServerInterface {
public $last = array();
public function onCall(ConnectionInterface $conn, $id, $procURI, array $params) {

View File

@ -1,16 +1,16 @@
<?php
namespace Ratchet\Tests\Application\Server;
use Ratchet\Component\Server\FlashPolicyComponent;
use Ratchet\Server\FlashPolicy;
/**
* @covers Ratchet\Component\Server\FlashPolicyComponent
* @covers Ratchet\Server\FlashPolicy
*/
class FlashPolicyComponentTest extends \PHPUnit_Framework_TestCase {
class FlashPolicyTest extends \PHPUnit_Framework_TestCase {
protected $_policy;
public function setUp() {
$this->_policy = new FlashPolicyComponent();
$this->_policy = new FlashPolicy();
}
public function testPolicyRender() {

View File

@ -1,19 +1,19 @@
<?php
namespace Ratchet\Tests\Component\Server;
use Ratchet\Component\Server\IpBlackListComponent;
namespace Ratchet\Tests\Server;
use Ratchet\Server\IpBlackList;
use Ratchet\Tests\Mock\Connection;
use Ratchet\Tests\Mock\Component as MockComponent;
/**
* @covers Ratchet\Component\Server\IpBlackListComponent
* @covers Ratchet\Server\IpBlackList
*/
class IpBlackListComponentTest extends \PHPUnit_Framework_TestCase {
class IpBlackListTest extends \PHPUnit_Framework_TestCase {
protected $_comp;
protected $_mock;
public function setUp() {
$this->_mock = new MockComponent;
$this->_comp = new IpBlackListComponent($this->_mock);
$this->_comp = new IpBlackList($this->_mock);
}
public function testBlockAndCloseOnOpen() {
@ -86,6 +86,6 @@ class IpBlackListComponentTest extends \PHPUnit_Framework_TestCase {
}
public function testUnblockingSilentlyFails() {
$this->assertInstanceOf('\\Ratchet\\Component\\Server\\IpBlackListComponent', $this->_comp->unblockAddress('localhost'));
$this->assertInstanceOf('\\Ratchet\\Server\\IpBlackList', $this->_comp->unblockAddress('localhost'));
}
}

View File

@ -1,9 +1,9 @@
<?php
namespace Ratchet\Tests\Component\Session\Serialize;
use Ratchet\Component\Session\Serialize\PhpHandler;
namespace Ratchet\Tests\Session\Serialize;
use Ratchet\Session\Serialize\PhpHandler;
/**
* @covers Ratchet\Component\Session\Serialize\PhpHandler
* @covers Ratchet\Session\Serialize\PhpHandler
*/
class PhpHandlerTest extends \PHPUnit_Framework_TestCase {
protected $_handler;

View File

@ -1,6 +1,6 @@
<?php
namespace Ratchet\Tests\Component\Session;
use Ratchet\Component\Session\SessionComponent;
namespace Ratchet\Tests\Session;
use Ratchet\Session\SessionProvider;
use Ratchet\Tests\Mock\Component as MockComponent;
use Ratchet\Tests\Mock\MemorySessionHandler;
use Ratchet\Tests\Mock\Connection;
@ -9,11 +9,11 @@ use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;
use Guzzle\Http\Message\Request;
/**
* @covers Ratchet\Component\Session\SessionComponent
* @covers Ratchet\Component\Session\Storage\VirtualSessionStorage
* @covers Ratchet\Component\Session\Storage\Proxy\VirtualProxy
* @covers Ratchet\Session\SessionProvider
* @covers Ratchet\Session\Storage\VirtualSessionStorage
* @covers Ratchet\Session\Storage\Proxy\VirtualProxy
*/
class SessionComponentTest extends \PHPUnit_Framework_TestCase {
class SessionProviderTest extends \PHPUnit_Framework_TestCase {
public function setUp() {
if (!class_exists('Symfony\\Component\\HttpFoundation\\Session\\Session')) {
return $this->markTestSkipped('Dependency of Symfony HttpFoundation failed');
@ -31,11 +31,11 @@ class SessionComponentTest extends \PHPUnit_Framework_TestCase {
* @dataProvider classCaseProvider
*/
public function testToClassCase($in, $out) {
$ref = new \ReflectionClass('\\Ratchet\\Component\\Session\\SessionComponent');
$ref = new \ReflectionClass('\\Ratchet\\Session\\SessionProvider');
$method = $ref->getMethod('toClassCase');
$method->setAccessible(true);
$component = new SessionComponent(new MockComponent, new MemorySessionHandler);
$component = new SessionProvider(new MockComponent, new MemorySessionHandler);
$this->assertEquals($out, $method->invokeArgs($component, array($in)));
}
@ -56,7 +56,7 @@ class SessionComponentTest extends \PHPUnit_Framework_TestCase {
$pdo->exec(vsprintf("CREATE TABLE %s (%s VARCHAR(255) PRIMARY KEY, %s TEXT, %s INTEGER)", $dbOptions));
$pdo->prepare(vsprintf("INSERT INTO %s (%s, %s, %s) VALUES (?, ?, ?)", $dbOptions))->execute(array($sessionId, base64_encode('_sf2_attributes|a:2:{s:5:"hello";s:5:"world";s:4:"last";i:1332872102;}_sf2_flashes|a:0:{}'), time()));
$component = new SessionComponent(new MockComponent, new PdoSessionHandler($pdo, $dbOptions), array('auto_start' => 1));
$component = new SessionProvider(new MockComponent, new PdoSessionHandler($pdo, $dbOptions), array('auto_start' => 1));
$connection = new Connection();
$headers = $this->getMock('Guzzle\\Http\\Message\\Request', array('getCookie'), array('POST', '/', array()));
@ -83,7 +83,7 @@ class SessionComponentTest extends \PHPUnit_Framework_TestCase {
}
$mock = new MockComponent;
$comp = new SessionComponent($mock, new NullSessionHandler);
$comp = new SessionProvider($mock, new NullSessionHandler);
$comp->onOpen($conns[1]);
$comp->onOpen($conns[3]);

View File

@ -1,10 +1,10 @@
<?php
namespace Ratchet\Tests\Component\WAMP;
use Ratchet\Component\WAMP\WampConnection;
namespace Ratchet\Tests\Wamp;
use Ratchet\Wamp\WampConnection;
use Ratchet\Tests\Mock\Connection;
/**
* @covers Ratchet\Component\WAMP\WampConnection
* @covers Ratchet\Wamp\WampConnection
*/
class WampConnectionTest extends \PHPUnit_Framework_TestCase {
public function testCallResult() {

View File

@ -1,23 +1,23 @@
<?php
namespace Ratchet\Tests\Component\WAMP;
use Ratchet\Component\WAMP\WAMPServerComponent;
use Ratchet\Component\WAMP\WampConnection;
namespace Ratchet\Tests\Wamp;
use Ratchet\Wamp\WampServer;
use Ratchet\Wamp\WampConnection;
use Ratchet\Tests\Mock\Connection;
use Ratchet\Tests\Mock\WAMPComponent as TestComponent;
use Ratchet\Tests\Mock\WampComponent as TestComponent;
/**
* @covers Ratchet\Component\WAMP\WAMPServerComponent
* @covers Ratchet\Component\WAMP\WAMPServerComponentInterface
* @covers Ratchet\Component\WAMP\WampConnection
* @covers Ratchet\Wamp\WampServer
* @covers Ratchet\Wamp\WampServerInterface
* @covers Ratchet\Wamp\WampConnection
*/
class WAMPServerComponentTest extends \PHPUnit_Framework_TestCase {
class WampServerTest extends \PHPUnit_Framework_TestCase {
protected $_comp;
protected $_app;
public function setUp() {
$this->_app = new TestComponent;
$this->_comp = new WAMPServerComponent($this->_app);
$this->_comp = new WampServer($this->_app);
}
protected function newConn() {
@ -38,7 +38,7 @@ class WAMPServerComponentTest extends \PHPUnit_Framework_TestCase {
* @dataProvider invalidMessageProvider
*/
public function testInvalidMessages($type) {
$this->setExpectedException('\\Ratchet\\Component\\WAMP\\Exception');
$this->setExpectedException('\\Ratchet\\WAMP\\Exception');
$conn = $this->newConn();
$this->_comp->onOpen($conn);
@ -155,7 +155,7 @@ class WAMPServerComponentTest extends \PHPUnit_Framework_TestCase {
$this->_comp->onOpen($conn);
$this->_comp->onClose($conn);
$class = new \ReflectionClass('\\Ratchet\\Component\\WAMP\\WampConnection');
$class = new \ReflectionClass('\\Ratchet\\WAMP\\WampConnection');
$method = $class->getMethod('getConnection');
$method->setAccessible(true);
@ -172,7 +172,7 @@ class WAMPServerComponentTest extends \PHPUnit_Framework_TestCase {
$this->_comp->onOpen($conn);
$this->_comp->onError($conn, $e);
$class = new \ReflectionClass('\\Ratchet\\Component\\WAMP\\WampConnection');
$class = new \ReflectionClass('\\Ratchet\\WAMP\\WampConnection');
$method = $class->getMethod('getConnection');
$method->setAccessible(true);
@ -196,7 +196,7 @@ class WAMPServerComponentTest extends \PHPUnit_Framework_TestCase {
}
public function testMessageMustBeJson() {
$this->setExpectedException('\\Ratchet\\Component\\WAMP\\JsonException');
$this->setExpectedException('\\Ratchet\\WAMP\\JsonException');
$conn = new Connection;

View File

@ -1,9 +1,9 @@
<?php
namespace Ratchet\Tests\Component\WebSocket\Guzzle\Http\Message;
use Ratchet\Component\WebSocket\Guzzle\Http\Message\RequestFactory;
namespace Ratchet\Tests\WebSocket\Guzzle\Http\Message;
use Ratchet\WebSocket\Guzzle\Http\Message\RequestFactory;
/**
* @covers Ratchet\Component\WebSocket\Guzzle\Http\Message\RequestFactory
* @covers Ratchet\WebSocket\Guzzle\Http\Message\RequestFactory
*/
class RequestFactoryTest extends \PHPUnit_Framework_TestCase {
protected $factory;

View File

@ -1,9 +1,9 @@
<?php
namespace Ratchet\Tests\Component\WebSocket\Version;
use Ratchet\Component\WebSocket\Version\Hixie76;
namespace Ratchet\Tests\WebSocket\Version;
use Ratchet\WebSocket\Version\Hixie76;
/**
* @covers Ratchet\Component\WebSocket\Version\Hixie76
* @covers Ratchet\WebSocket\Version\Hixie76
*/
class Hixie76Test extends \PHPUnit_Framework_TestCase {
protected $_version;
@ -13,7 +13,7 @@ class Hixie76Test extends \PHPUnit_Framework_TestCase {
}
public function testClassImplementsVersionInterface() {
$constraint = $this->isInstanceOf('\\Ratchet\\Component\\WebSocket\\Version\\VersionInterface');
$constraint = $this->isInstanceOf('\\Ratchet\\WebSocket\\Version\\VersionInterface');
$this->assertThat($this->_version, $constraint);
}

View File

@ -1,10 +1,10 @@
<?php
namespace Ratchet\Tests\Component\WebSocket\Version;
use Ratchet\Component\WebSocket\Version\HyBi10;
use Ratchet\Component\WebSocket\Version\RFC6455\Frame;
namespace Ratchet\Tests\WebSocket\Version;
use Ratchet\WebSocket\Version\HyBi10;
use Ratchet\WebSocket\Version\RFC6455\Frame;
/**
* @covers Ratchet\Component\WebSocket\Version\Hybi10
* @covers Ratchet\WebSocket\Version\Hybi10
*/
class HyBi10Test extends \PHPUnit_Framework_TestCase {
protected $_version;
@ -17,7 +17,7 @@ class HyBi10Test extends \PHPUnit_Framework_TestCase {
* Is this useful?
*/
public function testClassImplementsVersionInterface() {
$constraint = $this->isInstanceOf('\\Ratchet\\Component\\WebSocket\\Version\\VersionInterface');
$constraint = $this->isInstanceOf('\\Ratchet\\WebSocket\\Version\\VersionInterface');
$this->assertThat($this->_version, $constraint);
}

View File

@ -1,9 +1,9 @@
<?php
namespace Ratchet\Tests\Component\WebSocket\Version\RFC6455;
use Ratchet\Component\WebSocket\Version\RFC6455\Frame;
namespace Ratchet\Tests\WebSocket\Version\RFC6455;
use Ratchet\WebSocket\Version\RFC6455\Frame;
/**
* @covers Ratchet\Component\WebSocket\Version\RFC6455\Frame
* @covers Ratchet\WebSocket\Version\RFC6455\Frame
* @todo getMaskingKey, getPayloadStartingByte don't have tests yet
* @todo Could use some clean up in general, I had to rush to fix a bug for a deadline, sorry.
*/

View File

@ -1,13 +1,13 @@
<?php
namespace Ratchet\Tests\Component\WebSocket\Version\RFC6455;
use Ratchet\Component\WebSocket\Version\RFC6455\HandshakeVerifier;
namespace Ratchet\Tests\WebSocket\Version\RFC6455;
use Ratchet\WebSocket\Version\RFC6455\HandshakeVerifier;
/**
* @covers Ratchet\Component\WebSocket\Version\RFC6455\HandshakeVerifier
* @covers Ratchet\WebSocket\Version\RFC6455\HandshakeVerifier
*/
class HandshakeVerifierTest extends \PHPUnit_Framework_TestCase {
/**
* @var Ratchet\Component\WebSocket\Version\RFC6455\HandshakeVerifier
* @var Ratchet\WebSocket\Version\RFC6455\HandshakeVerifier
*/
protected $_v;

View File

@ -1,11 +1,11 @@
<?php
namespace Ratchet\Tests\Component\WebSocket\Version;
use Ratchet\Component\WebSocket\Version\RFC6455;
use Ratchet\Component\WebSocket\Version\RFC6455\Frame;
namespace Ratchet\Tests\WebSocket\Version;
use Ratchet\WebSocket\Version\RFC6455;
use Ratchet\WebSocket\Version\RFC6455\Frame;
use Guzzle\Http\Message\RequestFactory;
/**
* @covers Ratchet\Component\WebSocket\Version\RFC6455
* @covers Ratchet\WebSocket\Version\RFC6455
*/
class RFC6455Test extends \PHPUnit_Framework_TestCase {
protected $_version;
@ -18,7 +18,7 @@ class RFC6455Test extends \PHPUnit_Framework_TestCase {
* Is this useful?
*/
public function testClassImplementsVersionInterface() {
$constraint = $this->isInstanceOf('\\Ratchet\\Component\\WebSocket\\Version\\VersionInterface');
$constraint = $this->isInstanceOf('\\Ratchet\\WebSocket\\Version\\VersionInterface');
$this->assertThat($this->_version, $constraint);
}
@ -127,10 +127,10 @@ class RFC6455Test extends \PHPUnit_Framework_TestCase {
}
public function testNewMessage() {
$this->assertInstanceOf('\\Ratchet\\Component\\WebSocket\\Version\\RFC6455\\Message', $this->_version->newMessage());
$this->assertInstanceOf('\\Ratchet\\WebSocket\\Version\\RFC6455\\Message', $this->_version->newMessage());
}
public function testNewFrame() {
$this->assertInstanceOf('\\Ratchet\\Component\\WebSocket\\Version\\RFC6455\\Frame', $this->_version->newFrame());
$this->assertInstanceOf('\\Ratchet\\WebSocket\\Version\\RFC6455\\Frame', $this->_version->newFrame());
}
}