OCD API documentation updates
This commit is contained in:
parent
ffd29053bd
commit
e7887a4b17
@ -8,24 +8,24 @@ namespace Ratchet;
|
|||||||
interface ComponentInterface {
|
interface ComponentInterface {
|
||||||
/**
|
/**
|
||||||
* When a new connection is opened it will be passed to this method
|
* When a new connection is opened it will be passed to this method
|
||||||
* @param Ratchet\Connection The socket/connection that just connected to your application
|
* @param ConnectionInterface $conn The socket/connection that just connected to your application
|
||||||
* @throws Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
function onOpen(ConnectionInterface $conn);
|
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.
|
* 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\Connection The socket/connection that is closing/closed
|
* @param ConnectionInterface $conn The socket/connection that is closing/closed
|
||||||
* @throws Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
function onClose(ConnectionInterface $conn);
|
function onClose(ConnectionInterface $conn);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If there is an error with one of the sockets, or somewhere in the application where an Exception is thrown,
|
* 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
|
* the Exception is sent back down the stack, handled by the Server and bubbled back up the application through this method
|
||||||
* @param Ratchet\Connection
|
* @param ConnectionInterface $conn
|
||||||
* @param \Exception
|
* @param \Exception $e
|
||||||
* @throws Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
function onError(ConnectionInterface $conn, \Exception $e);
|
function onError(ConnectionInterface $conn, \Exception $e);
|
||||||
}
|
}
|
@ -14,7 +14,7 @@ const VERSION = 'Ratchet/0.2.3';
|
|||||||
interface ConnectionInterface {
|
interface ConnectionInterface {
|
||||||
/**
|
/**
|
||||||
* Send data to the connection
|
* Send data to the connection
|
||||||
* @param string
|
* @param string $data
|
||||||
* @return ConnectionInterface
|
* @return ConnectionInterface
|
||||||
*/
|
*/
|
||||||
function send($data);
|
function send($data);
|
||||||
|
@ -4,8 +4,8 @@ namespace Ratchet;
|
|||||||
interface MessageInterface {
|
interface MessageInterface {
|
||||||
/**
|
/**
|
||||||
* Triggered when a client sends data through the socket
|
* Triggered when a client sends data through the socket
|
||||||
* @param \Ratchet\ConnectionInterface The socket/connection that sent the message to your application
|
* @param \Ratchet\ConnectionInterface $from The socket/connection that sent the message to your application
|
||||||
* @param string The message received
|
* @param string $msg The message received
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
function onMessage(ConnectionInterface $from, $msg);
|
function onMessage(ConnectionInterface $from, $msg);
|
||||||
|
@ -45,15 +45,16 @@ class FlashPolicy implements MessageComponentInterface {
|
|||||||
/**
|
/**
|
||||||
* Add a domain to an allowed access list.
|
* Add a domain to an allowed access list.
|
||||||
*
|
*
|
||||||
* @param string Specifies a requesting domain to be granted access. Both named domains and IP
|
* @param string $domain Specifies a requesting domain to be granted access. Both named domains and IP
|
||||||
* addresses are acceptable values. Subdomains are considered different domains. A wildcard (*) can
|
* addresses are acceptable values. Subdomains are considered different domains. A wildcard (*) can
|
||||||
* be used to match all domains when used alone, or multiple domains (subdomains) when used as a
|
* be used to match all domains when used alone, or multiple domains (subdomains) when used as a
|
||||||
* prefix for an explicit, second-level domain name separated with a dot (.)
|
* prefix for an explicit, second-level domain name separated with a dot (.)
|
||||||
* @param string A comma-separated list of ports or range of ports that a socket connection
|
* @param string $ports A comma-separated list of ports or range of ports that a socket connection
|
||||||
* is allowed to connect to. A range of ports is specified through a dash (-) between two port numbers.
|
* is allowed to connect to. A range of ports is specified through a dash (-) between two port numbers.
|
||||||
* Ranges can be used with individual ports when separated with a comma. A single wildcard (*) can
|
* Ranges can be used with individual ports when separated with a comma. A single wildcard (*) can
|
||||||
* be used to allow all ports.
|
* be used to allow all ports.
|
||||||
* @param bool
|
* @param bool $secure
|
||||||
|
* @throws \UnexpectedValueException
|
||||||
* @return FlashPolicy
|
* @return FlashPolicy
|
||||||
*/
|
*/
|
||||||
public function addAllowedAccess($domain, $ports = '*', $secure = false) {
|
public function addAllowedAccess($domain, $ports = '*', $secure = false) {
|
||||||
@ -76,7 +77,8 @@ class FlashPolicy implements MessageComponentInterface {
|
|||||||
* domain policy files other than the master policy file located in the target domain's root and named
|
* domain policy files other than the master policy file located in the target domain's root and named
|
||||||
* crossdomain.xml.
|
* crossdomain.xml.
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string $permittedCrossDomainPolicies
|
||||||
|
* @throws \UnexpectedValueException
|
||||||
* @return FlashPolicy
|
* @return FlashPolicy
|
||||||
*/
|
*/
|
||||||
public function setSiteControl($permittedCrossDomainPolicies = 'all') {
|
public function setSiteControl($permittedCrossDomainPolicies = 'all') {
|
||||||
@ -124,7 +126,8 @@ class FlashPolicy implements MessageComponentInterface {
|
|||||||
/**
|
/**
|
||||||
* Builds the crossdomain file based on the template policy
|
* Builds the crossdomain file based on the template policy
|
||||||
*
|
*
|
||||||
* @return SimpleXMLElement
|
* @throws \UnexpectedValueException
|
||||||
|
* @return \SimpleXMLElement
|
||||||
*/
|
*/
|
||||||
public function renderPolicy() {
|
public function renderPolicy() {
|
||||||
$policy = new \SimpleXMLElement($this->_policy);
|
$policy = new \SimpleXMLElement($this->_policy);
|
||||||
@ -154,7 +157,7 @@ class FlashPolicy implements MessageComponentInterface {
|
|||||||
/**
|
/**
|
||||||
* Make sure the proper site control was passed
|
* Make sure the proper site control was passed
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string $permittedCrossDomainPolicies
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function validateSiteControl($permittedCrossDomainPolicies) {
|
public function validateSiteControl($permittedCrossDomainPolicies) {
|
||||||
@ -165,7 +168,7 @@ class FlashPolicy implements MessageComponentInterface {
|
|||||||
/**
|
/**
|
||||||
* Validate for proper domains (wildcards allowed)
|
* Validate for proper domains (wildcards allowed)
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string $domain
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function validateDomain($domain) {
|
public function validateDomain($domain) {
|
||||||
@ -175,7 +178,7 @@ class FlashPolicy implements MessageComponentInterface {
|
|||||||
/**
|
/**
|
||||||
* Make sure valid ports were passed
|
* Make sure valid ports were passed
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string $port
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function validatePorts($port) {
|
public function validatePorts($port) {
|
||||||
|
@ -8,10 +8,14 @@ use React\Socket\ConnectionInterface as ReactConn;
|
|||||||
*/
|
*/
|
||||||
class IoConnection implements ConnectionInterface {
|
class IoConnection implements ConnectionInterface {
|
||||||
/**
|
/**
|
||||||
* @var React\Socket\ConnectionInterface
|
* @var \React\Socket\ConnectionInterface
|
||||||
*/
|
*/
|
||||||
protected $conn;
|
protected $conn;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \React\Socket\ConnectionInterface $conn
|
||||||
|
*/
|
||||||
public function __construct(ReactConn $conn) {
|
public function __construct(ReactConn $conn) {
|
||||||
$this->conn = $conn;
|
$this->conn = $conn;
|
||||||
}
|
}
|
||||||
|
@ -12,25 +12,25 @@ use React\Socket\Server as Reactor;
|
|||||||
*/
|
*/
|
||||||
class IoServer {
|
class IoServer {
|
||||||
/**
|
/**
|
||||||
* @var React\EventLoop\LoopInterface
|
* @var \React\EventLoop\LoopInterface
|
||||||
*/
|
*/
|
||||||
public $loop;
|
public $loop;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Ratchet\MessageComponentInterface
|
* @var \Ratchet\MessageComponentInterface
|
||||||
*/
|
*/
|
||||||
public $app;
|
public $app;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of React event handlers
|
* Array of React event handlers
|
||||||
* @var SplFixedArray
|
* @var \SplFixedArray
|
||||||
*/
|
*/
|
||||||
protected $handlers;
|
protected $handlers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Ratchet\MessageComponentInterface The Ratchet application stack to host
|
* @param \Ratchet\MessageComponentInterface $app The Ratchet application stack to host
|
||||||
* @param React\Socket\ServerInterface The React socket server to run the Ratchet application off of
|
* @param \React\Socket\ServerInterface $socket The React socket server to run the Ratchet application off of
|
||||||
* @param React\EventLoop\LoopInterface|null The React looper to run the Ratchet application off of
|
* @param \React\EventLoop\LoopInterface|null $loop The React looper to run the Ratchet application off of
|
||||||
*/
|
*/
|
||||||
public function __construct(MessageComponentInterface $app, ServerInterface $socket, LoopInterface $loop = null) {
|
public function __construct(MessageComponentInterface $app, ServerInterface $socket, LoopInterface $loop = null) {
|
||||||
gc_enable();
|
gc_enable();
|
||||||
@ -49,10 +49,10 @@ class IoServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Ratchet\MessageComponentInterface The application that I/O will call when events are received
|
* @param \Ratchet\MessageComponentInterface $component The application that I/O will call when events are received
|
||||||
* @param int The port to server sockets on
|
* @param int $port The port to server sockets on
|
||||||
* @param string The address to receive sockets on (0.0.0.0 means receive connections from any)
|
* @param string $address The address to receive sockets on (0.0.0.0 means receive connections from any)
|
||||||
* @return Ratchet\Server\IoServer
|
* @return IoServer
|
||||||
*/
|
*/
|
||||||
public static function factory(MessageComponentInterface $component, $port = 80, $address = '0.0.0.0') {
|
public static function factory(MessageComponentInterface $component, $port = 80, $address = '0.0.0.0') {
|
||||||
$loop = LoopFactory::create();
|
$loop = LoopFactory::create();
|
||||||
@ -64,7 +64,7 @@ class IoServer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the application by entering the event loop
|
* Run the application by entering the event loop
|
||||||
* @throws RuntimeException If a loop was not previously specified
|
* @throws \RuntimeException If a loop was not previously specified
|
||||||
*/
|
*/
|
||||||
public function run() {
|
public function run() {
|
||||||
if (null === $this->loop) {
|
if (null === $this->loop) {
|
||||||
@ -78,6 +78,7 @@ class IoServer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggered when a new connection is received from React
|
* Triggered when a new connection is received from React
|
||||||
|
* @param \React\Socket\ConnectionInterface $conn
|
||||||
*/
|
*/
|
||||||
public function handleConnect($conn) {
|
public function handleConnect($conn) {
|
||||||
$conn->decor = new IoConnection($conn);
|
$conn->decor = new IoConnection($conn);
|
||||||
@ -94,8 +95,8 @@ class IoServer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Data has been received from React
|
* Data has been received from React
|
||||||
* @param string
|
* @param string $data
|
||||||
* @param React\Socket\Connection
|
* @param \React\Socket\ConnectionInterface $conn
|
||||||
*/
|
*/
|
||||||
public function handleData($data, $conn) {
|
public function handleData($data, $conn) {
|
||||||
try {
|
try {
|
||||||
@ -107,7 +108,7 @@ class IoServer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A connection has been closed by React
|
* A connection has been closed by React
|
||||||
* @param React\Socket\Connection
|
* @param \React\Socket\ConnectionInterface $conn
|
||||||
*/
|
*/
|
||||||
public function handleEnd($conn) {
|
public function handleEnd($conn) {
|
||||||
try {
|
try {
|
||||||
@ -121,8 +122,8 @@ class IoServer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An error has occurred, let the listening application know
|
* An error has occurred, let the listening application know
|
||||||
* @param Exception
|
* @param \Exception $e
|
||||||
* @param React\Socket\Connection
|
* @param \React\Socket\ConnectionInterface $conn
|
||||||
*/
|
*/
|
||||||
public function handleError(\Exception $e, $conn) {
|
public function handleError(\Exception $e, $conn) {
|
||||||
$this->app->onError($conn->decor, $e);
|
$this->app->onError($conn->decor, $e);
|
||||||
|
@ -10,17 +10,20 @@ class IpBlackList implements MessageComponentInterface {
|
|||||||
protected $_blacklist = array();
|
protected $_blacklist = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Ratchet\MessageComponentInterface
|
* @var \Ratchet\MessageComponentInterface
|
||||||
*/
|
*/
|
||||||
protected $_decorating;
|
protected $_decorating;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Ratchet\MessageComponentInterface $component
|
||||||
|
*/
|
||||||
public function __construct(MessageComponentInterface $component) {
|
public function __construct(MessageComponentInterface $component) {
|
||||||
$this->_decorating = $component;
|
$this->_decorating = $component;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an address to the blacklist that will not be allowed to connect to your application
|
* Add an address to the blacklist that will not be allowed to connect to your application
|
||||||
* @param string IP address to block from connecting to your application
|
* @param string $ip IP address to block from connecting to your application
|
||||||
* @return IpBlackList
|
* @return IpBlackList
|
||||||
*/
|
*/
|
||||||
public function blockAddress($ip) {
|
public function blockAddress($ip) {
|
||||||
@ -31,7 +34,7 @@ class IpBlackList implements MessageComponentInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Unblock an address so they can access your application again
|
* Unblock an address so they can access your application again
|
||||||
* @param string IP address to unblock from connecting to your application
|
* @param string $ip IP address to unblock from connecting to your application
|
||||||
* @return IpBlackList
|
* @return IpBlackList
|
||||||
*/
|
*/
|
||||||
public function unblockAddress($ip) {
|
public function unblockAddress($ip) {
|
||||||
@ -43,7 +46,7 @@ class IpBlackList implements MessageComponentInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string $address
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isBlocked($address) {
|
public function isBlocked($address) {
|
||||||
@ -59,7 +62,7 @@ class IpBlackList implements MessageComponentInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string $address
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function filterAddress($address) {
|
public function filterAddress($address) {
|
||||||
|
@ -12,7 +12,7 @@ class PhpHandler implements HandlerInterface {
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
* @link http://ca2.php.net/manual/en/function.session-decode.php#108037 Code from this comment on php.net
|
* @link http://ca2.php.net/manual/en/function.session-decode.php#108037 Code from this comment on php.net
|
||||||
* @throws UnexpectedValueException If there is a problem parsing the data
|
* @throws \UnexpectedValueException If there is a problem parsing the data
|
||||||
*/
|
*/
|
||||||
public function unserialize($raw) {
|
public function unserialize($raw) {
|
||||||
$returnData = array();
|
$returnData = array();
|
||||||
|
@ -16,33 +16,33 @@ use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;
|
|||||||
*/
|
*/
|
||||||
class SessionProvider implements MessageComponentInterface, WsServerInterface {
|
class SessionProvider implements MessageComponentInterface, WsServerInterface {
|
||||||
/**
|
/**
|
||||||
* @var Ratchet\MessageComponentInterface
|
* @var \Ratchet\MessageComponentInterface
|
||||||
*/
|
*/
|
||||||
protected $_app;
|
protected $_app;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selected handler storage assigned by the developer
|
* Selected handler storage assigned by the developer
|
||||||
* @var SessionHandlerInterface
|
* @var \SessionHandlerInterface
|
||||||
*/
|
*/
|
||||||
protected $_handler;
|
protected $_handler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Null storage handler if no previous session was found
|
* Null storage handler if no previous session was found
|
||||||
* @var SessionHandlerInterface
|
* @var \SessionHandlerInterface
|
||||||
*/
|
*/
|
||||||
protected $_null;
|
protected $_null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Ratchet\Session\Serialize\HandlerInterface
|
* @var \Ratchet\Session\Serialize\HandlerInterface
|
||||||
*/
|
*/
|
||||||
protected $_serializer;
|
protected $_serializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Ratchet\MessageComponentInterface
|
* @param \Ratchet\MessageComponentInterface $app
|
||||||
* @param SessionHandlerInterface
|
* @param \SessionHandlerInterface $handler
|
||||||
* @param array
|
* @param array $options
|
||||||
* @param Ratchet\Session\Serialize\HandlerInterface
|
* @param \Ratchet\Session\Serialize\HandlerInterface $serializer
|
||||||
* @throws RuntimeException If unable to match serialization methods
|
* @throws \RuntimeExcpetion
|
||||||
*/
|
*/
|
||||||
public function __construct(MessageComponentInterface $app, \SessionHandlerInterface $handler, array $options = array(), HandlerInterface $serializer = null) {
|
public function __construct(MessageComponentInterface $app, \SessionHandlerInterface $handler, array $options = array(), HandlerInterface $serializer = null) {
|
||||||
$this->_app = $app;
|
$this->_app = $app;
|
||||||
@ -124,7 +124,7 @@ class SessionProvider implements MessageComponentInterface, WsServerInterface {
|
|||||||
/**
|
/**
|
||||||
* Set all the php session. ini options
|
* Set all the php session. ini options
|
||||||
* © Symfony
|
* © Symfony
|
||||||
* @param array
|
* @param array $options
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function setOptions(array $options) {
|
protected function setOptions(array $options) {
|
||||||
@ -152,7 +152,7 @@ class SessionProvider implements MessageComponentInterface, WsServerInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string Input to convert
|
* @param string $langDef Input to convert
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function toClassCase($langDef) {
|
protected function toClassCase($langDef) {
|
||||||
|
@ -46,8 +46,7 @@ class VirtualProxy extends SessionHandlerProxy {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DO NOT CALL THIS METHOD
|
* DO NOT CALL THIS METHOD
|
||||||
* @param string
|
* @internal
|
||||||
* @throws RuntimeException
|
|
||||||
*/
|
*/
|
||||||
public function setName($name) {
|
public function setName($name) {
|
||||||
throw new \RuntimeException("Can not change session name in VirtualProxy");
|
throw new \RuntimeException("Can not change session name in VirtualProxy");
|
||||||
|
@ -6,14 +6,14 @@ use Ratchet\Session\Serialize\HandlerInterface;
|
|||||||
|
|
||||||
class VirtualSessionStorage extends NativeSessionStorage {
|
class VirtualSessionStorage extends NativeSessionStorage {
|
||||||
/**
|
/**
|
||||||
* @var Ratchet\Session\Serialize\HandlerInterface
|
* @var \Ratchet\Session\Serialize\HandlerInterface
|
||||||
*/
|
*/
|
||||||
protected $_serializer;
|
protected $_serializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SessionHandlerInterface
|
* @param \SessionHandlerInterface $handler
|
||||||
* @param string The ID of the session to retrieve
|
* @param string $sessionId The ID of the session to retrieve
|
||||||
* @param Ratchet\Session\Serialize\HandlerInterface
|
* @param \Ratchet\Session\Serialize\HandlerInterface $serializer
|
||||||
*/
|
*/
|
||||||
public function __construct(\SessionHandlerInterface $handler, $sessionId, HandlerInterface $serializer) {
|
public function __construct(\SessionHandlerInterface $handler, $sessionId, HandlerInterface $serializer) {
|
||||||
$this->setSaveHandler($handler);
|
$this->setSaveHandler($handler);
|
||||||
|
@ -41,12 +41,12 @@ class ServerProtocol implements MessageComponentInterface, WsServerInterface {
|
|||||||
protected $_decorating;
|
protected $_decorating;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var SplObjectStorage
|
* @var \SplObjectStorage
|
||||||
*/
|
*/
|
||||||
protected $connections;
|
protected $connections;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param WampServerInterface An class to propagate calls through
|
* @param WampServerInterface $serverComponent An class to propagate calls through
|
||||||
*/
|
*/
|
||||||
public function __construct(WampServerInterface $serverComponent) {
|
public function __construct(WampServerInterface $serverComponent) {
|
||||||
$this->_decorating = $serverComponent;
|
$this->_decorating = $serverComponent;
|
||||||
@ -79,7 +79,7 @@ class ServerProtocol implements MessageComponentInterface, WsServerInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
* @throws Exception
|
* @throws \Exception
|
||||||
* @throws JsonException
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
public function onMessage(ConnectionInterface $from, $msg) {
|
public function onMessage(ConnectionInterface $from, $msg) {
|
||||||
|
@ -11,7 +11,7 @@ class Topic implements \IteratorAggregate, \Countable {
|
|||||||
private $subscribers;
|
private $subscribers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string Unique ID for this object
|
* @param string $topicId Unique ID for this object
|
||||||
*/
|
*/
|
||||||
public function __construct($topicId) {
|
public function __construct($topicId) {
|
||||||
$this->id = $topicId;
|
$this->id = $topicId;
|
||||||
@ -31,7 +31,7 @@ class Topic implements \IteratorAggregate, \Countable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message to all the connections in this topic
|
* Send a message to all the connections in this topic
|
||||||
* @param string
|
* @param string $msg
|
||||||
* @return Topic
|
* @return Topic
|
||||||
*/
|
*/
|
||||||
public function broadcast($msg) {
|
public function broadcast($msg) {
|
||||||
@ -43,7 +43,7 @@ class Topic implements \IteratorAggregate, \Countable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param WampConnection
|
* @param WampConnection $conn
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function has(ConnectionInterface $conn) {
|
public function has(ConnectionInterface $conn) {
|
||||||
@ -51,7 +51,7 @@ class Topic implements \IteratorAggregate, \Countable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param WampConnection
|
* @param WampConnection $conn
|
||||||
* @return Topic
|
* @return Topic
|
||||||
*/
|
*/
|
||||||
public function add(ConnectionInterface $conn) {
|
public function add(ConnectionInterface $conn) {
|
||||||
@ -61,7 +61,7 @@ class Topic implements \IteratorAggregate, \Countable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param WampConnection
|
* @param WampConnection $conn
|
||||||
* @return Topic
|
* @return Topic
|
||||||
*/
|
*/
|
||||||
public function remove(ConnectionInterface $conn) {
|
public function remove(ConnectionInterface $conn) {
|
||||||
|
@ -7,7 +7,7 @@ use Ratchet\Wamp\ServerProtocol as WAMP;
|
|||||||
/**
|
/**
|
||||||
* A ConnectionInterface object wrapper that is passed to your WAMP application
|
* A ConnectionInterface object wrapper that is passed to your WAMP application
|
||||||
* representing a client. Methods on this Connection are therefore different.
|
* representing a client. Methods on this Connection are therefore different.
|
||||||
* @property stdClass $WAMP
|
* @property \stdClass $WAMP
|
||||||
*/
|
*/
|
||||||
class WampConnection extends AbstractConnectionDecorator {
|
class WampConnection extends AbstractConnectionDecorator {
|
||||||
/**
|
/**
|
||||||
@ -25,8 +25,9 @@ class WampConnection extends AbstractConnectionDecorator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Successfully respond to a call made by the client
|
* Successfully respond to a call made by the client
|
||||||
* @param string The unique ID given by the client to respond to
|
* @param string $id The unique ID given by the client to respond to
|
||||||
* @param array An array of data to return to the client
|
* @param array $data An array of data to return to the client
|
||||||
|
* @return WampConnection
|
||||||
*/
|
*/
|
||||||
public function callResult($id, array $data = array()) {
|
public function callResult($id, array $data = array()) {
|
||||||
return $this->send(json_encode(array(WAMP::MSG_CALL_RESULT, $id, $data)));
|
return $this->send(json_encode(array(WAMP::MSG_CALL_RESULT, $id, $data)));
|
||||||
@ -34,10 +35,11 @@ class WampConnection extends AbstractConnectionDecorator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Respond with an error to a client call
|
* Respond with an error to a client call
|
||||||
* @param string The unique ID given by the client to respond to
|
* @param string $id The unique ID given by the client to respond to
|
||||||
* @param string The URI given to identify the specific error
|
* @param string $errorUri The URI given to identify the specific error
|
||||||
* @param string A developer-oriented description of the error
|
* @param string $desc A developer-oriented description of the error
|
||||||
* @param string|null An optional human readable detail message to send back
|
* @param string $details An optional human readable detail message to send back
|
||||||
|
* @return WampConnection
|
||||||
*/
|
*/
|
||||||
public function callError($id, $errorUri, $desc = '', $details = null) {
|
public function callError($id, $errorUri, $desc = '', $details = null) {
|
||||||
if ($errorUri instanceof Topic) {
|
if ($errorUri instanceof Topic) {
|
||||||
@ -54,16 +56,18 @@ class WampConnection extends AbstractConnectionDecorator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string The topic to broadcast to
|
* @param string $topic The topic to broadcast to
|
||||||
* @param mixed Data to send with the event. Anything that is json'able
|
* @param mixed $msg Data to send with the event. Anything that is json'able
|
||||||
|
* @return WampConnection
|
||||||
*/
|
*/
|
||||||
public function event($topic, $msg) {
|
public function event($topic, $msg) {
|
||||||
return $this->send(json_encode(array(WAMP::MSG_EVENT, (string)$topic, $msg)));
|
return $this->send(json_encode(array(WAMP::MSG_EVENT, (string)$topic, $msg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string $curie
|
||||||
* @param string
|
* @param string $uri
|
||||||
|
* @return WampConnection
|
||||||
*/
|
*/
|
||||||
public function prefix($curie, $uri) {
|
public function prefix($curie, $uri) {
|
||||||
$this->WAMP->prefixes[$curie] = (string)$uri;
|
$this->WAMP->prefixes[$curie] = (string)$uri;
|
||||||
@ -73,7 +77,7 @@ class WampConnection extends AbstractConnectionDecorator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the full request URI from the connection object if a prefix has been established for it
|
* Get the full request URI from the connection object if a prefix has been established for it
|
||||||
* @param string
|
* @param string $uri
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUri($uri) {
|
public function getUri($uri) {
|
||||||
|
@ -10,34 +10,34 @@ use Ratchet\ConnectionInterface;
|
|||||||
interface WampServerInterface extends ComponentInterface {
|
interface WampServerInterface extends ComponentInterface {
|
||||||
/**
|
/**
|
||||||
* An RPC call has been received
|
* An RPC call has been received
|
||||||
* @param Ratchet\ConnectionInterface
|
* @param \Ratchet\ConnectionInterface $conn
|
||||||
* @param string The unique ID of the RPC, required to respond to
|
* @param string $id The unique ID of the RPC, required to respond to
|
||||||
* @param string|Topic The topic to execute the call against
|
* @param string|Topic $topic The topic to execute the call against
|
||||||
* @param array Call parameters received from the client
|
* @param array $params Call parameters received from the client
|
||||||
*/
|
*/
|
||||||
function onCall(ConnectionInterface $conn, $id, $topic, array $params);
|
function onCall(ConnectionInterface $conn, $id, $topic, array $params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A request to subscribe to a topic has been made
|
* A request to subscribe to a topic has been made
|
||||||
* @param Ratchet\ConnectionInterface
|
* @param \Ratchet\ConnectionInterface $conn
|
||||||
* @param string|Topic The topic to subscribe to
|
* @param string|Topic $topic The topic to subscribe to
|
||||||
*/
|
*/
|
||||||
function onSubscribe(ConnectionInterface $conn, $topic);
|
function onSubscribe(ConnectionInterface $conn, $topic);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A request to unsubscribe from a topic has been made
|
* A request to unsubscribe from a topic has been made
|
||||||
* @param Ratchet\ConnectionInterface
|
* @param \Ratchet\ConnectionInterface $conn
|
||||||
* @param string|Topic The topic to unsubscribe from
|
* @param string|Topic $topic The topic to unsubscribe from
|
||||||
*/
|
*/
|
||||||
function onUnSubscribe(ConnectionInterface $conn, $topic);
|
function onUnSubscribe(ConnectionInterface $conn, $topic);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A client is attempting to publish content to a subscribed connections on a URI
|
* A client is attempting to publish content to a subscribed connections on a URI
|
||||||
* @param Ratchet\ConnectionInterface
|
* @param \Ratchet\ConnectionInterface $conn
|
||||||
* @param string|Topic The topic the user has attempted to publish to
|
* @param string|Topic $topic The topic the user has attempted to publish to
|
||||||
* @param string Payload of the publish
|
* @param string $event Payload of the publish
|
||||||
* @param array A list of session IDs the message should be excluded from (blacklist)
|
* @param array $exclude A list of session IDs the message should be excluded from (blacklist)
|
||||||
* @param array A list of session Ids the message should be send to (whitelist)
|
* @param array $eligible A list of session Ids the message should be send to (whitelist)
|
||||||
*/
|
*/
|
||||||
function onPublish(ConnectionInterface $conn, $topic, $event, array $exclude, array $eligible);
|
function onPublish(ConnectionInterface $conn, $topic, $event, array $exclude, array $eligible);
|
||||||
}
|
}
|
@ -49,8 +49,8 @@ class Validator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string The value to check the encoding
|
* @param string $str The value to check the encoding
|
||||||
* @param string The type of encoding to check against
|
* @param string $against The type of encoding to check against
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function checkEncoding($str, $against) {
|
public function checkEncoding($str, $against) {
|
||||||
|
@ -4,8 +4,8 @@ namespace Ratchet\WebSocket\Encoding;
|
|||||||
interface ValidatorInterface {
|
interface ValidatorInterface {
|
||||||
/**
|
/**
|
||||||
* Verify a string matches the encoding type
|
* Verify a string matches the encoding type
|
||||||
* @param string The string to check
|
* @param string $str The string to check
|
||||||
* @param string The encoding type to check against
|
* @param string $encoding The encoding type to check against
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function checkEncoding($str, $encoding);
|
function checkEncoding($str, $encoding);
|
||||||
|
@ -20,10 +20,10 @@ class HttpRequestParser implements MessageInterface {
|
|||||||
public $maxSize = 4096;
|
public $maxSize = 4096;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Ratchet\ConnectionInterface
|
* @param \Ratchet\ConnectionInterface $context
|
||||||
* @param string Data stream to buffer
|
* @param string $data Data stream to buffer
|
||||||
* @return Guzzle\Http\Message\RequestInterface|null
|
* @return \Guzzle\Http\Message\RequestInterface|null
|
||||||
* @throws OverflowException If the message buffer has become too large
|
* @throws \OverflowException If the message buffer has become too large
|
||||||
*/
|
*/
|
||||||
public function onMessage(ConnectionInterface $context, $data) {
|
public function onMessage(ConnectionInterface $context, $data) {
|
||||||
if (!isset($context->httpBuffer)) {
|
if (!isset($context->httpBuffer)) {
|
||||||
@ -47,7 +47,7 @@ class HttpRequestParser implements MessageInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the message has been buffered as per the HTTP specification
|
* Determine if the message has been buffered as per the HTTP specification
|
||||||
* @param string
|
* @param string $message
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isEom($message) {
|
public function isEom($message) {
|
||||||
|
@ -34,8 +34,8 @@ class Hixie76 implements VersionInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Guzzle\Http\Message\RequestInterface
|
* @param \Guzzle\Http\Message\RequestInterface $request
|
||||||
* @return Guzzle\Http\Message\Response
|
* @return \Guzzle\Http\Message\Response
|
||||||
*/
|
*/
|
||||||
public function handshake(RequestInterface $request) {
|
public function handshake(RequestInterface $request) {
|
||||||
$body = $this->sign($request->getHeader('Sec-WebSocket-Key1', true), $request->getHeader('Sec-WebSocket-Key2', true), (string)$request->getBody());
|
$body = $this->sign($request->getHeader('Sec-WebSocket-Key1', true), $request->getHeader('Sec-WebSocket-Key2', true), (string)$request->getBody());
|
||||||
|
@ -3,7 +3,7 @@ namespace Ratchet\WebSocket\Version;
|
|||||||
|
|
||||||
interface MessageInterface extends DataInterface {
|
interface MessageInterface extends DataInterface {
|
||||||
/**
|
/**
|
||||||
* @param FragmentInterface
|
* @param FrameInterface $fragment
|
||||||
* @return MessageInterface
|
* @return MessageInterface
|
||||||
*/
|
*/
|
||||||
function addFrame(FrameInterface $fragment);
|
function addFrame(FrameInterface $fragment);
|
||||||
|
@ -31,7 +31,7 @@ class RFC6455 implements VersionInterface {
|
|||||||
private $closeCodes = array();
|
private $closeCodes = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Ratchet\WebSocket\Encoding\ValidatorInterface
|
* @var \Ratchet\WebSocket\Encoding\ValidatorInterface
|
||||||
*/
|
*/
|
||||||
protected $validator;
|
protected $validator;
|
||||||
|
|
||||||
@ -78,8 +78,9 @@ class RFC6455 implements VersionInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Ratchet\ConnectionInterface
|
* @param \Ratchet\ConnectionInterface $conn
|
||||||
* @return Ratchet\WebSocket\Version\RFC6455\Connection
|
* @param \Ratchet\MessageInterface $coalescedCallback
|
||||||
|
* @return \Ratchet\WebSocket\Version\RFC6455\Connection
|
||||||
*/
|
*/
|
||||||
public function upgradeConnection(ConnectionInterface $conn, MessageInterface $coalescedCallback) {
|
public function upgradeConnection(ConnectionInterface $conn, MessageInterface $coalescedCallback) {
|
||||||
$upgraded = new Connection($conn);
|
$upgraded = new Connection($conn);
|
||||||
@ -94,8 +95,8 @@ class RFC6455 implements VersionInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Ratchet\WebSocket\Version\RFC6455\Connection
|
* @param \Ratchet\WebSocket\Version\RFC6455\Connection $from
|
||||||
* @param string
|
* @param string $data
|
||||||
*/
|
*/
|
||||||
public function onMessage(ConnectionInterface $from, $data) {
|
public function onMessage(ConnectionInterface $from, $data) {
|
||||||
$overflow = '';
|
$overflow = '';
|
||||||
@ -214,6 +215,9 @@ class RFC6455 implements VersionInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param string|null $payload
|
||||||
|
* @param bool|null $final
|
||||||
|
* @param int|null $opcode
|
||||||
* @return RFC6455\Frame
|
* @return RFC6455\Frame
|
||||||
*/
|
*/
|
||||||
public function newFrame($payload = null, $final = null, $opcode = null) {
|
public function newFrame($payload = null, $final = null, $opcode = null) {
|
||||||
@ -222,7 +226,7 @@ class RFC6455 implements VersionInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Used when doing the handshake to encode the key, verifying client/server are speaking the same language
|
* Used when doing the handshake to encode the key, verifying client/server are speaking the same language
|
||||||
* @param string
|
* @param string $key
|
||||||
* @return string
|
* @return string
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
|
@ -62,6 +62,12 @@ class Frame implements FrameInterface {
|
|||||||
*/
|
*/
|
||||||
protected $secondByte = -1;
|
protected $secondByte = -1;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string|null $payload
|
||||||
|
* @param bool $final
|
||||||
|
* @param int $opcode
|
||||||
|
*/
|
||||||
public function __construct($payload = null, $final = true, $opcode = 1) {
|
public function __construct($payload = null, $final = true, $opcode = 1) {
|
||||||
if (null === $payload) {
|
if (null === $payload) {
|
||||||
return;
|
return;
|
||||||
@ -136,7 +142,7 @@ class Frame implements FrameInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @throws UnderflowException
|
* @throws \UnderflowException
|
||||||
*/
|
*/
|
||||||
public function getRsv1() {
|
public function getRsv1() {
|
||||||
if (-1 === $this->firstByte) {
|
if (-1 === $this->firstByte) {
|
||||||
@ -148,7 +154,7 @@ class Frame implements FrameInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @throws UnderflowException
|
* @throws \UnderflowException
|
||||||
*/
|
*/
|
||||||
public function getRsv2() {
|
public function getRsv2() {
|
||||||
if (-1 === $this->firstByte) {
|
if (-1 === $this->firstByte) {
|
||||||
@ -160,7 +166,7 @@ class Frame implements FrameInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @throws UnderflowException
|
* @throws \UnderflowException
|
||||||
*/
|
*/
|
||||||
public function getRsv3() {
|
public function getRsv3() {
|
||||||
if (-1 === $this->firstByte) {
|
if (-1 === $this->firstByte) {
|
||||||
@ -215,8 +221,9 @@ class Frame implements FrameInterface {
|
|||||||
/**
|
/**
|
||||||
* Apply a mask to the payload
|
* Apply a mask to the payload
|
||||||
* @param string|null If NULL is passed a masking key will be generated
|
* @param string|null If NULL is passed a masking key will be generated
|
||||||
* @throws InvalidArgumentException If there is an issue with the given masking key
|
* @throws \OutOfBoundsException
|
||||||
* @throws UnderflowException If the frame is not coalesced
|
* @throws \InvalidArgumentException If there is an issue with the given masking key
|
||||||
|
* @return Frame
|
||||||
*/
|
*/
|
||||||
public function maskPayload($maskingKey = null) {
|
public function maskPayload($maskingKey = null) {
|
||||||
if (null === $maskingKey) {
|
if (null === $maskingKey) {
|
||||||
@ -246,7 +253,7 @@ class Frame implements FrameInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a mask from the payload
|
* Remove a mask from the payload
|
||||||
* @throws UnderFlowException If the frame is not coalesced
|
* @throws \UnderFlowException If the frame is not coalesced
|
||||||
* @return Frame
|
* @return Frame
|
||||||
*/
|
*/
|
||||||
public function unMaskPayload() {
|
public function unMaskPayload() {
|
||||||
@ -273,9 +280,9 @@ class Frame implements FrameInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply a mask to a string or the payload of the instance
|
* Apply a mask to a string or the payload of the instance
|
||||||
* @param string The 4 character masking key to be applied
|
* @param string $maskingKey The 4 character masking key to be applied
|
||||||
* @param string|null A string to mask or null to use the payload
|
* @param string|null $payload A string to mask or null to use the payload
|
||||||
* @throws UnderflowException If using the payload but enough hasn't been buffered
|
* @throws \UnderflowException If using the payload but enough hasn't been buffered
|
||||||
* @return string The masked string
|
* @return string The masked string
|
||||||
*/
|
*/
|
||||||
public function applyMask($maskingKey, $payload = null) {
|
public function applyMask($maskingKey, $payload = null) {
|
||||||
@ -309,7 +316,7 @@ class Frame implements FrameInterface {
|
|||||||
/**
|
/**
|
||||||
* Gets the decimal value of bits 9 (10th) through 15 inclusive
|
* Gets the decimal value of bits 9 (10th) through 15 inclusive
|
||||||
* @return int
|
* @return int
|
||||||
* @throws UnderflowException If the buffer doesn't have enough data to determine this
|
* @throws \UnderflowException If the buffer doesn't have enough data to determine this
|
||||||
*/
|
*/
|
||||||
protected function getFirstPayloadVal() {
|
protected function getFirstPayloadVal() {
|
||||||
if (-1 === $this->secondByte) {
|
if (-1 === $this->secondByte) {
|
||||||
@ -321,7 +328,7 @@ class Frame implements FrameInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int (7|23|71) Number of bits defined for the payload length in the fame
|
* @return int (7|23|71) Number of bits defined for the payload length in the fame
|
||||||
* @throws UnderflowException
|
* @throws \UnderflowException
|
||||||
*/
|
*/
|
||||||
protected function getNumPayloadBits() {
|
protected function getNumPayloadBits() {
|
||||||
if (-1 === $this->secondByte) {
|
if (-1 === $this->secondByte) {
|
||||||
|
@ -10,7 +10,7 @@ use Guzzle\Http\Message\RequestInterface;
|
|||||||
class HandshakeVerifier {
|
class HandshakeVerifier {
|
||||||
/**
|
/**
|
||||||
* Given an array of the headers this method will run through all verification methods
|
* Given an array of the headers this method will run through all verification methods
|
||||||
* @param Guzzle\Http\Message\RequestInterface
|
* @param \Guzzle\Http\Message\RequestInterface $request
|
||||||
* @return bool TRUE if all headers are valid, FALSE if 1 or more were invalid
|
* @return bool TRUE if all headers are valid, FALSE if 1 or more were invalid
|
||||||
*/
|
*/
|
||||||
public function verifyAll(RequestInterface $request) {
|
public function verifyAll(RequestInterface $request) {
|
||||||
@ -78,7 +78,7 @@ class HandshakeVerifier {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify the Upgrade request to WebSockets.
|
* Verify the Upgrade request to WebSockets.
|
||||||
* @param string MUST equal "websocket"
|
* @param string $val MUST equal "websocket"
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function verifyUpgradeRequest($val) {
|
public function verifyUpgradeRequest($val) {
|
||||||
@ -87,7 +87,7 @@ class HandshakeVerifier {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify the Connection header
|
* Verify the Connection header
|
||||||
* @param string MUST equal "Upgrade"
|
* @param string $val MUST equal "Upgrade"
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function verifyConnection($val) {
|
public function verifyConnection($val) {
|
||||||
|
@ -5,7 +5,7 @@ use Ratchet\WebSocket\Version\FrameInterface;
|
|||||||
|
|
||||||
class Message implements MessageInterface, \Countable {
|
class Message implements MessageInterface, \Countable {
|
||||||
/**
|
/**
|
||||||
* @var SplDoublyLinkedList
|
* @var \SplDoublyLinkedList
|
||||||
*/
|
*/
|
||||||
protected $_frames;
|
protected $_frames;
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ use Guzzle\Http\Message\RequestInterface;
|
|||||||
interface VersionInterface extends MessageInterface {
|
interface VersionInterface extends MessageInterface {
|
||||||
/**
|
/**
|
||||||
* Given an HTTP header, determine if this version should handle the protocol
|
* Given an HTTP header, determine if this version should handle the protocol
|
||||||
* @param Guzzle\Http\Message\RequestInterface
|
* @param \Guzzle\Http\Message\RequestInterface $request
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws UnderflowException If the protocol thinks the headers are still fragmented
|
* @throws \UnderflowException If the protocol thinks the headers are still fragmented
|
||||||
*/
|
*/
|
||||||
function isProtocol(RequestInterface $request);
|
function isProtocol(RequestInterface $request);
|
||||||
|
|
||||||
@ -24,16 +24,16 @@ interface VersionInterface extends MessageInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform the handshake and return the response headers
|
* Perform the handshake and return the response headers
|
||||||
* @param Guzzle\Http\Message\RequestInterface
|
* @param \Guzzle\Http\Message\RequestInterface $request
|
||||||
* @return Guzzle\Http\Message\Response
|
* @return \Guzzle\Http\Message\Response
|
||||||
* @throws UnderflowException If the message hasn't finished buffering (not yet implemented, theoretically will only happen with Hixie version)
|
* @throws \UnderflowException If the message hasn't finished buffering (not yet implemented, theoretically will only happen with Hixie version)
|
||||||
*/
|
*/
|
||||||
function handshake(RequestInterface $request);
|
function handshake(RequestInterface $request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Ratchet\ConnectionInterface
|
* @param \Ratchet\ConnectionInterface $conn
|
||||||
* @param Ratchet\MessageInterface
|
* @param \Ratchet\MessageInterface $coalescedCallback
|
||||||
* @return Ratchet\ConnectionInterface
|
* @return \Ratchet\ConnectionInterface
|
||||||
*/
|
*/
|
||||||
function upgradeConnection(ConnectionInterface $conn, MessageInterface $coalescedCallback);
|
function upgradeConnection(ConnectionInterface $conn, MessageInterface $coalescedCallback);
|
||||||
|
|
||||||
|
@ -22,8 +22,9 @@ class VersionManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the protocol negotiator for the request, if supported
|
* Get the protocol negotiator for the request, if supported
|
||||||
* @param Guzzle\Http\Message\RequestInterface
|
* @param \Guzzle\Http\Message\RequestInterface $request
|
||||||
* @return Ratchet\WebSocket\Version\VersionInterface
|
* @throws \InvalidArgumentException
|
||||||
|
* @return \Ratchet\WebSocket\Version\VersionInterface
|
||||||
*/
|
*/
|
||||||
public function getVersion(RequestInterface $request) {
|
public function getVersion(RequestInterface $request) {
|
||||||
foreach ($this->versions as $version) {
|
foreach ($this->versions as $version) {
|
||||||
@ -36,7 +37,7 @@ class VersionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Guzzle\Http\Message\RequestInterface
|
* @param \Guzzle\Http\Message\RequestInterface
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isVersionEnabled(RequestInterface $request) {
|
public function isVersionEnabled(RequestInterface $request) {
|
||||||
@ -51,8 +52,8 @@ class VersionManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable support for a specific version of the WebSocket protocol
|
* Enable support for a specific version of the WebSocket protocol
|
||||||
* @param Ratchet\WebSocket\Version\VersionInterface
|
* @param \Ratchet\WebSocket\Version\VersionInterface $version
|
||||||
* @return HandshakeNegotiator
|
* @return VersionManager
|
||||||
*/
|
*/
|
||||||
public function enableVersion(VersionInterface $version) {
|
public function enableVersion(VersionInterface $version) {
|
||||||
$this->versions[$version->getVersionNumber()] = $version;
|
$this->versions[$version->getVersionNumber()] = $version;
|
||||||
@ -68,8 +69,8 @@ class VersionManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable support for a specific WebSocket protocol version
|
* Disable support for a specific WebSocket protocol version
|
||||||
* @param int The version ID to un-support
|
* @param int $versionId The version ID to un-support
|
||||||
* @return HandshakeNegotiator
|
* @return VersionManager
|
||||||
*/
|
*/
|
||||||
public function disableVersion($versionId) {
|
public function disableVersion($versionId) {
|
||||||
unset($this->versions[$versionId]);
|
unset($this->versions[$versionId]);
|
||||||
|
@ -29,12 +29,12 @@ class WsServer implements MessageComponentInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Decorated component
|
* Decorated component
|
||||||
* @var Ratchet\MessageComponentInterface
|
* @var \Ratchet\MessageComponentInterface
|
||||||
*/
|
*/
|
||||||
protected $_decorating;
|
protected $_decorating;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var SplObjectStorage
|
* @var \SplObjectStorage
|
||||||
*/
|
*/
|
||||||
protected $connections;
|
protected $connections;
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ class WsServer implements MessageComponentInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* UTF-8 validator
|
* UTF-8 validator
|
||||||
* @var Ratchet\WebSocket\Encoding\ValidatorInterface
|
* @var \Ratchet\WebSocket\Encoding\ValidatorInterface
|
||||||
*/
|
*/
|
||||||
protected $validator;
|
protected $validator;
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class WsServer implements MessageComponentInterface {
|
|||||||
private $isSpGenerated = false;
|
private $isSpGenerated = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Ratchet\MessageComponentInterface Your application to run with WebSockets
|
* @param \Ratchet\MessageComponentInterface $component Your application to run with WebSockets
|
||||||
* If you want to enable sub-protocols have your component implement WsServerInterface as well
|
* If you want to enable sub-protocols have your component implement WsServerInterface as well
|
||||||
*/
|
*/
|
||||||
public function __construct(MessageComponentInterface $component) {
|
public function __construct(MessageComponentInterface $component) {
|
||||||
@ -155,7 +155,7 @@ class WsServer implements MessageComponentInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable a specific version of the WebSocket protocol
|
* Disable a specific version of the WebSocket protocol
|
||||||
* @param int Version ID to disable
|
* @param int $versionId Version ID to disable
|
||||||
* @return WsServer
|
* @return WsServer
|
||||||
*/
|
*/
|
||||||
public function disableVersion($versionId) {
|
public function disableVersion($versionId) {
|
||||||
@ -192,7 +192,7 @@ class WsServer implements MessageComponentInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Traversable
|
* @param \Traversable|null $requested
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getSubProtocolString(\Traversable $requested = null) {
|
protected function getSubProtocolString(\Traversable $requested = null) {
|
||||||
@ -213,8 +213,9 @@ class WsServer implements MessageComponentInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Close a connection with an HTTP response
|
* Close a connection with an HTTP response
|
||||||
* @param Ratchet\ConnectionInterface
|
* @param \Ratchet\ConnectionInterface $conn
|
||||||
* @param int HTTP status code
|
* @param int $code HTTP status code
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function close(ConnectionInterface $conn, $code = 400) {
|
protected function close(ConnectionInterface $conn, $code = 400) {
|
||||||
$response = new Response($code, array(
|
$response = new Response($code, array(
|
||||||
|
Loading…
Reference in New Issue
Block a user