private void ProcessConnection(Microsoft.ServiceBus.Channels.IConnection connection)
            {
                TimeoutHelper timeoutHelper = new TimeoutHelper(Microsoft.ServiceBus.ServiceDefaults.ReceiveTimeout);
                bool          flag          = false;

                try
                {
                    byte[] numArray = new byte[16];
                    if (connection.Read(numArray, 0, 16, timeoutHelper.RemainingTime()) != 16)
                    {
                        throw new CommunicationException(SRClient.InvalidLengthofReceivedContent);
                    }
                    Guid guid = new Guid(numArray);
                    this.connectionListener.EnqueueConnection(guid, connection, this.socketType, new Action(this.OnSocketDequeued));
                    byte[] numArray1 = new byte[] { 1 };
                    connection.Write(numArray1, 0, 1, true, timeoutHelper.RemainingTime());
                    flag = true;
                }
                finally
                {
                    if (!flag)
                    {
                        connection.Abort();
                    }
                }
            }
Пример #2
0
 private void DirectConnectComplete(IAsyncResult result, bool completedSynchronously)
 {
     try
     {
         Microsoft.ServiceBus.Channels.IConnection connection = this.directSocketInitiator.EndConnect(result);
         if (!this.disposed)
         {
             this.hybridConnectionInitiator.SendInitiateMessage(connection, this.timeout.RemainingTime());
             this.HybridConnection.EnqueueConnection(connection);
         }
         else
         {
             connection.Abort();
         }
     }
     catch (Exception exception)
     {
         if (Fx.IsFatal(exception))
         {
             throw;
         }
     }
 }
Пример #3
0
 private void EndConnectCallback(IAsyncResult ar)
 {
     Microsoft.ServiceBus.Channels.IConnection asyncState = (Microsoft.ServiceBus.Channels.IConnection)ar.AsyncState;
     try
     {
         Message message = this.messageHelper.EndReceiveMessage(ar);
         if (message.IsFault)
         {
             throw ErrorUtility.ConvertToError(MessageFault.CreateFault(message, 65536));
         }
         this.listener.Success(this, asyncState);
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         if (Fx.IsFatal(exception))
         {
             throw;
         }
         asyncState.Abort();
         this.listener.Failure(this, exception);
     }
 }
        private void EnqueueConnection(Guid connectionId, Microsoft.ServiceBus.Channels.IConnection connection, HybridConnectionListener.HybridConnectionSocketType socketType, Action dequeuedCallback)
        {
            HybridConnection hybridConnection;
            bool             flag = false;

            try
            {
                lock (this.connectionTable)
                {
                    if (this.connectionTable.TryGetValue(connectionId, out hybridConnection))
                    {
                        hybridConnection.EnqueueConnection(connection);
                    }
                    else if (socketType != HybridConnectionListener.HybridConnectionSocketType.Direct)
                    {
                        hybridConnection         = new HybridConnection(HybridConnectionRole.Listener, connection, null, this.bufferSize);
                        hybridConnection.Closed += new EventHandler((object o, EventArgs e) => this.connectionTable.Remove(connectionId));
                        flag = true;
                        this.connectionTable.Add(connectionId, hybridConnection);
                    }
                    else
                    {
                        connection.Abort();
                        return;
                    }
                }
                if (flag)
                {
                    this.connectionQueue.EnqueueAndDispatch(hybridConnection);
                }
            }
            finally
            {
                dequeuedCallback();
            }
        }