protected override void OnProcessTransfer(Delivery delivery, Transfer transfer, Frame frame) { if (base.Settings.MaxMessageSize.HasValue) { ulong bytesTransfered = (ulong)(this.currentMessage.BytesTransfered + (long)frame.Payload.Count); if (bytesTransfered > base.Settings.MaxMessageSize.Value) { if (!base.IsClosing()) { Microsoft.ServiceBus.Messaging.Amqp.Framing.Error messageSizeExceeded = AmqpError.MessageSizeExceeded; object value = this.currentMessage.DeliveryId.Value; object obj = bytesTransfered; ulong? maxMessageSize = base.Settings.MaxMessageSize; throw new AmqpException(messageSizeExceeded, SRAmqp.AmqpMessageSizeExceeded(value, obj, maxMessageSize.Value)); } return; } } ArraySegment <byte> payload = frame.Payload; frame.RawByteBuffer.AdjustPosition(payload.Offset, payload.Count); frame.RawByteBuffer.Clone(); this.currentMessage.AddPayload(frame.RawByteBuffer, !transfer.More()); if (!transfer.More()) { AmqpMessage amqpMessage = this.currentMessage; this.currentMessage = null; Action <ReceivingAmqpLink, uint, int> action = (ReceivingAmqpLink source, uint id, int count) => { }; SequenceNumber deliveryId = amqpMessage.DeliveryId; MessagingClientEtwProvider.TraceClient <ReceivingAmqpLink, uint, int>(action, this, deliveryId.Value, amqpMessage.RawByteBuffers.Count); this.OnReceiveMessage(amqpMessage); } }
protected override IEnumerator <IteratorAsyncResult <AmqpMessageSender.SendAsyncResult> .AsyncStep> GetAsyncSteps() { try { this.amqpMessage = this.CreateAmqpMessage(); } catch (Exception exception) { base.Complete(exception); goto Label0; } if (!this.parent.sendLink.TryGetOpenedObject(out this.amqpLink)) { AmqpMessageSender.SendAsyncResult sendAsyncResult = this; IteratorAsyncResult <AmqpMessageSender.SendAsyncResult> .BeginCall beginCall = (AmqpMessageSender.SendAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.parent.sendLink.BeginGetInstance(t, c, s); yield return(sendAsyncResult.CallAsync(beginCall, (AmqpMessageSender.SendAsyncResult thisPtr, IAsyncResult r) => thisPtr.amqpLink = thisPtr.parent.sendLink.EndGetInstance(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); if (base.LastAsyncStepException == null) { goto Label1; } base.Complete(ExceptionHelper.GetClientException(base.LastAsyncStepException, this.parent.messagingFactory.RemoteContainerId)); goto Label0; } Label1: if (this.amqpLink.Settings.MaxMessageSize.HasValue) { ulong serializedMessageSize = (ulong)this.amqpMessage.SerializedMessageSize; if (serializedMessageSize <= Convert.ToUInt64(this.amqpLink.Settings.MaxMessageSize)) { goto Label2; } AmqpMessageSender.SendAsyncResult sendAsyncResult1 = this; object value = this.amqpMessage.DeliveryId.Value; object obj = serializedMessageSize; ulong? maxMessageSize = this.amqpLink.Settings.MaxMessageSize; sendAsyncResult1.Complete(new MessageSizeExceededException(SRAmqp.AmqpMessageSizeExceeded(value, obj, maxMessageSize.Value))); goto Label0; } Label2: AmqpMessageSender.SendAsyncResult sendAsyncResult2 = this; IteratorAsyncResult <AmqpMessageSender.SendAsyncResult> .BeginCall beginCall1 = (AmqpMessageSender.SendAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.amqpLink.BeginSendMessage(thisPtr.amqpMessage, thisPtr.parent.GetDeliveryTag(), AmqpConstants.NullBinary, t, c, s); yield return(sendAsyncResult2.CallAsync(beginCall1, (AmqpMessageSender.SendAsyncResult thisPtr, IAsyncResult r) => thisPtr.outcome = thisPtr.amqpLink.EndSendMessage(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); if (base.LastAsyncStepException != null) { base.Complete(ExceptionHelper.GetClientException(base.LastAsyncStepException, this.amqpLink.GetTrackingId())); } else if (this.outcome.DescriptorCode == Rejected.Code) { Rejected rejected = (Rejected)this.outcome; base.Complete(ExceptionHelper.ToMessagingContract(rejected.Error)); } Label0: yield break; }