mirror of
https://github.com/linuxserver/Heimdall.git
synced 2026-08-07 07:16:13 +00:00
d16b7f60f3
The WebSocket support added for TrueNAS JSON-RPC 2.0 requires the phrity/websocket library to actually be available at runtime. This repo commits the vendor/ tree (CI does not run composer install), so the dependency and composer.lock must be committed for class_exists() checks in the TrueNAS app to succeed. - composer require phrity/websocket:^3.6 (resolves to 3.7.3) with lock and vendor/ committed - Fix TrueNASWebSocketClient to catch WebSocket\Exception\Exception (phrity/websocket v3 namespace) instead of the non-existent WebSocket\ConnectionException from the old textalk/websocket v1/v2 API, so connection/call failures are logged and wrapped as intended
58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Nyholm\Psr7;
|
|
|
|
use Psr\Http\Message\StreamInterface;
|
|
use Symfony\Component\Debug\ErrorHandler as SymfonyLegacyErrorHandler;
|
|
use Symfony\Component\ErrorHandler\ErrorHandler as SymfonyErrorHandler;
|
|
|
|
if (\PHP_VERSION_ID >= 70400 || (new \ReflectionMethod(StreamInterface::class, '__toString'))->hasReturnType()) {
|
|
/**
|
|
* @internal
|
|
*/
|
|
trait StreamTrait
|
|
{
|
|
public function __toString(): string
|
|
{
|
|
if ($this->isSeekable()) {
|
|
$this->seek(0);
|
|
}
|
|
|
|
return $this->getContents();
|
|
}
|
|
}
|
|
} else {
|
|
/**
|
|
* @internal
|
|
*/
|
|
trait StreamTrait
|
|
{
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function __toString()
|
|
{
|
|
try {
|
|
if ($this->isSeekable()) {
|
|
$this->seek(0);
|
|
}
|
|
|
|
return $this->getContents();
|
|
} catch (\Throwable $e) {
|
|
if (\is_array($errorHandler = \set_error_handler('var_dump'))) {
|
|
$errorHandler = $errorHandler[0] ?? null;
|
|
}
|
|
\restore_error_handler();
|
|
|
|
if ($e instanceof \Error || $errorHandler instanceof SymfonyErrorHandler || $errorHandler instanceof SymfonyLegacyErrorHandler) {
|
|
return \trigger_error((string) $e, \E_USER_ERROR);
|
|
}
|
|
|
|
return '';
|
|
}
|
|
}
|
|
}
|
|
}
|