API documentation

This commit is contained in:
Chris Boden 2012-07-22 11:25:55 -04:00
parent fbe1d1763b
commit faa4083b81
5 changed files with 25 additions and 2 deletions

View File

@ -6,6 +6,11 @@ use Ratchet\WebSocket\Guzzle\Http\Message\RequestFactory;
use Ratchet\WebSocket\Version\VersionInterface;
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 {
const EOM = "\r\n\r\n";
@ -20,7 +25,7 @@ class HttpRequestParser implements MessageInterface {
* @param Ratchet\ConnectionInterface
* @param string Data stream to buffer
* @return Guzzle\Http\Message\RequestInterface|null
* @throws OverflowException
* @throws OverflowException If the message buffer has become too large
*/
public function onMessage(ConnectionInterface $context, $data) {
if (!isset($context->httpBuffer)) {

View File

@ -12,6 +12,7 @@ use Guzzle\Http\Message\RequestInterface;
use Guzzle\Http\Message\Response;
/**
* The latest version of the WebSocket protocol
* @link http://tools.ietf.org/html/rfc6455
* @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 Guzzle\Http\Message\RequestInterface;
/**
* Manage the various versions of the WebSocket protocol
* This accepts interfaces of versions to enable/disable
*/
class VersionManager {
/**
* The header string to let clients know which versions are supported
* @var string
*/
private $versionString = '';
/**
* Storage of each version enabled
* @var array
*/
protected $versions = array();
/**

View File

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

View File

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