Merge branch 'refs/heads/flash-policy-fix'

This commit is contained in:
Chris Boden 2014-06-07 10:56:50 -04:00
commit a0db6e6727
3 changed files with 43 additions and 1 deletions

View File

@ -1,5 +1,7 @@
<?php <?php
namespace Ratchet; namespace Ratchet;
use React\EventLoop\LoopInterface; use React\EventLoop\LoopInterface;
use React\EventLoop\Factory as LoopFactory; use React\EventLoop\Factory as LoopFactory;
use React\Socket\Server as Reactor; use React\Socket\Server as Reactor;
@ -75,7 +77,7 @@ class App {
$this->routes = new RouteCollection; $this->routes = new RouteCollection;
$this->_server = new IoServer(new HttpServer(new Router(new UrlMatcher($this->routes, new RequestContext))), $socket, $loop); $this->_server = new IoServer(new HttpServer(new Router(new UrlMatcher($this->routes, new RequestContext))), $socket, $loop);
$policy = new FlashPolicy; $policy = new FlashPolicy();
$policy->addAllowedAccess($httpHost, 80); $policy->addAllowedAccess($httpHost, 80);
$policy->addAllowedAccess($httpHost, $port); $policy->addAllowedAccess($httpHost, $port);
$flashSock = new Reactor($loop); $flashSock = new Reactor($loop);
@ -88,6 +90,24 @@ class App {
} }
} }
/**
* Returns the FlashPolicy running in the flash server. Modifications of this object take effect immediately!
*
* @return FlashPolicy
*/
public function getFlashPolicy() {
return $this->flashServer->app;
}
/**
* Returns the FlashSocket of the flash server.
*
* @return \React\Socket\ServerInterface
*/
public function getFlashSocket() {
return $this->flashServer->socket;
}
/** /**
* Add an endpiont/application to the server * Add an endpiont/application to the server
* @param string $path The URI the client will connect to * @param string $path The URI the client will connect to
@ -131,3 +151,4 @@ class App {
$this->_server->run(); $this->_server->run();
} }
} }

View File

@ -72,6 +72,18 @@ class FlashPolicy implements MessageComponentInterface {
return $this; return $this;
} }
/**
* Removes all domains from the allowed access list.
*
* @return \Ratchet\Server\FlashPolicy
*/
public function clearAllowedAccess() {
$this->_access = array();
$this->_cacheValid = false;
return $this;
}
/** /**
* site-control defines the meta-policy for the current domain. A meta-policy specifies acceptable * site-control defines the meta-policy for the current domain. A meta-policy specifies acceptable
* domain policy files other than the master policy file located in the target domain's root and named * domain policy files other than the master policy file located in the target domain's root and named

View File

@ -1,5 +1,7 @@
<?php <?php
namespace Ratchet\Server; namespace Ratchet\Server;
use Ratchet\MessageComponentInterface; use Ratchet\MessageComponentInterface;
use React\EventLoop\LoopInterface; use React\EventLoop\LoopInterface;
use React\Socket\ServerInterface; use React\Socket\ServerInterface;
@ -27,6 +29,12 @@ class IoServer {
*/ */
protected $handlers; protected $handlers;
/**
* The socket server the Ratchet Application is run off of
* @var \React\Socket\ServerInterface
*/
public $socket;
/** /**
* @param \Ratchet\MessageComponentInterface $app The Ratchet application stack to host * @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\Socket\ServerInterface $socket The React socket server to run the Ratchet application off of
@ -42,6 +50,7 @@ class IoServer {
$this->loop = $loop; $this->loop = $loop;
$this->app = $app; $this->app = $app;
$this->socket = $socket;
$socket->on('connection', array($this, 'handleConnect')); $socket->on('connection', array($this, 'handleConnect'));