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++);
}