Ejemplo n.º 1
0
                public SendPreambleAsyncResult(Microsoft.ServiceBus.Channels.StreamedFramingRequestChannel channel, Microsoft.ServiceBus.Channels.IConnection connection, ref Microsoft.ServiceBus.Common.TimeoutHelper timeoutHelper, Microsoft.ServiceBus.Channels.ClientFramingDecoder decoder, AsyncCallback callback, object state) : base(callback, state)
                {
                    this.channel       = channel;
                    this.connection    = connection;
                    this.timeoutHelper = timeoutHelper;
                    this.decoder       = decoder;
                    IAsyncResult asyncResult = connection.BeginWrite(channel.Preamble, 0, (int)channel.Preamble.Length, true, timeoutHelper.RemainingTime(), Microsoft.ServiceBus.Channels.StreamedFramingRequestChannel.StreamedConnectionPoolHelper.SendPreambleAsyncResult.onWritePreamble, this);

                    if (!asyncResult.CompletedSynchronously)
                    {
                        return;
                    }
                    if (this.HandleWritePreamble(asyncResult))
                    {
                        base.Complete(true);
                    }
                }
Ejemplo n.º 2
0
            public SendPreambleAsyncResult(Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel channel, Microsoft.ServiceBus.Channels.IConnection connection, ArraySegment <byte> preamble, ref Microsoft.ServiceBus.Common.TimeoutHelper timeoutHelper, AsyncCallback callback, object state) : base(callback, state)
            {
                this.channel       = channel;
                this.timeoutHelper = timeoutHelper;
                this.connection    = connection;
                channel.decoder    = new Microsoft.ServiceBus.Channels.ClientDuplexDecoder((long)0);
                IAsyncResult asyncResult = connection.BeginWrite(preamble.Array, preamble.Offset, preamble.Count, true, timeoutHelper.RemainingTime(), Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.onWritePreamble, this);

                if (!asyncResult.CompletedSynchronously)
                {
                    return;
                }
                if (this.HandleWritePreamble(asyncResult))
                {
                    base.Complete(true);
                }
            }
            public WriteMessageAsyncResult(Message message, Microsoft.ServiceBus.Channels.IConnection connection, bool isRequest, Microsoft.ServiceBus.Channels.IConnectionOrientedTransportFactorySettings settings, ref TimeoutHelper timeoutHelper, AsyncCallback callback, object state) : base(callback, state)
            {
                bool flag;

                this.connection    = connection;
                this.encoder       = settings.MessageEncoderFactory.Encoder;
                this.bufferManager = settings.BufferManager;
                this.timeoutHelper = timeoutHelper;
                this.message       = message;
                this.settings      = settings;
                bool flag1 = true;
                bool flag2 = false;

                if (message != null)
                {
                    try
                    {
                        byte[] envelopeStartBytes = Microsoft.ServiceBus.Channels.SingletonEncoder.EnvelopeStartBytes;
                        if (!isRequest)
                        {
                            this.endBytes = Microsoft.ServiceBus.Channels.SingletonEncoder.EnvelopeEndBytes;
                            flag          = Microsoft.ServiceBus.Channels.TransferModeHelper.IsResponseStreamed(settings.TransferMode);
                        }
                        else
                        {
                            this.endBytes = Microsoft.ServiceBus.Channels.SingletonEncoder.EnvelopeEndFramingEndBytes;
                            flag          = Microsoft.ServiceBus.Channels.TransferModeHelper.IsRequestStreamed(settings.TransferMode);
                        }
                        if (!flag)
                        {
                            ArraySegment <byte> nums = settings.MessageEncoderFactory.Encoder.WriteMessage(message, 2147483647, this.bufferManager, (int)envelopeStartBytes.Length + 5);
                            nums = Microsoft.ServiceBus.Channels.SingletonEncoder.EncodeMessageFrame(nums);
                            this.bufferToFree = nums.Array;
                            Buffer.BlockCopy(envelopeStartBytes, 0, nums.Array, nums.Offset - (int)envelopeStartBytes.Length, (int)envelopeStartBytes.Length);
                            if (Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteBufferedMessage == null)
                            {
                                Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteBufferedMessage = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.OnWriteBufferedMessage));
                            }
                            IAsyncResult asyncResult = connection.BeginWrite(nums.Array, nums.Offset - (int)envelopeStartBytes.Length, nums.Count + (int)envelopeStartBytes.Length, true, timeoutHelper.RemainingTime(), Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteBufferedMessage, this);
                            if (asyncResult.CompletedSynchronously)
                            {
                                flag2 = this.HandleWriteBufferedMessage(asyncResult);
                            }
                        }
                        else
                        {
                            if (Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteStartBytes == null)
                            {
                                Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteStartBytes = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.OnWriteStartBytes));
                            }
                            IAsyncResult asyncResult1 = connection.BeginWrite(envelopeStartBytes, 0, (int)envelopeStartBytes.Length, true, timeoutHelper.RemainingTime(), Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteStartBytes, this);
                            if (asyncResult1.CompletedSynchronously)
                            {
                                if (Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteStartBytesScheduled == null)
                                {
                                    Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteStartBytesScheduled = new Action <object>(Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.OnWriteStartBytesScheduled);
                                }
                                IOThreadScheduler.ScheduleCallbackNoFlow(Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteStartBytesScheduled, asyncResult1);
                            }
                        }
                        flag1 = false;
                    }
                    finally
                    {
                        if (flag1)
                        {
                            this.Cleanup();
                        }
                    }
                }
                else
                {
                    if (isRequest)
                    {
                        this.endBytes = Microsoft.ServiceBus.Channels.SingletonEncoder.EndBytes;
                    }
                    flag2 = this.WriteEndBytes();
                }
                if (flag2)
                {
                    base.Complete(true);
                }
            }