async Task CreateTransportAsync()

in src/Net/ConnectionFactory.cs [156:197]


        async Task<IAsyncTransport> CreateTransportAsync(Address address, SaslProfile saslProfile, IHandler handler, CancellationToken cancellationToken)
        {
            IAsyncTransport transport;
            TransportProvider provider;
            if (this.transportFactories != null && this.transportFactories.TryGetValue(address.Scheme, out provider))
            {
                transport = await provider.CreateAsync(address).ConfigureAwait(false);
            }
            else if (TcpTransport.MatchScheme(address.Scheme))
            {
                TcpTransport tcpTransport = new TcpTransport(this.BufferManager);
                await tcpTransport.ConnectAsync(address, this, handler, cancellationToken).ConfigureAwait(false);
                transport = tcpTransport;
            }
#if NETFX
            else if (WebSocketTransport.MatchScheme(address.Scheme))
            {
                WebSocketTransport wsTransport = new WebSocketTransport();
                await wsTransport.ConnectAsync(address, null).ConfigureAwait(false);
                transport = wsTransport;
            }
#endif
            else
            {
                throw new NotSupportedException(address.Scheme);
            }

            if (saslProfile != null)
            {
                try
                {
                    transport = await saslProfile.OpenAsync(address.Host, this.BufferManager, transport, null).ConfigureAwait(false);
                }
                catch
                {
                    transport.Close();
                    throw;
                }
            }

            return transport;
        }