diff --git a/HttpServer/Events/OnClose.php b/HttpServer/Events/OnClose.php index 77bf4646..7b07b938 100644 --- a/HttpServer/Events/OnClose.php +++ b/HttpServer/Events/OnClose.php @@ -58,7 +58,7 @@ class OnClose extends Callback } $node = $router->search('/' . Socket::CLOSE . '::event', 'sw::socket'); if ($node instanceof Node) { - $node->dispatch(); + $node->dispatch($server, $fd); } } catch (\Throwable $exception) { $this->addError($exception); diff --git a/HttpServer/Events/OnHandshake.php b/HttpServer/Events/OnHandshake.php index 894e6bea..a7f11487 100644 --- a/HttpServer/Events/OnHandshake.php +++ b/HttpServer/Events/OnHandshake.php @@ -102,7 +102,7 @@ class OnHandshake extends Callback if ($node === null) { return $this->disconnect($response, 502); } - return $node->dispatch(); + return $node->dispatch($request, $response); } catch (\Throwable $exception) { $this->addError($exception->getMessage()); return $this->disconnect($response, 500); diff --git a/HttpServer/Events/OnMessage.php b/HttpServer/Events/OnMessage.php index 0107b6b8..65f78cfa 100644 --- a/HttpServer/Events/OnMessage.php +++ b/HttpServer/Events/OnMessage.php @@ -68,7 +68,7 @@ class OnMessage extends Callback if ($node === null) { throw new Exception('Page not found.'); } - return $node->dispatch(); + return $node->dispatch($server, $frame); } } diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index c08976fb..16bf5697 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -425,7 +425,12 @@ class Node extends Application if (empty($this->callback)) { return JSON::to(404, $node->_error ?? 'Page not found.'); } - return call_user_func($this->callback, \request()); + $requestParams = func_get_args(); + if (func_num_args() > 0) { + return call_user_func($this->callback, ...$requestParams); + } else { + return call_user_func($this->callback, \request()); + } }