Skip to content

Commit

Permalink
Allow empty message
Browse files Browse the repository at this point in the history
  • Loading branch information
tlebreton authored and nekufa committed Mar 4, 2024
1 parent 5dab15b commit 2a8072a
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 2a8072a

Please sign in to comment.