本文整理汇总了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);
}
示例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());
}
}
示例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++;
}