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}"); }); }); } } }