This commit is contained in:
Marcel Pociot
2020-04-14 21:19:23 +02:00
commit 2b03398f40
48 changed files with 8099 additions and 0 deletions

39
app/Client/Client.php Normal file
View File

@@ -0,0 +1,39 @@
<?php
namespace App\Client;
use React\EventLoop\LoopInterface;
use React\Socket\ConnectionInterface;
use React\Socket\Connector;
class Client
{
/** @var LoopInterface */
protected $loop;
protected $host;
protected $port;
public function __construct(LoopInterface $loop, $host, $port)
{
$this->loop = $loop;
$this->host = $host;
$this->port = $port;
}
public function share($sharedUrl, array $subdomains = [])
{
foreach ($subdomains as $subdomain) {
$connector = new Connector($this->loop);
$connector->connect("{$this->host}:{$this->port}")
->then(function (ConnectionInterface $clientConnection) use ($sharedUrl, $subdomain) {
$connection = Connection::create($clientConnection, new ProxyManager($this->host, $this->port, $this->loop));
$connection->authenticate($sharedUrl, $subdomain);
$clientConnection->on('authenticated', function ($data) {
dump("Connected to http://$data->subdomain.{$this->host}:{$this->port}");
});
});
}
}
}