CS and API docs
This commit is contained in:
parent
710ec2535f
commit
5f80c291b7
@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Ratchet;
|
namespace Ratchet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps ConnectionInterface objects via the decorator pattern but allows
|
||||||
|
* parameters to bubble through with magic methods
|
||||||
|
*/
|
||||||
abstract class AbstractConnectionDecorator implements ConnectionInterface {
|
abstract class AbstractConnectionDecorator implements ConnectionInterface {
|
||||||
/**
|
/**
|
||||||
* @var ConnectionInterface
|
* @var ConnectionInterface
|
||||||
|
@ -3,6 +3,10 @@ namespace Ratchet;
|
|||||||
|
|
||||||
const VERSION = 'Ratchet/0.1';
|
const VERSION = 'Ratchet/0.1';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A proxy object representing a connection to the application
|
||||||
|
* This acts as a container to storm data (in memory) about the connection
|
||||||
|
*/
|
||||||
interface ConnectionInterface {
|
interface ConnectionInterface {
|
||||||
/**
|
/**
|
||||||
* Send data to the connection
|
* Send data to the connection
|
||||||
|
@ -4,8 +4,7 @@ use Ratchet\ConnectionInterface;
|
|||||||
use React\Socket\ConnectionInterface as ReactConn;
|
use React\Socket\ConnectionInterface as ReactConn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A proxy object representing a connection to the application
|
* {@inheritdoc}
|
||||||
* This acts as a container to storm data (in memory) about the connection
|
|
||||||
*/
|
*/
|
||||||
class IoConnection implements ConnectionInterface {
|
class IoConnection implements ConnectionInterface {
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Ratchet\Wamp;
|
namespace Ratchet\Wamp;
|
||||||
|
|
||||||
class JSONException extends Exception {
|
class JsonException extends Exception {
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$code = json_last_error();
|
$code = json_last_error();
|
||||||
|
|
@ -5,6 +5,8 @@ use Ratchet\AbstractConnectionDecorator;
|
|||||||
use Ratchet\Wamp\WampServer as WAMP;
|
use Ratchet\Wamp\WampServer 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 {
|
class WampConnection extends AbstractConnectionDecorator {
|
||||||
|
@ -72,13 +72,13 @@ class WampServer implements WsServerInterface {
|
|||||||
/**
|
/**
|
||||||
* @{inheritdoc}
|
* @{inheritdoc}
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @throws JSONException
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
public function onMessage(ConnectionInterface $from, $msg) {
|
public function onMessage(ConnectionInterface $from, $msg) {
|
||||||
$from = $this->connections[$from];
|
$from = $this->connections[$from];
|
||||||
|
|
||||||
if (null === ($json = @json_decode($msg, true))) {
|
if (null === ($json = @json_decode($msg, true))) {
|
||||||
throw new JSONException;
|
throw new JsonException;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($json[0]) {
|
switch ($json[0]) {
|
||||||
|
@ -3,6 +3,7 @@ namespace Ratchet\WebSocket;
|
|||||||
use Ratchet\AbstractConnectionDecorator;
|
use Ratchet\AbstractConnectionDecorator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
* @property stdClass $WebSocket
|
* @property stdClass $WebSocket
|
||||||
*/
|
*/
|
||||||
class WsConnection extends AbstractConnectionDecorator {
|
class WsConnection extends AbstractConnectionDecorator {
|
||||||
|
Loading…
Reference in New Issue
Block a user