From f0accd908db49df691c93b26467903f4be16495a Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Sun, 3 May 2020 22:35:22 +0200 Subject: [PATCH] wip --- app/Client/Client.php | 7 +++++-- app/Logger/CliRequestLogger.php | 8 ++++++++ app/Server/Connections/ControlConnection.php | 4 +++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/Client/Client.php b/app/Client/Client.php index abc06ad..a08fcb4 100644 --- a/app/Client/Client.php +++ b/app/Client/Client.php @@ -96,12 +96,15 @@ class Client }); $connection->on('setMaximumConnectionLength', function ($data) { - $this->loop->addPeriodicTimer(1, function() use ($data) { + $timeoutSection = $this->logger->getOutput()->section(); + + $this->loop->addPeriodicTimer(1, function() use ($data, $timeoutSection) { $this->timeConnected++; $carbon = Carbon::createFromFormat('s', str_pad($data->length * 60 - $this->timeConnected, 2, 0, STR_PAD_LEFT)); - $this->logger->info('Remaining time: '.$carbon->format('H:i:s')); + $timeoutSection->clear(); + $timeoutSection->writeln('Remaining time: '.$carbon->format('H:i:s')); }); }); diff --git a/app/Logger/CliRequestLogger.php b/app/Logger/CliRequestLogger.php index 2cce701..3eab8ff 100644 --- a/app/Logger/CliRequestLogger.php +++ b/app/Logger/CliRequestLogger.php @@ -30,6 +30,14 @@ class CliRequestLogger extends Logger $this->requests = new Collection(); } + /** + * @return ConsoleOutputInterface + */ + public function getOutput() + { + return $this->output; + } + public function logRequest(LoggedRequest $loggedRequest) { if ($this->requests->has($loggedRequest->id())) { diff --git a/app/Server/Connections/ControlConnection.php b/app/Server/Connections/ControlConnection.php index e748372..f6c1f55 100644 --- a/app/Server/Connections/ControlConnection.php +++ b/app/Server/Connections/ControlConnection.php @@ -37,7 +37,9 @@ class ControlConnection { $this->socket->send(json_encode([ 'event' => 'setMaximumConnectionLength', - 'length' => $maximumConnectionLength, + 'data' => [ + 'length' => $maximumConnectionLength, + ], ])); }