[Http] HttpServerInterface

Force HttpServerInterface on route
Call controller on all events
This commit is contained in:
Chris Boden 2013-04-26 20:00:11 -04:00
parent 43003d69f9
commit 4a87375f10

View File

@ -34,7 +34,7 @@ class HttpServer implements MessageComponentInterface {
* @param Ratchet\Http\HttpServerInterface * @param Ratchet\Http\HttpServerInterface
* @param array * @param array
*/ */
public function addRoute($name, $path, MessageComponentInterface $controller, $allowedOrigins = array()) { public function addRoute($name, $path, HttpServerInterface $controller, $allowedOrigins = array()) {
$this->_routes->add($name, new Route($path, array( $this->_routes->add($name, new Route($path, array(
'_controller' => $controller '_controller' => $controller
, 'allowedOrigins' => $allowedOrigins , 'allowedOrigins' => $allowedOrigins
@ -87,7 +87,7 @@ class HttpServer implements MessageComponentInterface {
*/ */
public function onClose(ConnectionInterface $conn) { public function onClose(ConnectionInterface $conn) {
if ($conn->Http->headers) { if ($conn->Http->headers) {
$this->_decorating->onClose($conn); $conn->Http->controller->onClose($conn);
} }
} }
@ -96,7 +96,7 @@ class HttpServer implements MessageComponentInterface {
*/ */
public function onError(ConnectionInterface $conn, \Exception $e) { public function onError(ConnectionInterface $conn, \Exception $e) {
if ($conn->Http->headers) { if ($conn->Http->headers) {
$this->_decorating->onError($conn, $e); $conn->Http->controller->onError($conn, $e);
} else { } else {
$conn->close(); $conn->close();
} }