当前位置: 首页>>代码示例>>C#>>正文


C# Message.Encode方法代码示例

本文整理汇总了C#中Amqp.Message.Encode方法的典型用法代码示例。如果您正苦于以下问题:C# Message.Encode方法的具体用法?C# Message.Encode怎么用?C# Message.Encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Amqp.Message的用法示例。


在下文中一共展示了Message.Encode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Send

        internal void Send(Message message, DeliveryState deliveryState, OutcomeCallback callback, object state)
        {
            var buffer = message.Encode();
            if (buffer.Length < 1)
            {
                throw new ArgumentException("Cannot send an empty message.");
            }

            Delivery delivery = new Delivery()
            {
                Message = message,
                Buffer = buffer,
                State = deliveryState,
                Link = this,
                OnOutcome = callback,
                UserToken = state,
                Settled = this.settleMode == SenderSettleMode.Settled || callback == null
            };

            lock (this.ThisLock)
            {
                this.ThrowIfDetaching("Send");

                if (this.credit <= 0 || this.writing)
                {
                    this.outgoingList.Add(delivery);
                    return;
                }

                delivery.Tag = GetDeliveryTag(this.deliveryCount);
                this.credit--;
                this.deliveryCount++;
                this.writing = true;
            }

            this.WriteDelivery(delivery);
        }
开发者ID:farukc,项目名称:amqpnetlite,代码行数:37,代码来源:SenderLink.cs

示例2: OnFlow

 public override void OnFlow(FlowContext flowContext)
 {
     for (int i = 0; i < flowContext.Messages; i++)
     {
         var message = new Message("test message");
         flowContext.Link.SendMessage(message, message.Encode());
     }
 }
开发者ID:yonglehou,项目名称:amqpnetlite,代码行数:8,代码来源:ContainerHostTests.cs

示例3: Send

        internal uint Send(Sender sender, Message message, bool settled)
        {
            ByteBuffer buffer = new ByteBuffer(128, true);
            buffer.AdjustPosition(TransferFramePrefixSize, 0);   // reserve space for frame header and transfer
            message.Encode(buffer);

            while (buffer.Length > 0)
            {
                this.Wait(o => ((Client)o).outWindow == 0, this, 60000);
                lock (this)
                {
                    this.nextOutgoingId++;
                    if (this.outWindow < uint.MaxValue)
                    {
                        this.outWindow--;
                    }
                }

                int payload = this.WriteTransferFrame(sender.Handle, this.deliveryId, settled, buffer, this.maxFrameSize);
                Fx.DebugPrint(true, 0, "transfer", new List { this.deliveryId, settled, payload }, "delivery-id", "settled", "payload");
            }

            return this.deliveryId++;
        }
开发者ID:Eclo,项目名称:amqpnetlite,代码行数:24,代码来源:Client.cs


注:本文中的Amqp.Message.Encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。