From 2a8072a63cb8883eccb83d1195be67f6fa9c8bbc Mon Sep 17 00:00:00 2001 From: tlebreton Date: Mon, 26 Feb 2024 18:41:09 +0100 Subject: [PATCH] Allow empty message --- src/Client.php | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/Client.php b/src/Client.php index 4667604..b8e8696 100644 --- a/src/Client.php +++ b/src/Client.php @@ -294,28 +294,29 @@ public function process(null|int|float $timeout = 0, bool $reply = true, bool $c } $payload = ''; - if ($message instanceof Msg && $message->length) { - $iteration = 0; - while (strlen($payload) < $message->length) { - $payloadLine = $this->readLine($message->length, '', false); - if (!$payloadLine) { - if ($iteration > 16) { - $this->processSocketException( - new LogicException("No payload for message $message->sid") + if ($message instanceof Msg) { + if ($message->length) { + $iteration = 0; + while (strlen($payload) < $message->length) { + $payloadLine = $this->readLine($message->length, '', false); + if (!$payloadLine) { + if ($iteration > 16) { + $this->processSocketException( + new LogicException("No payload for message $message->sid") + ); + break; + } + $this->configuration->delay($iteration++); + continue; + } + if (strlen($payloadLine) != $message->length) { + $this->logger?->debug( + 'got ' . strlen($payloadLine) . '/' . $message->length . ': ' . $payloadLine ); - break; } - $this->configuration->delay($iteration++); - continue; - } - if (strlen($payloadLine) != $message->length) { - $this->logger?->debug( - 'got ' . strlen($payloadLine) . '/' . $message->length . ': ' . $payloadLine - ); + $payload .= $payloadLine; } - $payload .= $payloadLine; } - $message->parse($payload); }