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();
                    }
                }
            }
Example #2
0
 private void SendInitiateMessage(Microsoft.ServiceBus.Channels.IConnection connection, TimeSpan timeout)
 {
     try
     {
         TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);
         byte[]        byteArray     = this.connectionId.ToByteArray();
         connection.Write(byteArray, 0, (int)byteArray.Length, true, timeoutHelper.RemainingTime());
         byte[] numArray = new byte[1];
         if (connection.Read(numArray, 0, 1, timeoutHelper.RemainingTime()) < 1 || numArray[0] != 1)
         {
             throw new CommunicationException(SRClient.InvalidReceivedContent);
         }
     }
     catch
     {
         connection.Close(TimeSpan.Zero);
         throw;
     }
 }