OCD API documentation updates
This commit is contained in:
parent
ffd29053bd
commit
e7887a4b17
@ -8,24 +8,24 @@ namespace Ratchet;
|
||||
interface ComponentInterface {
|
||||
/**
|
||||
* 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
|
||||
* @throws Exception
|
||||
* @param ConnectionInterface $conn 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\Connection The socket/connection that is closing/closed
|
||||
* @throws Exception
|
||||
* @param ConnectionInterface $conn The socket/connection that is closing/closed
|
||||
* @throws \Exception
|
||||
*/
|
||||
function onClose(ConnectionInterface $conn);
|
||||
|
||||
/**
|
||||
* 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\Connection
|
||||
* @param \Exception
|
||||
* @throws Exception
|
||||
* @param ConnectionInterface $conn
|
||||
* @param \Exception $e
|
||||
* @throws \Exception
|
||||
*/
|
||||
function onError(ConnectionInterface $conn, \Exception $e);
|
||||
}
|
@ -14,7 +14,7 @@ const VERSION = 'Ratchet/0.2.3';
|
||||
interface ConnectionInterface {
|
||||
/**
|
||||
* Send data to the connection
|
||||
* @param string
|
||||
* @param string $data
|
||||
* @return ConnectionInterface
|
||||
*/
|
||||
function send($data);
|
||||
|
@ -4,8 +4,8 @@ namespace Ratchet;
|
||||
interface MessageInterface {
|
||||
/**
|
||||
* Triggered when a client sends data through the socket
|
||||
* @param \Ratchet\ConnectionInterface The socket/connection that sent the message to your application
|
||||
* @param string The message received
|
||||
* @param \Ratchet\ConnectionInterface $from The socket/connection that sent the message to your application
|
||||
* @param string $msg The message received
|
||||
* @throws \Exception
|
||||
*/
|
||||
function onMessage(ConnectionInterface $from, $msg);
|
||||
|
@ -45,15 +45,16 @@ class FlashPolicy implements MessageComponentInterface {
|
||||
/**
|
||||
* 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
|
||||
* 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 (.)
|
||||
* @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.
|
||||
* Ranges can be used with individual ports when separated with a comma. A single wildcard (*) can
|
||||
* be used to allow all ports.
|
||||
* @param bool
|
||||
* @param bool $secure
|
||||
* @throws \UnexpectedValueException
|
||||
* @return FlashPolicy
|
||||
*/
|
||||
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
|
||||
* crossdomain.xml.
|
||||
*
|
||||
* @param string
|
||||
* @param string $permittedCrossDomainPolicies
|
||||
* @throws \UnexpectedValueException
|
||||
* @return FlashPolicy
|
||||
*/
|
||||
public function setSiteControl($permittedCrossDomainPolicies = 'all') {
|
||||
@ -124,7 +126,8 @@ class FlashPolicy implements MessageComponentInterface {
|
||||
/**
|
||||
* Builds the crossdomain file based on the template policy
|
||||
*
|
||||
* @return SimpleXMLElement
|
||||
* @throws \UnexpectedValueException
|
||||
* @return \SimpleXMLElement
|
||||
*/
|
||||
public function renderPolicy() {
|
||||
$policy = new \SimpleXMLElement($this->_policy);
|
||||
@ -154,7 +157,7 @@ class FlashPolicy implements MessageComponentInterface {
|
||||
/**
|
||||
* Make sure the proper site control was passed
|
||||
*
|
||||
* @param string
|
||||
* @param string $permittedCrossDomainPolicies
|
||||
* @return bool
|
||||
*/
|
||||
public function validateSiteControl($permittedCrossDomainPolicies) {
|
||||
@ -165,7 +168,7 @@ class FlashPolicy implements MessageComponentInterface {
|
||||
/**
|
||||
* Validate for proper domains (wildcards allowed)
|
||||
*
|
||||
* @param string
|
||||
* @param string $domain
|
||||
* @return bool
|
||||
*/
|
||||
public function validateDomain($domain) {
|
||||
@ -175,7 +178,7 @@ class FlashPolicy implements MessageComponentInterface {
|
||||
/**
|
||||
* Make sure valid ports were passed
|
||||
*
|
||||
* @param string
|
||||
* @param string $port
|
||||
* @return bool
|
||||
*/
|
||||
public function validatePorts($port) {
|
||||
|
@ -8,10 +8,14 @@ use React\Socket\ConnectionInterface as ReactConn;
|
||||
*/
|
||||
class IoConnection implements ConnectionInterface {
|
||||
/**
|
||||
* @var React\Socket\ConnectionInterface
|
||||
* @var \React\Socket\ConnectionInterface
|
||||
*/
|
||||
protected $conn;
|
||||
|
||||
|
||||
/**
|
||||
* @param \React\Socket\ConnectionInterface $conn
|
||||
*/
|
||||
public function __construct(ReactConn $conn) {
|
||||
$this->conn = $conn;
|
||||
}
|
||||
|
@ -12,25 +12,25 @@ use React\Socket\Server as Reactor;
|
||||
*/
|
||||
class IoServer {
|
||||
/**
|
||||
* @var React\EventLoop\LoopInterface
|
||||
* @var \React\EventLoop\LoopInterface
|
||||
*/
|
||||
public $loop;
|
||||
|
||||
/**
|
||||
* @var Ratchet\MessageComponentInterface
|
||||
* @var \Ratchet\MessageComponentInterface
|
||||
*/
|
||||
public $app;
|
||||
|
||||
/**
|
||||
* Array of React event handlers
|
||||
* @var SplFixedArray
|
||||
* @var \SplFixedArray
|
||||
*/
|
||||
protected $handlers;
|
||||
|
||||
/**
|
||||
* @param Ratchet\MessageComponentInterface The Ratchet application stack to host
|
||||
* @param React\Socket\ServerInterface 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 \Ratchet\MessageComponentInterface $app The Ratchet application stack to host
|
||||
* @param \React\Socket\ServerInterface $socket The React socket server 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) {
|
||||
gc_enable();
|
||||
@ -49,10 +49,10 @@ class IoServer {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ratchet\MessageComponentInterface The application that I/O will call when events are received
|
||||
* @param int The port to server sockets on
|
||||
* @param string The address to receive sockets on (0.0.0.0 means receive connections from any)
|
||||
* @return Ratchet\Server\IoServer
|
||||
* @param \Ratchet\MessageComponentInterface $component The application that I/O will call when events are received
|
||||
* @param int $port The port to server sockets on
|
||||
* @param string $address The address to receive sockets on (0.0.0.0 means receive connections from any)
|
||||
* @return IoServer
|
||||
*/
|
||||
public static function factory(MessageComponentInterface $component, $port = 80, $address = '0.0.0.0') {
|
||||
$loop = LoopFactory::create();
|
||||
@ -64,7 +64,7 @@ class IoServer {
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (null === $this->loop) {
|
||||
@ -78,6 +78,7 @@ class IoServer {
|
||||
|
||||
/**
|
||||
* Triggered when a new connection is received from React
|
||||
* @param \React\Socket\ConnectionInterface $conn
|
||||
*/
|
||||
public function handleConnect($conn) {
|
||||
$conn->decor = new IoConnection($conn);
|
||||
@ -94,8 +95,8 @@ class IoServer {
|
||||
|
||||
/**
|
||||
* Data has been received from React
|
||||
* @param string
|
||||
* @param React\Socket\Connection
|
||||
* @param string $data
|
||||
* @param \React\Socket\ConnectionInterface $conn
|
||||
*/
|
||||
public function handleData($data, $conn) {
|
||||
try {
|
||||
@ -107,7 +108,7 @@ class IoServer {
|
||||
|
||||
/**
|
||||
* A connection has been closed by React
|
||||
* @param React\Socket\Connection
|
||||
* @param \React\Socket\ConnectionInterface $conn
|
||||
*/
|
||||
public function handleEnd($conn) {
|
||||
try {
|
||||
@ -121,8 +122,8 @@ class IoServer {
|
||||
|
||||
/**
|
||||
* An error has occurred, let the listening application know
|
||||
* @param Exception
|
||||
* @param React\Socket\Connection
|
||||
* @param \Exception $e
|
||||
* @param \React\Socket\ConnectionInterface $conn
|
||||
*/
|
||||
public function handleError(\Exception $e, $conn) {
|
||||
$this->app->onError($conn->decor, $e);
|
||||
|
@ -10,17 +10,20 @@ class IpBlackList implements MessageComponentInterface {
|
||||
protected $_blacklist = array();
|
||||
|
||||
/**
|
||||
* @var Ratchet\MessageComponentInterface
|
||||
* @var \Ratchet\MessageComponentInterface
|
||||
*/
|
||||
protected $_decorating;
|
||||
|
||||
/**
|
||||
* @param \Ratchet\MessageComponentInterface $component
|
||||
*/
|
||||
public function __construct(MessageComponentInterface $component) {
|
||||
$this->_decorating = $component;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function blockAddress($ip) {
|
||||
@ -31,7 +34,7 @@ class IpBlackList implements MessageComponentInterface {
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function unblockAddress($ip) {
|
||||
@ -43,7 +46,7 @@ class IpBlackList implements MessageComponentInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @param string $address
|
||||
* @return bool
|
||||
*/
|
||||
public function isBlocked($address) {
|
||||
@ -59,7 +62,7 @@ class IpBlackList implements MessageComponentInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @param string $address
|
||||
* @return string
|
||||
*/
|
||||
public function filterAddress($address) {
|
||||
|
@ -12,7 +12,7 @@ class PhpHandler implements HandlerInterface {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @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) {
|
||||
$returnData = array();
|
||||
|
@ -16,33 +16,33 @@ use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;
|
||||
*/
|
||||
class SessionProvider implements MessageComponentInterface, WsServerInterface {
|
||||
/**
|
||||
* @var Ratchet\MessageComponentInterface
|
||||
* @var \Ratchet\MessageComponentInterface
|
||||
*/
|
||||
protected $_app;
|
||||
|
||||
/**
|
||||
* Selected handler storage assigned by the developer
|
||||
* @var SessionHandlerInterface
|
||||
* @var \SessionHandlerInterface
|
||||
*/
|
||||
protected $_handler;
|
||||
|
||||
/**
|
||||
* Null storage handler if no previous session was found
|
||||
* @var SessionHandlerInterface
|
||||
* @var \SessionHandlerInterface
|
||||
*/
|
||||
protected $_null;
|
||||
|
||||
/**
|
||||
* @var Ratchet\Session\Serialize\HandlerInterface
|
||||
* @var \Ratchet\Session\Serialize\HandlerInterface
|
||||
*/
|
||||
protected $_serializer;
|
||||
|
||||
/**
|
||||
* @param Ratchet\MessageComponentInterface
|
||||
* @param SessionHandlerInterface
|
||||
* @param array
|
||||
* @param Ratchet\Session\Serialize\HandlerInterface
|
||||
* @throws RuntimeException If unable to match serialization methods
|
||||
* @param \Ratchet\MessageComponentInterface $app
|
||||
* @param \SessionHandlerInterface $handler
|
||||
* @param array $options
|
||||
* @param \Ratchet\Session\Serialize\HandlerInterface $serializer
|
||||
* @throws \RuntimeExcpetion
|
||||
*/
|
||||
public function __construct(MessageComponentInterface $app, \SessionHandlerInterface $handler, array $options = array(), HandlerInterface $serializer = null) {
|
||||
$this->_app = $app;
|
||||
@ -124,7 +124,7 @@ class SessionProvider implements MessageComponentInterface, WsServerInterface {
|
||||
/**
|
||||
* Set all the php session. ini options
|
||||
* © Symfony
|
||||
* @param array
|
||||
* @param array $options
|
||||
* @return array
|
||||
*/
|
||||
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
|
||||
*/
|
||||
protected function toClassCase($langDef) {
|
||||
|
@ -45,9 +45,8 @@ class VirtualProxy extends SessionHandlerProxy {
|
||||
}
|
||||
|
||||
/**
|
||||
* DO NOT CALL THIS METHOD
|
||||
* @param string
|
||||
* @throws RuntimeException
|
||||
* DO NOT CALL THIS METHOD
|
||||
* @internal
|
||||
*/
|
||||
public function setName($name) {
|
||||
throw new \RuntimeException("Can not change session name in VirtualProxy");
|
||||
|
@ -6,14 +6,14 @@ use Ratchet\Session\Serialize\HandlerInterface;
|
||||
|
||||
class VirtualSessionStorage extends NativeSessionStorage {
|
||||
/**
|
||||
* @var Ratchet\Session\Serialize\HandlerInterface
|
||||
* @var \Ratchet\Session\Serialize\HandlerInterface
|
||||
*/
|
||||
protected $_serializer;
|
||||
|
||||
/**
|
||||
* @param SessionHandlerInterface
|
||||
* @param string The ID of the session to retrieve
|
||||
* @param Ratchet\Session\Serialize\HandlerInterface
|
||||
* @param \SessionHandlerInterface $handler
|
||||
* @param string $sessionId The ID of the session to retrieve
|
||||
* @param \Ratchet\Session\Serialize\HandlerInterface $serializer
|
||||
*/
|
||||
public function __construct(\SessionHandlerInterface $handler, $sessionId, HandlerInterface $serializer) {
|
||||
$this->setSaveHandler($handler);
|
||||
|
@ -41,12 +41,12 @@ class ServerProtocol implements MessageComponentInterface, WsServerInterface {
|
||||
protected $_decorating;
|
||||
|
||||
/**
|
||||
* @var SplObjectStorage
|
||||
* @var \SplObjectStorage
|
||||
*/
|
||||
protected $connections;
|
||||
|
||||
/**
|
||||
* @param WampServerInterface An class to propagate calls through
|
||||
* @param WampServerInterface $serverComponent An class to propagate calls through
|
||||
*/
|
||||
public function __construct(WampServerInterface $serverComponent) {
|
||||
$this->_decorating = $serverComponent;
|
||||
@ -79,7 +79,7 @@ class ServerProtocol implements MessageComponentInterface, WsServerInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function onMessage(ConnectionInterface $from, $msg) {
|
||||
|
@ -11,7 +11,7 @@ class Topic implements \IteratorAggregate, \Countable {
|
||||
private $subscribers;
|
||||
|
||||
/**
|
||||
* @param string Unique ID for this object
|
||||
* @param string $topicId Unique ID for this object
|
||||
*/
|
||||
public function __construct($topicId) {
|
||||
$this->id = $topicId;
|
||||
@ -31,7 +31,7 @@ class Topic implements \IteratorAggregate, \Countable {
|
||||
|
||||
/**
|
||||
* Send a message to all the connections in this topic
|
||||
* @param string
|
||||
* @param string $msg
|
||||
* @return Topic
|
||||
*/
|
||||
public function broadcast($msg) {
|
||||
@ -43,7 +43,7 @@ class Topic implements \IteratorAggregate, \Countable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WampConnection
|
||||
* @param WampConnection $conn
|
||||
* @return boolean
|
||||
*/
|
||||
public function has(ConnectionInterface $conn) {
|
||||
@ -51,7 +51,7 @@ class Topic implements \IteratorAggregate, \Countable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WampConnection
|
||||
* @param WampConnection $conn
|
||||
* @return Topic
|
||||
*/
|
||||
public function add(ConnectionInterface $conn) {
|
||||
@ -61,7 +61,7 @@ class Topic implements \IteratorAggregate, \Countable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WampConnection
|
||||
* @param WampConnection $conn
|
||||
* @return Topic
|
||||
*/
|
||||
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
|
||||
* representing a client. Methods on this Connection are therefore different.
|
||||
* @property stdClass $WAMP
|
||||
* @property \stdClass $WAMP
|
||||
*/
|
||||
class WampConnection extends AbstractConnectionDecorator {
|
||||
/**
|
||||
@ -25,8 +25,9 @@ class WampConnection extends AbstractConnectionDecorator {
|
||||
|
||||
/**
|
||||
* Successfully respond to a call made by the client
|
||||
* @param string The unique ID given by the client to respond to
|
||||
* @param array An array of data to return to the client
|
||||
* @param string $id The unique ID given by the client to respond to
|
||||
* @param array $data An array of data to return to the client
|
||||
* @return WampConnection
|
||||
*/
|
||||
public function callResult($id, array $data = array()) {
|
||||
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
|
||||
* @param string The unique ID given by the client to respond to
|
||||
* @param string The URI given to identify the specific error
|
||||
* @param string A developer-oriented description of the error
|
||||
* @param string|null An optional human readable detail message to send back
|
||||
* @param string $id The unique ID given by the client to respond to
|
||||
* @param string $errorUri The URI given to identify the specific error
|
||||
* @param string $desc A developer-oriented description of the error
|
||||
* @param string $details An optional human readable detail message to send back
|
||||
* @return WampConnection
|
||||
*/
|
||||
public function callError($id, $errorUri, $desc = '', $details = null) {
|
||||
if ($errorUri instanceof Topic) {
|
||||
@ -54,16 +56,18 @@ class WampConnection extends AbstractConnectionDecorator {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string The topic to broadcast to
|
||||
* @param mixed Data to send with the event. Anything that is json'able
|
||||
* @param string $topic The topic to broadcast to
|
||||
* @param mixed $msg Data to send with the event. Anything that is json'able
|
||||
* @return WampConnection
|
||||
*/
|
||||
public function event($topic, $msg) {
|
||||
return $this->send(json_encode(array(WAMP::MSG_EVENT, (string)$topic, $msg)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @param string
|
||||
* @param string $curie
|
||||
* @param string $uri
|
||||
* @return WampConnection
|
||||
*/
|
||||
public function prefix($curie, $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
|
||||
* @param string
|
||||
* @param string $uri
|
||||
* @return string
|
||||
*/
|
||||
public function getUri($uri) {
|
||||
|
@ -10,34 +10,34 @@ use Ratchet\ConnectionInterface;
|
||||
interface WampServerInterface extends ComponentInterface {
|
||||
/**
|
||||
* An RPC call has been received
|
||||
* @param Ratchet\ConnectionInterface
|
||||
* @param string The unique ID of the RPC, required to respond to
|
||||
* @param string|Topic The topic to execute the call against
|
||||
* @param array Call parameters received from the client
|
||||
* @param \Ratchet\ConnectionInterface $conn
|
||||
* @param string $id The unique ID of the RPC, required to respond to
|
||||
* @param string|Topic $topic The topic to execute the call against
|
||||
* @param array $params Call parameters received from the client
|
||||
*/
|
||||
function onCall(ConnectionInterface $conn, $id, $topic, array $params);
|
||||
|
||||
/**
|
||||
* A request to subscribe to a topic has been made
|
||||
* @param Ratchet\ConnectionInterface
|
||||
* @param string|Topic The topic to subscribe to
|
||||
* @param \Ratchet\ConnectionInterface $conn
|
||||
* @param string|Topic $topic The topic to subscribe to
|
||||
*/
|
||||
function onSubscribe(ConnectionInterface $conn, $topic);
|
||||
|
||||
/**
|
||||
* A request to unsubscribe from a topic has been made
|
||||
* @param Ratchet\ConnectionInterface
|
||||
* @param string|Topic The topic to unsubscribe from
|
||||
* @param \Ratchet\ConnectionInterface $conn
|
||||
* @param string|Topic $topic The topic to unsubscribe from
|
||||
*/
|
||||
function onUnSubscribe(ConnectionInterface $conn, $topic);
|
||||
|
||||
/**
|
||||
* A client is attempting to publish content to a subscribed connections on a URI
|
||||
* @param Ratchet\ConnectionInterface
|
||||
* @param string|Topic The topic the user has attempted to publish to
|
||||
* @param string Payload of the publish
|
||||
* @param array 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 \Ratchet\ConnectionInterface $conn
|
||||
* @param string|Topic $topic The topic the user has attempted to publish to
|
||||
* @param string $event Payload of the publish
|
||||
* @param array $exclude A list of session IDs the message should be excluded from (blacklist)
|
||||
* @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);
|
||||
}
|
@ -49,8 +49,8 @@ class Validator {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string The value to check the encoding
|
||||
* @param string The type of encoding to check against
|
||||
* @param string $str The value to check the encoding
|
||||
* @param string $against The type of encoding to check against
|
||||
* @return bool
|
||||
*/
|
||||
public function checkEncoding($str, $against) {
|
||||
|
@ -4,8 +4,8 @@ namespace Ratchet\WebSocket\Encoding;
|
||||
interface ValidatorInterface {
|
||||
/**
|
||||
* Verify a string matches the encoding type
|
||||
* @param string The string to check
|
||||
* @param string The encoding type to check against
|
||||
* @param string $str The string to check
|
||||
* @param string $encoding The encoding type to check against
|
||||
* @return bool
|
||||
*/
|
||||
function checkEncoding($str, $encoding);
|
||||
|
@ -20,10 +20,10 @@ class HttpRequestParser implements MessageInterface {
|
||||
public $maxSize = 4096;
|
||||
|
||||
/**
|
||||
* @param Ratchet\ConnectionInterface
|
||||
* @param string Data stream to buffer
|
||||
* @return Guzzle\Http\Message\RequestInterface|null
|
||||
* @throws OverflowException If the message buffer has become too large
|
||||
* @param \Ratchet\ConnectionInterface $context
|
||||
* @param string $data Data stream to buffer
|
||||
* @return \Guzzle\Http\Message\RequestInterface|null
|
||||
* @throws \OverflowException If the message buffer has become too large
|
||||
*/
|
||||
public function onMessage(ConnectionInterface $context, $data) {
|
||||
if (!isset($context->httpBuffer)) {
|
||||
@ -47,7 +47,7 @@ class HttpRequestParser implements MessageInterface {
|
||||
|
||||
/**
|
||||
* Determine if the message has been buffered as per the HTTP specification
|
||||
* @param string
|
||||
* @param string $message
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEom($message) {
|
||||
|
@ -34,8 +34,8 @@ class Hixie76 implements VersionInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Guzzle\Http\Message\RequestInterface
|
||||
* @return Guzzle\Http\Message\Response
|
||||
* @param \Guzzle\Http\Message\RequestInterface $request
|
||||
* @return \Guzzle\Http\Message\Response
|
||||
*/
|
||||
public function handshake(RequestInterface $request) {
|
||||
$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 {
|
||||
/**
|
||||
* @param FragmentInterface
|
||||
* @param FrameInterface $fragment
|
||||
* @return MessageInterface
|
||||
*/
|
||||
function addFrame(FrameInterface $fragment);
|
||||
|
@ -31,7 +31,7 @@ class RFC6455 implements VersionInterface {
|
||||
private $closeCodes = array();
|
||||
|
||||
/**
|
||||
* @var Ratchet\WebSocket\Encoding\ValidatorInterface
|
||||
* @var \Ratchet\WebSocket\Encoding\ValidatorInterface
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
@ -78,8 +78,9 @@ class RFC6455 implements VersionInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ratchet\ConnectionInterface
|
||||
* @return Ratchet\WebSocket\Version\RFC6455\Connection
|
||||
* @param \Ratchet\ConnectionInterface $conn
|
||||
* @param \Ratchet\MessageInterface $coalescedCallback
|
||||
* @return \Ratchet\WebSocket\Version\RFC6455\Connection
|
||||
*/
|
||||
public function upgradeConnection(ConnectionInterface $conn, MessageInterface $coalescedCallback) {
|
||||
$upgraded = new Connection($conn);
|
||||
@ -94,8 +95,8 @@ class RFC6455 implements VersionInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ratchet\WebSocket\Version\RFC6455\Connection
|
||||
* @param string
|
||||
* @param \Ratchet\WebSocket\Version\RFC6455\Connection $from
|
||||
* @param string $data
|
||||
*/
|
||||
public function onMessage(ConnectionInterface $from, $data) {
|
||||
$overflow = '';
|
||||
@ -214,6 +215,9 @@ class RFC6455 implements VersionInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $payload
|
||||
* @param bool|null $final
|
||||
* @param int|null $opcode
|
||||
* @return RFC6455\Frame
|
||||
*/
|
||||
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
|
||||
* @param string
|
||||
* @param string $key
|
||||
* @return string
|
||||
* @internal
|
||||
*/
|
||||
|
@ -62,6 +62,12 @@ class Frame implements FrameInterface {
|
||||
*/
|
||||
protected $secondByte = -1;
|
||||
|
||||
|
||||
/**
|
||||
* @param string|null $payload
|
||||
* @param bool $final
|
||||
* @param int $opcode
|
||||
*/
|
||||
public function __construct($payload = null, $final = true, $opcode = 1) {
|
||||
if (null === $payload) {
|
||||
return;
|
||||
@ -136,7 +142,7 @@ class Frame implements FrameInterface {
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
* @throws UnderflowException
|
||||
* @throws \UnderflowException
|
||||
*/
|
||||
public function getRsv1() {
|
||||
if (-1 === $this->firstByte) {
|
||||
@ -148,7 +154,7 @@ class Frame implements FrameInterface {
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
* @throws UnderflowException
|
||||
* @throws \UnderflowException
|
||||
*/
|
||||
public function getRsv2() {
|
||||
if (-1 === $this->firstByte) {
|
||||
@ -160,7 +166,7 @@ class Frame implements FrameInterface {
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
* @throws UnderflowException
|
||||
* @throws \UnderflowException
|
||||
*/
|
||||
public function getRsv3() {
|
||||
if (-1 === $this->firstByte) {
|
||||
@ -215,8 +221,9 @@ class Frame implements FrameInterface {
|
||||
/**
|
||||
* Apply a mask to the payload
|
||||
* @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 UnderflowException If the frame is not coalesced
|
||||
* @throws \OutOfBoundsException
|
||||
* @throws \InvalidArgumentException If there is an issue with the given masking key
|
||||
* @return Frame
|
||||
*/
|
||||
public function maskPayload($maskingKey = null) {
|
||||
if (null === $maskingKey) {
|
||||
@ -246,7 +253,7 @@ class Frame implements FrameInterface {
|
||||
|
||||
/**
|
||||
* Remove a mask from the payload
|
||||
* @throws UnderFlowException If the frame is not coalesced
|
||||
* @throws \UnderFlowException If the frame is not coalesced
|
||||
* @return Frame
|
||||
*/
|
||||
public function unMaskPayload() {
|
||||
@ -273,10 +280,10 @@ class Frame implements FrameInterface {
|
||||
|
||||
/**
|
||||
* Apply a mask to a string or the payload of the instance
|
||||
* @param string The 4 character masking key to be applied
|
||||
* @param string|null A string to mask or null to use the payload
|
||||
* @throws UnderflowException If using the payload but enough hasn't been buffered
|
||||
* @return string The masked string
|
||||
* @param string $maskingKey The 4 character masking key to be applied
|
||||
* @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
|
||||
* @return string The masked string
|
||||
*/
|
||||
public function applyMask($maskingKey, $payload = null) {
|
||||
if (null === $payload) {
|
||||
@ -309,7 +316,7 @@ class Frame implements FrameInterface {
|
||||
/**
|
||||
* Gets the decimal value of bits 9 (10th) through 15 inclusive
|
||||
* @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() {
|
||||
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
|
||||
* @throws UnderflowException
|
||||
* @throws \UnderflowException
|
||||
*/
|
||||
protected function getNumPayloadBits() {
|
||||
if (-1 === $this->secondByte) {
|
||||
|
@ -10,7 +10,7 @@ use Guzzle\Http\Message\RequestInterface;
|
||||
class HandshakeVerifier {
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function verifyAll(RequestInterface $request) {
|
||||
@ -78,7 +78,7 @@ class HandshakeVerifier {
|
||||
|
||||
/**
|
||||
* Verify the Upgrade request to WebSockets.
|
||||
* @param string MUST equal "websocket"
|
||||
* @param string $val MUST equal "websocket"
|
||||
* @return bool
|
||||
*/
|
||||
public function verifyUpgradeRequest($val) {
|
||||
@ -87,7 +87,7 @@ class HandshakeVerifier {
|
||||
|
||||
/**
|
||||
* Verify the Connection header
|
||||
* @param string MUST equal "Upgrade"
|
||||
* @param string $val MUST equal "Upgrade"
|
||||
* @return bool
|
||||
*/
|
||||
public function verifyConnection($val) {
|
||||
|
@ -5,7 +5,7 @@ use Ratchet\WebSocket\Version\FrameInterface;
|
||||
|
||||
class Message implements MessageInterface, \Countable {
|
||||
/**
|
||||
* @var SplDoublyLinkedList
|
||||
* @var \SplDoublyLinkedList
|
||||
*/
|
||||
protected $_frames;
|
||||
|
||||
|
@ -10,9 +10,9 @@ use Guzzle\Http\Message\RequestInterface;
|
||||
interface VersionInterface extends MessageInterface {
|
||||
/**
|
||||
* 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
|
||||
* @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);
|
||||
|
||||
@ -24,16 +24,16 @@ interface VersionInterface extends MessageInterface {
|
||||
|
||||
/**
|
||||
* Perform the handshake and return the response headers
|
||||
* @param Guzzle\Http\Message\RequestInterface
|
||||
* @return Guzzle\Http\Message\Response
|
||||
* @throws UnderflowException If the message hasn't finished buffering (not yet implemented, theoretically will only happen with Hixie version)
|
||||
* @param \Guzzle\Http\Message\RequestInterface $request
|
||||
* @return \Guzzle\Http\Message\Response
|
||||
* @throws \UnderflowException If the message hasn't finished buffering (not yet implemented, theoretically will only happen with Hixie version)
|
||||
*/
|
||||
function handshake(RequestInterface $request);
|
||||
|
||||
/**
|
||||
* @param Ratchet\ConnectionInterface
|
||||
* @param Ratchet\MessageInterface
|
||||
* @return Ratchet\ConnectionInterface
|
||||
* @param \Ratchet\ConnectionInterface $conn
|
||||
* @param \Ratchet\MessageInterface $coalescedCallback
|
||||
* @return \Ratchet\ConnectionInterface
|
||||
*/
|
||||
function upgradeConnection(ConnectionInterface $conn, MessageInterface $coalescedCallback);
|
||||
|
||||
|
@ -22,8 +22,9 @@ class VersionManager {
|
||||
|
||||
/**
|
||||
* Get the protocol negotiator for the request, if supported
|
||||
* @param Guzzle\Http\Message\RequestInterface
|
||||
* @return Ratchet\WebSocket\Version\VersionInterface
|
||||
* @param \Guzzle\Http\Message\RequestInterface $request
|
||||
* @throws \InvalidArgumentException
|
||||
* @return \Ratchet\WebSocket\Version\VersionInterface
|
||||
*/
|
||||
public function getVersion(RequestInterface $request) {
|
||||
foreach ($this->versions as $version) {
|
||||
@ -36,7 +37,7 @@ class VersionManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Guzzle\Http\Message\RequestInterface
|
||||
* @param \Guzzle\Http\Message\RequestInterface
|
||||
* @return bool
|
||||
*/
|
||||
public function isVersionEnabled(RequestInterface $request) {
|
||||
@ -51,8 +52,8 @@ class VersionManager {
|
||||
|
||||
/**
|
||||
* Enable support for a specific version of the WebSocket protocol
|
||||
* @param Ratchet\WebSocket\Version\VersionInterface
|
||||
* @return HandshakeNegotiator
|
||||
* @param \Ratchet\WebSocket\Version\VersionInterface $version
|
||||
* @return VersionManager
|
||||
*/
|
||||
public function enableVersion(VersionInterface $version) {
|
||||
$this->versions[$version->getVersionNumber()] = $version;
|
||||
@ -68,8 +69,8 @@ class VersionManager {
|
||||
|
||||
/**
|
||||
* Disable support for a specific WebSocket protocol version
|
||||
* @param int The version ID to un-support
|
||||
* @return HandshakeNegotiator
|
||||
* @param int $versionId The version ID to un-support
|
||||
* @return VersionManager
|
||||
*/
|
||||
public function disableVersion($versionId) {
|
||||
unset($this->versions[$versionId]);
|
||||
|
@ -29,12 +29,12 @@ class WsServer implements MessageComponentInterface {
|
||||
|
||||
/**
|
||||
* Decorated component
|
||||
* @var Ratchet\MessageComponentInterface
|
||||
* @var \Ratchet\MessageComponentInterface
|
||||
*/
|
||||
protected $_decorating;
|
||||
|
||||
/**
|
||||
* @var SplObjectStorage
|
||||
* @var \SplObjectStorage
|
||||
*/
|
||||
protected $connections;
|
||||
|
||||
@ -47,7 +47,7 @@ class WsServer implements MessageComponentInterface {
|
||||
|
||||
/**
|
||||
* UTF-8 validator
|
||||
* @var Ratchet\WebSocket\Encoding\ValidatorInterface
|
||||
* @var \Ratchet\WebSocket\Encoding\ValidatorInterface
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
@ -58,7 +58,7 @@ class WsServer implements MessageComponentInterface {
|
||||
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
|
||||
*/
|
||||
public function __construct(MessageComponentInterface $component) {
|
||||
@ -155,7 +155,7 @@ class WsServer implements MessageComponentInterface {
|
||||
|
||||
/**
|
||||
* Disable a specific version of the WebSocket protocol
|
||||
* @param int Version ID to disable
|
||||
* @param int $versionId Version ID to disable
|
||||
* @return WsServer
|
||||
*/
|
||||
public function disableVersion($versionId) {
|
||||
@ -192,7 +192,7 @@ class WsServer implements MessageComponentInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Traversable
|
||||
* @param \Traversable|null $requested
|
||||
* @return string
|
||||
*/
|
||||
protected function getSubProtocolString(\Traversable $requested = null) {
|
||||
@ -213,8 +213,9 @@ class WsServer implements MessageComponentInterface {
|
||||
|
||||
/**
|
||||
* Close a connection with an HTTP response
|
||||
* @param Ratchet\ConnectionInterface
|
||||
* @param int HTTP status code
|
||||
* @param \Ratchet\ConnectionInterface $conn
|
||||
* @param int $code HTTP status code
|
||||
* @return void
|
||||
*/
|
||||
protected function close(ConnectionInterface $conn, $code = 400) {
|
||||
$response = new Response($code, array(
|
||||
|
Loading…
Reference in New Issue
Block a user