This commit is contained in:
Marcel Pociot
2020-05-03 22:10:34 +02:00
parent 7d0a570d85
commit 7821a2f172
6 changed files with 69 additions and 45 deletions

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Server\Http\Controllers\Admin;
use App\Contracts\ConnectionManager;
use App\Http\Controllers\Controller;
use App\Server\Configuration;
use GuzzleHttp\Psr7\Response;
use Illuminate\Http\Request;
use Ratchet\ConnectionInterface;
use Twig\Environment;
use Twig\Loader\ArrayLoader;
use function GuzzleHttp\Psr7\str;
use function GuzzleHttp\Psr7\stream_for;
class DisconnectSiteController extends AdminController
{
/** @var ConnectionManager */
protected $connectionManager;
/** @var Configuration */
protected $configuration;
public function __construct(ConnectionManager $connectionManager)
{
$this->connectionManager = $connectionManager;
}
public function handle(Request $request, ConnectionInterface $httpConnection)
{
$connection = $this->connectionManager->findControlConnectionForClientId($request->get('id'));
if (! is_null($connection)) {
$connection->close();
$this->connectionManager->removeControlConnection($connection);
}
$httpConnection->send(respond_json([
'sites' => $this->connectionManager->getConnections()
]));
}
}

View File

@@ -27,15 +27,11 @@ class ListSitesController extends AdminController
public function handle(Request $request, ConnectionInterface $httpConnection)
{
try {
$sites = $this->getView($httpConnection, 'server.sites.index', [
'scheme' => $this->configuration->port() === 443 ? 'https' : 'http',
'configuration' => $this->configuration,
'sites' => $this->connectionManager->getConnections()
]);
} catch (\Exception $e) {
dump($e->getMessage());
}
$sites = $this->getView($httpConnection, 'server.sites.index', [
'scheme' => $this->configuration->port() === 443 ? 'https' : 'http',
'configuration' => $this->configuration,
'sites' => $this->connectionManager->getConnections()
]);
$httpConnection->send(
respond_html($sites)