Skip to content

Commit

Permalink
feat: do not call empty handler on ping message
Browse files Browse the repository at this point in the history
  • Loading branch information
oxidmod authored and nekufa committed Jun 9, 2023
1 parent 2670283 commit 8384a31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,12 @@ public function process(null|int|float $timeout = 0)
switch (trim($line)) {
case 'PING':
$this->logger?->debug('receive ' . $line);
return $this->send(new Pong([]));
$this->send(new Pong([]));
$now = microtime(true);
if ($now >= $max) {
return null;
}
return $this->process($max - $now);

case 'PONG':
$this->logger?->debug('receive ' . $line);
Expand Down
2 changes: 1 addition & 1 deletion src/Consumer/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function handle(Closure $handler, Closure $emptyHandler = null): int
break;
}

if ($iteration && $runtime->empty) {
if ($iteration && $runtime->empty && !$expires) {
usleep((int) floor($this->getDelay() * 1_000_000));
}
}
Expand Down

0 comments on commit 8384a31

Please sign in to comment.