Skip to content

Commit

Permalink
fixed: api-server root middlewares
Browse files Browse the repository at this point in the history
  • Loading branch information
chaz6chez committed Jul 12, 2024
1 parent 1b19acd commit ef27539
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/PushServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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);
}
Expand Down

0 comments on commit ef27539

Please sign in to comment.