while(delivery != null && buffer.remaining() >= _maxFrameSize )
{
if((delivery.getLink() instanceof SenderImpl) && delivery.isLocalStateChange() && delivery.getTransportDelivery() != null)
{
TransportDelivery transportDelivery = delivery.getTransportDelivery();
Disposition disposition = new Disposition();
disposition.setFirst(transportDelivery.getDeliveryId());
disposition.setLast(transportDelivery.getDeliveryId());
disposition.setRole(Role.SENDER);
disposition.setSettled(delivery.isSettled());
if(delivery.isSettled())
{
transportDelivery.settled();
}
disposition.setState(delivery.getLocalState());
int frameBytes = writeFrame(buffer, delivery.getLink().getSession()
.getTransportSession().getLocalChannel(),
disposition, null, null);
written += frameBytes;
delivery = delivery.clearTransportWork();