in src/SenderLink.cs [169:217]
void SendInternal(Message message, DeliveryState deliveryState, OutcomeCallback callback, object state, bool sync)
{
const int reservedBytes = 40;
#if NETFX || NETFX40 || DOTNET
var buffer = message.Encode(this.Session.Connection.BufferManager, reservedBytes);
#else
var buffer = message.Encode(reservedBytes);
#endif
if (buffer.Length < 1)
{
throw new ArgumentException("Cannot send an empty message.");
}
Delivery delivery = new Delivery()
{
Message = message,
Buffer = buffer,
ReservedBufferSize = reservedBytes,
State = deliveryState,
Link = this,
OnOutcome = callback,
UserToken = state,
Settled = this.settleMode == SenderSettleMode.Settled || callback == null,
Batchable = !sync
};
IHandler handler = this.Session.Connection.Handler;
if (handler != null && handler.CanHandle(EventId.SendDelivery))
{
handler.Handle(Event.Create(EventId.SendDelivery, this.Session.Connection, this.Session, this, context: delivery));
}
lock (this.ThisLock)
{
this.ThrowIfDetaching("Send");
if (this.credit <= 0 || this.writing)
{
this.outgoingList.Add(delivery);
return;
}
this.credit--;
this.deliveryCount++;
this.writing = true;
}
this.WriteDelivery(delivery);
}