This commit is contained in:
Marcel Pociot
2020-05-03 22:35:22 +02:00
parent 0325162718
commit f0accd908d
3 changed files with 16 additions and 3 deletions

View File

@@ -96,12 +96,15 @@ class Client
}); });
$connection->on('setMaximumConnectionLength', function ($data) { $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++; $this->timeConnected++;
$carbon = Carbon::createFromFormat('s', str_pad($data->length * 60 - $this->timeConnected, 2, 0, STR_PAD_LEFT)); $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'));
}); });
}); });

View File

@@ -30,6 +30,14 @@ class CliRequestLogger extends Logger
$this->requests = new Collection(); $this->requests = new Collection();
} }
/**
* @return ConsoleOutputInterface
*/
public function getOutput()
{
return $this->output;
}
public function logRequest(LoggedRequest $loggedRequest) public function logRequest(LoggedRequest $loggedRequest)
{ {
if ($this->requests->has($loggedRequest->id())) { if ($this->requests->has($loggedRequest->id())) {

View File

@@ -37,7 +37,9 @@ class ControlConnection
{ {
$this->socket->send(json_encode([ $this->socket->send(json_encode([
'event' => 'setMaximumConnectionLength', 'event' => 'setMaximumConnectionLength',
'length' => $maximumConnectionLength, 'data' => [
'length' => $maximumConnectionLength,
],
])); ]));
} }