This commit is contained in:
Marcel Pociot
2020-09-04 16:25:45 +02:00
parent eaf04a8eae
commit 12f08db391
11 changed files with 365 additions and 39 deletions

View File

@@ -6,6 +6,7 @@ use App\Contracts\ConnectionManager as ConnectionManagerContract;
use App\Contracts\SubdomainGenerator;
use Ratchet\ConnectionInterface;
use React\EventLoop\LoopInterface;
use React\Socket\Server;
class ConnectionManager implements ConnectionManagerContract
{
@@ -53,6 +54,24 @@ class ConnectionManager implements ConnectionManagerContract
return $storedConnection;
}
public function storeTcpConnection(int $port, ConnectionInterface $connection): ControlConnection
{
$clientId = (string) uniqid();
$connection->client_id = $clientId;
$storedConnection = new TcpControlConnection($connection, $port, $this->getSharedTcpServer(), $clientId);
$this->connections[] = $storedConnection;
return $storedConnection;
}
protected function getSharedTcpServer(): Server
{
return new Server(0, $this->loop);
}
public function storeHttpConnection(ConnectionInterface $httpConnection, $requestId): HttpConnection
{
$this->httpConnections[$requestId] = new HttpConnection($httpConnection);