Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Adapter/ServerQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Reply;
use PlanetTeamSpeak\TeamSpeak3Framework\Exception\AdapterException;
use PlanetTeamSpeak\TeamSpeak3Framework\Exception\ServerQueryException;
use PlanetTeamSpeak\TeamSpeak3Framework\Exception\TransportException;
use PlanetTeamSpeak\TeamSpeak3Framework\Helper\Profiler;
use PlanetTeamSpeak\TeamSpeak3Framework\Helper\Signal;
use PlanetTeamSpeak\TeamSpeak3Framework\Helper\StringHelper;
Expand Down Expand Up @@ -99,7 +100,7 @@ public function __destruct()
if ($this->getTransport() instanceof Transport && $this->transport->isConnected()) {
try {
$this->request("quit");
} catch (AdapterException) {
} catch (AdapterException | TransportException) {
// The transport destructor will close an unavailable connection.
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Transport/TCP.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public function readLine(string $token = "\n"): StringHelper

if ($data === false) {
if (feof($this->stream)) {
$this->disconnect();
throw new TransportException("connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "' lost");
}
} else {
Expand Down
11 changes: 8 additions & 3 deletions tests/Transport/TCPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ public function setStreamForTest(): void

$transport->setStreamForTest();

$this->expectException(TransportException::class);
$this->expectExceptionMessage("connection to server 'test:12345' lost");
$transport->readLine();
try {
$transport->readLine();
$this->fail('Expected a transport exception for a closed connection.');
} catch (TransportException $exception) {
$this->assertSame("connection to server 'test:12345' lost", $exception->getMessage());
}

$this->assertFalse($transport->isConnected());
}

/**
Expand Down
Loading