예제 #1
0
        internal static TransportBase EstablistClientTransport(TransportSettings settings)
        {
            ManualResetEvent complete  = new ManualResetEvent(false);
            TransportBase    transport = null;

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

                complete.Set();
            };

            TransportInitiator initiator = settings.CreateInitiator();

            Trace.WriteLine("Initiator is connecting to the server...");
            TransportAsyncCallbackArgs args = new TransportAsyncCallbackArgs();

            args.CompletedCallback = onTransport;
            initiator.ConnectAsync(TimeSpan.FromSeconds(10), args);

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

            return(transport);
        }
예제 #2
0
            public OpenContainerAsyncResult(Container parent, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.parent = parent;

                int port = this.parent.addressUri.Port;

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

                TcpTransportSettings tcpSettings = new TcpTransportSettings();

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

                TransportInitiator         initiator = transportSettings.CreateInitiator();
                TransportAsyncCallbackArgs args      = new TransportAsyncCallbackArgs();

                args.CompletedCallback = onTransport;
                args.UserToken         = this;
                if (!initiator.ConnectAsync(TimeSpan.MaxValue, args))
                {
                    OnTransport(args);
                }
            }
예제 #3
0
            protected override void Start(TransportSettings transportSettings)
            {
                this.initiator = transportSettings.CreateInitiator();
                TransportAsyncCallbackArgs args = new TransportAsyncCallbackArgs();

                args.CompletedCallback = this.OnEstablishTransport;
                if (!initiator.ConnectAsync(this.TimeoutHelper.RemainingTime(), args))
                {
                    this.OnEstablishTransport(args);
                }
            }
예제 #4
0
        internal static TransportBase EstablistClientTransport(TransportSettings settings)
        {
            ManualResetEvent complete = new ManualResetEvent(false);
            TransportBase transport = null;

            Action<TransportAsyncCallbackArgs> onTransport = (a) =>
            {
                if (a.Exception != null)
                {
                    Debug.WriteLine(a.Exception.Message);
                }
                else
                {
                    Debug.WriteLine("Initiator established a transport.");
                    transport = a.Transport;
                }

                complete.Set();
            };

            TransportInitiator initiator = settings.CreateInitiator();
            Debug.WriteLine("Initiator is connecting to the server...");
            TransportAsyncCallbackArgs args = new TransportAsyncCallbackArgs();
            args.CompletedCallback = onTransport;
            initiator.ConnectAsync(TimeSpan.FromSeconds(10), args);

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

            return transport;
        }