Added the property socket to the IOServer class and exposed the app and socket properties through getters.

This commit is contained in:
Gerrit Drost 2014-05-23 16:21:13 +02:00
parent a456c50df4
commit a1c27ac91b

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;
@ -26,6 +28,12 @@ class IoServer {
* @var \SplFixedArray * @var \SplFixedArray
*/ */
protected $handlers; protected $handlers;
/**
* The socket server the Ratchet Application is run off of
* @var \React\Socket\ServerInterface
*/
protected $socket;
/** /**
* @param \Ratchet\MessageComponentInterface $app The Ratchet application stack to host * @param \Ratchet\MessageComponentInterface $app The Ratchet application stack to host
@ -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'));
@ -50,6 +59,24 @@ class IoServer {
$this->handlers[1] = array($this, 'handleEnd'); $this->handlers[1] = array($this, 'handleEnd');
$this->handlers[2] = array($this, 'handleError'); $this->handlers[2] = array($this, 'handleError');
} }
/**
* Returns the Ratchet App
*
* @return \Ratchet\MessageComponentInterface
*/
public function getApp() {
return $this->app;
}
/**
* Returns the Socket
*
* @return \React\Socket\ServerInterface
*/
public function getSocket() {
return $this->socket;
}
/** /**
* @param \Ratchet\MessageComponentInterface $component The application that I/O will call when events are received * @param \Ratchet\MessageComponentInterface $component The application that I/O will call when events are received