From fe811549a20846d3f92e4ec331b2ca74d442a0b8 Mon Sep 17 00:00:00 2001 From: freek Date: Tue, 27 Nov 2018 21:14:08 +0100 Subject: [PATCH] commit --- config/websockets.php | 4 ++-- src/Server/OriginCheck.php | 1 - src/Server/Router.php | 27 ++++++++++++++++----------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/config/websockets.php b/config/websockets.php index 67efc05..ce79f2c 100644 --- a/config/websockets.php +++ b/config/websockets.php @@ -37,9 +37,9 @@ return [ ], /* - * The maximum request size that is allowed for an incoming websocket request. + * The maximum request size in bytes that is allowed for an incoming websocket request. */ - 'maxRequestSize' => 256000, + 'maxRequestSize' => 1024 * 250, /* * Define the optional SSL context for your websocket connections. diff --git a/src/Server/OriginCheck.php b/src/Server/OriginCheck.php index 689ef07..883efb7 100644 --- a/src/Server/OriginCheck.php +++ b/src/Server/OriginCheck.php @@ -10,7 +10,6 @@ use Psr\Http\Message\RequestInterface; class OriginCheck implements HttpServerInterface { - use CloseResponseTrait; /** @var \Ratchet\MessageComponentInterface */ diff --git a/src/Server/Router.php b/src/Server/Router.php index 800c8a5..64d4a52 100644 --- a/src/Server/Router.php +++ b/src/Server/Router.php @@ -25,6 +25,11 @@ class Router $this->routes = new RouteCollection; } + public function getRoutes(): RouteCollection + { + return $this->routes; + } + public function websocket(string $uri, $action) { if (!is_subclass_of($action, MessageComponentInterface::class)) { @@ -81,27 +86,27 @@ class Router } /** - * @param $action + * @param string $action * * @return \Ratchet\WebSocket\WsServer|\Ratchet\Http\HttpServerInterface */ - protected function wrapAction($action) + protected function wrapAction(string $action) { if (is_subclass_of($action, MessageComponentInterface::class)) { - $app = app($action); - - if (MessageLogger::isEnabled()) { - $app = MessageLogger::decorate($app); - } - - return new WsServer($app); + return $this->createWebSocketsServer($action); } return app($action); } - public function getRoutes(): RouteCollection + protected function createWebSocketsServer(MessageComponentInterface $action): WsServer { - return $this->routes; + $app = app($action); + + if (MessageLogger::isEnabled()) { + $app = MessageLogger::decorate($app); + } + + return new WsServer($app); } } \ No newline at end of file