Reverted the changes previously made in favor of a different approach as requested in https://github.com/cboden/Ratchet/pull/188
This commit is contained in:
parent
06c4c3ddd8
commit
a456c50df4
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Ratchet;
|
||||
|
||||
use React\EventLoop\LoopInterface;
|
||||
use React\EventLoop\Factory as LoopFactory;
|
||||
use React\Socket\Server as Reactor;
|
||||
@ -49,16 +51,12 @@ class App {
|
||||
protected $_routeCounter = 0;
|
||||
|
||||
/**
|
||||
* @param string $httpHost HTTP hostname clients intend to connect to. MUST match JS `new WebSocket('ws://$httpHost')
|
||||
* @param int $port Port to listen on
|
||||
* @param string $address IP address to bind to. Default is localhost/proxy only. '0.0.0.0' for any machine
|
||||
* @param array $flashAllowedHosts associative array with hostnames as key and ports as value. These domains are the domains the flash websocket fallback may connect from
|
||||
* @param int $flashPort the port the flash cross-domain-policy file will be hosted on
|
||||
* @param string $flashAddress the IP address the flash cross-domain-policy server will bind to
|
||||
* @param string $httpHost HTTP hostname clients intend to connect to. MUST match JS `new WebSocket('ws://$httpHost');`
|
||||
* @param int $port Port to listen on. If 80, assuming production, Flash on 843 otherwise expecting Flash to be proxied through 8843
|
||||
* @param string $address IP address to bind to. Default is localhost/proxy only. '0.0.0.0' for any machine.
|
||||
* @param LoopInterface $loop Specific React\EventLoop to bind the application to. null will create one for you.
|
||||
*/
|
||||
public function __construct($httpHost = 'localhost', $port = 8080, $address = '127.0.0.1', $flashAllowedHosts = false, $flashPort = 8843, $flashAddress = '0.0.0.0', LoopInterface $loop = null) {
|
||||
|
||||
public function __construct($httpHost = 'localhost', $port = 8080, $address = '127.0.0.1', LoopInterface $loop = null) {
|
||||
if (extension_loaded('xdebug')) {
|
||||
trigger_error("XDebug extension detected. Remember to disable this if performance testing or going live!", E_USER_WARNING);
|
||||
}
|
||||
@ -79,20 +77,26 @@ class App {
|
||||
$this->routes = new RouteCollection;
|
||||
$this->_server = new IoServer(new HttpServer(new Router(new UrlMatcher($this->routes, new RequestContext))), $socket, $loop);
|
||||
|
||||
if ($flashAllowedHosts === false) {
|
||||
$flashAllowedHosts = array( 80 => $httpHost );
|
||||
}
|
||||
|
||||
$policy = new FlashPolicy();
|
||||
$policy->addAllowedAccess($httpHost, 80);
|
||||
$policy->addAllowedAccess($httpHost, $port);
|
||||
$flashSock = new Reactor($loop);
|
||||
$this->flashServer = new IoServer($policy, $flashSock);
|
||||
|
||||
foreach ($flashAllowedHosts as $flashAllowedHost => $flashAllowedPort) {
|
||||
$policy->addAllowedAccess($flashAllowedHost, $flashAllowedPort);
|
||||
if (80 == $port) {
|
||||
$flashSock->listen(843, '0.0.0.0');
|
||||
} else {
|
||||
$flashSock->listen(8843);
|
||||
}
|
||||
}
|
||||
|
||||
$flashSock = new Reactor($loop);
|
||||
|
||||
$this->flashServer = new IoServer($policy, $flashSock);
|
||||
$flashSock->listen($flashPort, $flashAddress);
|
||||
/**
|
||||
* Returns the FlashPolicy running in the FlashServer. Modifications of this object take effect immediately!
|
||||
*
|
||||
* @return FlashPolicy
|
||||
*/
|
||||
public function getFlashPolicy() {
|
||||
return $this->flashServer->getApp();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,3 +140,4 @@ class App {
|
||||
$this->_server->run();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user