private void createContentBodies(ByteBuffer payload, AMQFrame[] frames, int offset, int channelId)
{
if (frames.length == (offset + 1))
{
frames[offset] = ContentBody.createAMQFrame(channelId, new ContentBody(payload));
}
else
{
final long framePayloadMax = _session.getAMQConnection().getMaximumFrameSize() - 1;
long remaining = payload.remaining();
for (int i = offset; i < frames.length; i++)
{
payload.position((int) framePayloadMax * (i - offset));
int length = (remaining >= framePayloadMax) ? (int) framePayloadMax : (int) remaining;
payload.limit(payload.position() + length);
frames[i] = ContentBody.createAMQFrame(channelId, new ContentBody(payload.slice()));
remaining -= length;
}
}