From ef275391c53a745b24f3e4f9a2c3a03b37ef9645 Mon Sep 17 00:00:00 2001 From: chaz6chez Date: Fri, 12 Jul 2024 23:27:18 +0800 Subject: [PATCH] fixed: api-server root middlewares --- src/PushServer.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/PushServer.php b/src/PushServer.php index 359d04c..97ed5fe 100644 --- a/src/PushServer.php +++ b/src/PushServer.php @@ -187,7 +187,7 @@ function (TcpConnection $connection, string $header) use ($socketId) { */ public function onMessage(TcpConnection $connection, $data): void { - $handler = function ($connection, $data) { + $handler = function (TcpConnection $connection, $data) { if (is_string($data)) { static::setRecvBytesStatistics($connection, $data); if ($data = @json_decode($data, true)) { @@ -207,13 +207,12 @@ public function onMessage(TcpConnection $connection, $data): void call_user_func(array_reduce( array_reverse($this->_middlewares), function (Closure $carry, Closure $pipe) { - - return function (...$arguments) use ($carry, $pipe) { - return $pipe($carry, ...$arguments); + return function (TcpConnection $connection, $data) use ($carry, $pipe) { + return $pipe($carry, $connection, $data); }; }, - function (...$arguments) use ($handler) { - return $handler(...$arguments); + function (TcpConnection $connection, $data) use ($handler) { + return $handler($connection, $data); } ), $connection, $data); }