private function negotiateCrypto(string $watcher, $socket, HttpDriverFactory $driverFactory)
    {
        if ($handshake = @\stream_socket_enable_crypto($this->socket, true)) {
            Loop::cancel($this->readWatcher);

            $this->isEncrypted = true;
            $this->cryptoInfo = \stream_get_meta_data($this->socket)["crypto"];

            \assert($this->logger->debug(\sprintf(
                "Crypto negotiated (ALPN: %s) %s:%d",
                ($this->cryptoInfo["alpn_protocol"] ?? "none"),
                $this->clientAddress,
                $this->clientPort
            )) || true);

            $this->setup($driverFactory->selectDriver($this));

            $this->readWatcher = Loop::onReadable($this->socket, $this->callableFromInstanceMethod("onReadable"));
            return;
        }

        if ($handshake === false) {
            \assert($this->logger->debug("Crypto handshake error {$this->clientAddress}:{$this->clientPort}") || true);
            $this->close();
        }
    }
private function negotiateCrypto(string $watcher, $socket, HttpDriverFactory $driverFactory)
    {
        if ($handshake = @\stream_socket_enable_crypto($this->socket, true)) {
            Loop::cancel($this->readWatcher);

            $this->isEncrypted = true;
            $this->cryptoInfo = \stream_get_meta_data($this->socket)["crypto"];

            \assert($this->logger->debug(\sprintf(
                "Crypto negotiated (ALPN: %s) %s:%d",
                ($this->cryptoInfo["alpn_protocol"] ?? "none"),
                $this->clientAddress,
                $this->clientPort
            )) || true);

            $this->setup($driverFactory->selectDriver($this));

            $this->readWatcher = Loop::onReadable($this->socket, $this->callableFromInstanceMethod("onReadable"));
            return;
        }

        if ($handshake === false) {
            \assert($this->logger->debug("Crypto handshake error {$this->clientAddress}:{$this->clientPort}") || true);
            $this->close();
        }
    }
private function negotiateCrypto ( string $ watcher , $ socket , HttpDriverFactory $ driverFactory ) { if ( $ handshake = @ \ stream_socket_enable_crypto ( $ this -> socket , true ) ) { Loop :: cancel ( $ this -> readWatcher ) ; $ this -> isEncrypted = true ; $ this -> cryptoInfo = \ stream_get_meta_data ( $ this -> socket ) [ "crypto" ] ; \ assert ( $ this -> logger -> debug ( \ sprintf ( "Crypto negotiated (ALPN: %s) %s:%d" , ( $ this -> cryptoInfo [ "alpn_protocol" ] ?? "none" ) , $ this -> clientAddress , $ this -> clientPort ) ) || true ) ; $ this -> setup ( $ driverFactory -> selectDriver ( $ this ) ) ; $ this -> readWatcher = Loop :: onReadable ( $ this -> socket , $ this -> callableFromInstanceMethod ( "onReadable" ) ) ; return ; } if ( $ handshake === false ) { \ assert ( $ this -> logger -> debug ( "Crypto handshake error {$this->clientAddress}:{$this->clientPort}" ) || true ) ; $ this -> close ( ) ; } }
Called by the onReadable watcher after the client connects until encryption is enabled.

@param string                                    $watcher
@param resource                                  $socket
@param \Amp\Http\Server\Driver\HttpDriverFactory $driverFactory
Called by the onReadable watcher after the client connects until encryption is enabled .