Skip to content

Commit

Permalink
Test timeout enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
lotharthesavior committed Dec 28, 2023
1 parent 761d48c commit eb459a1
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ protected function handleDisconnection(): void
);
}

/**
* @throws TimeoutException|Exception
*/
protected function handleClientConnection(): void
{
$this->client = new WsClient(
Expand All @@ -196,11 +199,19 @@ protected function handleClientConnection(): void
$this->handleListeners();
$this->connectionReady();

while($message = $this->client->receive()) {
if (null === $this->onMessageCallback) {
continue;
try {
while ($message = $this->client->receive()) {
if (null === $this->onMessageCallback) {
continue;
}
call_user_func($this->onMessageCallback, $this, $message);
}
call_user_func($this->onMessageCallback, $this, $message);
} catch (TimeoutException $e) {
if ($this->timeout !== -1) {
throw $e;
}
} catch (Exception $e) {
throw $e;
}
}

Expand Down

0 comments on commit eb459a1

Please sign in to comment.