pos += chunkLength;
lastChunk = pos >= bodySize;
final SessionSendContinuationMessage chunk = new SessionSendContinuationMessage(msgI,
bodyBuffer.toByteBuffer()
.array(),
!lastChunk,
lastChunk && sendBlocking);
if (sendBlocking && lastChunk)
{
// When sending it blocking, only the last chunk will be blocking.
channel.sendBlocking(chunk);
}
else
{
channel.send(chunk);
}
try
{
credits.acquireCredits(chunk.getPacketSize());
}
catch (InterruptedException e)
{
}
}