Esempio n. 1
0
        public static AmqpTransportListener CreateListener(string host, int port, string certFindValue, bool doSslUpgrade, SaslHandler saslHandler)
        {
            AmqpSettings settings = GetAmqpSettings(false, certFindValue, doSslUpgrade, saslHandler);

            TransportSettings transportSettings = GetTcpSettings(host, port, true);

            if (!doSslUpgrade && certFindValue != null)
            {
                TlsTransportSettings tlsSettings = new TlsTransportSettings(transportSettings, false);
                tlsSettings.Certificate = GetCertificate(certFindValue);
                transportSettings       = tlsSettings;
            }

            TransportListener listener = transportSettings.CreateListener();

            return(new AmqpTransportListener(new TransportListener[] { listener }, settings));
        }
Esempio n. 2
0
            public void Open()
            {
                int port = this.container.addressUri.Port;

                if (port == -1)
                {
                    port = AmqpConstants.DefaultPort;
                }

                TcpTransportSettings tcpSettings = new TcpTransportSettings();

                tcpSettings.TcpBacklog    = 20;
                tcpSettings.TcpBufferSize = 4096;
                tcpSettings.SetEndPoint(this.container.addressUri.Host, port, true);
                TransportSettings transportSettings = tcpSettings;

                this.listener = transportSettings.CreateListener();
                this.listener.Listen(this.OnAcceptTransport);
            }
Esempio n. 3
0
        internal static TransportBase AcceptServerTransport(TransportSettings settings)
        {
            ManualResetEvent complete = new ManualResetEvent(false);
            int           closed      = 0;
            TransportBase transport   = null;

            Action <TransportAsyncCallbackArgs> onTransport = (a) =>
            {
                if (a.Exception != null)
                {
                    Trace.WriteLine(a.Exception.Message);
                }
                else
                {
                    Trace.WriteLine("Listener accepted a transport.");
                    transport = a.Transport;
                }

                if (Interlocked.Exchange(ref closed, 1) == 0)
                {
                    complete.Set();
                }
            };

            TransportListener listener = settings.CreateListener();

            Trace.WriteLine("Listeners are waiting for connections...");
            listener.Listen(onTransport);

            complete.WaitOne();
            complete.Close();

            transport.Closed += (s, a) =>
            {
                listener.Close();
                Trace.WriteLine("Listeners Closed.");
            };

            return(transport);
        }
Esempio n. 4
0
        internal static TransportBase AcceptServerTransport(TransportSettings settings)
        {
            ManualResetEvent complete = new ManualResetEvent(false);
            int closed = 0;
            TransportBase transport = null;

            Action<TransportListener, TransportAsyncCallbackArgs> onTransport = (l, a) =>
            {
                if (a.Exception != null)
                {
                    Debug.WriteLine(a.Exception.Message);
                }
                else
                {
                    Debug.WriteLine("Listener accepted a transport.");
                    transport = a.Transport;
                }

                if (Interlocked.Exchange(ref closed, 1) == 0)
                {
                    complete.Set();
                }
            };

            TransportListener listener = settings.CreateListener();
            Debug.WriteLine("Listeners are waiting for connections...");
            listener.Listen(onTransport);

            complete.WaitOne();
            complete.Dispose();

            transport.Closed += (s, a) =>
            {
                listener.Close();
                Debug.WriteLine("Listeners Closed.");
            };

            return transport;
        }
Esempio n. 5
0
 protected override void Start(TransportSettings transportSettings)
 {
     this.listener = transportSettings.CreateListener();
     this.listener.Listen(this.OnAcceptTransport);
 }