diff --git a/src/Ratchet/App.php b/src/Ratchet/App.php index 465f270..ae8690a 100644 --- a/src/Ratchet/App.php +++ b/src/Ratchet/App.php @@ -3,6 +3,7 @@ namespace Ratchet; use React\EventLoop\LoopInterface; use React\EventLoop\Factory as LoopFactory; use React\Socket\Server as Reactor; +use React\Socket\SecureServer as SecureReactor; use Ratchet\Http\HttpServerInterface; use Ratchet\Http\OriginCheck; use Ratchet\Wamp\WampServerInterface; @@ -60,7 +61,7 @@ class App { * @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', LoopInterface $loop = null) { + public function __construct($httpHost = 'localhost', $port = 8080, $address = '127.0.0.1', LoopInterface $loop = null, array $sslContext = null) { if (extension_loaded('xdebug')) { trigger_error('XDebug extension detected. Remember to disable this if performance testing or going live!', E_USER_WARNING); } @@ -74,6 +75,10 @@ class App { $socket = new Reactor($address . ':' . $port, $loop); + if (is_array($sslContext)) { + $socket = new SecureReactor($socket, $loop, $sslContext); + } + $this->routes = new RouteCollection; $this->_server = new IoServer(new HttpServer(new Router(new UrlMatcher($this->routes, new RequestContext))), $socket, $loop); diff --git a/src/Ratchet/Server/IoServer.php b/src/Ratchet/Server/IoServer.php index 1a992fd..f64c960 100644 --- a/src/Ratchet/Server/IoServer.php +++ b/src/Ratchet/Server/IoServer.php @@ -49,17 +49,17 @@ class IoServer { } /** - * @param \Ratchet\MessageComponentInterface $component The application that I/O will call when events are received - * @param int $port The port to server sockets on - * @param string $address The address to receive sockets on (0.0.0.0 means receive connections from any) - * @param array $sslconf An array of PHP stream context options in order to support SSL + * @param \Ratchet\MessageComponentInterface $component The application that I/O will call when events are received + * @param int $port The port to server sockets on + * @param string $address The address to receive sockets on (0.0.0.0 means receive connections from any) + * @param array $sslContext An array of PHP stream context options in order to support SSL * @return IoServer */ - public static function factory(MessageComponentInterface $component, $port = 80, $address = '0.0.0.0', $sslconf = null) { + public static function factory(MessageComponentInterface $component, $port = 80, $address = '0.0.0.0', array $sslContext = null) { $loop = LoopFactory::create(); $socket = new Reactor($address . ':' . $port, $loop); - if (is_array($sslconf)) { - $socket = new SecureReactor($socket, $loop, $sslconf); + if (is_array($sslContext)) { + $socket = new SecureReactor($socket, $loop, $sslContext); } return new static($component, $socket, $loop);