API documentation

This commit is contained in:
Chris Boden 2012-07-22 11:25:55 -04:00
parent b43c29a183
commit 002ae9419c
9 changed files with 41 additions and 8 deletions

View File

@ -1,11 +1,15 @@
<?php <?php
namespace Ratchet; namespace Ratchet;
/**
* The version of Ratchet being used
* @var string
*/
const VERSION = 'Ratchet/0.2b'; const VERSION = 'Ratchet/0.2b';
/** /**
* A proxy object representing a connection to the application * A proxy object representing a connection to the application
* This acts as a container to storm data (in memory) about the connection * This acts as a container to store data (in memory) about the connection
*/ */
interface ConnectionInterface { interface ConnectionInterface {
/** /**

View File

@ -19,6 +19,7 @@ class IpBlackList implements MessageComponentInterface {
} }
/** /**
* 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 yoru application * @param string IP address to block from connecting to yoru application
* @return IpBlackList * @return IpBlackList
*/ */
@ -29,6 +30,7 @@ class IpBlackList implements MessageComponentInterface {
} }
/** /**
* Unblock an address so they can access your application again
* @param string IP address to unblock from connecting to yoru application * @param string IP address to unblock from connecting to yoru application
* @return IpBlackList * @return IpBlackList
*/ */

View File

@ -5,9 +5,11 @@ use Ratchet\WebSocket\WsServerInterface;
use Ratchet\ConnectionInterface; use Ratchet\ConnectionInterface;
/** /**
* This class just makes it 1 step easier to use Topic objects in WAMP * Enable support for the offical WAMP sub-protocol in your application
* If you're looking at the source code, look in the __construct of this * WAMP allows for Pub/Sub and RPC
* class and use that to make your application instead of using this * @link http://wamp.ws The WAMP specification
* @link https://github.com/oberstet/AutobahnJS Souce for client side library
* @link http://autobahn.s3.amazonaws.com/js/autobahn.min.js Minified client side library
*/ */
class WampServer implements MessageComponentInterface, WsServerInterface { class WampServer implements MessageComponentInterface, WsServerInterface {
/** /**
@ -16,7 +18,9 @@ class WampServer implements MessageComponentInterface, WsServerInterface {
private $wampProtocol; private $wampProtocol;
/** /**
* {@inheritdoc} * This class just makes it 1 step easier to use Topic objects in WAMP
* If you're looking at the source code, look in the __construct of this
* class and use that to make your application instead of using this
*/ */
public function __construct(WampServerInterface $app) { public function __construct(WampServerInterface $app) {
$this->wampProtocol = new ServerProtocol(new TopicManager($app)); $this->wampProtocol = new ServerProtocol(new TopicManager($app));

View File

@ -4,7 +4,7 @@ use Ratchet\ComponentInterface;
use Ratchet\ConnectionInterface; use Ratchet\ConnectionInterface;
/** /**
* A (not literal) extension of Ratchet\ConnectionInterface * An extension of Ratchet\ComponentInterface to server a WAMP application
* onMessage is replaced by various types of messages for this protocol (pub/sub or rpc) * onMessage is replaced by various types of messages for this protocol (pub/sub or rpc)
*/ */
interface WampServerInterface extends ComponentInterface { interface WampServerInterface extends ComponentInterface {

View File

@ -6,6 +6,11 @@ use Ratchet\WebSocket\Guzzle\Http\Message\RequestFactory;
use Ratchet\WebSocket\Version\VersionInterface; use Ratchet\WebSocket\Version\VersionInterface;
use Guzzle\Http\Message\RequestInterface; use Guzzle\Http\Message\RequestInterface;
/**
* This class receives streaming data from a client request
* and parses HTTP headers, returning a Guzzle Request object
* once it's been buffered
*/
class HttpRequestParser implements MessageInterface { class HttpRequestParser implements MessageInterface {
const EOM = "\r\n\r\n"; const EOM = "\r\n\r\n";
@ -20,7 +25,7 @@ class HttpRequestParser implements MessageInterface {
* @param Ratchet\ConnectionInterface * @param Ratchet\ConnectionInterface
* @param string Data stream to buffer * @param string Data stream to buffer
* @return Guzzle\Http\Message\RequestInterface|null * @return Guzzle\Http\Message\RequestInterface|null
* @throws OverflowException * @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)) {

View File

@ -12,6 +12,7 @@ use Guzzle\Http\Message\RequestInterface;
use Guzzle\Http\Message\Response; use Guzzle\Http\Message\Response;
/** /**
* The latest version of the WebSocket protocol
* @link http://tools.ietf.org/html/rfc6455 * @link http://tools.ietf.org/html/rfc6455
* @todo Unicode: return mb_convert_encoding(pack("N",$u), mb_internal_encoding(), 'UCS-4BE'); * @todo Unicode: return mb_convert_encoding(pack("N",$u), mb_internal_encoding(), 'UCS-4BE');
*/ */

View File

@ -3,9 +3,21 @@ namespace Ratchet\WebSocket;
use Ratchet\WebSocket\Version\VersionInterface; use Ratchet\WebSocket\Version\VersionInterface;
use Guzzle\Http\Message\RequestInterface; use Guzzle\Http\Message\RequestInterface;
/**
* Manage the various versions of the WebSocket protocol
* This accepts interfaces of versions to enable/disable
*/
class VersionManager { class VersionManager {
/**
* The header string to let clients know which versions are supported
* @var string
*/
private $versionString = ''; private $versionString = '';
/**
* Storage of each version enabled
* @var array
*/
protected $versions = array(); protected $versions = array();
/** /**

View File

@ -29,7 +29,7 @@ class WsServer implements MessageComponentInterface {
/** /**
* Decorated component * Decorated component
* @var Ratchet\MessageComponentInterface|WsServerInterface * @var Ratchet\MessageComponentInterface
*/ */
protected $_decorating; protected $_decorating;
@ -46,6 +46,7 @@ class WsServer implements MessageComponentInterface {
protected $acceptedSubProtocols = array(); protected $acceptedSubProtocols = array();
/** /**
* UTF-8 validator
* @var Ratchet\WebSocket\Encoding\ValidatorInterface * @var Ratchet\WebSocket\Encoding\ValidatorInterface
*/ */
protected $validator; protected $validator;
@ -58,6 +59,7 @@ class WsServer implements MessageComponentInterface {
/** /**
* @param Ratchet\MessageComponentInterface Your application to run with WebSockets * @param Ratchet\MessageComponentInterface 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) { public function __construct(MessageComponentInterface $component) {
$this->reqParser = new HttpRequestParser; $this->reqParser = new HttpRequestParser;

View File

@ -1,6 +1,9 @@
<?php <?php
namespace Ratchet\WebSocket; namespace Ratchet\WebSocket;
/**
* WebSocket Server Interface
*/
interface WsServerInterface { interface WsServerInterface {
/** /**
* If any component in a stack supports a WebSocket sub-protocol return each supported in an array * If any component in a stack supports a WebSocket sub-protocol return each supported in an array