Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
Browse files Browse the repository at this point in the history
sy-records committed Jan 17, 2025
1 parent 2c2dd8e commit a1353ca
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/BaseClient.php
Original file line number Diff line number Diff line change
@@ -344,7 +344,7 @@ public function auth(int $code = ReasonCode::SUCCESS, array $properties = [])
return $this->send(['type' => Protocol\Types::AUTH, 'code' => $code, 'properties' => $properties]);
}

abstract protected function reConnect();
abstract protected function reConnect(): void;

abstract public function send(array $data, bool $response = true);

2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ public function __construct(
}
}

protected function reConnect()
protected function reConnect(): void
{
$result = false;
$maxAttempts = $this->getConfig()->getMaxAttempts();
8 changes: 3 additions & 5 deletions src/WebSocketClient.php
Original file line number Diff line number Diff line change
@@ -35,12 +35,12 @@ public function __construct(
$client->setHeaders($config->getHeaders());
$upgrade = $client->upgrade($path);
$this->setClient($client);
if ($upgrade && $client->getStatusCode() !== Status::SWITCHING_PROTOCOLS) {
if (!$upgrade || $client->getStatusCode() !== Status::SWITCHING_PROTOCOLS) {
$this->handleException();
}
}

protected function reConnect()
protected function reConnect(): void
{
$result = false;
$maxAttempts = $this->getConfig()->getMaxAttempts();
@@ -80,7 +80,7 @@ public function recv()
if ($response === false && $this->getClient()->errCode === 0) {
$this->reConnect();
$this->connect($this->getConnectData('clean_session') ?? true, $this->getConnectData('will') ?? []);
} elseif ($response === false && $this->getClient()->errCode) {
} elseif ($response === false && $this->getClient()->errCode !== SOCKET_ETIMEDOUT) {
$this->handleException();
} elseif (is_string($response) && strlen($response) !== 0) {
$this->handleVerbose($response);
@@ -101,8 +101,6 @@ protected function getResponse()
return $response->data;
}

// TODO: closeFrame?
return true;
}
}

0 comments on commit a1353ca

Please sign in to comment.