API documentation
This commit is contained in:
parent
fbe1d1763b
commit
faa4083b81
@ -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)) {
|
||||||
|
@ -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');
|
||||||
*/
|
*/
|
||||||
|
@ -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();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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;
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user