void Connect(SaslProfile saslProfile, Open open) { ITransport transport; TcpTransport tcpTransport = new TcpTransport(); tcpTransport.Connect(this, this.address, DisableServerCertValidation); transport = tcpTransport; if (saslProfile != null) { transport = saslProfile.Open(this.address.Host, transport); } else if (this.address.User != null) { transport = new SaslPlainProfile(this.address.User, this.address.Password).Open(this.address.Host, transport); } this.transport = transport; // after getting the transport, move state to open pipe before starting the pump this.SendHeader(); this.SendOpen(open); this.state = State.OpenPipe; this.reader = new Pump(this); this.reader.Start(); }
void Connect(SaslProfile saslProfile, Open open) { ITransport transport; #if NETFX if (WebSocketTransport.MatchScheme(address.Scheme)) { WebSocketTransport wsTransport = new WebSocketTransport(); wsTransport.ConnectAsync(address).GetAwaiter().GetResult(); transport = wsTransport; } else #endif { TcpTransport tcpTransport = new TcpTransport(); tcpTransport.Connect(this, this.address, DisableServerCertValidation); transport = tcpTransport; } if (saslProfile != null) { transport = saslProfile.Open(this.address.Host, transport); } else if (this.address.User != null) { transport = new SaslPlainProfile(this.address.User, this.address.Password).Open(this.address.Host, transport); } this.transport = transport; // after getting the transport, move state to open pipe before starting the pump this.SendHeader(); this.SendOpen(open); this.state = State.OpenPipe; this.reader = new Pump(this); this.reader.Start(); }