Example #1
0
            private void ClientSendConnectRequest(IPEndPoint externalEndpoint, List <IPEndPoint> localEndpoints)
            {
                AddressCandidates addressCandidate = new AddressCandidates();

                addressCandidate.AddEndpoints(AddressType.External, new IPEndPoint[] { externalEndpoint });
                addressCandidate.AddEndpoints(AddressType.Local, localEndpoints.ToArray());
                try
                {
                    DirectConnectionSession session = base.Session;
                    int attempts = session.Attempts;
                    int num      = attempts;
                    session.Attempts = attempts + 1;
                    if (num != 0)
                    {
                        IDirectConnectionControl channel = base.Session.Channel;
                        Guid id = base.Session.Id;
                        channel.ConnectRetry(new ConnectRetryMessage(id.ToString(), addressCandidate));
                    }
                    else
                    {
                        IDirectConnectionControl directConnectionControl = base.Session.Channel;
                        Guid guid = base.Session.Id;
                        directConnectionControl.Connect(new DirectConnectMessage(guid.ToString(), addressCandidate));
                    }
                }
                catch (Exception exception)
                {
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }
                }
            }
        void Microsoft.ServiceBus.IDirectConnectionParent.Success(object sender, Socket socket)
        {
            DirectConnectionSession directConnectionSession = (DirectConnectionSession)sender;
            Guid id = directConnectionSession.Id;
            EventTraceActivity eventTraceActivity = new EventTraceActivity(id);

            lock (this.ThisLock)
            {
                this.connectionSessions.Remove(id.ToString());
            }
            try
            {
                directConnectionSession.Close(Microsoft.ServiceBus.ServiceDefaults.CloseTimeout);
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                if (Fx.IsFatal(exception))
                {
                    throw;
                }
                Fx.Exception.TraceHandled(exception, "DirectSocketListener.Success", eventTraceActivity);
                directConnectionSession.Abort();
            }
            this.socketQueue.EnqueueAndDispatch(new Microsoft.ServiceBus.Channels.SocketConnection(socket, this.bufferSize, eventTraceActivity));
        }
        void Microsoft.ServiceBus.IDirectConnectionParent.Failure(object sender, Exception exception)
        {
            DirectConnectionSession directConnectionSession = (DirectConnectionSession)sender;
            Guid id = directConnectionSession.Id;

            lock (this.ThisLock)
            {
                this.connectionSessions.Remove(id.ToString());
            }
            try
            {
                directConnectionSession.Close(Microsoft.ServiceBus.ServiceDefaults.CloseTimeout);
            }
            catch (Exception exception2)
            {
                Exception exception1 = exception2;
                if (Fx.IsFatal(exception1))
                {
                    throw;
                }
                EventTraceActivity eventTraceActivity = new EventTraceActivity(id);
                Fx.Exception.TraceHandled(exception1, "DirectSocketListener.Failure", eventTraceActivity);
                directConnectionSession.Abort();
            }
        }
            public DirectConnectAsyncResult(int bufferSize, Uri uri, TimeSpan timeout, Binding innerBinding, AsyncCallback callback, object state) : base(callback, state)
            {
                this.bufferSize = bufferSize;
                ProbingClient probingClient = new ProbingClient(uri.Host, ConnectConstants.DefaultProbePorts);

                this.session        = new DirectConnectionSession(Guid.NewGuid(), probingClient, this);
                this.channelFactory = new DuplexChannelFactory <IDirectConnectionControl>(this.session, innerBinding, new EndpointAddress(uri, new AddressHeader[0]));
            }
            public DirectConnectWaiter(int bufferSize, Uri uri, TimeSpan timeout, Binding innerBinding)
            {
                this.bufferSize = bufferSize;
                ProbingClient probingClient = new ProbingClient(uri.Host, ConnectConstants.DefaultProbePorts);

                this.session        = new DirectConnectionSession(Guid.NewGuid(), probingClient, this);
                this.channelFactory = new DuplexChannelFactory <IDirectConnectionControl>(this.session, innerBinding, new EndpointAddress(uri, new AddressHeader[0]));
                this.timeoutHelper  = new Microsoft.ServiceBus.Common.TimeoutHelper(timeout);
                this.socketEvent    = new ManualResetEvent(false);
                this.mutex          = new object();
            }
        void Microsoft.ServiceBus.IDirectConnectionControl.Connect(DirectConnectMessage request)
        {
            DirectConnectionSession directConnectionSession;

            lock (this.ThisLock)
            {
                if (this.isClosed)
                {
                    throw Fx.Exception.AsError(new FaultException(SRClient.EndpointNotFound), null);
                }
                if (this.connectionSessions.ContainsKey(request.Id))
                {
                    throw Fx.Exception.AsError(new FaultException(SRClient.DuplicateConnectionID), null);
                }
                directConnectionSession = new DirectConnectionSession(new Guid(request.Id), this.probingClient, this)
                {
                    Channel = OperationContext.Current.GetCallbackChannel <IDirectConnectionControl>()
                };
                directConnectionSession.Listen();
                this.connectionSessions.Add(request.Id, directConnectionSession);
            }
            ((IDirectConnectionControl)directConnectionSession).Connect(request);
        }
Example #7
0
 public ListenActivity(DirectConnectionSession session) : base(session)
 {
     this.localDerivedEndpoint = new DerivedEndpoint();
     this.localEndpoints       = new List <IPEndPoint>();
 }
Example #8
0
 public ConnectActivity(DirectConnectionSession session) : base(session)
 {
     this.completeEvent        = new ManualResetEvent(false);
     this.localDerivedEndpoint = new DerivedEndpoint();
     this.localEndpoints       = new List <IPEndPoint>();
 }
Example #9
0
 protected Activity(DirectConnectionSession session)
 {
     this.session    = session;
     this.parent     = session;
     this.candidates = new DirectConnectionCandidateManager(this);
 }