Namespaces
Fixed all the namespaces to match new folder structure
This commit is contained in:
parent
5386b4c066
commit
47b7110dc1
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace Ratchet\Protocol;
|
||||
use Ratchet\SocketObserver;
|
||||
namespace Ratchet\Application;
|
||||
use Ratchet\ObserverInterface;
|
||||
|
||||
interface ProtocolInterface extends SocketObserver {
|
||||
interface ProtocolInterface extends ObserverInterface {
|
||||
/**
|
||||
* @param Ratchet\SocketObserver Application to wrap in protocol
|
||||
* @param Ratchet\ObserverInterface Application to wrap in protocol
|
||||
*/
|
||||
function __construct(SocketObserver $application);
|
||||
// function __construct(ObserverInterface $application);
|
||||
|
||||
/**
|
||||
* @return array
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
namespace Ratchet;
|
||||
use Ratchet\Server\Aggregator;
|
||||
use Ratchet\Protocol\ProtocolInterface;
|
||||
use Ratchet\Command\CommandInterface;
|
||||
namespace Ratchet\Application\Server;
|
||||
use Ratchet\ObserverInterface;
|
||||
use Ratchet\SocketInterface;
|
||||
use Ratchet\Resource\Command\CommandInterface;
|
||||
|
||||
/**
|
||||
* Creates an open-ended socket to listen on a port for incomming connections. Events are delegated through this to attached applications
|
||||
@ -10,10 +10,10 @@ use Ratchet\Command\CommandInterface;
|
||||
* @todo Currently passing Socket object down the decorated chain - should be sending reference to it instead; Receivers do not interact with the Socket directly, they do so through the Command pattern
|
||||
* @todo With all these options for the server I should probably use a DIC
|
||||
*/
|
||||
class Server implements SocketObserver, \IteratorAggregate {
|
||||
class App implements ObserverInterface {
|
||||
/**
|
||||
* The master socket, receives all connections
|
||||
* @type Socket
|
||||
* @var Socket
|
||||
*/
|
||||
protected $_master = null;
|
||||
|
||||
@ -28,41 +28,35 @@ class Server implements SocketObserver, \IteratorAggregate {
|
||||
protected $_connections;
|
||||
|
||||
/**
|
||||
* @var SocketObserver
|
||||
* @var Ratchet\ObserverInterface
|
||||
* Maybe temporary?
|
||||
*/
|
||||
protected $_app;
|
||||
|
||||
/**
|
||||
* @param Ratchet\Socket
|
||||
* @param SocketObserver
|
||||
* @param Ratchet\ObserverInterface
|
||||
*/
|
||||
public function __construct(SocketInterface $host, SocketObserver $application) {
|
||||
$this->_master = $host;
|
||||
$socket = $host->getResource();
|
||||
$this->_resources[] = $socket;
|
||||
|
||||
$this->_connections = new \ArrayIterator(array());
|
||||
|
||||
$this->_app = $application;
|
||||
public function __construct(ObserverInterface $application = null) {
|
||||
if (null === $application) {
|
||||
throw new \UnexpectedValueException("Server requires an application to run off of");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayIterator of SocketInterfaces
|
||||
* @todo This interface was originally in place as Server was passed up/down chain, but isn't anymore, consider removing
|
||||
*/
|
||||
public function getIterator() {
|
||||
return $this->_connections;
|
||||
$this->_app = $application;
|
||||
$this->_connections = new \ArrayIterator(array());
|
||||
}
|
||||
|
||||
/*
|
||||
* @param Ratchet\SocketInterface
|
||||
* @param mixed The address to listen for incoming connections on. "0.0.0.0" to listen from anywhere
|
||||
* @param int The port to listen to connections on
|
||||
* @throws Exception
|
||||
* @throws Ratchet\Exception
|
||||
* @todo Validate address. Use socket_get_option, if AF_INET must be IP, if AF_UNIX must be path
|
||||
* @todo Consider making the 4kb listener changable
|
||||
*/
|
||||
public function run($address = '127.0.0.1', $port = 1025) {
|
||||
public function run(SocketInterface $host, $address = '127.0.0.1', $port = 1025) {
|
||||
$this->_master = $host;
|
||||
$this->_resources[] = $host->getResource();
|
||||
|
||||
$recv_bytes = 1024;
|
||||
|
||||
set_time_limit(0);
|
||||
|
@ -1,13 +1,14 @@
|
||||
<?php
|
||||
namespace Ratchet\Protocol;
|
||||
use Ratchet\Protocol\WebSocket\Client;
|
||||
use Ratchet\Protocol\WebSocket\VersionInterface;
|
||||
namespace Ratchet\Application\WebSocket;
|
||||
use Ratchet\Application\WebSocket\Client;
|
||||
use Ratchet\Application\WebSocket\VersionInterface;
|
||||
use Ratchet\SocketInterface;
|
||||
use Ratchet\SocketObserver;
|
||||
use Ratchet\Command\Factory;
|
||||
use Ratchet\Command\CommandInterface;
|
||||
use Ratchet\Command\Action\SendMessage;
|
||||
use Ratchet\Protocol\WebSocket\Util\HTTP;
|
||||
use Ratchet\ObserverInterface;
|
||||
use Ratchet\Resource\Command\Factory;
|
||||
use Ratchet\Resource\Command\CommandInterface;
|
||||
use Ratchet\Resource\Command\Action\SendMessage;
|
||||
use Ratchet\Application\WebSocket\Util\HTTP;
|
||||
use Ratchet\Application\ProtocolInterface;
|
||||
|
||||
/**
|
||||
* The adapter to handle WebSocket requests/responses
|
||||
@ -16,10 +17,10 @@ use Ratchet\Protocol\WebSocket\Util\HTTP;
|
||||
* @todo Make sure this works both ways (client/server) as stack needs to exist on client for framing
|
||||
* @todo Learn about closing the socket. A message has to be sent prior to closing - does the message get sent onClose event or CloseConnection command?
|
||||
* @todo Consider cheating the application...don't call _app::onOpen until handshake is complete - only issue is sending headers/cookies
|
||||
* @todo Consider chaning this class to a State Pattern. If a SocketObserver is passed in __construct, do what is there now. If it's an AppInterface change behaviour of socket interaction (onOpen, handshake, etc)
|
||||
* @todo Change namespace to Ratchet\Protocol\WebSocket\Adapter
|
||||
* @todo Consider chaning this class to a State Pattern. If a ObserverInterface is passed in __construct, do what is there now. If it's an AppInterface change behaviour of socket interaction (onOpen, handshake, etc)
|
||||
* @todo Change namespace to Ratchet\Application\WebSocket\Adapter
|
||||
*/
|
||||
class WebSocket implements ProtocolInterface {
|
||||
class App implements ProtocolInterface {
|
||||
/**
|
||||
* Lookup for connected clients
|
||||
* @var SplObjectStorage
|
||||
@ -28,12 +29,12 @@ class WebSocket implements ProtocolInterface {
|
||||
|
||||
/**
|
||||
* Decorated application
|
||||
* @var Ratchet\SocketObserver
|
||||
* @var Ratchet\ObserverInterface
|
||||
*/
|
||||
protected $_app;
|
||||
|
||||
/**
|
||||
* @var Ratchet\Command\Factory
|
||||
* @var Ratchet\Resource\Command\Factory
|
||||
*/
|
||||
protected $_factory;
|
||||
|
||||
@ -45,9 +46,13 @@ class WebSocket implements ProtocolInterface {
|
||||
, 'Hixie76' => null
|
||||
);
|
||||
|
||||
public function __construct(SocketObserver $application) {
|
||||
public function __construct(ObserverInterface $app = null) {
|
||||
if (null === $app) {
|
||||
throw new \UnexpectedValueException("WebSocket requires an application to run off of");
|
||||
}
|
||||
|
||||
$this->_clients = new \SplObjectStorage;
|
||||
$this->_app = $application;
|
||||
$this->_app = $app;
|
||||
$this->_factory = new Factory;
|
||||
}
|
||||
|
||||
@ -128,8 +133,8 @@ class WebSocket implements ProtocolInterface {
|
||||
|
||||
/**
|
||||
* Checks if a return Command from your application is a message, if so encode it/them
|
||||
* @param Ratchet\Command\CommandInterface|NULL
|
||||
* @return Ratchet\Command\CommandInterface|NULL
|
||||
* @param Ratchet\Resource\Command\CommandInterface|NULL
|
||||
* @return Ratchet\Resource\Command\CommandInterface|NULL
|
||||
*/
|
||||
protected function prepareCommand(CommandInterface $command = null) {
|
||||
if ($command instanceof SendMessage) {
|
||||
@ -169,7 +174,7 @@ class WebSocket implements ProtocolInterface {
|
||||
*/
|
||||
protected function versionFactory($version) {
|
||||
if (null === $this->_versions[$version]) {
|
||||
$ns = __CLASS__ . "\\Version\\{$version}";
|
||||
$ns = __NAMESPACE__ . "\\Version\\{$version}";
|
||||
$this->_version[$version] = new $ns;
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
namespace Ratchet\Protocol\WebSocket;
|
||||
use Ratchet\SocketObserver;
|
||||
namespace Ratchet\Application\WebSocket;
|
||||
use Ratchet\ObserverInterface;
|
||||
use Ratchet\SocketInterface;
|
||||
|
||||
/**
|
||||
* @todo App interfaces this (optionally) if is meant for WebSocket
|
||||
* @todo WebSocket checks if instanceof AppInterface, if so uses getSubProtocol() when doing handshake
|
||||
*/
|
||||
interface AppInterface extends SocketObserver {
|
||||
interface AppInterface extends ObserverInterface {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@ -16,7 +16,7 @@ interface AppInterface extends SocketObserver {
|
||||
/**
|
||||
* @param Ratchet\SocketInterface
|
||||
* @param string
|
||||
* @return Ratchet\Command\CommandInterface|null
|
||||
* @return Ratchet\Resource\Command\CommandInterface|null
|
||||
*/
|
||||
function onOpen(SocketInterface $conn, $headers);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
namespace Ratchet\Protocol\WebSocket;
|
||||
use Ratchet\Protocol\WebSocket\Version\VersionInterface;
|
||||
namespace Ratchet\Application\WebSocket;
|
||||
use Ratchet\Application\WebSocket\Version\VersionInterface;
|
||||
|
||||
/**
|
||||
* A representation of a Socket connection of the user on the other end of the socket
|
||||
@ -8,7 +8,7 @@ use Ratchet\Protocol\WebSocket\Version\VersionInterface;
|
||||
*/
|
||||
class Client {
|
||||
/**
|
||||
* @var Ratchet\Protocol\WebSocket\Version\VersionInterface
|
||||
* @var Ratchet\Application\WebSocket\Version\VersionInterface
|
||||
*/
|
||||
protected $_version = null;
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
namespace Ratchet\Protocol\WebSocket\Command\Action;
|
||||
namespace Ratchet\Application\WebSocket\Command\Action;
|
||||
use Ratchet\SocketInterface;
|
||||
use Ratchet\Command\Action\SendMessage;
|
||||
use Ratchet\SocketObserver;
|
||||
use Ratchet\Resource\Command\Action\SendMessage;
|
||||
use Ratchet\ObserverInterface;
|
||||
|
||||
class Disconnect extends SendMessage {
|
||||
protected $_code = 1000;
|
||||
@ -13,7 +13,7 @@ class Disconnect extends SendMessage {
|
||||
// re-do message based on code
|
||||
}
|
||||
|
||||
public function execute(SocketObserver $scope = null) {
|
||||
public function execute(ObserverInterface $scope = null) {
|
||||
parent::execute();
|
||||
$this->_socket->close();
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace Ratchet\Protocol\WebSocket\Command\Action;
|
||||
use Ratchet\Command\ActionTemplate;
|
||||
use Ratchet\SocketObserver;
|
||||
namespace Ratchet\Application\WebSocket\Command\Action;
|
||||
use Ratchet\Resource\Command\ActionTemplate;
|
||||
use Ratchet\ObserverInterface;
|
||||
|
||||
class Ping extends ActionTemplate {
|
||||
public function execute(SocketObserver $scope = null) {
|
||||
public function execute(ObserverInterface $scope = null) {
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace Ratchet\Protocol\WebSocket\Command\Action;
|
||||
use Ratchet\Command\ActionTemplate;
|
||||
use Ratchet\SocketObserver;
|
||||
namespace Ratchet\Application\WebSocket\Command\Action;
|
||||
use Ratchet\Resource\Command\ActionTemplate;
|
||||
use Ratchet\ObserverInterface;
|
||||
|
||||
class Pong extends ActionTemplate {
|
||||
public function execute(SocketObserver $scope = null) {
|
||||
public function execute(ObserverInterface $scope = null) {
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace Ratchet\Protocol\WebSocket\Util;
|
||||
namespace Ratchet\Application\WebSocket\Util;
|
||||
|
||||
/**
|
||||
* A helper class for handling HTTP requests
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace Ratchet\Protocol\WebSocket\Version;
|
||||
namespace Ratchet\Application\WebSocket\Version;
|
||||
|
||||
/**
|
||||
* The Hixie76 is currently implemented by Safari
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
namespace Ratchet\Protocol\WebSocket\Version;
|
||||
use Ratchet\Protocol\WebSocket\Util\HTTP;
|
||||
namespace Ratchet\Application\WebSocket\Version;
|
||||
use Ratchet\Application\WebSocket\Util\HTTP;
|
||||
|
||||
/**
|
||||
* The HyBi-10 version, identified in the headers as version 8, is currently implemented by the latest Chrome and Firefix version
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace Ratchet\Protocol\WebSocket\Version;
|
||||
namespace Ratchet\Application\WebSocket\Version;
|
||||
|
||||
/**
|
||||
* Despite the version iterations of WebInterface the actions they go through are similar
|
||||
|
@ -5,14 +5,21 @@ namespace Ratchet;
|
||||
* Observable/Observer design pattern interface for handing events on a socket
|
||||
* @todo Consider an onException method. Since server is running its own loop the app currently doesn't know when a problem is handled
|
||||
* @todo Consider an onDisconnect method for a server-side close()'ing of a connection - onClose would be client side close()
|
||||
* @todo Consider adding __construct(SocketObserver $decorator = null) - on Server move Socket as parameter to run()
|
||||
* @todo Consider adding __construct(ObserverInterface $decorator = null) - on Server move Socket as parameter to run()
|
||||
* @todo Does this belong in \Ratchet\Server\?
|
||||
*/
|
||||
interface SocketObserver {
|
||||
interface ObserverInterface {
|
||||
/**
|
||||
* Decorator pattern
|
||||
* @param ObserverInterface If nothing is passed it's the end of the line
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
public function __construct(ObserverInterface $app = null);
|
||||
|
||||
/**
|
||||
* When a new connection is opened it will be passed to this method
|
||||
* @param SocketInterface The socket/connection that just connected to your application
|
||||
* @return Ratchet\Command\CommandInterface|null
|
||||
* @return Ratchet\Resource\Command\CommandInterface|null
|
||||
*/
|
||||
function onOpen(SocketInterface $conn);
|
||||
|
||||
@ -20,14 +27,14 @@ interface SocketObserver {
|
||||
* Triggered when a client sends data through the socket
|
||||
* @param SocketInterface The socket/connection that sent the message to your application
|
||||
* @param string The message received
|
||||
* @return Ratchet\Command\CommandInterface|null
|
||||
* @return Ratchet\Resource\Command\CommandInterface|null
|
||||
*/
|
||||
function onRecv(SocketInterface $from, $msg);
|
||||
|
||||
/**
|
||||
* 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 SocketInterface The socket/connection that is closing/closed
|
||||
* @return Ratchet\Command\CommandInterface|null
|
||||
* @return Ratchet\Resource\Command\CommandInterface|null
|
||||
*/
|
||||
function onClose(SocketInterface $conn);
|
||||
|
||||
@ -36,7 +43,7 @@ interface SocketObserver {
|
||||
* the Exception is sent back down the stack, handled by the Server and bubbled back up the application through this method
|
||||
* @param SocketInterface
|
||||
* @param \Exception
|
||||
* @return Ratchet\Command\CommandInterface|null
|
||||
* @return Ratchet\Resource\Command\CommandInterface|null
|
||||
*/
|
||||
function onError(SocketInterface $conn, \Exception $e);
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
<?php
|
||||
namespace Ratchet\Command\Action;
|
||||
use Ratchet\Command\ActionTemplate;
|
||||
use Ratchet\SocketObserver;
|
||||
namespace Ratchet\Resource\Command\Action;
|
||||
use Ratchet\Resource\Command\ActionTemplate;
|
||||
use Ratchet\ObserverInterface;
|
||||
use Ratchet\SocketInterface;
|
||||
use Ratchet\Command\CommandInterface;
|
||||
use Ratchet\Command\Composite;
|
||||
use Ratchet\Resource\Command\CommandInterface;
|
||||
use Ratchet\Resource\Command\Composite;
|
||||
|
||||
/**
|
||||
* Close the connection to the sockets passed in the constructor
|
||||
*/
|
||||
class CloseConnection extends ActionTemplate {
|
||||
function execute(SocketObserver $scope = null) {
|
||||
function execute(ObserverInterface $scope = null) {
|
||||
// All this code allows an application to have its onClose method executed before the socket is actually closed
|
||||
$ret = $scope->onClose($this->getSocket());
|
||||
|
||||
@ -19,7 +19,7 @@ class CloseConnection extends ActionTemplate {
|
||||
$comp->enqueue($ret);
|
||||
|
||||
$rt = new Runtime($this->getSocket());
|
||||
$rt->setCommand(function(SocketInterface $socket, SocketObserver $scope) {
|
||||
$rt->setCommand(function(SocketInterface $socket, ObserverInterface $scope) {
|
||||
$socket->close();
|
||||
});
|
||||
$comp->enqueue($rt);
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace Ratchet\Command\Action;
|
||||
use Ratchet\Command\ActionTemplate;
|
||||
use Ratchet\SocketObserver;
|
||||
namespace Ratchet\Resource\Command\Action;
|
||||
use Ratchet\Resource\Command\ActionTemplate;
|
||||
use Ratchet\ObserverInterface;
|
||||
|
||||
/**
|
||||
* Null pattern - execution does nothing, something needs to be passed back though
|
||||
*/
|
||||
class Null extends ActionTemplate {
|
||||
public function execute(SocketObserver $scope = null) {
|
||||
public function execute(ObserverInterface $scope = null) {
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace Ratchet\Command\Action;
|
||||
use Ratchet\Command\ActionTemplate;
|
||||
use Ratchet\SocketObserver;
|
||||
namespace Ratchet\Resource\Command\Action;
|
||||
use Ratchet\Resource\Command\ActionTemplate;
|
||||
use Ratchet\ObserverInterface;
|
||||
|
||||
class Runtime extends ActionTemplate {
|
||||
/**
|
||||
@ -10,14 +10,14 @@ class Runtime extends ActionTemplate {
|
||||
protected $_command = null;
|
||||
|
||||
/**
|
||||
* Your closure should accept two parameters (\Ratchet\SocketInterface, \Ratchet\SocketObserver) parameter and return a CommandInterface or NULL
|
||||
* Your closure should accept two parameters (\Ratchet\SocketInterface, \Ratchet\ObserverInterface) parameter and return a CommandInterface or NULL
|
||||
* @param Closure Your closure/lambda to execute when the time comes
|
||||
*/
|
||||
public function setCommand(\Closure $callback) {
|
||||
$this->_command = $callback;
|
||||
}
|
||||
|
||||
public function execute(SocketObserver $scope = null) {
|
||||
public function execute(ObserverInterface $scope = null) {
|
||||
return call_user_func($this->_command, $this->getSocket(), $scope);
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace Ratchet\Command\Action;
|
||||
use Ratchet\Command\ActionTemplate;
|
||||
use Ratchet\SocketObserver;
|
||||
namespace Ratchet\Resource\Command\Action;
|
||||
use Ratchet\Resource\Command\ActionTemplate;
|
||||
use Ratchet\ObserverInterface;
|
||||
|
||||
/**
|
||||
* Send text back to the client end of the socket(s)
|
||||
@ -33,7 +33,7 @@ class SendMessage extends ActionTemplate {
|
||||
/**
|
||||
* @throws \UnexpectedValueException if a message was not set with setMessage()
|
||||
*/
|
||||
public function execute(SocketObserver $scope = null) {
|
||||
public function execute(ObserverInterface $scope = null) {
|
||||
if (empty($this->_message)) {
|
||||
throw new \UnexpectedValueException("Message is empty");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace Ratchet\Command;
|
||||
namespace Ratchet\Resource\Command;
|
||||
use Ratchet\SocketInterface;
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace Ratchet\Command;
|
||||
namespace Ratchet\Resource\Command;
|
||||
use Ratchet\SocketInterface;
|
||||
|
||||
abstract class ActionTemplate implements ActionInterface {
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
namespace Ratchet\Command;
|
||||
use Ratchet\SocketObserver;
|
||||
namespace Ratchet\Resource\Command;
|
||||
use Ratchet\ObserverInterface;
|
||||
|
||||
/**
|
||||
* Socket implementation of the Command Pattern
|
||||
@ -9,8 +9,8 @@ use Ratchet\SocketObserver;
|
||||
interface CommandInterface {
|
||||
/**
|
||||
* The Server class will call the execution
|
||||
* @param Ratchet\SocketObserver Scope to execute the command under
|
||||
* @param Ratchet\ObserverInterface Scope to execute the command under
|
||||
* @return CommandInterface|NULL
|
||||
*/
|
||||
function execute(SocketObserver $scope = null);
|
||||
function execute(ObserverInterface $scope = null);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
namespace Ratchet\Command;
|
||||
use Ratchet\SocketObserver;
|
||||
namespace Ratchet\Resource\Command;
|
||||
use Ratchet\ObserverInterface;
|
||||
|
||||
class Composite extends \SplQueue implements CommandInterface {
|
||||
/**
|
||||
@ -22,7 +22,7 @@ class Composite extends \SplQueue implements CommandInterface {
|
||||
}
|
||||
}
|
||||
|
||||
public function execute(SocketObserver $scope = null) {
|
||||
public function execute(ObserverInterface $scope = null) {
|
||||
$this->setIteratorMode(static::IT_MODE_DELETE);
|
||||
|
||||
$recursive = new self;
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace Ratchet\Command;
|
||||
namespace Ratchet\Resource\Command;
|
||||
use Ratchet\SocketInterface;
|
||||
|
||||
/**
|
||||
* A factory pattern class to easily create all the things in the Ratchet\Command interface
|
||||
* A factory pattern class to easily create all the things in the Ratchet\Resource\Command interface
|
||||
*/
|
||||
class Factory {
|
||||
protected $_paths = array();
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace Ratchet\Server;
|
||||
namespace Ratchet\Resource\Connection;
|
||||
use Ratchet\SocketInterface;
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace Ratchet\Server;
|
||||
namespace Ratchet\Resource\Connection;
|
||||
use Ratchet\SocketInterface;
|
||||
|
||||
interface ConnectionInterface {
|
||||
|
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
namespace Ratchet;
|
||||
use Ratchet\Protocol\ProtocolInterface;
|
||||
use Ratchet\Application\ProtocolInterface;
|
||||
|
||||
/**
|
||||
* A wrapper for the PHP socket_ functions
|
||||
* @author Chris Boden <shout at chrisboden dot ca>
|
||||
* @todo Possibly move this into Ratchet\Resource - another concrete could use streams
|
||||
*/
|
||||
class Socket implements SocketInterface {
|
||||
/**
|
||||
@ -110,7 +111,7 @@ class Socket implements SocketInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ratchet\Protocol\ProtocolInterface
|
||||
* @param Ratchet\Application\ProtocolInterface
|
||||
* @return Socket
|
||||
* @throws Exception
|
||||
*/
|
||||
|
@ -1,11 +1,13 @@
|
||||
<?php
|
||||
namespace Ratchet\Tests\Mock;
|
||||
use Ratchet\SocketObserver;
|
||||
use Ratchet\Server;
|
||||
use Ratchet\ObserverInterface;
|
||||
use Ratchet\Tests\Mock\Socket as MockSocket;
|
||||
use Ratchet\SocketInterface;
|
||||
|
||||
class Application implements SocketObserver {
|
||||
class Application implements ObserverInterface {
|
||||
public function __construct(ObserverInterface $app = null) {
|
||||
}
|
||||
|
||||
public function onOpen(SocketInterface $conn) {
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace Ratchet\Tests\Mock;
|
||||
use Ratchet\SocketObserver;
|
||||
use Ratchet\Protocol\ProtocolInterface;
|
||||
use Ratchet\ObserverInterface;
|
||||
use Ratchet\Application\ProtocolInterface;
|
||||
use Ratchet\Server;
|
||||
use Ratchet\SocketInterface;
|
||||
|
||||
class Protocol implements ProtocolInterface {
|
||||
public function __construct(SocketObserver $application) {
|
||||
public function __construct(ObserverInterface $app = null) {
|
||||
}
|
||||
|
||||
public static function getDefaultConfig() {
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace Ratchet\Tests\Protocol\WebSocket\Version;
|
||||
use Ratchet\Protocol\WebSocket\Version\Hixie76;
|
||||
use Ratchet\Application\WebSocket\Version\Hixie76;
|
||||
|
||||
/**
|
||||
* @covers Ratchet\Protocol\WebSocket\Version\Hixie76
|
||||
* @covers Ratchet\Application\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\\Protocol\\WebSocket\\Version\\VersionInterface');
|
||||
$constraint = $this->isInstanceOf('\\Ratchet\\Application\\WebSocket\\Version\\VersionInterface');
|
||||
$this->assertThat($this->_version, $constraint);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace Ratchet\Tests\Protocol\WebSocket\Version;
|
||||
use Ratchet\Protocol\WebSocket\Version\HyBi10;
|
||||
use Ratchet\Application\WebSocket\Version\HyBi10;
|
||||
|
||||
/**
|
||||
* @covers Ratchet\Protocol\WebSocket\Version\Hybi10
|
||||
* @covers Ratchet\Application\WebSocket\Version\Hybi10
|
||||
*/
|
||||
class HyBi10Test extends \PHPUnit_Framework_TestCase {
|
||||
protected $_version;
|
||||
@ -12,8 +12,11 @@ class HyBi10Test extends \PHPUnit_Framework_TestCase {
|
||||
$this->_version = new HyBi10();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this useful?
|
||||
*/
|
||||
public function testClassImplementsVersionInterface() {
|
||||
$constraint = $this->isInstanceOf('\\Ratchet\\Protocol\\WebSocket\\Version\\VersionInterface');
|
||||
$constraint = $this->isInstanceOf('\\Ratchet\\Application\\WebSocket\\Version\\VersionInterface');
|
||||
$this->assertThat($this->_version, $constraint);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
namespace Ratchet\Tests\Protocol;
|
||||
use Ratchet\Protocol\WebSocket;
|
||||
use Ratchet\Application\WebSocket\App as WebSocket;
|
||||
use Ratchet\Tests\Mock\Socket;
|
||||
use Ratchet\Tests\Mock\Application;
|
||||
|
||||
/**
|
||||
* @covers Ratchet\Protocol\WebSocket
|
||||
* @covers Ratchet\Application\WebSocket
|
||||
*/
|
||||
class WebSocketTest extends \PHPUnit_Framework_TestCase {
|
||||
protected $_ws;
|
||||
@ -15,12 +15,7 @@ class WebSocketTest extends \PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
public function testServerImplementsServerInterface() {
|
||||
$constraint = $this->isInstanceOf('\\Ratchet\\SocketObserver');
|
||||
$this->assertThat($this->_ws, $constraint);
|
||||
}
|
||||
|
||||
public function testServerImplementsProtocolInterface() {
|
||||
$constraint = $this->isInstanceOf('\\Ratchet\\Protocol\ProtocolInterface');
|
||||
$constraint = $this->isInstanceOf('\\Ratchet\\ObserverInterface');
|
||||
$this->assertThat($this->_ws, $constraint);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
namespace Ratchet\Tests;
|
||||
use Ratchet\Server;
|
||||
use Ratchet\Application\Server\App as Server;
|
||||
use Ratchet\Tests\Mock\FakeSocket as Socket;
|
||||
use Ratchet\Tests\Mock\Application as TestApp;
|
||||
|
||||
@ -15,7 +15,7 @@ class ServerTest extends \PHPUnit_Framework_TestCase {
|
||||
public function setUp() {
|
||||
$this->_catalyst = new Socket;
|
||||
$this->_app = new TestApp;
|
||||
$this->_server = new Server($this->_catalyst, $this->_app);
|
||||
$this->_server = new Server($this->_app);
|
||||
}
|
||||
|
||||
protected function getPrivateProperty($class, $name) {
|
||||
@ -26,30 +26,6 @@ class ServerTest extends \PHPUnit_Framework_TestCase {
|
||||
return $property->getValue($class);
|
||||
}
|
||||
|
||||
public function testServerHasServerInterface() {
|
||||
$constraint = $this->isInstanceOf('\\Ratchet\\SocketObserver');
|
||||
$this->assertThat($this->_server, $constraint);
|
||||
}
|
||||
|
||||
public function testIteration() {
|
||||
$this->assertInstanceOf('\\Iterator', $this->_server->getIterator());
|
||||
}
|
||||
|
||||
public function SKIPtestServerCanNotRunWithoutApplication() {
|
||||
$this->setExpectedException('\\RuntimeException');
|
||||
$this->_server->run();
|
||||
}
|
||||
|
||||
/*
|
||||
public function testAttatchedReceiverIsSet() {
|
||||
$app = new TestApp();
|
||||
|
||||
$this->_server->attatchReceiver($app);
|
||||
// todo, use proper assertions...can't look them up atm, no internet
|
||||
$this->assertAttributeEquals(Array(spl_object_hash($app) => $app), '_receivers', $this->_server);
|
||||
}
|
||||
|
||||
/**/
|
||||
public function testBindToInvalidAddress() {
|
||||
return $this->markTestIncomplete();
|
||||
|
||||
|
@ -23,12 +23,6 @@ class SocketTest extends \PHPUnit_Framework_TestCase {
|
||||
$this->_socket = new Socket();
|
||||
}
|
||||
|
||||
/*
|
||||
public function testWhatGoesInConstructComesOut() {
|
||||
$this->assertTrue(false);
|
||||
}
|
||||
*/
|
||||
|
||||
public function testGetDefaultConfigForConstruct() {
|
||||
$ref_conf = static::getMethod('getConfig');
|
||||
$config = $ref_conf->invokeArgs($this->_socket, array());
|
||||
|
Loading…
Reference in New Issue
Block a user