protected function addSecureConnection(ConnectionInterface $connection)
{
// @see https://github.com/reactphp/socket-client/issues/4
if ($this->getForceIpv4Flag($connection)) {
throw new Exception('Using the SSL transport and IPv4 together is not currently supported', Exception::ERR_CONNECTION_STATE_UNSUPPORTED);
}
$hostname = $connection->getServerHostname();
$port = $connection->getServerPort();
$this->getSecureConnector()->create($hostname, $port)->then(function (DuplexStreamInterface $stream) use($connection) {
$this->initializeStream($stream, $connection);
$this->emit('connect.after.each', array($connection, $connection->getOption('write')));
});
}