public static Connection Connect(String host, int port, String mechanism, X509Certificate certificate, bool rejectUntrusted, Client client) { ClientConnectionDelegate connectionDelegate = new ClientConnectionDelegate(client, string.Empty, string.Empty, mechanism); ManualResetEvent negotiationComplete = new ManualResetEvent(true); connectionDelegate.SetCondition(negotiationComplete); connectionDelegate.VirtualHost = string.Empty; IIoTransport transport = new IoSSLTransport(host, port, certificate, rejectUntrusted, connectionDelegate); Connection _conn = transport.Connection; _conn.Send(new ProtocolHeader(1, 0, 10)); negotiationComplete.WaitOne(); if (connectionDelegate.Exception != null) throw connectionDelegate.Exception; connectionDelegate.SetCondition(null); return _conn; }
public static Connection Connect(String host, int port, String mechanism, X509Certificate certificate, bool rejectUntrusted, Client client) { ClientConnectionDelegate connectionDelegate = new ClientConnectionDelegate(client, string.Empty, string.Empty, mechanism); ManualResetEvent negotiationComplete = new ManualResetEvent(true); connectionDelegate.SetCondition(negotiationComplete); connectionDelegate.VirtualHost = string.Empty; IIoTransport transport = new IoSSLTransport(host, port, certificate, rejectUntrusted, connectionDelegate); Connection _conn = transport.Connection; _conn.Send(new ProtocolHeader(1, 0, 10)); negotiationComplete.WaitOne(); if (connectionDelegate.Exception != null) { throw connectionDelegate.Exception; } connectionDelegate.SetCondition(null); return(_conn); }